Class ImguiManager
Forward declaration — see app/Window.h .More...
#include <ImguiManager.h>
Public Attributes
| Type | Name |
|---|---|
| std::function< void(void)> | ParaUpdate = [] {}Callback invoked when parameters are updated. |
Public Static Attributes
| Type | Name |
|---|---|
| bool | is_prefW_open = falsePreferences window open state. |
Public Functions
| Type | Name |
|---|---|
| void | ActivateLayer (const std::string & name) Activates (shows) a layer by name. |
| std::shared_ptr< LayerType > | CreateImguiLayer (std::string name) Creates and registers a new typed layer. |
| std::shared_ptr< ImguiMenu > | CreateImguiMenu (std::string name) Creates and registers a new menu. |
| void | DefultViewports () Sets up default viewport layout configuration. |
| ImguiItem * | FindImguiItem (const std::string & layer, const std::string & name) const Finds an item within a layer by name. |
| ImguiItem * | FindImguiItem (int id, const std::string & name) const Finds an item within a layer by layer ID and item name. |
| ImguiItem * | FindImguiItem (int id, int item_id) const Finds an item by layer ID and item ID. |
| T * | FindImguiItemAs (Args &&... args) const Finds an item and casts to derived type. |
| ImguiLayer * | FindImguiLayer (const std::string & name) const Finds a layer by name. |
| ImguiLayer * | FindImguiLayer (int id) const Finds a layer by index ID. |
| T * | FindImguiLayerAs (Args &&... args) const Finds a layer and casts to derived type. |
| ImguiMenu * | FindImguiMenu (const std::string & name) const Finds a menu by name. |
| ImguiMenuItem * | FindImguiMenuItem (const std::string & menu, const std::string & submenu) const Finds a menu item within a menu. |
| ImGuiIO * | GetIO () const Returns ImGui I/O interface. |
| Parameters * | GetParaValue (const std::string & ly_name, const std::string & it_name) Retrieves parameter value from a parameter input item. |
| ImGuiStyle * | GetStyle () const Returns ImGui style settings. |
| ImguiManager (EventPool & evt, Window & w) Constructs and fully initializes the ImguiManager . |
|
| ImguiManager (const ImguiManager &) = delete |
|
| void | NewFrame () const Prepares ImGui for a new frame. |
| void | PushImguiLayer (std::shared_ptr< ImguiLayer > layer) Adds a layer ( UI panel) to the manager. |
| void | PushImguiMenu (std::shared_ptr< ImguiMenu > _menu) Adds a menu to the menu bar. |
| void | RegistarMenuEvents (EventPool & evt) Registers all menu event subscriptions. |
| void | RegisterLayerEvents (EventPool & evt) Registers all layer event subscriptions. |
| void | RenderUI (const Context & ctx, EventPool & evt, bool rend=true) Renders all active UI layers and menus. |
| void | SetBackendFlag (ImGuiBackendFlags_ flag) const Sets an ImGui backend flag. |
| void | SetButtonFunc (const std::string & ly_name, const std::string & it_name, const std::function< void(void)> & func) Sets the callback function for a button item. |
| void | SetConfigFlag (ImGuiConfigFlags_ flag) const Sets an ImGui configuration flag. |
| void | _debug () const Debug utility for printing UI component hierarchy. |
| ImguiManager & | operator= (const ImguiManager &) = delete |
| ~ImguiManager () Shuts down ImGui backends and destroys context. |
Detailed Description
Central UI coordinator managing ImGui lifecycle, layers, and menus.
ImguiManager orchestrates the UI system by: * Initializing ImGui context and backends (GLFW + OpenGL3) * Managing UI panels (ImguiLayer) and menus (ImguiMenu) * Coordinating event subscriptions across UI components * Rendering all active UI elements each frame * Providing lookup and access to UI components by name or ID
UI Rendering Flow: * NewFrame() - Prepare ImGui for new frame * RenderUI() - Render all active layers and menus * Destructor - Cleanup ImGui resources
Component Management: * Layers: Dockable UI panels (Viewport, Outliner, etc.) * Menus: Top-level menu bar items * Items: Widgets within layers (buttons, sliders, etc.)
Note:
Thread-safety: Not thread-safe. Must be used from main thread only.
Note:
Ownership: ImguiManager owns all Layer and Menu instances via shared_ptr
Public Attributes Documentation
variable ParaUpdate
Callback invoked when parameters are updated.
std::function<void(void)> ImguiManager::ParaUpdate;
This hook allows external systems to react to parameter changes. Set this to a custom function to handle updates globally.
Note:
Default: No-op lambda
Public Static Attributes Documentation
variable is_prefW_open
Preferences window open state.
bool ImguiManager::is_prefW_open;
Public Functions Documentation
function ActivateLayer
Activates (shows) a layer by name.
void ImguiManager::ActivateLayer (
const std::string & name
)
Sets uly_activate = true, making the layer visible and renderable.
Parameters:
nameLayer name to activate
function CreateImguiLayer
Creates and registers a new typed layer.
template<class LayerType>
std::shared_ptr< LayerType > ImguiManager::CreateImguiLayer (
std::string name
)
Template factory method for creating specific layer types (e.g., Viewport, Outliner, TransformPanel).
Template parameters:
LayerTypeDerived type of ImguiLayer
Parameters:
nameLayer name for lookup and display
Returns:
Shared pointer to created layer
function CreateImguiMenu
Creates and registers a new menu.
std::shared_ptr< ImguiMenu > ImguiManager::CreateImguiMenu (
std::string name
)
Parameters:
nameMenu name for lookup and display
Returns:
Shared pointer to created menu
function DefultViewports
Sets up default viewport layout configuration.
void ImguiManager::DefultViewports ()
Note:
Called during initialization to establish docking layout
function FindImguiItem [1/3]
Finds an item within a layer by name.
ImguiItem * ImguiManager::FindImguiItem (
const std::string & layer,
const std::string & name
) const
Parameters:
layerLayer namenameItem name
Returns:
Pointer to item, or nullptr if not found
function FindImguiItem [2/3]
Finds an item within a layer by layer ID and item name.
ImguiItem * ImguiManager::FindImguiItem (
int id,
const std::string & name
) const
Parameters:
idLayer IDnameItem name
Returns:
Pointer to item, or nullptr if not found
function FindImguiItem [3/3]
Finds an item by layer ID and item ID.
ImguiItem * ImguiManager::FindImguiItem (
int id,
int item_id
) const
Parameters:
idLayer IDitem_idItem ID within layer
Returns:
Pointer to item, or nullptr if not found
function FindImguiItemAs
Finds an item and casts to derived type.
template<ImguiItemType T, typename... Args>
inline T * ImguiManager::FindImguiItemAs (
Args &&... args
) const
Type-safe helper for accessing specific item types (e.g., Button, Slider).
Template parameters:
TDerived item typeArgsArgument types for FindImguiItem
Parameters:
argsArguments forwarded to FindImguiItem
Returns:
Pointer to item cast to T, or nullptr
function FindImguiLayer [1/2]
Finds a layer by name.
ImguiLayer * ImguiManager::FindImguiLayer (
const std::string & name
) const
Parameters:
nameLayer name
Returns:
Pointer to layer, or nullptr if not found
function FindImguiLayer [2/2]
Finds a layer by index ID.
ImguiLayer * ImguiManager::FindImguiLayer (
int id
) const
Parameters:
idLayer index in layer_list
Returns:
Pointer to layer, or nullptr if invalid ID
function FindImguiLayerAs
Finds a layer and casts to derived type.
template<ImguiLayerType T, typename... Args>
inline T * ImguiManager::FindImguiLayerAs (
Args &&... args
) const
Type-safe helper for accessing specific layer types without manual casting.
Template parameters:
TDerived layer type (e.g., Viewport)ArgsArgument types for FindImguiLayer
Parameters:
argsArguments forwarded to FindImguiLayer
Returns:
Pointer to layer cast to T, or nullptr
Note:
No runtime type checking. Caller must ensure correct type.
function FindImguiMenu
Finds a menu by name.
ImguiMenu * ImguiManager::FindImguiMenu (
const std::string & name
) const
Parameters:
nameMenu name
Returns:
Pointer to menu, or nullptr if not found
function FindImguiMenuItem
Finds a menu item within a menu.
ImguiMenuItem * ImguiManager::FindImguiMenuItem (
const std::string & menu,
const std::string & submenu
) const
Parameters:
menuParent menu namesubmenuMenu item name
Returns:
Pointer to menu item, or nullptr if not found
function GetIO
Returns ImGui I/O interface.
inline ImGuiIO * ImguiManager::GetIO () const
Returns:
Pointer to ImGuiIO for configuration access
function GetParaValue
Retrieves parameter value from a parameter input item.
Parameters * ImguiManager::GetParaValue (
const std::string & ly_name,
const std::string & it_name
)
Used to read values from sliders, text inputs, color pickers, etc.
Parameters:
ly_nameLayer name containing the parameter itemit_nameItem name of the parameter input
Returns:
Pointer to Parameters, or nullptr if item is not a parameter input
function GetStyle
Returns ImGui style settings.
inline ImGuiStyle * ImguiManager::GetStyle () const
Returns:
Pointer to ImGuiStyle for theme customization
function ImguiManager [1/2]
Constructs and fully initializes the ImguiManager .
ImguiManager::ImguiManager (
EventPool & evt,
Window & w
)
Takes Window& to enforce that the GLFW/GL context (steps 1–3) is active before ImGui backend initialization. Creates the ImGui context internally. Sets up: * ImGui context with GLFW + OpenGL3 backends * Configuration flags (docking, viewports, etc.) * UI theme and style * Default layers and menus * Event subscriptions for all UI components
Parameters:
evtEventPool for subscribing to UI-related eventswActive Window — used for GLFW backend initialization
function ImguiManager [2/2]
ImguiManager::ImguiManager (
const ImguiManager &
) = delete
function NewFrame
Prepares ImGui for a new frame.
void ImguiManager::NewFrame () const
Must be called at the start of each frame before any ImGui calls. Updates input state, timing, and prepares rendering context.
Note:
Call sequence: NewFrame() → RenderUI() → backend render
function PushImguiLayer
Adds a layer ( UI panel) to the manager.
void ImguiManager::PushImguiLayer (
std::shared_ptr< ImguiLayer > layer
)
Parameters:
layerShared pointer to layer to add
Note:
Layer is registered in name buffer for lookup
function PushImguiMenu
Adds a menu to the menu bar.
void ImguiManager::PushImguiMenu (
std::shared_ptr< ImguiMenu > _menu
)
Parameters:
_menuShared pointer to menu to add
function RegistarMenuEvents
Registers all menu event subscriptions.
void ImguiManager::RegistarMenuEvents (
EventPool & evt
)
Parameters:
evtEventPool for event subscription
function RegisterLayerEvents
Registers all layer event subscriptions.
void ImguiManager::RegisterLayerEvents (
EventPool & evt
)
Iterates through all layers and calls RegisterEvents() on each, allowing them to subscribe to relevant events.
Parameters:
evtEventPool for event subscription
function RenderUI
Renders all active UI layers and menus.
void ImguiManager::RenderUI (
const Context & ctx,
EventPool & evt,
bool rend=true
)
Rendering flow: * Begin main dockspace * Render menu bar * Render all active layers (if uly_activate && uly_is_rendered) * Finalize ImGui rendering
Parameters:
ctxContext for read-only access to scene/editor stateevtEventPool for emitting UI eventsrendEnable rendering (default: true)
Note:
UI reads Context but never mutates it
Note:
User actions emit Events via evt
function SetBackendFlag
Sets an ImGui backend flag.
inline void ImguiManager::SetBackendFlag (
ImGuiBackendFlags_ flag
) const
Parameters:
flagBackend flag to enable (e.g., renderer features)
function SetButtonFunc
Sets the callback function for a button item.
void ImguiManager::SetButtonFunc (
const std::string & ly_name,
const std::string & it_name,
const std::function< void(void)> & func
)
Assigns a lambda or function to be called when the button is pressed.
Parameters:
ly_nameLayer name containing the buttonit_nameItem name of the buttonfuncCallback function to execute on button press
function SetConfigFlag
Sets an ImGui configuration flag.
inline void ImguiManager::SetConfigFlag (
ImGuiConfigFlags_ flag
) const
Parameters:
flagConfiguration flag to enable (e.g., docking, viewports)
function _debug
Debug utility for printing UI component hierarchy.
void ImguiManager::_debug () const
Note:
Development/diagnostic use only
function operator=
ImguiManager & ImguiManager::operator= (
const ImguiManager &
) = delete
function ~ImguiManager
Shuts down ImGui backends and destroys context.
ImguiManager::~ImguiManager ()
The documentation for this class was generated from the following file src/UI/ImguiManager.h