From 8cfae350426bd437d9417ce04c9a2c910f85bd5f Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 24 May 2015 17:30:59 +0100 Subject: [PATCH] Added Dummy() helper --- imgui.cpp | 16 ++++++++++++++-- imgui.h | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index b405e529..de8a71d9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7472,16 +7472,22 @@ void ImGui::Separator() } } -// A little vertical spacing. void ImGui::Spacing() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; - ItemSize(ImVec2(0,0)); } +void ImGui::Dummy(const ImVec2& size) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return; + ItemSize(size); +} + // Advance cursor given item size. static void ItemSize(ImVec2 size, float text_offset_y) { @@ -10463,6 +10469,12 @@ void ImGui::ShowTestWindow(bool* opened) } ImGui::PopItemWidth(); + // Dummy + ImVec2 sz(30,30); + ImGui::Button("A", sz); ImGui::SameLine(); + ImGui::Dummy(sz); ImGui::SameLine(); + ImGui::Button("B", sz); + ImGui::TreePop(); } diff --git a/imgui.h b/imgui.h index 8331d747..8432862b 100644 --- a/imgui.h +++ b/imgui.h @@ -169,11 +169,12 @@ namespace ImGui IMGUI_API void EndPopup(); // Layout - IMGUI_API void BeginGroup(); + IMGUI_API void BeginGroup(); // once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc. IMGUI_API void EndGroup(); IMGUI_API void Separator(); // horizontal line IMGUI_API void SameLine(int column_x = 0, int spacing_w = -1); // call between widgets or groups to layout them horizontally - IMGUI_API void Spacing(); // add vertical spacing + IMGUI_API void Spacing(); // add spacing + IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels IMGUI_API void Unindent(); // move content position back to the left (cancel Indent) IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border=true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).