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

@ -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();
}