MultiSelect: Temporary fix/work-around for child/popup to not inherit MultiSelectEnabled flag, until we make mulit-select data stackable.

This commit is contained in:
ocornut
2020-08-20 20:46:57 +02:00
parent 00c4b8f2a3
commit b9721c1ed7
3 changed files with 17 additions and 9 deletions

View File

@@ -6464,7 +6464,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiID storage_id, ImGuiTreeNodeFlags
const bool was_selected = selected;
// Multi-selection support (header)
const bool is_multi_select = g.MultiSelectEnabled;
const bool is_multi_select = (g.MultiSelectEnabledWindow == window);
if (is_multi_select)
{
MultiSelectItemHeader(id, &selected);
@@ -6816,7 +6816,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ((flags & ImGuiSelectableFlags_AllowOverlap) || (g.LastItemData.InFlags & ImGuiItemFlags_AllowOverlap)) { button_flags |= ImGuiButtonFlags_AllowOverlap; }
// Multi-selection support (header)
const bool is_multi_select = g.MultiSelectEnabled;
const bool is_multi_select = (g.MultiSelectEnabledWindow == window);
const bool was_selected = selected;
if (is_multi_select)
{
@@ -7126,7 +7126,7 @@ ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void*
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(g.MultiSelectEnabled == false); // No recursion allowed yet (we could allow it if we deem it useful)
IM_ASSERT(g.MultiSelectEnabledWindow == NULL); // No recursion allowed yet (we could allow it if we deem it useful)
IM_ASSERT(g.MultiSelectFlags == 0);
IM_ASSERT(g.MultiSelectState.FocusScopeId == 0);
@@ -7135,7 +7135,7 @@ ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void*
ms->Clear();
ms->FocusScopeId = window->IDStack.back();
PushFocusScope(ms->FocusScopeId);
g.MultiSelectEnabled = true;
g.MultiSelectEnabledWindow = window;
g.MultiSelectFlags = flags;
// Use copy of keyboard mods at the time of the request, otherwise we would requires mods to be held for an extra frame.
@@ -7182,7 +7182,7 @@ ImGuiMultiSelectData* ImGui::EndMultiSelect()
ms->Out.RangeValue = true;
g.MultiSelectState.FocusScopeId = 0;
PopFocusScope();
g.MultiSelectEnabled = false;
g.MultiSelectEnabledWindow = NULL;
g.MultiSelectFlags = ImGuiMultiSelectFlags_None;
#ifdef IMGUI_DEBUG_MULTISELECT