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

features/range_select
ocornut ago%!(EXTRA string=5 years)
parent 25f49eaf42
commit 21b2691e55
  1. 10
      imgui_demo.cpp
  2. 6
      imgui_internal.h
  3. 10
      imgui_widgets.cpp

@ -2837,7 +2837,7 @@ static void ShowDemoWindowMultiSelect()
if (ImGui::RadioButton("Tree nodes", widget_type == WidgetType_TreeNode)) { widget_type = WidgetType_TreeNode; }
ImGui::SameLine();
ImGui::Checkbox("Use 2 columns", &use_columns);
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int*)&ImGui::GetIO().ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", &ImGui::GetIO().ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::SameLine(); HelpMarker("Hold CTRL and click to select multiple items. Hold SHIFT to select a range. Keyboard is also supported.");
// Open a scrolling region
@ -2898,6 +2898,14 @@ static void ShowDemoWindowMultiSelect()
ImGui::TreePop();
}
// Right-click: context menu
if (ImGui::BeginPopupContextItem())
{
ImGui::Text("(Testing Selectable inside an embedded popup)");
ImGui::Selectable("Close");
ImGui::EndPopup();
}
if (use_columns)
{
ImGui::NextColumn();

@ -2113,9 +2113,9 @@ struct ImGuiContext
ImVec2 NavWindowingAccumDeltaSize;
// Range-Select/Multi-Select
bool MultiSelectEnabled;
ImGuiWindow* MultiSelectEnabledWindow; // FIXME-MULTISELECT: We currently don't support recursing/stacking multi-select
ImGuiMultiSelectFlags MultiSelectFlags;
ImGuiMultiSelectState MultiSelectState; // We currently don't support recursing/stacking multi-select
ImGuiMultiSelectState MultiSelectState;
ImGuiKeyChord MultiSelectKeyMods;
// Render
@ -2375,7 +2375,7 @@ struct ImGuiContext
NavWindowingToggleLayer = false;
NavWindowingToggleKey = ImGuiKey_None;
MultiSelectEnabled = false;
MultiSelectEnabledWindow = NULL;
MultiSelectFlags = ImGuiMultiSelectFlags_None;
MultiSelectKeyMods = ImGuiMod_None;

@ -6352,7 +6352,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
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);
@ -6699,7 +6699,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)
{
@ -7009,7 +7009,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);
@ -7018,7 +7018,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.
@ -7065,7 +7065,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

Loading…
Cancel
Save