Updated Multi Select (markdown)

omar
2024-03-06 15:14:31 +01:00
parent 18045e4b0d
commit 06c9524a8a

@@ -49,7 +49,7 @@ struct ImGuiSelectionRequest
{
//------------------------------------------// BeginMultiSelect / EndMultiSelect
ImGuiSelectionRequestType Type; // ms:w, app:r / ms:w, app:r // Request type. You'll most often receive 1 Clear + 1 SetRange with a single-item range.
bool RangeSelected; // / ms:w, app:r // Parameter for SetRange request (true = select range, false = unselect range)
bool Selected; // / ms:w, app:r // Parameter for SetAll/SetRange request (true = select, false = unselect)
ImGuiSelectionUserData RangeFirstItem; // / ms:w, app:r // Parameter for SetRange request (this is generally == RangeSrcItem when shift selecting from top to bottom)
ImGuiSelectionUserData RangeLastItem; // / ms:w, app:r // Parameter for SetRange request (this is generally == RangeSrcItem when shift selecting from bottom to top)
};
@@ -58,9 +58,8 @@ struct ImGuiSelectionRequest
enum ImGuiSelectionRequestType
{
ImGuiSelectionRequestType_None = 0,
ImGuiSelectionRequestType_Clear, // Request app to clear selection.
ImGuiSelectionRequestType_SelectAll, // Request app to select all.
ImGuiSelectionRequestType_SetRange, // Request app to select/unselect [RangeFirstItem..RangeLastItem] items based on 'bool RangeSelected'. Only EndMultiSelect() request this, app code can read after BeginMultiSelect() and it will always be false.
ImGuiSelectionRequestType_SetAll, // Request app to clear selection (if Selected==false) or select all items (if Selected==true)
ImGuiSelectionRequestType_SetRange, // Request app to select/unselect [RangeFirstItem..RangeLastItem] items (inclusive) based on value of Selected. Only EndMultiSelect() request this, app code can read after BeginMultiSelect() and it will always be false.
};
```
@@ -70,13 +69,13 @@ enum ImGuiSelectionRequestType
- Store and maintain actual selection data using persistent object identifiers.
- Usage Flow:
- (1) Call `BeginMultiSelect()` and retrieve the `ImGuiMultiSelectIO*` result.
- (2) Honor request list (Clear/SelectAll/SetRange requests) by updating your selection data. Same code as Step 6.
- (2) [If using clipper] Honor request list (SetAll/SetRange requests) by updating your selection data. Same code as Step 6.
- (3) [If using clipper] You need to make sure RangeSrcItem is always submitted.
- Calculate its index and pass to `clipper.IncludeItemByIndex()`.
- If storing indices in `ImGuiSelectionUserData`, a simple `clipper.IncludeItemByIndex(ms_io->RangeSrcItem)` call will work.
- (4) Submit your items with `SetNextItemSelectionUserData()` + `Selectable()`/`TreeNode()` calls.
- (5) Call `EndMultiSelect()` and retrieve the `ImGuiMultiSelectIO*` result.
- (6) Honor request list (Clear/SelectAll/SetRange requests) by updating your selection data. Same code as Step 2.
- (6) Honor request list (SetAll/SetRange requests) by updating your selection data. Same code as Step 2.
- If you submit all items (no clipper), Step 2 and 3 are optional and will be handled by each item themselves. It is fine to always honor those steps.
### About ImGuiSelectionUserData