MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / Show

Method Show

imgui_tiny_app/imgui/imgui_demo.cpp:2679–2781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2677 qsort(Items[n].Data, (size_t)Items[n].Size, sizeof(Items[n][0]), CompareItemsByValue);
2678 }
2679 void Show()
2680 {
2681 //if (ImGui::Checkbox("Sorted", &OptKeepSorted) && OptKeepSorted) { SortItems(0); SortItems(1); }
2682 if (ImGui::BeginTable("split", 3, ImGuiTableFlags_None))
2683 {
2684 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch); // Left side
2685 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed); // Buttons
2686 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch); // Right side
2687 ImGui::TableNextRow();
2688
2689 int request_move_selected = -1;
2690 int request_move_all = -1;
2691 float child_height_0 = 0.0f;
2692 for (int side = 0; side < 2; side++)
2693 {
2694 // FIXME-MULTISELECT: Dual List Box: Add context menus
2695 // FIXME-NAV: Using ImGuiWindowFlags_NavFlattened exhibit many issues.
2696 ImVector<ImGuiID>& items = Items[side];
2697 ImGuiSelectionBasicStorage& selection = Selections[side];
2698
2699 ImGui::TableSetColumnIndex((side == 0) ? 0 : 2);
2700 ImGui::Text("%s (%d)", (side == 0) ? "Available" : "Basket", items.Size);
2701
2702 // Submit scrolling range to avoid glitches on moving/deletion
2703 const float items_height = ImGui::GetTextLineHeightWithSpacing();
2704 ImGui::SetNextWindowContentSize(ImVec2(0.0f, items.Size * items_height));
2705
2706 bool child_visible;
2707 if (side == 0)
2708 {
2709 // Left child is resizable
2710 ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, ImGui::GetFrameHeightWithSpacing() * 4), ImVec2(FLT_MAX, FLT_MAX));
2711 child_visible = ImGui::BeginChild("0", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY);
2712 child_height_0 = ImGui::GetWindowSize().y;
2713 }
2714 else
2715 {
2716 // Right child use same height as left one
2717 child_visible = ImGui::BeginChild("1", ImVec2(-FLT_MIN, child_height_0), ImGuiChildFlags_FrameStyle);
2718 }
2719 if (child_visible)
2720 {
2721 ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_BoxSelect1d;
2722 ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(flags, selection.Size, items.Size);
2723 ApplySelectionRequests(ms_io, side);
2724
2725 for (int item_n = 0; item_n < items.Size; item_n++)
2726 {
2727 ImGuiID item_id = items[item_n];
2728 bool item_is_selected = selection.Contains(item_id);
2729 ImGui::SetNextItemSelectionUserData(item_n);
2730 ImGui::Selectable(ExampleNames[item_id], item_is_selected, ImGuiSelectableFlags_AllowDoubleClick);
2731 if (ImGui::IsItemFocused())
2732 {
2733 // FIXME-MULTISELECT: Dual List Box: Transfer focus
2734 if (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter))
2735 request_move_selected = side;
2736 if (ImGui::IsMouseDoubleClicked(0)) // FIXME-MULTISELECT: Double-click on multi-selection?

Calls 2

ImVec2Function · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected