Skip to content

Commit 2688562

Browse files
committed
MultiSelect: Better document how TreeNode() is not trivially usable yet.
Will revert when the time is right.
1 parent 7814518 commit 2688562

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

imgui.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,12 @@ namespace ImGui
672672
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
673673
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
674674

675-
// Multi-selection system for Selectable() and TreeNode() functions.
675+
// Multi-selection system for Selectable(), Checkbox() functions*
676676
// - This enables standard multi-selection/range-selection idioms (CTRL+Mouse/Keyboard, SHIFT+Mouse/Keyboard, etc.) in a way that also allow a clipper to be used.
677677
// - ImGuiSelectionUserData is often used to store your item index within the current view (but may store something else).
678678
// - Read comments near ImGuiMultiSelectIO for instructions/details and see 'Demo->Widgets->Selection State & Multi-Select' for demo.
679+
// - (*) TreeNode() is technically supported but... using this correctly is more complicate: you need some sort of linear/random access to your tree,
680+
// which is suited to advanced trees setups already implementing filters and clipper. We will work toward simplifying and demoing this.
679681
// - 'selection_size' and 'items_count' parameters are optional and used by a few features. If they are costly for you to compute, you may avoid them.
680682
IMGUI_API ImGuiMultiSelectIO* BeginMultiSelect(ImGuiMultiSelectFlags flags, int selection_size = -1, int items_count = -1);
681683
IMGUI_API ImGuiMultiSelectIO* EndMultiSelect();
@@ -2734,7 +2736,9 @@ struct ImColor
27342736
// - Refer to 'Demo->Widgets->Selection State & Multi-Select' for demos using this.
27352737
// - This system implements standard multi-selection idioms (CTRL+Mouse/Keyboard, SHIFT+Mouse/Keyboard, etc)
27362738
// with support for clipper (skipping non-visible items), box-select and many other details.
2737-
// - TreeNode(), Selectable(), Checkbox() are supported but custom widgets may use it as well.
2739+
// - Selectable(), Checkbox() are supported but custom widgets may use it as well.
2740+
// - TreeNode() is technically supported but... using this correctly is more complicated: you need some sort of linear/random access to your tree,
2741+
// which is suited to advanced trees setups also implementing filters and clipper. We will work toward simplifying and demoing it.
27382742
// - In the spirit of Dear ImGui design, your code owns actual selection data.
27392743
// This is designed to allow all kinds of selection storage you may use in your application e.g. set/map/hash.
27402744
// About ImGuiSelectionBasicStorage:

imgui_demo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -3317,6 +3317,8 @@ static void ShowDemoWindowMultiSelect()
33173317
if (ImGui::RadioButton("Selectables", widget_type == WidgetType_Selectable)) { widget_type = WidgetType_Selectable; }
33183318
ImGui::SameLine();
33193319
if (ImGui::RadioButton("Tree nodes", widget_type == WidgetType_TreeNode)) { widget_type = WidgetType_TreeNode; }
3320+
ImGui::SameLine();
3321+
HelpMarker("TreeNode() is technically supported but... using this correctly is more complicated (you need some sort of linear/random access to your tree, which is suited to advanced trees setups already implementing filters and clipper. We will work toward simplifying and demoing this.\n\nFor now the tree demo is actually a little bit meaningless because it is an empty tree with only root nodes.");
33203322
ImGui::Checkbox("Enable clipper", &use_clipper);
33213323
ImGui::Checkbox("Enable deletion", &use_deletion);
33223324
ImGui::Checkbox("Enable drag & drop", &use_drag_drop);

0 commit comments

Comments
 (0)