Skip to main content

ImGuiOverlay.ixx File

Manages a collection of ImGui widgets and renders them using a backend. More...

Included Headers

#include <vector> #include "imgui.h" #include <helios.imgui.ImGuiWidget> #include <helios.imgui.ImGuiBackend>

Namespaces Index

namespacehelios
namespaceimgui

Classes Index

classImGuiOverlay

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

Description

Manages a collection of ImGui widgets and renders them using a backend.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <vector>
8
9#include "imgui.h"
10
11export module helios.imgui.ImGuiOverlay;
12
13import helios.imgui.ImGuiBackend;
14import helios.imgui.ImGuiWidget;
15
16
17export namespace helios::imgui {
18
30
31
32 private:
43 std::vector<helios::imgui::ImGuiWidget*> widgets_;
44
55 ImGuiBackend* backend_;
56
60 bool enableDockSpace_ = true;
61
71 explicit ImGuiOverlay(ImGuiBackend* backend) :
72 backend_(backend)
73 {
74 }
75
76 public:
77
85
86 static auto overlay = ImGuiOverlay(backend);
87
88 return overlay;
89 }
90
99 void addWidget(ImGuiWidget* widget) {
100
101 widgets_.emplace_back(widget);
102 }
103
111 void setDockSpaceEnabled(bool enabled) noexcept {
112 enableDockSpace_ = enabled;
113 }
114
122 void render() {
123
124 if (!backend_->newFrame()) {
125 return;
126 }
127
128 // Create a full-viewport DockSpace so widgets can be docked to window edges
129 if (enableDockSpace_) {
130 ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(),
131 ImGuiDockNodeFlags_PassthruCentralNode);
132 }
133
134 for (const auto it : widgets_) {
135 it->draw();
136 }
137
138 ImGui::Render();
139 backend_->renderDrawData(ImGui::GetDrawData());
140 }
141
142 };
143
144
145}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.