Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
EditorUI Class Reference

Handles rendering of the editor GUI using ImGui, scene hierarchy, inspector, gizmos, and raycast picking. More...

#include <EditorUI.hpp>

Public Types

using BuildGameCallback = std::function<int(const std::string& projectPath, const std::string& outPath)>
using ComponentInspectorCallback = std::function<void(Registry&, Entity)>
using ComponentAddCallback = std::function<void(Registry&, Entity)>

Public Member Functions

 EditorUI (Registry &registry, VulkanRenderer &renderer, SceneManager &sceneManager, EditorModeState &editorMode, const std::string &startScenePath="assets/scenes/test_scene.json", BuildGameCallback buildGameCallback={})
 Construct a new Editor UI object.
 ~EditorUI ()
 Destroy the Editor UI object.
void initialize (GLFWwindow *window)
 Initializes ImGui bindings and structures.
void shutdown ()
 Shuts down ImGui and releases descriptor pools.
void beginFrame ()
 Starts a new ImGui frame.
void drawPanels ()
 Processes and populates ImGui panel layout commands.
void render (VkCommandBuffer commandBuffer)
 Submits ImGui draw data to the current Vulkan command buffer.
void toggleFlyMode ()
 Toggles between first-person fly camera controls and editor UI control modes.

Static Public Member Functions

static void registerComponentInspector (const std::string &name, ComponentInspectorCallback callback)
static void registerComponentAddCallback (const std::string &name, ComponentAddCallback callback)
static std::vector< std::pair< std::string, ComponentInspectorCallback > > & getDynamicInspectors ()
static std::vector< std::pair< std::string, ComponentAddCallback > > & getDynamicAddCallbacks ()

Private Member Functions

void handleViewportPicking ()
 Processes viewport clicking rays for entity selection.
void createDescriptorPool ()
 Creates Vulkan descriptor pool specifically for ImGui.
void destroyDescriptorPool ()
 Releases ImGui Vulkan descriptor pool resources.
void drawSceneControls ()
 Renders panel controls for scene operations (New/Load/Save/Spawn).
void drawHierarchyPanel ()
 Renders hierarchical entity list panel.
void drawInspectorPanel ()
 Renders detail inspector panel for the selected entity.
void drawTransformEditor ()
 Renders inline controls for Transform component fields.
void drawMaterialEditor ()
 Renders inline controls for Material component fields.
void drawAssetBrowser ()
 Renders the asset browser panel.
void drawImportSettingsWindow ()
 Renders the floating asset import settings window.
void drawTilesetEditorWindow ()
 Renders the Tileset Editor window.
void drawAnimationEditorWindow ()
void drawNodeGraphDemoWindow ()
void drawAnimatorControllerWindow ()
void drawTilemapInspector ()
 Renders the Tilemap component inspector panel.
void drawSpriteRendererInspector ()
 Renders the SpriteRenderer component inspector panel.
void drawUIComponentsEditor ()
 Renders custom editor inspectors for all game UI components.
void drawTilemapGridOverlay ()
 Renders a 3D grid overlay on the tilemap for editor visual feedback.
void drawMeshEditor ()
 Renders inline controls for Mesh component fields.
void drawGridEditor ()
 Renders inline controls for Grid component fields.
void drawCameraEditor ()
 Renders inline controls for Camera component fields.
void drawSkeletonEditor ()
 Renders inline controls for Skeleton component fields.
void drawAnimatorEditor ()
 Renders inline controls for Animator component fields.
void drawHierarchyEditor ()
 Renders inline controls for Hierarchy component fields.
void drawIKSolverEditor ()
 Renders inline controls for IK Solver component fields.
void drawAnimationControllerEditor ()
 Renders inline controls for Animation Controller component fields.
void drawReflectedComponentsEditor ()
 Renders inline controls for all reflected component fields dynamically.
void drawColliderEditor ()
 Renders inline controls for Collider component fields.
void drawSectionHeader (const std::string &title)
 Draws a styled banner title inside component panels.
bool drawVec3Control (const char *label, float *values, float speed=0.05f)
 Renders custom controls for editing glm::vec3 variables.
void applyInputMode ()
 Applies mouse visibility cursor mode according to active editor mode.
void drawDebugPanel ()
 Renders the debug metrics and raycast state panel.
void drawGizmo ()
 Processes and displays transformation gizmo overlay on the selected entity.
void drawBuildSettingsPanel ()
 Renders the Build Settings panel for packaging the game.
void decomposeMatrixToTransform (const glm::mat4 &mat, Transform &t)
 Helper function to extract Euler transform fields from a 4x4 matrix.
