Skip to main content

ImGuiOverlay Class

Central manager for ImGui widgets rendered via a specific backend. More...

Declaration

class helios::ext::imgui::ImGuiOverlay { ... }

Private Constructors Index

ImGuiOverlay (ImGuiBackend *backend)

Constructs an ImGuiOverlay instance with a specified backend. More...

Public Member Functions Index

voidaddWidget (ImGuiWidget *widget)

Adds a widget to the overlay. More...

voidsetDockSpaceEnabled (bool enabled) noexcept

Enables or disables the full-viewport DockSpace. More...

voidrender ()

Renders all registered widgets using the backend. More...

Private Member Attributes Index

std::vector< helios::ext::imgui::ImGuiWidget * >widgets_

Container for dynamically registered ImGui widgets. More...

ImGuiBackend *backend_

Pointer to the backend used for rendering ImGui widgets. More...

boolenableDockSpace_ = true

Whether to enable a full-viewport DockSpace for docking widgets. More...

Public Static Functions Index

static ImGuiOverlay &forBackend (ImGuiBackend *backend)

Retrieves the singleton overlay instance for a given backend. More...

Description

Central manager for ImGui widgets rendered via a specific backend.

The overlay is a singleton per backend. Widgets can be registered dynamically, and all widgets are rendered in the order they were added.

info

This class is implemented as a singleton using `forBackend()`. Direct construction is not allowed.

Definition at line 29 of file ImGuiOverlay.ixx.

Private Constructors

ImGuiOverlay()

helios::ext::imgui::ImGuiOverlay::ImGuiOverlay (ImGuiBackend * backend)
inline explicit

Constructs an ImGuiOverlay instance with a specified backend.

This constructor initializes the overlay with the provided ImGui backend. It is private to enforce the singleton pattern of the overlay.

Parameters
backend

Pointer to the ImGuiBackend implementation. Must remain valid for the lifetime of the overlay.

Definition at line 71 of file ImGuiOverlay.ixx.

71 explicit ImGuiOverlay(ImGuiBackend* backend) :
72 backend_(backend)
73 {
74 }

Public Member Functions

addWidget()

void helios::ext::imgui::ImGuiOverlay::addWidget (ImGuiWidget * widget)
inline

Adds a widget to the overlay.

Widgets are rendered in the order they were added. The overlay does not take ownership; the caller must ensure the widget remains valid.

Parameters
widget

Pointer to the widget. Must remain valid for the lifetime of the overlay.

Definition at line 99 of file ImGuiOverlay.ixx.

99 void addWidget(ImGuiWidget* widget) {
100
101 widgets_.emplace_back(widget);
102 }

render()

void helios::ext::imgui::ImGuiOverlay::render ()
inline

Renders all registered widgets using the backend.

Calls `newFrame()` on the backend, optionally creates a DockSpace, invokes `draw()` on each widget, then finalizes rendering via `ImGui::Render()` and `renderDrawData()`.

Definition at line 122 of file ImGuiOverlay.ixx.

122 void render() {
123 backend_->newFrame();
124
125 // Create a full-viewport DockSpace so widgets can be docked to window edges
126 if (enableDockSpace_) {
127 ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(),
128 ImGuiDockNodeFlags_PassthruCentralNode);
129 }
130
131 for (const auto it : widgets_) {
132 it->draw();
133 }
134
135 ImGui::Render();
136 backend_->renderDrawData(ImGui::GetDrawData());
137 }

setDockSpaceEnabled()

void helios::ext::imgui::ImGuiOverlay::setDockSpaceEnabled (bool enabled)
inline noexcept

Enables or disables the full-viewport DockSpace.

When enabled, widgets can be docked to the edges of the main viewport.

Parameters
enabled

True to enable docking, false to disable.

Definition at line 111 of file ImGuiOverlay.ixx.

111 void setDockSpaceEnabled(bool enabled) noexcept {
112 enableDockSpace_ = enabled;
113 }

Private Member Attributes

backend_

ImGuiBackend* helios::ext::imgui::ImGuiOverlay::backend_

Pointer to the backend used for rendering ImGui widgets.

Represents the platform-specific implementation of ImGui functionality (e.g., OpenGL, Vulkan, etc.). The backend facilitates frame management, new frame initialization, and rendering draw data.

info

This pointer is initialized via the `ImGuiOverlay` constructor and must remain a valid instance for the lifetime of the `ImGuiOverlay`.

Definition at line 55 of file ImGuiOverlay.ixx.

55 ImGuiBackend* backend_;

enableDockSpace_

bool helios::ext::imgui::ImGuiOverlay::enableDockSpace_ = true

Whether to enable a full-viewport DockSpace for docking widgets.

Definition at line 60 of file ImGuiOverlay.ixx.

60 bool enableDockSpace_ = true;

widgets_

std::vector<helios::ext::imgui::ImGuiWidget*> helios::ext::imgui::ImGuiOverlay::widgets_

Container for dynamically registered ImGui widgets.

Stores pointers to widgets that are managed and rendered by the `ImGuiOverlay`. Widgets are added in the order they are registered and must remain valid for the lifetime of the overlay. The container does not take ownership of the widgets.

info

This is a private member of `ImGuiOverlay` and is utilized for managing the rendering lifecycle of widgets.

Definition at line 43 of file ImGuiOverlay.ixx.

43 std::vector<helios::ext::imgui::ImGuiWidget*> widgets_;

Public Static Functions

forBackend()

ImGuiOverlay & helios::ext::imgui::ImGuiOverlay::forBackend (ImGuiBackend * backend)
inline static

Retrieves the singleton overlay instance for a given backend.

Parameters
backend

Pointer to the ImGui backend (e.g., GLFW+OpenGL). Must remain valid.

Returns

Reference to the singleton overlay instance.

Definition at line 84 of file ImGuiOverlay.ixx.

84 static ImGuiOverlay& forBackend(ImGuiBackend* backend) {
85
86 static auto overlay = ImGuiOverlay(backend);
87
88 return overlay;
89 }

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.