mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
MultiSelect: removed DragDropActive/preserve_existing_selection logic which seems unused + comments.
Can't find trace of early prototype for range-select but I couldn't find way to trigger this anymore. May be wrong. Will find out.
This commit is contained in:
parent
85954c845e
commit
5d71314f71
4 changed files with 38 additions and 38 deletions
|
|
@ -2787,7 +2787,7 @@ struct ExampleSelection
|
|||
void Clear() { Storage.Clear(); SelectionSize = 0; }
|
||||
bool GetSelected(int n) const { return Storage.GetInt((ImGuiID)n, 0) != 0; }
|
||||
void SetSelected(int n, bool v) { int* p_int = Storage.GetIntRef((ImGuiID)n, 0); if (*p_int == (int)v) return; if (v) SelectionSize++; else SelectionSize--; *p_int = (bool)v; }
|
||||
int GetSelectionSize() const { return SelectionSize; }
|
||||
int GetSize() const { return SelectionSize; }
|
||||
|
||||
// When using SelectAll() / SetRange() we assume that our objects ID are indices.
|
||||
// In this demo we always store selection using indices and never in another manner (e.g. object ID or pointers).
|
||||
|
|
@ -2808,7 +2808,6 @@ struct ExampleSelection
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
static void ShowDemoWindowMultiSelect()
|
||||
{
|
||||
IMGUI_DEMO_MARKER("Widgets/Selection State");
|
||||
|
|
@ -2873,7 +2872,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
|
||||
// The BeginListBox() has no actual purpose for selection logic (other that offering a scrolling regions).
|
||||
const int ITEMS_COUNT = 50;
|
||||
ImGui::Text("Selection size: %d", selection.GetSelectionSize());
|
||||
ImGui::Text("Selection size: %d", selection.GetSize());
|
||||
if (ImGui::BeginListBox("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20)))
|
||||
{
|
||||
ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape;
|
||||
|
|
@ -2918,7 +2917,8 @@ static void ShowDemoWindowMultiSelect()
|
|||
static bool use_drag_drop = true;
|
||||
static bool use_multiple_scopes = false;
|
||||
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_None;
|
||||
static WidgetType widget_type = WidgetType_TreeNode;
|
||||
static WidgetType widget_type = WidgetType_Selectable;
|
||||
|
||||
if (ImGui::RadioButton("Selectables", widget_type == WidgetType_Selectable)) { widget_type = WidgetType_Selectable; }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Tree nodes", widget_type == WidgetType_TreeNode)) { widget_type = WidgetType_TreeNode; }
|
||||
|
|
@ -2951,7 +2951,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Selection size: %d", selection->GetSelectionSize());
|
||||
ImGui::Text("Selection size: %d", selection->GetSize());
|
||||
draw_selection = ImGui::BeginListBox("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20));
|
||||
}
|
||||
if (draw_selection)
|
||||
|
|
@ -2967,7 +2967,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
selection->ApplyRequests(multi_select_data, ITEMS_COUNT);
|
||||
|
||||
if (use_multiple_scopes)
|
||||
ImGui::Text("Selection size: %d", selection->GetSelectionSize()); // Draw counter below Separator and after BeginMultiSelect()
|
||||
ImGui::Text("Selection size: %d", selection->GetSize()); // Draw counter below Separator and after BeginMultiSelect()
|
||||
|
||||
if (use_table)
|
||||
{
|
||||
|
|
@ -2994,7 +2994,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
ImGui::PushID(n);
|
||||
const char* category = random_names[n % IM_ARRAYSIZE(random_names)];
|
||||
char label[64];
|
||||
sprintf(label, "Object %05d (category: %s)", n, category);
|
||||
sprintf(label, "Object %05d: category: %s", n, category);
|
||||
bool item_is_selected = selection->GetSelected(n);
|
||||
|
||||
// Emit a color button, to test that Shift+LeftArrow landing on an item that is not part
|
||||
|
|
@ -3011,7 +3011,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
selection->SetSelected(n, !item_is_selected);
|
||||
if (use_drag_drop && ImGui::BeginDragDropSource())
|
||||
{
|
||||
ImGui::Text("(Dragging %d items)", selection->GetSelectionSize());
|
||||
ImGui::Text("(Dragging %d items)", selection->GetSize());
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
}
|
||||
|
|
@ -3026,7 +3026,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
selection->SetSelected(n, !item_is_selected);
|
||||
if (use_drag_drop && ImGui::BeginDragDropSource())
|
||||
{
|
||||
ImGui::Text("(Dragging %d items)", selection->GetSelectionSize());
|
||||
ImGui::Text("(Dragging %d items)", selection->GetSize());
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
if (open)
|
||||
|
|
@ -3041,6 +3041,7 @@ static void ShowDemoWindowMultiSelect()
|
|||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// Demo content within a table
|
||||
if (use_table)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue