Added PushDisabled(), PopDisabled() currently only exposed in imgui_internal.h (#211)

This commit is contained in:
ocornut
2021-06-09 15:28:59 +02:00
parent a44d4da87c
commit 865b2ca6f9
3 changed files with 25 additions and 1 deletions

View File

@ -7178,6 +7178,28 @@ void ImGui::PopItemFlag()
g.CurrentItemFlags = g.ItemFlagsStack.back();
}
// PushDisabled()/PopDisabled()
// - Those are not yet exposed in imgui.h because we are unsure of how to alter the style in a way that works for everyone.
// We may rework this. Hypothetically, a future styling system may set a flag which make widgets use different colors.
// - Feedback welcome at https://github.com/ocornut/imgui/issues/211
// - You may trivially implement your own variation of this if needed.
// Here we test (CurrentItemFlags & ImGuiItemFlags_Disabled) to allow nested PushDisabled() calls.
void ImGui::PushDisabled()
{
ImGuiContext& g = *GImGui;
if ((g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0)
PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.6f);
PushItemFlag(ImGuiItemFlags_Disabled, true);
}
void ImGui::PopDisabled()
{
ImGuiContext& g = *GImGui;
PopItemFlag();
if ((g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0)
PopStyleVar();
}
// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system.
void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
{