glm::mat4 getEntityWorldMatrix (Entity entity, int depth=0)
 Recursively traverses parent references to build the entity's absolute world transform.
void drawColliderDebugOverlay ()
 Draws wireframe overlays for all active colliders when enabled.
void drawPhysgunDebugOverlay ()
 Draws physics gun debug rays when activated by the user.

Private Attributes

Registry & registry
 Reference to registry.
VulkanRenderer & renderer
 Reference to Vulkan renderer.
SceneManager & sceneManager
 Reference to scene manager.
EditorModeState & editorMode
 Reference to editor mode state tracker.
GLFWwindow * window = nullptr
 Pointer to GLFW window.
VkDescriptorPool descriptorPool = VK_NULL_HANDLE
 ImGui dedicated descriptor pool.
bool initialized = false
 State flag for ImGui initialization status.
std::string scenePath = "assets/scenes/test_scene.json"
 Target json file path for scene serialization.
std::string statusMessage = "Scene not saved yet."
 Status info message printed on UI panel.
std::string renameBuffer
 Cache buffer string for renaming entities.
Entity selectedEntity {}
 The entity currently selected.
bool hasSelection = false
 Selection flag.
bool previousLeftMouseDown = false
 Mouse click state tracking.
glm::vec3 lastPickRayOrigin { 0.0f }
 Raycast origin caching.
glm::vec3 lastPickRayDirection { 0.0f, 0.0f, -1.0f }
 Raycast direction caching.
std::string lastPickNearestEntityName = "None"
 Name of the picked entity.
float lastPickNearestDistance = -1.0f
 Distance to the picked entity.
std::string lastPickResult = "No pick attempted yet."
 Human-readable pick results.
bool previousToggleKeyDown = false
 Editor/Fly toggle key state cache.
bool showColliders = false
 Flag to toggle drawing collider wireframes in the viewport.
bool showBuildSettings = false
 Whether the Build Settings panel is open.
std::string buildOutputPath = "build/"
 Output path for game builds.
std::string buildStatusMessage
 Status message from last build attempt.
bool buildInProgress = false
 Whether a build is currently in progress.
BuildGameCallback buildGameCallback
 Optional callback used to build the game while the editor is running.

Detailed Description

Handles rendering of the editor GUI using ImGui, scene hierarchy, inspector, gizmos, and raycast picking.

Member Typedef Documentation

◆ BuildGameCallback

using EditorUI::BuildGameCallback = std::function<int(const std::string& projectPath, const std::string& outPath)>

◆ ComponentAddCallback

using EditorUI::ComponentAddCallback = std::function<void(Registry&, Entity)>

◆ ComponentInspectorCallback

using EditorUI::ComponentInspectorCallback = std::function<void(Registry&, Entity)>

Constructor & Destructor Documentation

◆ EditorUI()

EditorUI::EditorUI ( Registry & registry,
VulkanRenderer & renderer,
SceneManager & sceneManager,
EditorModeState & editorMode,
const std::string & startScenePath = "assets/scenes/test_scene.json",
BuildGameCallback buildGameCallback = {} )

Construct a new Editor UI object.

Parameters
registryReference to the ECS Registry.
rendererReference to the Vulkan Renderer.
sceneManagerReference to the Scene Manager.
editorModeReference to the Editor Mode State.

◆ ~EditorUI()

EditorUI::~EditorUI ( )

Destroy the Editor UI object.

Member Function Documentation

◆ applyInputMode()

void EditorUI::applyInputMode ( )
private

Applies mouse visibility cursor mode according to active editor mode.

◆ beginFrame()

void EditorUI::beginFrame ( )

Starts a new ImGui frame.

◆ createDescriptorPool()

void EditorUI::createDescriptorPool ( )
private

Creates Vulkan descriptor pool specifically for ImGui.

◆ decomposeMatrixToTransform()

void EditorUI::decomposeMatrixToTransform ( const glm::mat4 & mat,
Transform & t )
private

Helper function to extract Euler transform fields from a 4x4 matrix.

Parameters
matInput matrix.
tOutput transform parameters.

◆ destroyDescriptorPool()

void EditorUI::destroyDescriptorPool ( )
private

Releases ImGui Vulkan descriptor pool resources.

◆ drawAnimationControllerEditor()

void EditorUI::drawAnimationControllerEditor ( )
private

Renders inline controls for Animation Controller component fields.

◆ drawAnimationEditorWindow()

void EditorUI::drawAnimationEditorWindow ( )
private

