瀏覽代碼

MultiSelect: added Changelog for the feature. Removed IMGUI_HAS_MULTI_SELECT.

ocornut 1 年之前
父節點
當前提交
02c31a8dd1
共有 3 個文件被更改,包括 53 次插入8 次删除
  1. 51 0
      docs/CHANGELOG.txt
  2. 2 4
      imgui.h
  3. 0 4
      imgui_internal.h

+ 51 - 0
docs/CHANGELOG.txt

@@ -77,6 +77,57 @@ Other changes:
     Disabling this was previously possible for Selectable() via a direct flag but not for MenuItem().
     (#1379, #1468, #2200, #4936, #5216, #7302, #7573)
   - This was mostly all previously in imgui_internal.h.
+- Multi-Select: added multi-select API and demos. (#1861)
+   - This system implements standard multi-selection idioms (CTRL+mouse click, CTRL+keyboard moves,
+     SHIFT+mouse click, SHIFT+keyboard moves, etc.) with support for clipper (not submitting non-visible
+     items), box-selection with scrolling, and many other details.
+   - In the spirit of Dear ImGui design, your code owns both items and actual selection data.
+     This is designed to allow all kinds of selection storage you may use in your application
+     (e.g. set/map/hash, intrusive selection, interval trees, up to you).
+   - The supported widgets are Selectable(), Checkbox(). TreeNode() is also 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 later.
+   - A helper ImGuiSelectionBasicStorage is provided to facilitate getting started in a typical app.
+   - Documentation:
+     - Wiki page https://github.com/ocornut/imgui/wiki/Multi-Select for API overview.
+     - Demo code.
+     - Headers are well commented.
+  - Added BeginMultiSelect(), EndMultiSelect(), SetNextItemSelectionUserData().
+  - Added IsItemToggledSelection() for use if you need latest selection update during currnet iteration.
+  - Added ImGuiMultiSelectIO and ImGuiSelectionRequest structures:
+    - BeginMultiSelect() and EndMultiSelect() return a ImGuiMultiSelectIO structure, which
+      is mostly an array of ImGuiSelectionRequest actions (clear, select all, set range, etc.)
+    - Other fields are helpful when using a clipper, or wanting to handle deletion nicely.
+  - Added ImGuiSelectionBasicStorage helper to store and maintain a selection (optional):
+    - This is similar to if you used e.g. a std::set<ID> to store a selection, with all the right
+      glue to honor ImGuiMultiSelectIO requests. Most applications can use that.
+  - Added ImGuiSelectionExternalStorage helper to maintain an externally stored selection (optional):
+    - Helpful to easily bind multi-selection to e.g. an array of checkboxes.
+  - Added ImGuiMultiSelectFlags options:
+    - ImGuiMultiSelectFlags_SingleSelect
+    - ImGuiMultiSelectFlags_NoSelectAll
+    - ImGuiMultiSelectFlags_NoRangeSelect
+    - ImGuiMultiSelectFlags_NoAutoSelect
+    - ImGuiMultiSelectFlags_NoAutoClear
+    - ImGuiMultiSelectFlags_NoAutoClearOnReselect (#7424)
+    - ImGuiMultiSelectFlags_BoxSelect1d
+    - ImGuiMultiSelectFlags_BoxSelect2d
+    - ImGuiMultiSelectFlags_BoxSelectNoScroll
+    - ImGuiMultiSelectFlags_ClearOnEscape
+    - ImGuiMultiSelectFlags_ClearOnClickVoid
+    - ImGuiMultiSelectFlags_ScopeWindow (default), ImGuiMultiSelectFlags_ScopeRect
+    - ImGuiMultiSelectFlags_SelectOnClick (default), ImGuiMultiSelectFlags_SelectOnClickRelease
+    - ImGuiMultiSelectFlags_NavWrapX
+  - Demo: Added "Examples->Assets Browser" demo.
+  - Demo: Added "Widgets->Selection State & Multi-Select" section, with:
+    - Multi-Select
+    - Multi-Select (with clipper)
+    - Multi-Select (with deletion)
+    - Multi-Select (dual list box) (#6648)
+    - Multi-Select (checkboxes)
+    - Multi-Select (multiple scopes)
+    - Multi-Select (advanced)
 - Clipper: added SeekCursorForItem() function. When using ImGuiListClipper::Begin(INT_MAX) you can
   can use the clipper without knowing the amount of items beforehand. (#1311)
   In this situation, call ImGuiListClipper::SeekCursorForItem(items_count) as the end of your iteration

+ 2 - 4
imgui.h

@@ -28,7 +28,7 @@
 // Library Version
 // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
 #define IMGUI_VERSION       "1.91.0 WIP"
-#define IMGUI_VERSION_NUM   19095
+#define IMGUI_VERSION_NUM   19096
 #define IMGUI_HAS_TABLE
 
 /*
@@ -2729,8 +2729,6 @@ struct ImColor
 // [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiSelectionRequestType, ImGuiSelectionRequest, ImGuiMultiSelectIO, ImGuiSelectionBasicStorage)
 //-----------------------------------------------------------------------------
 
-#define IMGUI_HAS_MULTI_SELECT      // Multi-Select/Range-Select WIP branch // <-- This is currently _not_ in the top of imgui.h to prevent merge conflicts.
-
 // Multi-selection system
 // Documentation at: https://github.com/ocornut/imgui/wiki/Multi-Select
 // - Refer to 'Demo->Widgets->Selection State & Multi-Select' for demos using this.
@@ -2797,7 +2795,7 @@ struct ImGuiMultiSelectIO
 {
     //------------------------------------------// BeginMultiSelect / EndMultiSelect
     ImVector<ImGuiSelectionRequest> Requests;   //  ms:w, app:r     /  ms:w  app:r   // Requests to apply to your selection data.
-    ImGuiSelectionUserData      RangeSrcItem;   //  ms:w  app:r     /                // (If using clipper) Begin: Source item (generally the first selected item when multi-selecting, which is used as a reference point) must never be clipped!
+    ImGuiSelectionUserData      RangeSrcItem;   //  ms:w  app:r     /                // (If using clipper) Begin: Source item (often the first selected item) must never be clipped: use clipper.IncludeItemByIndex() to ensure it is submitted.
     ImGuiSelectionUserData      NavIdItem;      //  ms:w, app:r     /                // (If using deletion) Last known SetNextItemSelectionUserData() value for NavId (if part of submitted items).
     bool                        NavIdSelected;  //  ms:w, app:r     /        app:r   // (If using deletion) Last known selection state for NavId (if part of submitted items).
     bool                        RangeSrcReset;  //        app:w     /  ms:r          // (If using deletion) Set before EndMultiSelect() to reset ResetSrcItem (e.g. if deleted selection).

+ 0 - 4
imgui_internal.h

@@ -1741,8 +1741,6 @@ struct ImGuiBoxSelectState
 // We always assume that -1 is an invalid value (which works for indices and pointers)
 #define ImGuiSelectionUserData_Invalid        ((ImGuiSelectionUserData)-1)
 
-#ifdef IMGUI_HAS_MULTI_SELECT
-
 // Temporary storage for multi-select
 struct IMGUI_API ImGuiMultiSelectTempData
 {
@@ -1783,8 +1781,6 @@ struct IMGUI_API ImGuiMultiSelectState
     ImGuiMultiSelectState() { Window = NULL; ID = 0; LastFrameActive = LastSelectionSize = 0; RangeSelected = NavIdSelected = -1; RangeSrcItem = NavIdItem = ImGuiSelectionUserData_Invalid; }
 };
 
-#endif // #ifdef IMGUI_HAS_MULTI_SELECT
-
 //-----------------------------------------------------------------------------
 // [SECTION] Docking support
 //-----------------------------------------------------------------------------