From 97fcee0d0d602bab5bac0f3cc0c736bc04df282e Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 16 Jan 2015 10:55:49 +0000 Subject: [PATCH 1/3] Fix usage of multiple Begin/End pair for the same window, handling of move in End() was stealing Active ID --- imgui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 14589d01..e9fbbc2b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -201,6 +201,7 @@ - window: resizing from any sides? + mouse cursor directives for app. - widgets: switching from "widget-label" to "label-widget" would make it more convenient to integrate widgets in trees - widgets: clip text? hover clipped text shows it in a tooltip or in-place overlay + - main: considering adding EndFrame() - optional, else done in Render(). and Init() - main: IsItemHovered() returns true even if mouse is active on another widget (e.g. dragging outside of sliders). Maybe not a sensible default? Add parameter or alternate function? - main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes - main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode? @@ -1751,6 +1752,10 @@ void ImGui::Render() g.CurrentWindow->Visible = false; ImGui::End(); + // Select window for move/focus when we're done with all our widgets (we only consider non-childs windows here) + if (g.ActiveId == 0 && g.HoveredId == 0 && g.HoveredRootWindow != NULL && g.IO.MouseClicked[0]) + g.ActiveId = g.HoveredRootWindow->GetID("#MOVE"); + // Sort the window list so that all child windows are after their parent // We cannot do that on FocusWindow() because childs may not exist yet ImVector sorted_windows; @@ -2717,11 +2722,6 @@ void ImGui::End() PopClipRect(); // inner window clip rectangle PopClipRect(); // outer window clip rectangle - // Select window for move/focus when we're done with all our widgets (we only consider non-childs windows here) - const ImGuiAabb bb(window->Pos, window->Pos+window->Size); - if (g.ActiveId == 0 && g.HoveredId == 0 && g.HoveredRootWindow == window && IsMouseHoveringBox(bb) && g.IO.MouseClicked[0]) - g.ActiveId = window->GetID("#MOVE"); - // Stop logging if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging ImGui::LogFinish(); From 79d1a9d941eb51b7f35abf3291ef5dbe1122440f Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 17 Jan 2015 12:27:27 +0000 Subject: [PATCH 2/3] Commenting asserts. --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e9fbbc2b..d15bdb9c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2848,7 +2848,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) ImGuiState& g = GImGui; float* pvar = GetStyleVarFloatAddr(idx); - IM_ASSERT(pvar != NULL); // Called wrong function? + IM_ASSERT(pvar != NULL); // Called function with wrong-type? Variable is not a float. ImGuiStyleMod backup; backup.Var = idx; backup.PreviousValue = ImVec2(*pvar, 0.0f); @@ -2862,7 +2862,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) ImGuiState& g = GImGui; ImVec2* pvar = GetStyleVarVec2Addr(idx); - IM_ASSERT(pvar != NULL); // Called wrong function? + IM_ASSERT(pvar != NULL); // Called function with wrong-type? Varialble is not a ImVec2. ImGuiStyleMod backup; backup.Var = idx; backup.PreviousValue = *pvar; From a3e368a4771a2fd7786bf0e08bcd95f1ec133184 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 17 Jan 2015 17:19:07 +0000 Subject: [PATCH 3/3] Fixed alignment of ColorEdit4() label --- imgui.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index d15bdb9c..1e909fbc 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5448,9 +5448,13 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha) // Don't set local copy of 'edit_mode' right away! g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); } + ImGui::SameLine(); + } + else + { + ImGui::SameLine(0, (int)style.ItemInnerSpacing.x); } - ImGui::SameLine(); ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); // Convert back