◆ drawAnimatorControllerWindow()

void EditorUI::drawAnimatorControllerWindow ( )
private

◆ drawAnimatorEditor()

void EditorUI::drawAnimatorEditor ( )
private

Renders inline controls for Animator component fields.

◆ drawAssetBrowser()

void EditorUI::drawAssetBrowser ( )
private

Renders the asset browser panel.

◆ drawBuildSettingsPanel()

void EditorUI::drawBuildSettingsPanel ( )
private

Renders the Build Settings panel for packaging the game.

◆ drawCameraEditor()

void EditorUI::drawCameraEditor ( )
private

Renders inline controls for Camera component fields.

◆ drawColliderDebugOverlay()

void EditorUI::drawColliderDebugOverlay ( )
private

Draws wireframe overlays for all active colliders when enabled.

◆ drawColliderEditor()

void EditorUI::drawColliderEditor ( )
private

Renders inline controls for Collider component fields.

◆ drawDebugPanel()

void EditorUI::drawDebugPanel ( )
private

Renders the debug metrics and raycast state panel.

◆ drawGizmo()

void EditorUI::drawGizmo ( )
private

Processes and displays transformation gizmo overlay on the selected entity.

◆ drawGridEditor()

void EditorUI::drawGridEditor ( )
private

Renders inline controls for Grid component fields.

◆ drawHierarchyEditor()

void EditorUI::drawHierarchyEditor ( )
private

Renders inline controls for Hierarchy component fields.

◆ drawHierarchyPanel()

void EditorUI::drawHierarchyPanel ( )
private

Renders hierarchical entity list panel.

◆ drawIKSolverEditor()

void EditorUI::drawIKSolverEditor ( )
private

Renders inline controls for IK Solver component fields.

◆ drawImportSettingsWindow()

void EditorUI::drawImportSettingsWindow ( )
private

Renders the floating asset import settings window.

◆ drawInspectorPanel()

void EditorUI::drawInspectorPanel ( )
private

Renders detail inspector panel for the selected entity.

◆ drawMaterialEditor()

void EditorUI::drawMaterialEditor ( )
private

Renders inline controls for Material component fields.

◆ drawMeshEditor()

void EditorUI::drawMeshEditor ( )
private

Renders inline controls for Mesh component fields.

◆ drawNodeGraphDemoWindow()

void EditorUI::drawNodeGraphDemoWindow ( )
private

◆ drawPanels()

void EditorUI::drawPanels ( )

Processes and populates ImGui panel layout commands.

◆ drawPhysgunDebugOverlay()

void EditorUI::drawPhysgunDebugOverlay ( )
private

Draws physics gun debug rays when activated by the user.

◆ drawReflectedComponentsEditor()

void EditorUI::drawReflectedComponentsEditor ( )
private

Renders inline controls for all reflected component fields dynamically.

◆ drawSceneControls()

void EditorUI::drawSceneControls ( )
private

Renders panel controls for scene operations (New/Load/Save/Spawn).

◆ drawSectionHeader()

void EditorUI::drawSectionHeader ( const std::string & title)
private

Draws a styled banner title inside component panels.

Parameters
titleHeader title text.

◆ drawSkeletonEditor()

void EditorUI::drawSkeletonEditor ( )
private

Renders inline controls for Skeleton component fields.

◆ drawSpriteRendererInspector()

void EditorUI::drawSpriteRendererInspector ( )
private

Renders the SpriteRenderer component inspector panel.

◆ drawTilemapGridOverlay()

void EditorUI::drawTilemapGridOverlay ( )
private

Renders a 3D grid overlay on the tilemap for editor visual feedback.

◆ drawTilemapInspector()

void EditorUI::drawTilemapInspector ( )
private

Renders the Tilemap component inspector panel.

◆ drawTilesetEditorWindow()

void EditorUI::drawTilesetEditorWindow ( )
private

Renders the Tileset Editor window.

◆ drawTransformEditor()

void EditorUI::drawTransformEditor ( )
private

Renders inline controls for Transform component fields.

◆ drawUIComponentsEditor()

void EditorUI::drawUIComponentsEditor ( )
private

Renders custom editor inspectors for all game UI components.

◆ drawVec3Control()

bool EditorUI::drawVec3Control ( const char * label,
float * values,
float speed = 0.05f )
private

Renders custom controls for editing glm::vec3 variables.

Parameters
labelThe control's label.
valuesPointer to the float array of 3 values.
speedInteraction speed/step.
Returns
True if any values changed.

◆ getDynamicAddCallbacks()

