mirror of
https://github.com/ocornut/imgui.git
synced 2026-03-27 23:37:03 -05:00
MultiSelect: added ImGuiMultiSelectFlags_SelectOnClickAlways mode. Prevents Drag and Drop of multiple items but allows BoxSelect to always reselect even when clicking inside a selecttion. (#9307, #1861)
This commit is contained in:
@@ -2632,7 +2632,7 @@ struct ExampleDualListBox
|
||||
}
|
||||
if (child_visible)
|
||||
{
|
||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_None;
|
||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_BoxSelect1d;
|
||||
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size, items.Size);
|
||||
ApplySelectionRequests(ms_io, side);
|
||||
|
||||
@@ -3243,6 +3243,10 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
|
||||
flags &= ~ImGuiMultiSelectFlags_ScopeWindow;
|
||||
if (ImGui::CheckboxFlags("ImGuiMultiSelectFlags_SelectOnAuto", &flags, ImGuiMultiSelectFlags_SelectOnAuto))
|
||||
flags &= ~(ImGuiMultiSelectFlags_SelectOnMask_ ^ ImGuiMultiSelectFlags_SelectOnAuto);
|
||||
ImGui::SameLine(); HelpMarker("Apply selection on mouse down when clicking on unselected item, on mouse up when clicking on selected item. (Default)");
|
||||
if (ImGui::CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickAlways", &flags, ImGuiMultiSelectFlags_SelectOnClickAlways))
|
||||
flags &= ~(ImGuiMultiSelectFlags_SelectOnMask_ ^ ImGuiMultiSelectFlags_SelectOnClickAlways);
|
||||
ImGui::SameLine(); HelpMarker("Prevents Drag and Drop from being used on multi-selection, but allows e.g. BoxSelect to always reselect even when clicking inside an existing selection. (Excel style behavior)");
|
||||
if (ImGui::CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickRelease", &flags, ImGuiMultiSelectFlags_SelectOnClickRelease))
|
||||
flags &= ~(ImGuiMultiSelectFlags_SelectOnMask_ ^ ImGuiMultiSelectFlags_SelectOnClickRelease);
|
||||
ImGui::SameLine(); HelpMarker("Allow dragging an unselected item without altering selection.");
|
||||
@@ -10716,8 +10720,9 @@ struct ExampleAssetsBrowser
|
||||
// Options
|
||||
bool ShowTypeOverlay = true;
|
||||
bool AllowSorting = true;
|
||||
bool AllowDragUnselected = false;
|
||||
bool AllowBoxSelect = true;
|
||||
bool AllowBoxSelect = true; // Will set ImGuiMultiSelectFlags_BoxSelect2d
|
||||
bool AllowBoxSelectInsideSelection = false; // Will set ImGuiMultiSelectFlags_SelectOnClickAlways
|
||||
bool AllowDragUnselected = false; // Will set ImGuiMultiSelectFlags_SelectOnClickRelease
|
||||
float IconSize = 32.0f;
|
||||
int IconSpacing = 10;
|
||||
int IconHitSpacing = 4; // Increase hit-spacing if you want to make it possible to clear or box-select from gaps. Some spacing is required to able to amend with Shift+box-select. Value is small in Explorer.
|
||||
@@ -10822,8 +10827,11 @@ struct ExampleAssetsBrowser
|
||||
ImGui::Checkbox("Allow Sorting", &AllowSorting);
|
||||
|
||||
ImGui::SeparatorText("Selection Behavior");
|
||||
ImGui::Checkbox("Allow dragging unselected item", &AllowDragUnselected);
|
||||
ImGui::Checkbox("Allow box-selection", &AllowBoxSelect);
|
||||
if (ImGui::Checkbox("Allow box-selection from selected items", &AllowBoxSelectInsideSelection) && AllowBoxSelectInsideSelection)
|
||||
AllowDragUnselected = false;
|
||||
if (ImGui::Checkbox("Allow dragging unselected item", &AllowDragUnselected) && AllowDragUnselected)
|
||||
AllowBoxSelectInsideSelection = false;
|
||||
|
||||
ImGui::SeparatorText("Layout");
|
||||
ImGui::SliderFloat("Icon Size", &IconSize, 16.0f, 128.0f, "%.0f");
|
||||
@@ -10879,9 +10887,11 @@ struct ExampleAssetsBrowser
|
||||
if (AllowBoxSelect)
|
||||
ms_flags |= ImGuiMultiSelectFlags_BoxSelect2d;
|
||||
|
||||
// - This feature allows dragging an unselected item without selecting it (rarely used)
|
||||
// - Selection mode
|
||||
if (AllowDragUnselected)
|
||||
ms_flags |= ImGuiMultiSelectFlags_SelectOnClickRelease;
|
||||
ms_flags |= ImGuiMultiSelectFlags_SelectOnClickRelease; // Rarely used: Allows dragging an unselected item without selecting it(rarely used)
|
||||
else if (AllowBoxSelectInsideSelection)
|
||||
ms_flags |= ImGuiMultiSelectFlags_SelectOnClickAlways; // Rarely used: Prevents Drag and Drop from being used on multiple-selection, but allows e.g. BoxSelect to always reselect even when clicking inside an existing selection.
|
||||
|
||||
// - Enable keyboard wrapping on X axis
|
||||
// (FIXME-MULTISELECT: We haven't designed/exposed a general nav wrapping api yet, so this flag is provided as a courtesy to avoid doing:
|
||||
|
||||
Reference in New Issue
Block a user