2
0
Эх сурвалжийг харах

Merge branch 'master' into viewport

# Conflicts:
#	imgui.cpp
omar 7 жил өмнө
parent
commit
23b67e6ff5
4 өөрчлөгдсөн 37 нэмэгдсэн , 14 устгасан
  1. 2 1
      CHANGELOG.txt
  2. 14 13
      imgui.cpp
  3. 19 0
      imgui_demo.cpp
  4. 2 0
      imgui_draw.cpp

+ 2 - 1
CHANGELOG.txt

@@ -43,7 +43,7 @@ Other Changes:
 
 
  - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat).
  - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat).
  - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly.
  - 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: 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)
  - 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 
  - Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes 
@@ -57,6 +57,7 @@ Other Changes:
  - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276)
  - 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]
  - OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby]
  - Demo: Added basic Drag and Drop demo. (#143)
  - 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: Tweaked the main.cpp of each example.
  - Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm]
  - Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm]
  - Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut]
  - Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut]

+ 14 - 13
imgui.cpp

@@ -805,7 +805,9 @@
 #endif
 #endif
 
 
 #include "imgui.h"
 #include "imgui.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
 #define IMGUI_DEFINE_MATH_OPERATORS
 #define IMGUI_DEFINE_MATH_OPERATORS
+#endif
 #include "imgui_internal.h"
 #include "imgui_internal.h"
 
 
 #include <ctype.h>      // toupper, isprint
 #include <ctype.h>      // toupper, isprint
@@ -3243,11 +3245,7 @@ static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window)
 void ImGui::NavUpdateWindowingList()
 void ImGui::NavUpdateWindowingList()
 {
 {
     ImGuiContext& g = *GImGui;
     ImGuiContext& g = *GImGui;
-    if (!g.NavWindowingTarget)
-    {
-        g.NavWindowingList = NULL;
-        return;
-    }
+    IM_ASSERT(g.NavWindowingTarget != NULL);
 
 
     if (g.NavWindowingList == NULL)
     if (g.NavWindowingList == NULL)
         g.NavWindowingList = FindWindowByName("###NavWindowingList");
         g.NavWindowingList = FindWindowByName("###NavWindowingList");
@@ -4919,6 +4917,12 @@ void ImGui::EndFrame()
         g.PlatformImePosViewport = NULL;
         g.PlatformImePosViewport = NULL;
     }
     }
 
 
+    // 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();
+
     // Draw modal whitening background on _other_ viewports than the one the modal is one
     // Draw modal whitening background on _other_ viewports than the one the modal is one
     ImGuiWindow* modal_window = GetFrontMostPopupModal();
     ImGuiWindow* modal_window = GetFrontMostPopupModal();
     const bool dim_bg_for_modal = (modal_window != NULL);
     const bool dim_bg_for_modal = (modal_window != NULL);
@@ -4938,16 +4942,13 @@ void ImGui::EndFrame()
             draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
             draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
         }
         }
 
 
-    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();
 
 
     SetCurrentViewport(NULL, NULL);
     SetCurrentViewport(NULL, NULL);
 
 
+    // Initiate moving window
     if (g.ActiveId == 0 && g.HoveredId == 0)
     if (g.ActiveId == 0 && g.HoveredId == 0)
     {
     {
         if (!g.NavWindow || !g.NavWindow->Appearing) // Unless we just made a window/popup appear
         if (!g.NavWindow || !g.NavWindow->Appearing) // Unless we just made a window/popup appear
@@ -5037,7 +5038,7 @@ void ImGui::Render()
         g.Viewports[n]->DrawDataBuilder.Clear();
         g.Viewports[n]->DrawDataBuilder.Clear();
     ImGuiWindow* windows_to_render_front_most[2];
     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[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++)
     for (int n = 0; n != g.Windows.Size; n++)
     {
     {
         ImGuiWindow* window = g.Windows[n];
         ImGuiWindow* window = g.Windows[n];

+ 19 - 0
imgui_demo.cpp

@@ -1351,6 +1351,25 @@ void ImGui::ShowDemoWindow(bool* p_open)
             if (embed_all_inside_a_child_window)
             if (embed_all_inside_a_child_window)
                 EndChild();
                 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();
             ImGui::TreePop();
         }
         }
     }
     }

+ 2 - 0
imgui_draw.cpp

@@ -14,7 +14,9 @@
 #endif
 #endif
 
 
 #include "imgui.h"
 #include "imgui.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
 #define IMGUI_DEFINE_MATH_OPERATORS
 #define IMGUI_DEFINE_MATH_OPERATORS
+#endif
 #include "imgui_internal.h"
 #include "imgui_internal.h"
 
 
 #include <stdio.h>      // vsnprintf, sscanf, printf
 #include <stdio.h>      // vsnprintf, sscanf, printf