summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-15 02:50:08 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-15 02:50:08 +0000
commitb3378e7ed11f7f4ec16e1eb268768791d6861331 (patch)
tree4dd9beb30173a6e9707410c4e0cd9f799fb4e9de
parentWrap imgui_intenal if requested (diff)
downloadilt-b3378e7ed11f7f4ec16e1eb268768791d6861331.tar.bz2
ilt-b3378e7ed11f7f4ec16e1eb268768791d6861331.tar.xz
ilt-b3378e7ed11f7f4ec16e1eb268768791d6861331.zip
Add ImGui wrappers for creating a toolbar docked to a viewport edge
Based on, but simplified, code for BeginMainMenuBar.
-rw-r--r--ui/imgui_extras.cpp33
-rw-r--r--ui/imgui_extras.h10
2 files changed, 43 insertions, 0 deletions
diff --git a/ui/imgui_extras.cpp b/ui/imgui_extras.cpp
new file mode 100644
index 0000000..1643f4f
--- /dev/null
+++ b/ui/imgui_extras.cpp
@@ -0,0 +1,33 @@
+#define IMGUI_INTERNAL
+#include "imgui_extras.h"
+
+namespace IltGui {
+ bool
+ BeginToolbar(const char * name, ImGuiDir dir, float axisSize, ImGuiWindowFlags windowFlags)
+ {
+ return BeginToolbar(name, ImGui::GetMainViewport(), dir, axisSize, windowFlags);
+ }
+
+ bool
+ BeginToolbar(
+ const char * name, ImGuiViewport * viewport, ImGuiDir dir, float axisSize, ImGuiWindowFlags windowFlags)
+ {
+ bool isOpen = ImGui::BeginViewportSideBar(name, viewport, dir, axisSize,
+ windowFlags | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings);
+ if (isOpen) {
+ if (dir == ImGuiDir_Up || dir == ImGuiDir_Down) {
+ ImGui::GetCurrentWindow()->DC.LayoutType = ImGuiLayoutType_Horizontal;
+ }
+ }
+ else {
+ ImGui::End();
+ }
+ return isOpen;
+ }
+
+ void
+ EndToolbar()
+ {
+ ImGui::End();
+ }
+}
diff --git a/ui/imgui_extras.h b/ui/imgui_extras.h
new file mode 100644
index 0000000..0babaa3
--- /dev/null
+++ b/ui/imgui_extras.h
@@ -0,0 +1,10 @@
+#include "imgui_wrap.h"
+
+namespace IltGui {
+ // NOLINTBEGIN(readability-identifier-naming)
+ bool BeginToolbar(const char * name, ImGuiViewport * viewport, ImGuiDir dir, float axisSize,
+ ImGuiWindowFlags windowFlags = 0);
+ bool BeginToolbar(const char * name, ImGuiDir dir, float axisSize, ImGuiWindowFlags windowFlags = 0);
+ void EndToolbar();
+ // NOLINTEND(readability-identifier-naming)
+}