Fixed nested BeginDisabled()/EndDisabled() calls. (#211, #4452, #4453, #4462) [Legulysse]

This commit is contained in:
ocornut 2021-08-23 14:57:23 +02:00
parent e6ffc04291
commit d79ca9b0b6
3 changed files with 16 additions and 7 deletions

View File

@ -31,15 +31,22 @@ HOW TO UPDATE?
- Please report any issue! - Please report any issue!
-----------------------------------------------------------------------
VERSION 1.84.2 (Released 2021-08-23)
-----------------------------------------------------------------------
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.2
- Disabled: Fixed nested BeginDisabled()/EndDisabled() calls. (#211, #4452, #4453, #4462) [@Legulysse]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.84.1 (Released 2021-08-20) VERSION 1.84.1 (Released 2021-08-20)
----------------------------------------------------------------------- -----------------------------------------------------------------------
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.1 Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.1
Other Changes: - Disabled: Fixed BeginDisabled(false) - BeginDisabled(true) was working. (#211, #4452, #4453)
- Fixed BeginDisabled(false) - BeginDisabled(true) was working. (#211, #4452, #4453)
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -6627,9 +6627,11 @@ void ImGui::BeginDisabled(bool disabled)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
g.DisabledAlphaBackup = g.Style.Alpha;
if (!was_disabled && disabled) if (!was_disabled && disabled)
{
g.DisabledAlphaBackup = g.Style.Alpha;
g.Style.Alpha *= g.Style.DisabledAlpha; // PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * g.Style.DisabledAlpha); g.Style.Alpha *= g.Style.DisabledAlpha; // PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * g.Style.DisabledAlpha);
}
if (was_disabled || disabled) if (was_disabled || disabled)
g.CurrentItemFlags |= ImGuiItemFlags_Disabled; g.CurrentItemFlags |= ImGuiItemFlags_Disabled;
g.ItemFlagsStack.push_back(g.CurrentItemFlags); g.ItemFlagsStack.push_back(g.CurrentItemFlags);
@ -6641,7 +6643,7 @@ void ImGui::EndDisabled()
bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
//PopItemFlag(); //PopItemFlag();
g.ItemFlagsStack.pop_back(); g.ItemFlagsStack.pop_back();
g.CurrentItemFlags &= ~ImGuiItemFlags_Disabled; g.CurrentItemFlags = g.ItemFlagsStack.back();
if (was_disabled && (g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0) if (was_disabled && (g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0)
g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar(); g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar();
} }

View File

@ -60,8 +60,8 @@ Index of this file:
// Version // Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.84.1" #define IMGUI_VERSION "1.84.2"
#define IMGUI_VERSION_NUM 18404 #define IMGUI_VERSION_NUM 18405
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE