MultiSelect: Transition to use FocusScope bits merged in master.

Preserve ability to shift+arrow into an item that is part of FocusScope but doesn't carry a selection without breaking selection.
This commit is contained in:
omar
2024-07-18 18:19:12 +02:00
committed by ocornut
parent 4afbfd5e71
commit 9c7183dd04
3 changed files with 31 additions and 22 deletions
+8 -7
View File
@@ -1210,6 +1210,7 @@ enum ImGuiNextItemDataFlags_
ImGuiNextItemDataFlags_HasOpen = 1 << 1,
ImGuiNextItemDataFlags_HasShortcut = 1 << 2,
ImGuiNextItemDataFlags_HasRefVal = 1 << 3,
ImGuiNextItemDataFlags_HasSelectionData = 1 << 4,
};
struct ImGuiNextItemData
@@ -1217,6 +1218,7 @@ struct ImGuiNextItemData
ImGuiNextItemDataFlags Flags;
ImGuiItemFlags ItemFlags; // Currently only tested/used for ImGuiItemFlags_AllowOverlap.
// Non-flags members are NOT cleared by ItemAdd() meaning they are still valid during NavProcessItem()
ImGuiID FocusScopeId; // Set by SetNextItemSelectionUserData() (!= 0 signify value has been set)
ImGuiSelectionUserData SelectionUserData; // Set by SetNextItemSelectionUserData() (note that NULL/0 is a valid value, we use -1 == ImGuiSelectionUserData_Invalid to mark invalid values)
float Width; // Set by SetNextItemWidth()
ImGuiKeyChord Shortcut; // Set by SetNextItemShortcut()
@@ -1713,13 +1715,14 @@ struct ImGuiOldColumns
struct IMGUI_API ImGuiMultiSelectState
{
ImGuiID FocusScopeId; // Same as CurrentWindow->DC.FocusScopeIdCurrent (unless another selection scope was pushed manually)
ImGuiMultiSelectData In; // The In requests are set and returned by BeginMultiSelect()
ImGuiMultiSelectData Out; // The Out requests are finalized and returned by EndMultiSelect()
bool InRangeDstPassedBy; // (Internal) set by the the item that match NavJustMovedToId when InRequestRangeSetNav is set.
bool InRequestSetRangeNav; // (Internal) set by BeginMultiSelect() when using Shift+Navigation. Because scrolling may be affected we can't afford a frame of lag with Shift+Navigation.
ImGuiMultiSelectState() { Clear(); }
void Clear() { In.Clear(); Out.Clear(); InRangeDstPassedBy = InRequestSetRangeNav = false; }
void Clear() { FocusScopeId = 0; In.Clear(); Out.Clear(); InRangeDstPassedBy = InRequestSetRangeNav = false; }
};
#endif // #ifdef IMGUI_HAS_MULTI_SELECT
@@ -2117,10 +2120,9 @@ struct ImGuiContext
ImVec2 NavWindowingAccumDeltaSize;
// Range-Select/Multi-Select
ImGuiID MultiSelectScopeId;
ImGuiWindow* MultiSelectScopeWindow;
bool MultiSelectEnabled;
ImGuiMultiSelectFlags MultiSelectFlags;
ImGuiMultiSelectState MultiSelectState;
ImGuiMultiSelectState MultiSelectState; // We currently don't support recursing/stacking multi-select
// Render
float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
@@ -2385,9 +2387,8 @@ struct ImGuiContext
NavWindowingToggleLayer = false;
NavWindowingToggleKey = ImGuiKey_None;
MultiSelectScopeId = 0;
MultiSelectScopeWindow = NULL;
MultiSelectFlags = 0;
MultiSelectEnabled = false;
MultiSelectFlags = ImGuiMultiSelectFlags_None;
DimBgRatio = 0.0f;