boolRequestSelectAll;// ms:w, app:r / / ms:w, app:r // 2. Request app/user to select all.
boolRequestSetRange;// / / ms:w, app:r // 3. Request app/user to select/unselect [RangeSrcItem..RangeDstItem] items, based on RangeSelected. In practice, only EndMultiSelect() request this, app code can read after BeginMultiSelect() and it will always be false.
void*RequestFocusItem;// app:w / app:r / app:r // (If using deletion) 4. Request user to focus item. This is actually only manipulated in user-space, but we provide storage to facilitate implemention of deletion idiom (see demo).
// STATE/ARGUMENTS ---------// BEGIN / LOOP / END
void*RangeSrcItem;// ms:w / app:r / ms:w, app:r // Begin: Last known SetNextItemSelectionUserData() value for RangeSrcItem. End: parameter from RequestSetRange request.
ImS8RangeDirection;// / / ms:w, app:r // End: parameter from RequestSetRange request. +1 if RangeSrcItem came before RangeDstItem, -1 otherwise. Available as an indicator in case you cannot infer order from the void* values. If your void* values are storing indices you will never need this.
boolRangeSrcPassedBy;// / ms:rw app:w / ms:r // (If using clipper) Need to be set by app/user if RangeSrcItem was part of the clipped set before submitting the visible items. Ignore if not clipping.
boolRangeSrcReset;// / app:w / ms:r // (If using deletion) Set before EndMultiSelect() to reset ResetSrcItem (e.g. if deleted selection).
boolRangeSrcReset;// app:w / app:w / ms:r // (If using deletion) Set before EndMultiSelect() to reset ResetSrcItem (e.g. if deleted selection).
boolNavIdSelected;// ms:w, app:r / / // (If using deletion) Last known selection state for NavId (if part of submitted items).
void*NavIdItem;// ms:w, app:r / / ms:w app:r // (If using deletion) Last known SetNextItemSelectionUserData() value for NavId (if part of submitted items)
void*NavIdItem;// ms:w, app:r / / // (If using deletion) Last known SetNextItemSelectionUserData() value for NavId (if part of submitted items).
if(ms_io->NavIdSelected==false)// Here 'NavIdSelected' should be == to 'GetSelected(ms_io->NavIdData)'
{
ms_io->RangeSrcReset=true;// Request to recover RangeSrc from NavId next frame. Would be ok to reset even without the !NavIdSelected test but it would take an extra frame to recover RangeSrc when deleting a selected item.
return(int)(intptr_t)ms_io->NavIdItem;// Request to land on same item after deletion.
}
// Return first unselected item after RangeSrcItem
// If current item is selected: land on first unselected item after RangeSrc.
// Demonstrate holding/updating multi-selection data and using the BeginMultiSelect/EndMultiSelect API to support range-selection and clipping.
// Demonstrate holding/updating multi-selection data and using the BeginMultiSelect/EndMultiSelect API + support dynamic item list and deletion.
// SHIFT+Click w/ CTRL and other standard features are supported.
// In order to support Deletion without any glitches you need to:
// - (1) If items are submitted in their own scrolling area, submit contents size SetNextWindowContentSize() ahead of time to prevent one-frame readjustment of scrolling.
// - (2) Items needs to have persistent ID Stack identifier = ID needs to not depends on their index. PushID(index) = KO. PushID(item_id) = OK. This is in order to focus items reliably after a selection.
// - (3) BeginXXXX process
// - (4) Focus process
// - (5) EndXXXX process
IMGUI_DEMO_MARKER("Widgets/Selection State/Multiple Selection (full, with deletion)");
if(ImGui::TreeNode("Multiple Selection (full, with deletion)"))
{
// Intentionally separating items data from selection data!
// But you may decide to store selection data inside your item (aka '
// But you may decide to store selection data inside your item (aka intrusive storage).
if(ImGui::SmallButton("Remove 20 items")){for(intn=IM_MIN(20,items.Size);n>0;n--){selection.SetSelected(items.Size-1,false);items.pop_back();}}// This is to test
// Extra to support deletion: Submit scrolling range to avoid glitches on deletion
// (1) Extra to support deletion: Submit scrolling range to avoid glitches on deletion