瀏覽代碼

Disabled: Reworked 1.90.8 behavior of Begin() not inheriting current BeginDisabled() state. Only tooltip are clearing that state. (#211, #7640)

ocornut 1 年之前
父節點
當前提交
dd5c30d2d7
共有 4 個文件被更改,包括 7 次插入5 次删除
  1. 4 2
      docs/CHANGELOG.txt
  2. 1 1
      imgui.cpp
  3. 1 0
      imgui.h
  4. 1 2
      imgui_demo.cpp

+ 4 - 2
docs/CHANGELOG.txt

@@ -67,8 +67,6 @@ Other changes:
   on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
   on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
   ImGui::GetMouseCursor() value. (#1495)
   ImGui::GetMouseCursor() value. (#1495)
 - IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
 - IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
-- Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block bypassing
-  the disabled state. (#7726)
 - Windows: BeginChild(): fixed a glitch when during a resize of a child window which is
 - Windows: BeginChild(): fixed a glitch when during a resize of a child window which is
   tightly close to the boundaries of its parent (e.g. with zero WindowPadding), the child
   tightly close to the boundaries of its parent (e.g. with zero WindowPadding), the child
   position could have temporarily be moved around by erroneous padding application. (#7706)
   position could have temporarily be moved around by erroneous padding application. (#7706)
@@ -77,6 +75,10 @@ Other changes:
   Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
   Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
 - Tables: added TableGetHoveredColumn() to public API, as an alternative to testing for
 - Tables: added TableGetHoveredColumn() to public API, as an alternative to testing for
   'TableGetColumnFlags(column) & ImGuiTableColumnFlags_IsHovered' on each column. (#3740)
   'TableGetColumnFlags(column) & ImGuiTableColumnFlags_IsHovered' on each column. (#3740)
+- Disabled, Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block
+  bypassing the disabled state. (#7726)
+- Disabled: Reworked 1.90.8 behavior of Begin() not inheriting current BeginDisabled() state,
+  to make it that only tooltip windows are temporarily clearing it. (#211, #7640)
 - Drags: added ImGuiSliderFlags_WrapAround flag for DragInt(), DragFloat() etc. (#7749)
 - Drags: added ImGuiSliderFlags_WrapAround flag for DragInt(), DragFloat() etc. (#7749)
 - Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern sets
 - Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern sets
   active id so a multi-frame extern source doesn't interfere with hovered widgets. (#143)
   active id so a multi-frame extern source doesn't interfere with hovered widgets. (#143)

+ 1 - 1
imgui.cpp

@@ -6589,7 +6589,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
     window_stack_data.Window = window;
     window_stack_data.Window = window;
     window_stack_data.ParentLastItemDataBackup = g.LastItemData;
     window_stack_data.ParentLastItemDataBackup = g.LastItemData;
     window_stack_data.StackSizesOnBegin.SetToContextState(&g);
     window_stack_data.StackSizesOnBegin.SetToContextState(&g);
-    window_stack_data.DisabledOverrideReenable = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
+    window_stack_data.DisabledOverrideReenable = (flags & ImGuiWindowFlags_Tooltip) && (g.CurrentItemFlags & ImGuiItemFlags_Disabled);
     g.CurrentWindowStack.push_back(window_stack_data);
     g.CurrentWindowStack.push_back(window_stack_data);
     if (flags & ImGuiWindowFlags_ChildMenu)
     if (flags & ImGuiWindowFlags_ChildMenu)
         g.BeginMenuDepth++;
         g.BeginMenuDepth++;

+ 1 - 0
imgui.h

@@ -861,6 +861,7 @@ namespace ImGui
     // Disabling [BETA API]
     // Disabling [BETA API]
     // - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors)
     // - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors)
     // - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled)
     // - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled)
+    // - Tooltips windows by exception are opted out of disabling.
     // - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it.
     // - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it.
     IMGUI_API void          BeginDisabled(bool disabled = true);
     IMGUI_API void          BeginDisabled(bool disabled = true);
     IMGUI_API void          EndDisabled();
     IMGUI_API void          EndDisabled();

+ 1 - 2
imgui_demo.cpp

@@ -889,12 +889,11 @@ static void ShowDemoWindowWidgets()
 
 
         // Using ImGuiHoveredFlags_ForTooltip will pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav',
         // Using ImGuiHoveredFlags_ForTooltip will pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav',
         // which default value include the ImGuiHoveredFlags_AllowWhenDisabled flag.
         // which default value include the ImGuiHoveredFlags_AllowWhenDisabled flag.
-        // As a result, Set
         ImGui::BeginDisabled();
         ImGui::BeginDisabled();
         ImGui::Button("Disabled item", sz);
         ImGui::Button("Disabled item", sz);
-        ImGui::EndDisabled();
         if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
         if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
             ImGui::SetTooltip("I am a a tooltip for a disabled item.");
             ImGui::SetTooltip("I am a a tooltip for a disabled item.");
+        ImGui::EndDisabled();
 
 
         ImGui::TreePop();
         ImGui::TreePop();
     }
     }