mirror of https://github.com/ocornut/imgui
MultiSelect: (breaking) renamed ImGuiMultiSelectFlags_BoxSelect -> ImGuiMultiSelectFlags_BoxSelect1d, ImGuiMultiSelectFlags_BoxSelect2d -> ImGuiMultiSelectFlags_BoxSelect.
ImGuiMultiSelectFlags_BoxSelect1d being an optimization it is the optional flag.
This commit is contained in:
parent
7bbbbea200
commit
f6b5caf82c
4
imgui.h
4
imgui.h
|
@ -2775,8 +2775,8 @@ enum ImGuiMultiSelectFlags_
|
||||||
ImGuiMultiSelectFlags_NoRangeSelect = 1 << 2, // Disable Shift+Click/Shift+Keyboard handling (useful for unordered 2D selection).
|
ImGuiMultiSelectFlags_NoRangeSelect = 1 << 2, // Disable Shift+Click/Shift+Keyboard handling (useful for unordered 2D selection).
|
||||||
ImGuiMultiSelectFlags_NoAutoSelect = 1 << 3, // Disable selecting items when navigating (useful for e.g. supporting range-select in a list of checkboxes)
|
ImGuiMultiSelectFlags_NoAutoSelect = 1 << 3, // Disable selecting items when navigating (useful for e.g. supporting range-select in a list of checkboxes)
|
||||||
ImGuiMultiSelectFlags_NoAutoClear = 1 << 4, // Disable clearing other items when navigating or selecting another one (generally used with ImGuiMultiSelectFlags_NoAutoSelect. useful for e.g. supporting range-select in a list of checkboxes)
|
ImGuiMultiSelectFlags_NoAutoClear = 1 << 4, // Disable clearing other items when navigating or selecting another one (generally used with ImGuiMultiSelectFlags_NoAutoSelect. useful for e.g. supporting range-select in a list of checkboxes)
|
||||||
ImGuiMultiSelectFlags_BoxSelect = 1 << 5, // Enable box-selection with same width and same x pos items. Box-selection works better with little bit of spacing between items hit-box in order to be able to aim at empty space.
|
ImGuiMultiSelectFlags_BoxSelect = 1 << 5, // Enable box-selection with varying width or varying x pos items support (e.g. different width labels, or 2D layout/grid). This alters clipping logic so that e.g. horizontal movements will update selection of normally clipped items. Box-selection works better with little bit of spacing between items hit-box in order to be able to aim at empty space.
|
||||||
ImGuiMultiSelectFlags_BoxSelect2d = 1 << 6, // Enable box-selection with varying width or varying x pos items (e.g. different width labels, or 2D layout/grid). This alters clipping logic so that e.g. horizontal movements will update selection of normally clipped items.
|
ImGuiMultiSelectFlags_BoxSelect1d = 1 << 6, // Enable box-selection with same width and same x pos items (e.g. only full row Selectable()). Small optimization.
|
||||||
ImGuiMultiSelectFlags_BoxSelectNoScroll = 1 << 7, // Disable scrolling when box-selecting near edges of scope.
|
ImGuiMultiSelectFlags_BoxSelectNoScroll = 1 << 7, // Disable scrolling when box-selecting near edges of scope.
|
||||||
ImGuiMultiSelectFlags_ClearOnEscape = 1 << 8, // Clear selection when pressing Escape while scope is focused.
|
ImGuiMultiSelectFlags_ClearOnEscape = 1 << 8, // Clear selection when pressing Escape while scope is focused.
|
||||||
ImGuiMultiSelectFlags_ClearOnClickVoid = 1 << 9, // Clear selection when clicking on empty location within scope.
|
ImGuiMultiSelectFlags_ClearOnClickVoid = 1 << 9, // Clear selection when clicking on empty location within scope.
|
||||||
|
|
|
@ -3059,7 +3059,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
// The BeginChild() has no purpose for selection logic, other that offering a scrolling region.
|
// The BeginChild() has no purpose for selection logic, other that offering a scrolling region.
|
||||||
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
||||||
{
|
{
|
||||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect;
|
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d;
|
||||||
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
||||||
selection.ApplyRequests(ms_io, ITEMS_COUNT);
|
selection.ApplyRequests(ms_io, ITEMS_COUNT);
|
||||||
|
|
||||||
|
@ -3093,7 +3093,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
ImGui::Text("Selection: %d/%d", selection.Size, ITEMS_COUNT);
|
ImGui::Text("Selection: %d/%d", selection.Size, ITEMS_COUNT);
|
||||||
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
||||||
{
|
{
|
||||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect;
|
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d;
|
||||||
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
||||||
selection.ApplyRequests(ms_io, ITEMS_COUNT);
|
selection.ApplyRequests(ms_io, ITEMS_COUNT);
|
||||||
|
|
||||||
|
@ -3157,7 +3157,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
|
|
||||||
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
if (ImGui::BeginChild("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
|
||||||
{
|
{
|
||||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect;
|
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d;
|
||||||
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size);
|
||||||
selection.ApplyRequests(ms_io, items.Size);
|
selection.ApplyRequests(ms_io, items.Size);
|
||||||
|
|
||||||
|
@ -3215,7 +3215,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_NoAutoSelect | ImGuiMultiSelectFlags_NoAutoClear | ImGuiMultiSelectFlags_ClearOnEscape;
|
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_NoAutoSelect | ImGuiMultiSelectFlags_NoAutoClear | ImGuiMultiSelectFlags_ClearOnEscape;
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", &flags, ImGuiMultiSelectFlags_NoAutoSelect);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", &flags, ImGuiMultiSelectFlags_NoAutoSelect);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", &flags, ImGuiMultiSelectFlags_NoAutoClear);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", &flags, ImGuiMultiSelectFlags_NoAutoClear);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", &flags, ImGuiMultiSelectFlags_BoxSelect2d); // Use 2D version as checkboxes are not same width.
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect", &flags, ImGuiMultiSelectFlags_BoxSelect); // Cannot use ImGuiMultiSelectFlags_BoxSelect1d as checkboxes are varying width.
|
||||||
|
|
||||||
struct Funcs
|
struct Funcs
|
||||||
{
|
{
|
||||||
|
@ -3268,7 +3268,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
if (ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", &flags, ImGuiMultiSelectFlags_ScopeRect) && (flags & ImGuiMultiSelectFlags_ScopeRect))
|
if (ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", &flags, ImGuiMultiSelectFlags_ScopeRect) && (flags & ImGuiMultiSelectFlags_ScopeRect))
|
||||||
flags &= ~ImGuiMultiSelectFlags_ScopeWindow;
|
flags &= ~ImGuiMultiSelectFlags_ScopeWindow;
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", &flags, ImGuiMultiSelectFlags_ClearOnClickVoid);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", &flags, ImGuiMultiSelectFlags_ClearOnClickVoid);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect", &flags, ImGuiMultiSelectFlags_BoxSelect);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", &flags, ImGuiMultiSelectFlags_BoxSelect1d);
|
||||||
|
|
||||||
for (int selection_scope_n = 0; selection_scope_n < SCOPES_COUNT; selection_scope_n++)
|
for (int selection_scope_n = 0; selection_scope_n < SCOPES_COUNT; selection_scope_n++)
|
||||||
{
|
{
|
||||||
|
@ -3321,7 +3321,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
static bool use_drag_drop = true;
|
static bool use_drag_drop = true;
|
||||||
static bool show_in_table = false;
|
static bool show_in_table = false;
|
||||||
static bool show_color_button = false;
|
static bool show_color_button = false;
|
||||||
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect;
|
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d;
|
||||||
static WidgetType widget_type = WidgetType_Selectable;
|
static WidgetType widget_type = WidgetType_Selectable;
|
||||||
|
|
||||||
if (ImGui::TreeNode("Options"))
|
if (ImGui::TreeNode("Options"))
|
||||||
|
@ -3340,6 +3340,7 @@ static void ShowDemoWindowMultiSelect()
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", &flags, ImGuiMultiSelectFlags_NoAutoSelect);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", &flags, ImGuiMultiSelectFlags_NoAutoSelect);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", &flags, ImGuiMultiSelectFlags_NoAutoClear);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", &flags, ImGuiMultiSelectFlags_NoAutoClear);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect", &flags, ImGuiMultiSelectFlags_BoxSelect);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect", &flags, ImGuiMultiSelectFlags_BoxSelect);
|
||||||
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", &flags, ImGuiMultiSelectFlags_BoxSelect1d);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelectNoScroll", &flags, ImGuiMultiSelectFlags_BoxSelectNoScroll);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelectNoScroll", &flags, ImGuiMultiSelectFlags_BoxSelectNoScroll);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnEscape", &flags, ImGuiMultiSelectFlags_ClearOnEscape);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnEscape", &flags, ImGuiMultiSelectFlags_ClearOnEscape);
|
||||||
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", &flags, ImGuiMultiSelectFlags_ClearOnClickVoid);
|
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", &flags, ImGuiMultiSelectFlags_ClearOnClickVoid);
|
||||||
|
@ -9843,7 +9844,7 @@ struct ExampleAssetsBrowser
|
||||||
if (AllowDragUnselected)
|
if (AllowDragUnselected)
|
||||||
ms_flags |= ImGuiMultiSelectFlags_SelectOnClickRelease; // To allow dragging an unselected item without altering selection.
|
ms_flags |= ImGuiMultiSelectFlags_SelectOnClickRelease; // To allow dragging an unselected item without altering selection.
|
||||||
if (AllowBoxSelect)
|
if (AllowBoxSelect)
|
||||||
ms_flags |= ImGuiMultiSelectFlags_BoxSelect2d; // Enable box-select in 2D mode.
|
ms_flags |= ImGuiMultiSelectFlags_BoxSelect; // Enable box-select in 2D mode.
|
||||||
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(ms_flags, Selection.Size);
|
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(ms_flags, Selection.Size);
|
||||||
|
|
||||||
// Use custom selection adapter: store ID in selection (recommended)
|
// Use custom selection adapter: store ID in selection (recommended)
|
||||||
|
@ -9918,7 +9919,7 @@ struct ExampleAssetsBrowser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render icon (a real app would likely display an image/thumbnail here)
|
// Render icon (a real app would likely display an image/thumbnail here)
|
||||||
// Because we use ImGuiMultiSelectFlags_BoxSelect2d mode,
|
// Because we use ImGuiMultiSelectFlags_BoxSelect (without ImGuiMultiSelectFlags_BoxSelect1d flag),
|
||||||
// clipping vertical range may occasionally be larger so we coarse-clip our rendering.
|
// clipping vertical range may occasionally be larger so we coarse-clip our rendering.
|
||||||
if (item_is_visible)
|
if (item_is_visible)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7235,7 +7235,7 @@ bool ImGui::BeginBoxSelect(ImGuiWindow* window, ImGuiID box_select_id, ImGuiMult
|
||||||
|
|
||||||
// Box-select 2D mode detects horizontal changes (vertical ones are already picked by Clipper)
|
// Box-select 2D mode detects horizontal changes (vertical ones are already picked by Clipper)
|
||||||
// Storing an extra rect used by widgets supporting box-select.
|
// Storing an extra rect used by widgets supporting box-select.
|
||||||
if (ms_flags & ImGuiMultiSelectFlags_BoxSelect2d)
|
if ((ms_flags & ImGuiMultiSelectFlags_BoxSelect) && !(ms_flags & ImGuiMultiSelectFlags_BoxSelect1d))
|
||||||
if (bs->BoxSelectRectPrev.Min.x != bs->BoxSelectRectCurr.Min.x || bs->BoxSelectRectPrev.Max.x != bs->BoxSelectRectCurr.Max.x)
|
if (bs->BoxSelectRectPrev.Min.x != bs->BoxSelectRectCurr.Min.x || bs->BoxSelectRectPrev.Max.x != bs->BoxSelectRectCurr.Max.x)
|
||||||
{
|
{
|
||||||
bs->UnclipMode = true;
|
bs->UnclipMode = true;
|
||||||
|
@ -7316,8 +7316,8 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, int cur
|
||||||
if ((flags & (ImGuiMultiSelectFlags_ScopeWindow | ImGuiMultiSelectFlags_ScopeRect)) == 0)
|
if ((flags & (ImGuiMultiSelectFlags_ScopeWindow | ImGuiMultiSelectFlags_ScopeRect)) == 0)
|
||||||
flags |= ImGuiMultiSelectFlags_ScopeWindow;
|
flags |= ImGuiMultiSelectFlags_ScopeWindow;
|
||||||
if (flags & ImGuiMultiSelectFlags_SingleSelect)
|
if (flags & ImGuiMultiSelectFlags_SingleSelect)
|
||||||
flags &= ~(ImGuiMultiSelectFlags_BoxSelect | ImGuiMultiSelectFlags_BoxSelect2d);
|
flags &= ~(ImGuiMultiSelectFlags_BoxSelect | ImGuiMultiSelectFlags_BoxSelect1d);
|
||||||
if (flags & ImGuiMultiSelectFlags_BoxSelect2d)
|
if (flags & ImGuiMultiSelectFlags_BoxSelect1d)
|
||||||
flags |= ImGuiMultiSelectFlags_BoxSelect;
|
flags |= ImGuiMultiSelectFlags_BoxSelect;
|
||||||
|
|
||||||
// FIXME: BeginFocusScope()
|
// FIXME: BeginFocusScope()
|
||||||
|
|
Loading…
Reference in New Issue