From d79ca9b0b682681698ac12132d2c87673b986552 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 23 Aug 2021 14:57:23 +0200 Subject: [PATCH] Fixed nested BeginDisabled()/EndDisabled() calls. (#211, #4452, #4453, #4462) [Legulysse] --- docs/CHANGELOG.txt | 13 ++++++++++--- imgui.cpp | 6 ++++-- imgui.h | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f4d4a4476..951f3f643 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -31,15 +31,22 @@ HOW TO UPDATE? - 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) ----------------------------------------------------------------------- Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.1 -Other Changes: - -- Fixed BeginDisabled(false) - BeginDisabled(true) was working. (#211, #4452, #4453) +- Disabled: Fixed BeginDisabled(false) - BeginDisabled(true) was working. (#211, #4452, #4453) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 9139afeef..ab27f1307 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6627,9 +6627,11 @@ void ImGui::BeginDisabled(bool disabled) { ImGuiContext& g = *GImGui; bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; - g.DisabledAlphaBackup = g.Style.Alpha; if (!was_disabled && disabled) + { + g.DisabledAlphaBackup = g.Style.Alpha; g.Style.Alpha *= g.Style.DisabledAlpha; // PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * g.Style.DisabledAlpha); + } if (was_disabled || disabled) g.CurrentItemFlags |= ImGuiItemFlags_Disabled; g.ItemFlagsStack.push_back(g.CurrentItemFlags); @@ -6641,7 +6643,7 @@ void ImGui::EndDisabled() bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; //PopItemFlag(); g.ItemFlagsStack.pop_back(); - g.CurrentItemFlags &= ~ImGuiItemFlags_Disabled; + g.CurrentItemFlags = g.ItemFlagsStack.back(); if (was_disabled && (g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0) g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar(); } diff --git a/imgui.h b/imgui.h index c6132abe8..b56cb8524 100644 --- a/imgui.h +++ b/imgui.h @@ -60,8 +60,8 @@ Index of this file: // 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) -#define IMGUI_VERSION "1.84.1" -#define IMGUI_VERSION_NUM 18404 +#define IMGUI_VERSION "1.84.2" +#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_HAS_TABLE