mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
RangeSelect/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:
parent
a7977d1e8b
commit
a02d500990
@ -1272,7 +1272,7 @@ static void ShowDemoWindowWidgets()
|
||||
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
|
||||
@ -1333,6 +1333,14 @@ static void ShowDemoWindowWidgets()
|
||||
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();
|
||||
|
@ -1718,9 +1718,9 @@ struct ImGuiContext
|
||||
bool NavWindowingToggleLayer;
|
||||
|
||||
// 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;
|
||||
ImGuiKeyModFlags MultiSelectKeyMods;
|
||||
|
||||
// Render
|
||||
@ -1919,7 +1919,7 @@ struct ImGuiContext
|
||||
NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
|
||||
NavWindowingToggleLayer = false;
|
||||
|
||||
MultiSelectEnabled = false;
|
||||
MultiSelectEnabledWindow = NULL;
|
||||
MultiSelectFlags = ImGuiMultiSelectFlags_None;
|
||||
MultiSelectKeyMods = ImGuiKeyModFlags_None;
|
||||
|
||||
|
@ -5922,7 +5922,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);
|
||||
@ -6255,7 +6255,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; }
|
||||
|
||||
// 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)
|
||||
{
|
||||
@ -6375,7 +6375,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);
|
||||
|
||||
@ -6384,7 +6384,7 @@ ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void*
|
||||
state->Clear();
|
||||
state->BackupFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
state->FocusScopeId = window->DC.NavFocusScopeIdCurrent = window->IDStack.back();
|
||||
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.
|
||||
@ -6434,7 +6434,7 @@ ImGuiMultiSelectData* ImGui::EndMultiSelect()
|
||||
state->Out.RangeValue = true;
|
||||
g.MultiSelectState.FocusScopeId = 0;
|
||||
window->DC.NavFocusScopeIdCurrent = g.MultiSelectState.BackupFocusScopeId;
|
||||
g.MultiSelectEnabled = false;
|
||||
g.MultiSelectEnabledWindow = NULL;
|
||||
g.MultiSelectFlags = ImGuiMultiSelectFlags_None;
|
||||
|
||||
#ifdef IMGUI_DEBUG_MULTISELECT
|
||||
|
Loading…
Reference in New Issue
Block a user