From 25256ee6a73cf96e4ed163bab78fdcfeb038d67f Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Tue, 9 Jul 2024 20:28:58 +0200 Subject: [PATCH] Update imgui (fix issue stack layout / clipping in node with spring) See https://github.com/ocornut/imgui/pull/846#issuecomment-2218360061 + sandbox to reproduce the issue --- .../demos_cpp/sandbox/sandbox_stacklayout.cpp | 57 +++++++++++++++++++ .../sandbox/sandbox_stacklayout.py | 22 +++++++ external/imgui/imgui | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 bindings/imgui_bundle/demos_cpp/sandbox/sandbox_stacklayout.cpp create mode 100644 bindings/imgui_bundle/demos_python/sandbox/sandbox_stacklayout.py diff --git a/bindings/imgui_bundle/demos_cpp/sandbox/sandbox_stacklayout.cpp b/bindings/imgui_bundle/demos_cpp/sandbox/sandbox_stacklayout.cpp new file mode 100644 index 00000000..8f5238c7 --- /dev/null +++ b/bindings/imgui_bundle/demos_cpp/sandbox/sandbox_stacklayout.cpp @@ -0,0 +1,57 @@ +#include "imgui.h" +#include "immapp/immapp.h" +#include "imgui-node-editor/imgui_node_editor.h" + +namespace ed = ax::NodeEditor; + + +void GuiNode() +{ + // Basically a vertical layout with 2 inner horizontal layouts that contain text elements + a spring element + ImGui::BeginVertical("V"); + { + ImGui::BeginHorizontal("H"); + { + ImGui::Text("Hello"); + ImGui::Spring(); + ImGui::Text("world"); // With the new version, this is clipped out! + } + ImGui::EndHorizontal(); + + ImGui::BeginHorizontal("H2"); + { + ImGui::Text("Hello"); + ImGui::Spring(); + ImGui::Text("world"); + ImGui::Text("And again"); + } + ImGui::EndHorizontal(); + } + ImGui::EndVertical(); +} + + +void Gui() +{ + // A simple node editor with a single node + ed::Begin("Node editor"); + ed::BeginNode(ed::NodeId(1)); + { + GuiNode(); + } + ed::EndNode(); + ed::End(); +} + + +int main(int, char**) +{ + // Run the application using ImmApp (from ImGui Bundle) + // This is simply a way to quickly setup an application with ImGui + Node Editor + HelloImGui::RunnerParams runnerParams; + runnerParams.callbacks.ShowGui = Gui; + ImmApp::AddOnsParams addOnsParams; + addOnsParams.withNodeEditor = true; + ImmApp::Run(runnerParams, addOnsParams); + return 0; +} diff --git a/bindings/imgui_bundle/demos_python/sandbox/sandbox_stacklayout.py b/bindings/imgui_bundle/demos_python/sandbox/sandbox_stacklayout.py new file mode 100644 index 00000000..69dd9e95 --- /dev/null +++ b/bindings/imgui_bundle/demos_python/sandbox/sandbox_stacklayout.py @@ -0,0 +1,22 @@ +from imgui_bundle import imgui, immapp, imgui_ctx, imgui_node_editor as ed + + +def gui(): + with imgui_ctx.begin_vertical("V"): + ed.begin("Node editor") + ed.begin_node(ed.NodeId(1)) + with imgui_ctx.begin_horizontal("H"): + imgui.text("Hello") + imgui.spring() + imgui.text("world") + + with imgui_ctx.begin_horizontal("H2"): + imgui.text("Hello") + imgui.spring() + imgui.text("world") + imgui.text("And again") + ed.end_node() + ed.end() + + +immapp.run(gui, with_node_editor=True) diff --git a/external/imgui/imgui b/external/imgui/imgui index d674b59b..9efb7f8b 160000 --- a/external/imgui/imgui +++ b/external/imgui/imgui @@ -1 +1 @@ -Subproject commit d674b59ba8f0b16cba5f582e04abd3a2f4652ec4 +Subproject commit 9efb7f8b195f5db9a68bae3e76b2a8e5a8319bd4