From 0c207b7bc9bcf62fafb28913246e283137ba1d68 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 17 Jul 2018 11:33:31 +0200 Subject: [PATCH 1/3] Demo: Clarified the use of IsItemHovered()/IsItemActive() right after being in the "Active, Focused, Hovered & Focused Tests" section. This will be of more importance with the introduction of tabs. --- CHANGELOG.txt | 1 + imgui_demo.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e22e3655..a35410c0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -57,6 +57,7 @@ Other Changes: - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) - OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby] - Demo: Added basic Drag and Drop demo. (#143) + - Demo: Clarified the use of IsItemHovered()/IsItemActive() right after being in the "Active, Focused, Hovered & Focused Tests" section. - Examples: Tweaked the main.cpp of each example. - Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm] - Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index d9ceaf82..5020e04c 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1350,6 +1350,25 @@ void ImGui::ShowDemoWindow(bool* p_open) if (embed_all_inside_a_child_window) EndChild(); + // Calling IsItemHovered() after begin returns the hovered status of the title bar. + // This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window. + static bool test_window = false; + ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window); + if (test_window) + { + ImGui::Begin("Title bar Hovered/Active tests", &test_window); + if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() + { + if (ImGui::MenuItem("Close")) { test_window = false; } + ImGui::EndPopup(); + } + ImGui::Text( + "IsItemHovered() after begin = %d (== is title bar hovered)\n" + "IsItemActive() after begin = %d (== is window being clicked/moved)\n", + ImGui::IsItemHovered(), ImGui::IsItemActive()); + ImGui::End(); + } + ImGui::TreePop(); } } From 7e59eb026b5e9ede5560492def408e65e1c01c20 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys <19151258+rokups@users.noreply.github.com> Date: Tue, 17 Jul 2018 18:17:56 +0300 Subject: [PATCH 2/3] Fix warning when IMGUI_DEFINE_MATH_OPERATORS is already defined by build system. (#1950) --- imgui.cpp | 2 ++ imgui_draw.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 499ac2ea..7f5ecc40 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -794,7 +794,9 @@ #endif #include "imgui.h" +#ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS +#endif #include "imgui_internal.h" #include // toupper, isprint diff --git a/imgui_draw.cpp b/imgui_draw.cpp index a192fff4..0f69a82b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -14,7 +14,9 @@ #endif #include "imgui.h" +#ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS +#endif #include "imgui_internal.h" #include // vsnprintf, sscanf, printf From 93321d3280f58f5cbbba28d4d31ba05e5eb029f9 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 17 Jul 2018 19:48:53 +0200 Subject: [PATCH 3/3] Nav: Fixed CTRL+TAB windowing list from always showing the implicit Debug window. (#787) --- CHANGELOG.txt | 2 +- imgui.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a35410c0..c2044d3d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -43,7 +43,7 @@ Other Changes: - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat). - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. - - Nav: Added a CTRL+TAB window list and changed the highlight system accordingly. This is designed to allow CTRL+TAB between Tabs in the future. + - Nav: Added a CTRL+TAB window list and changed the highlight system accordingly. This is designed to allow CTRL+TAB between Tabs in the future. (#787) - Window: Allow menu and popups windows from ignoring the style.WindowMinSize values so short menus/popups are not padded. (#1909) - Window: Added global io.OptResizeWindowsFromEdges option to enable resizing windows from their edges and from the lower-left corner. (#1495) - Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes diff --git a/imgui.cpp b/imgui.cpp index 7f5ecc40..b54b86b8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3188,11 +3188,7 @@ static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) void ImGui::NavUpdateWindowingList() { ImGuiContext& g = *GImGui; - if (!g.NavWindowingTarget) - { - g.NavWindowingList = NULL; - return; - } + IM_ASSERT(g.NavWindowingTarget != NULL); if (g.NavWindowingList == NULL) g.NavWindowingList = FindWindowByName("###NavWindowingList"); @@ -4387,14 +4383,17 @@ void ImGui::EndFrame() g.PlatformImeLastPos = g.PlatformImePos; } - NavUpdateWindowingList(); - // Hide implicit "Debug" window if it hasn't been used IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin()/End() calls, did you forget to call end on g.CurrentWindow->Name? if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) g.CurrentWindow->Active = false; End(); + // Show CTRL+TAB list + if (g.NavWindowingTarget) + NavUpdateWindowingList(); + + // Initiate moving window if (g.ActiveId == 0 && g.HoveredId == 0) { if (!g.NavWindow || !g.NavWindow->Appearing) // Unless we just made a window/popup appear @@ -4468,7 +4467,7 @@ void ImGui::Render() g.DrawDataBuilder.Clear(); ImGuiWindow* windows_to_render_front_most[2]; windows_to_render_front_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL; - windows_to_render_front_most[1] = (g.NavWindowingList); + windows_to_render_front_most[1] = g.NavWindowingTarget ? g.NavWindowingList : NULL; for (int n = 0; n != g.Windows.Size; n++) { ImGuiWindow* window = g.Windows[n];