MultiSelect: Renamed SetNextItemMultiSelectData() to SetNextItemSelectionUserData()

This commit is contained in:
omar
2020-01-14 16:18:55 +01:00
committed by ocornut
parent 17c4c2154a
commit 4afbfd5e71
3 changed files with 13 additions and 5 deletions
+9 -1
View File
@@ -2845,7 +2845,7 @@ static void ShowDemoWindowMultiSelect()
};
int COUNT = 1000;
HelpMarker("Hold CTRL and click to select multiple items. Hold SHIFT to select a range.");
HelpMarker("Hold CTRL and click to select multiple items. Hold SHIFT to select a range. Keyboard is also supported.");
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int*)&ImGui::GetIO().ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
if (ImGui::BeginListBox("##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20)))
@@ -2853,6 +2853,7 @@ static void ShowDemoWindowMultiSelect()
ImGuiMultiSelectData* multi_select_data = ImGui::BeginMultiSelect(ImGuiMultiSelectFlags_None, (void*)(intptr_t)selection_ref, selection.GetSelected((int)selection_ref));
if (multi_select_data->RequestClear) { selection.Clear(); }
if (multi_select_data->RequestSelectAll) { selection.SelectAll(COUNT); }
ImVec2 color_button_sz(ImGui::GetFontSize(), ImGui::GetFontSize());
ImGuiListClipper clipper;
clipper.Begin(COUNT);
while (clipper.Step())
@@ -2865,6 +2866,13 @@ static void ShowDemoWindowMultiSelect()
char label[64];
sprintf(label, "Object %05d (category: %s)", n, random_names[n % IM_ARRAYSIZE(random_names)]);
bool item_is_selected = selection.GetSelected(n);
// Emit a color button, to test that Shift+LeftArrow landing on an item that is not part
// of the selection scope doesn't erroneously alter our selection.
ImVec4 dummy_col = ImColor((ImU32)ImGui::GetID(label));
ImGui::ColorButton("##", dummy_col, ImGuiColorEditFlags_NoTooltip, color_button_sz);
ImGui::SameLine();
ImGui::SetNextItemSelectionUserData(n);
if (ImGui::Selectable(label, item_is_selected))
selection.SetSelected(n, !item_is_selected);