From 34841871dea1a86a15311c82b66245285960d943 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 19 Jul 2024 22:17:29 -0400 Subject: [PATCH] add multi select to gfx sheet list --- src/app/editor/graphics/graphics_editor.cc | 30 ++++++++++++++++++---- src/app/editor/graphics/graphics_editor.h | 15 ----------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/app/editor/graphics/graphics_editor.cc b/src/app/editor/graphics/graphics_editor.cc index f7befba8..57e771c0 100644 --- a/src/app/editor/graphics/graphics_editor.cc +++ b/src/app/editor/graphics/graphics_editor.cc @@ -25,12 +25,18 @@ namespace yaze { namespace app { namespace editor { +using gfx::kPaletteGroupAddressesKeys; using ImGui::Button; using ImGui::InputInt; using ImGui::InputText; using ImGui::SameLine; using ImGui::TableNextColumn; +static constexpr absl::string_view kGfxToolsetColumnNames[] = { + "#memoryEditor", + "##separator_gfx1", +}; + constexpr ImGuiTableFlags kGfxEditTableFlags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | @@ -41,6 +47,10 @@ constexpr ImGuiTabBarFlags kGfxEditTabBarFlags = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_TabListPopupButton; +constexpr ImGuiTableFlags kGfxEditFlags = ImGuiTableFlags_Reorderable | + ImGuiTableFlags_Resizable | + ImGuiTableFlags_SizingStretchSame; + absl::Status GraphicsEditor::Update() { TAB_BAR("##TabBar") status_ = UpdateGfxEdit(); @@ -184,17 +194,25 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() { "##GfxEditChild", ImVec2(0, 0), true, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + // TODO: Update the interaction for multi select on sheets + static ImGuiSelectionBasicStorage selection; + ImGuiMultiSelectFlags flags = + ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d; + ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect( + flags, selection.Size, rom()->bitmap_manager().size()); + selection.ApplyRequests(ms_io); + ImGuiListClipper clipper; + clipper.Begin(rom()->bitmap_manager().size()); + if (ms_io->RangeSrcItem != -1) + clipper.IncludeItemByIndex( + (int)ms_io->RangeSrcItem); // Ensure RangeSrc item is not clipped. + for (auto& [key, value] : rom()->bitmap_manager()) { ImGui::BeginChild(absl::StrFormat("##GfxSheet%02X", key).c_str(), ImVec2(0x100 + 1, 0x40 + 1), true, ImGuiWindowFlags_NoDecoration); ImGui::PopStyleVar(); gui::Canvas graphics_bin_canvas_; - // auto select_tile_event = [&]() { - // }; - // graphics_bin_canvas_.UpdateEvent( - // select_tile_event, ImVec2(0x100 + 1, 0x40 + 1), 0x20, sheet_scale_, - // /*grid_size=*/16.0f); graphics_bin_canvas_.DrawBackground(ImVec2(0x100 + 1, 0x40 + 1)); graphics_bin_canvas_.DrawContextMenu(); @@ -236,6 +254,8 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() { ImGui::EndChild(); } ImGui::PopStyleVar(); + ms_io = ImGui::EndMultiSelect(); + selection.ApplyRequests(ms_io); ImGui::EndChild(); return absl::OkStatus(); } diff --git a/src/app/editor/graphics/graphics_editor.h b/src/app/editor/graphics/graphics_editor.h index 41e258ab..ef200688 100644 --- a/src/app/editor/graphics/graphics_editor.h +++ b/src/app/editor/graphics/graphics_editor.h @@ -44,21 +44,6 @@ const std::string kSuperDonkeySprites[] = { "BE115", "BE5C2", "BEB63", "BF0CB", "BF607", "BFA55", "BFD71", "C017D", "C0567", "C0981", "C0BA7", "C116D", "C166A", "C1FE0", "C24CE", "C2B19"}; -constexpr const char* kPaletteGroupAddressesKeys[] = { - "ow_main", "ow_aux", "ow_animated", "hud", - "global_sprites", "armors", "swords", "shields", - "sprites_aux1", "sprites_aux2", "sprites_aux3", "dungeon_main", - "grass", "3d_object", "ow_mini_map", -}; - -static constexpr absl::string_view kGfxToolsetColumnNames[] = { - "#memoryEditor", - "##separator_gfx1", -}; - -constexpr ImGuiTableFlags kGfxEditFlags = ImGuiTableFlags_Reorderable | - ImGuiTableFlags_Resizable | - ImGuiTableFlags_SizingStretchSame; /** * @class GraphicsEditor