std::vector< std::pair< std::string, EditorUI::ComponentAddCallback > > & EditorUI::getDynamicAddCallbacks ( )
static

◆ getDynamicInspectors()

std::vector< std::pair< std::string, EditorUI::ComponentInspectorCallback > > & EditorUI::getDynamicInspectors ( )
static

◆ getEntityWorldMatrix()

glm::mat4 EditorUI::getEntityWorldMatrix ( Entity entity,
int depth = 0 )
private

Recursively traverses parent references to build the entity's absolute world transform.

◆ handleViewportPicking()

void EditorUI::handleViewportPicking ( )
private

Processes viewport clicking rays for entity selection.

◆ initialize()

void EditorUI::initialize ( GLFWwindow * window)

Initializes ImGui bindings and structures.

Parameters
windowPointer to the GLFW window.

◆ registerComponentAddCallback()

void EditorUI::registerComponentAddCallback ( const std::string & name,
ComponentAddCallback callback )
static

◆ registerComponentInspector()

void EditorUI::registerComponentInspector ( const std::string & name,
ComponentInspectorCallback callback )
static

◆ render()

void EditorUI::render ( VkCommandBuffer commandBuffer)

Submits ImGui draw data to the current Vulkan command buffer.

Parameters
commandBufferCommand buffer to write commands to.

◆ shutdown()

void EditorUI::shutdown ( )

Shuts down ImGui and releases descriptor pools.

◆ toggleFlyMode()

void EditorUI::toggleFlyMode ( )

Toggles between first-person fly camera controls and editor UI control modes.

Member Data Documentation

◆ buildGameCallback

BuildGameCallback EditorUI::buildGameCallback
private

Optional callback used to build the game while the editor is running.

◆ buildInProgress

bool EditorUI::buildInProgress = false
private

Whether a build is currently in progress.

◆ buildOutputPath

std::string EditorUI::buildOutputPath = "build/"
private

Output path for game builds.

◆ buildStatusMessage

std::string EditorUI::buildStatusMessage
private

Status message from last build attempt.

◆ descriptorPool

VkDescriptorPool EditorUI::descriptorPool = VK_NULL_HANDLE
private

ImGui dedicated descriptor pool.

◆ editorMode

EditorModeState& EditorUI::editorMode
private

Reference to editor mode state tracker.

◆ hasSelection

bool EditorUI::hasSelection = false
private

Selection flag.

◆ initialized

bool EditorUI::initialized = false
private

State flag for ImGui initialization status.

◆ lastPickNearestDistance

float EditorUI::lastPickNearestDistance = -1.0f
private

Distance to the picked entity.

◆ lastPickNearestEntityName

std::string EditorUI::lastPickNearestEntityName = "None"
private

Name of the picked entity.

◆ lastPickRayDirection

glm::vec3 EditorUI::lastPickRayDirection { 0.0f, 0.0f, -1.0f }
private

Raycast direction caching.

◆ lastPickRayOrigin

glm::vec3 EditorUI::lastPickRayOrigin { 0.0f }
private

Raycast origin caching.

◆ lastPickResult

std::string EditorUI::lastPickResult = "No pick attempted yet."
private

Human-readable pick results.

◆ previousLeftMouseDown

bool EditorUI::previousLeftMouseDown = false
private

Mouse click state tracking.

◆ previousToggleKeyDown

bool EditorUI::previousToggleKeyDown = false
private

Editor/Fly toggle key state cache.

◆ registry

Registry& EditorUI::registry
private

Reference to registry.

◆ renameBuffer

std::string EditorUI::renameBuffer
private

Cache buffer string for renaming entities.

◆ renderer

VulkanRenderer& EditorUI::renderer
private

Reference to Vulkan renderer.

◆ sceneManager

SceneManager& EditorUI::sceneManager
private

Reference to scene manager.

◆ scenePath

std::string EditorUI::scenePath = "assets/scenes/test_scene.json"
private

Target json file path for scene serialization.

◆ selectedEntity

Entity EditorUI::selectedEntity {}
private

The entity currently selected.

◆ showBuildSettings

bool EditorUI::showBuildSettings = false
private

Whether the Build Settings panel is open.

◆ showColliders

bool EditorUI::showColliders = false
private

Flag to toggle drawing collider wireframes in the viewport.

◆ statusMessage

std::string EditorUI::statusMessage = "Scene not saved yet."
private

Status info message printed on UI panel.

◆ window

GLFWwindow* EditorUI::window = nullptr
private

Pointer to GLFW window.


The documentation for this class was generated from the following files: