Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::UIManager Class Reference

Manages UI lifecycle, panels, and rendering for both editor and runtime. More...

#include <UIManager.h>

Public Member Functions

void Init ()
 Initializes UI resources and prepares the ImGui renderer.
void Shutdown ()
 Cleans up resources and shuts down the UI system.
void Begin ()
 Begins a new UI frame, setting up ImGui and framebuffers.
void End ()
 Ends the current UI frame, finalizing ImGui rendering.
void DrawUI ()
 Draws all registered UI panels and menu bars.
void AddPanel (const std::string &panelName, PanelScope scope, const std::function< void(UIPanelContext &)> &callback, bool startVisible=true)
 Registers a UI panel.
void AddMenuBar (float height, const std::function< void(UIPanelContext &)> &callback)
 Registers a menu bar callback.
void AddDockspace (bool enabled)
 Enables or disables ImGui dockspace for UI layout.
void TogglePanelVisibility (const std::string &panelName)
 Toggles the visibility state of a registered panel.
void SetScene (Scene &scene)
 Sets the active scene pointer for UI context.
void DeferResourceCleanup (const std::function< void()> &fn, void *fence)
 Enqueues a function to be called during ImGui cleanup.
void Resize (u32 width, u32 height)
 Resizes UI render targets and related resources.

Detailed Description

Manages UI lifecycle, panels, and rendering for both editor and runtime.

Handles initialization, rendering, and shutdown of the UI system. Supports panel registration with visibility scopes, menu bars, dockspaces, and deferred resource cleanup.

Member Function Documentation

◆ AddDockspace()

void Raven::UIManager::AddDockspace ( bool enabled)
inline

Enables or disables ImGui dockspace for UI layout.

Parameters
enabledTrue to enable dockspace, false to disable.

◆ AddMenuBar()

void Raven::UIManager::AddMenuBar ( float height,
const std::function< void(UIPanelContext &)> & callback )

Registers a menu bar callback.

Only one menu bar can be active at a time.

Parameters
heightHeight of the menu bar in pixels.
callbackFunction invoked to render the menu bar.

◆ AddPanel()

void Raven::UIManager::AddPanel ( const std::string & panelName,
PanelScope scope,
const std::function< void(UIPanelContext &)> & callback,
bool startVisible = true )

Registers a UI panel.

Parameters
panelNameName identifier for the panel.
scopeVisibility scope of the panel (Editor, Runtime, or both).
callbackFunction invoked every frame to render panel contents.
startVisibleSet the starting Visibility.
Note
If startVisible is set to false, the TogglePanelVisibility function must be invoked to display it.

◆ Begin()

void Raven::UIManager::Begin ( )

Begins a new UI frame, setting up ImGui and framebuffers.

◆ DeferResourceCleanup()

void Raven::UIManager::DeferResourceCleanup ( const std::function< void()> & fn,
void * fence )

Enqueues a function to be called during ImGui cleanup.

Used for deferred resource cleanup tasks.

Parameters
fnFunction to execute later.
fenceThe fence used for the frame

◆ DrawUI()

void Raven::UIManager::DrawUI ( )

Draws all registered UI panels and menu bars.

◆ End()

void Raven::UIManager::End ( )

Ends the current UI frame, finalizing ImGui rendering.

◆ Init()

void Raven::UIManager::Init ( )

Initializes UI resources and prepares the ImGui renderer.

◆ Resize()

void Raven::UIManager::Resize ( u32 width,
u32 height )

Resizes UI render targets and related resources.

Must be called when the window size changes to keep UI rendering correct.

Parameters
widthNew width in pixels.
heightNew height in pixels.

◆ SetScene()

void Raven::UIManager::SetScene ( Scene & scene)
inline

Sets the active scene pointer for UI context.

Parameters
sceneReference to the active Scene.

◆ Shutdown()

void Raven::UIManager::Shutdown ( )

Cleans up resources and shuts down the UI system.

◆ TogglePanelVisibility()

void Raven::UIManager::TogglePanelVisibility ( const std::string & panelName)

Toggles the visibility state of a registered panel.

Parameters
panelNameName of the panel to toggle.

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