1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

MultiSelect: Remove the need for using IsItemToggledSelection(). Update comments.

This is the simple version that past our tests. MultiSelectItemFooter() is in need of a cleanup.
This commit is contained in:
ocornut 2023-06-29 17:00:43 +02:00
parent 6ef70a97fd
commit 1ea9ca748c
3 changed files with 23 additions and 22 deletions

View file

@ -2888,8 +2888,6 @@ static void ShowDemoWindowMultiSelect()
bool item_is_selected = selection.GetSelected(n);
ImGui::SetNextItemSelectionUserData(n);
ImGui::Selectable(label, item_is_selected);
if (ImGui::IsItemToggledSelection())
selection.SetSelected(n, !item_is_selected);
}
// Apply multi-select requests
@ -2929,8 +2927,6 @@ static void ShowDemoWindowMultiSelect()
bool item_is_selected = selection->GetSelected(n);
ImGui::SetNextItemSelectionUserData(n);
ImGui::Selectable(label, item_is_selected);
if (ImGui::IsItemToggledSelection())
selection->SetSelected(n, !item_is_selected);
}
// Apply multi-select requests
@ -3032,8 +3028,6 @@ static void ShowDemoWindowMultiSelect()
if (widget_type == WidgetType_Selectable)
{
ImGui::Selectable(label, item_is_selected);
if (ImGui::IsItemToggledSelection())
selection.SetSelected(n, !item_is_selected);
if (use_drag_drop && ImGui::BeginDragDropSource())
{
ImGui::Text("(Dragging %d items)", selection.GetSize());
@ -3047,8 +3041,6 @@ static void ShowDemoWindowMultiSelect()
if (item_is_selected)
tree_node_flags |= ImGuiTreeNodeFlags_Selected;
bool open = ImGui::TreeNodeEx(label, tree_node_flags);
if (ImGui::IsItemToggledSelection())
selection.SetSelected(n, !item_is_selected);
if (use_drag_drop && ImGui::BeginDragDropSource())
{
ImGui::Text("(Dragging %d items)", selection.GetSize());