Skip to content

Class ImguiManager

ClassList > 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 = false
Preferences 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:

  • name Layer 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:

Parameters:

  • name Layer 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:

  • name Menu 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:

  • layer Layer name
  • name Item 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:

  • id Layer ID
  • name Item 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:

  • id Layer ID
  • item_id Item 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:

  • T Derived item type
  • Args Argument types for FindImguiItem

Parameters:

  • args Arguments 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:

  • name Layer 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:

  • id Layer 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:

  • T Derived layer type (e.g., Viewport)
  • Args Argument types for FindImguiLayer

Parameters:

  • args Arguments 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:

  • name Menu 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:

  • menu Parent menu name
  • submenu Menu 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_name Layer name containing the parameter item
  • it_name Item 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:

  • evt EventPool for subscribing to UI-related events
  • w Active 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:

  • layer Shared 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:

  • _menu Shared pointer to menu to add

function RegistarMenuEvents

Registers all menu event subscriptions.

void ImguiManager::RegistarMenuEvents (
    EventPool & evt
) 

Parameters:


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:


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:

  • ctx Context for read-only access to scene/editor state
  • evt EventPool for emitting UI events
  • rend Enable 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:

  • flag Backend 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_name Layer name containing the button
  • it_name Item name of the button
  • func Callback function to execute on button press

function SetConfigFlag

Sets an ImGui configuration flag.

inline void ImguiManager::SetConfigFlag (
    ImGuiConfigFlags_ flag
) const

Parameters:

  • flag Configuration 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