You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: imgui.h
+23-18Lines changed: 23 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2154,31 +2154,36 @@ struct ImGuiListClipper
2154
2154
};
2155
2155
2156
2156
// Abstract:
2157
-
// - This system implements standard multi-selection idioms (CTRL+Click/Arrow, SHIFT+Click/Arrow, etc) in a way that allow items to be
2158
-
// fully clipped (= not submitted at all) when not visible. Clipping is typically provided by ImGuiListClipper.
2157
+
// - This system helps you implements standard multi-selection idioms (CTRL+Click/Arrow, SHIFT+Click/Arrow, etc) in a way that allow
2158
+
//selectable items to be fully clipped (= not submitted at all) when not visible. Clipping is typically provided by ImGuiListClipper.
2159
2159
// Handling all of this in a single pass imgui is a little tricky, and this is why we provide those functionalities.
2160
-
// Note however that if you don't need SHIFT+Click/Arrow range-select, you can handle a simpler form of multi-selection yourself,
2161
-
// by reacting to click/presses on Selectable() items and checking keyboard modifiers.
2162
-
// The complexity of this system here is mostly caused by the handling of range-select while optionally allowing to clip elements.
2160
+
// Note however that if you don't need SHIFT+Click/Arrow range-select + clipping, you can handle a simpler form of multi-selection
2161
+
// yourself, by reacting to click/presses on Selectable() items and checking keyboard modifiers.
2162
+
// The unusual complexity of this system is mostly caused by supporting SHIFT+Click/Arrow range-select with clipped elements.
2163
+
// - TreeNode() and Selectable() are supported.
2163
2164
// - The work involved to deal with multi-selection differs whether you want to only submit visible items (and clip others) or submit all items
2164
2165
// regardless of their visibility. Clipping items is more efficient and will allow you to deal with large lists (1k~100k items) with near zero
2165
2166
// performance penalty, but requires a little more work on the code. If you only have a few hundreds elements in your possible selection set,
2166
-
// you may as well not bother with clipping, as the cost should be negligible (as least on imgui side).
2167
+
// you may as well not bother with clipping, as the cost should be negligible (as least on Dear ImGui side).
2167
2168
// If you are not sure, always start without clipping and you can work your way to the more optimized version afterwards.
2168
-
// - The void* Src/Dst value represent a selectable object. They are the values you pass to SetNextItemSelectionData().
2169
-
// Storing an integer index is the easiest thing to do, as SetRange requests will give you two end points. But the code never assume that sortable integers are used.
2170
-
// - In the spirit of imgui design, your code own the selection data. So this is designed to handle all kind of selection data: instructive (store a bool inside each object),
2171
-
// external array (store an array aside from your objects), set (store only selected items in a hash/map/set), using intervals (store indices in an interval tree), etc.
2169
+
// - The void* RangeSrc/RangeDst value represent a selectable object. They are the values you pass to SetNextItemSelectionData().
2170
+
// Storing an integer index is the easiest thing to do, as SetRange requests will give you two end points and you will need to interpolate
2171
+
// between them to honor range selection. But the code never assume that sortable integers are used (you may store pointers to your object,
2172
+
// and then from the pointer have your own way of iterating from RangeSrc to RangeDst).
2173
+
// - In the spirit of Dear ImGui design, your code own the selection data. So this is designed to handle all kind of selection data:
2174
+
// e.g. instructive selection (store a bool inside each object), external array (store an array aside from your objects),
2175
+
// hash/map/set (store only selected items in a hash/map/set), or other structures (store indices in an interval tree), etc.
2172
2176
// Usage flow:
2173
-
// 1) Call BeginMultiSelect() with the last saved value of ->RangeSrc and its selection status. As a default value for the initial frame or when,
2174
-
// resetting your selection state: you may use the value for your first item or a "null" value that matches the type stored in your void*.
2175
-
// 2) Honor Clear/SelectAll requests by updating your selection data. [Only required if you are using a clipper in step 4]
2176
-
// 3) Set RangeSrcPassedBy=true if the RangeSrc item is part of the items clipped before the first submitted/visible item. [Only required if you are using a clipper in step 4]
2177
+
// 1) Call BeginMultiSelect() with the last saved value of ->RangeSrc and its selection state.
2178
+
// It is because you need to pass its selection state (and you own selection) that we don't store this value in Dear ImGui.
2179
+
// (For the initial frame or when resetting your selection state: you may use the value for your first item or a "null" value that matches the type stored in your void*).
2180
+
// 2) Honor Clear/SelectAll requests by updating your selection data. [Only required if you are using a clipper in step 4]
2181
+
// 3) Set RangeSrcPassedBy=true if the RangeSrc item is part of the items clipped before the first submitted/visible item. [Only required if you are using a clipper in step 4]
2177
2182
// This is because for range-selection we need to know if we are currently "inside" or "outside" the range.
2178
-
// If you are using integer indices everywhere, this is easy to compute: if (clipper.DisplayStart > (int)data->RangeSrc) { data->RangeSrcPassedBy = true; }
2183
+
// If you are using integer indices everywhere, this is easy to compute: if (clipper.DisplayStart > (int)data->RangeSrc) { data->RangeSrcPassedBy = true; }
2179
2184
// 4) Submit your items with SetNextItemSelectionData() + Selectable()/TreeNode() calls.
2180
-
// Call IsItemSelectionToggled() to query with the selection state has been toggled, in which you need the info immediately (before EndMultiSelect()) for your display.
2181
-
// When cannot reliably return a "IsItemSelected()" value because we need to consider clipped (unprocessed) item, this is why we return a toggle event instead.
2185
+
// Call IsItemToggledSelection() to query if the selection state has been toggled, if you need the info immediately for your display (before EndMultiSelect()).
2186
+
// When cannot return a "IsItemSelected()" value because we need to consider clipped/unprocessed items, this is why we return a "Toggle" event instead.
2182
2187
// 5) Call EndMultiSelect(). Save the value of ->RangeSrc for the next frame (you may convert the value in a format that is safe for persistance)
2183
2188
// 6) Honor Clear/SelectAll/SetRange requests by updating your selection data. Always process them in this order (as you will receive Clear+SetRange request simultaneously)
2184
2189
// If you submit all items (no clipper), Step 2 and 3 and will be handled by Selectable() on a per-item basis.
@@ -2188,7 +2193,7 @@ struct ImGuiMultiSelectData
2188
2193
bool RequestClear; // Begin, End // Request user to clear selection
2189
2194
bool RequestSelectAll; // Begin, End // Request user to select all
2190
2195
bool RequestSetRange; // End // Request user to set or clear selection in the [RangeSrc..RangeDst] range
2191
-
bool RangeSrcPassedBy; //After Begin // Need to be set by user is RangeSrc was part of the clipped set before submitting the visible items. Ignore if not clipping.
2196
+
bool RangeSrcPassedBy; //In loop // (If clipping) Need to be set by user if RangeSrc was part of the clipped set before submitting the visible items. Ignore if not clipping.
2192
2197
bool RangeValue; // End // End: parameter from RequestSetRange request. True = Select Range, False = Unselect range.
2193
2198
void* RangeSrc; // Begin, End // End: parameter from RequestSetRange request + you need to save this value so you can pass it again next frame. / Begin: this is the value you passed to BeginMultiSelect()
2194
2199
void* RangeDst; // End // End: parameter from RequestSetRange request.
// To handle drag and drop of multiple items we need to avoid clearing selection on click.
5718
-
// Enabling this test makes actions using CTRL+SHIFT delay their effect on the mouse release which is annoying, but it allows drag and drop of multiple items.
5718
+
// Enabling this test makes actions using CTRL+SHIFT delay their effect on MouseUp which is annoying, but it allows drag and drop of multiple items.
5719
5719
// FIXME-MULTISELECT: Consider opt-in for drag and drop behavior in ImGuiMultiSelectFlags?
5720
5720
if (!selected || (g.ActiveId == id && g.ActiveIdHasBeenPressedBefore))
0 commit comments