diff --git a/src/app/editor/code/assembly_editor.h b/src/app/editor/code/assembly_editor.h index 810d073f..93a6acc3 100644 --- a/src/app/editor/code/assembly_editor.h +++ b/src/app/editor/code/assembly_editor.h @@ -8,7 +8,6 @@ #include "app/editor/editor.h" #include "app/gui/widgets/text_editor.h" #include "app/gui/app/editor_layout.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gui/core/style.h" #include "app/rom.h" diff --git a/src/app/editor/dungeon/dungeon_editor_v2.h b/src/app/editor/dungeon/dungeon_editor_v2.h index 3d493585..6f008809 100644 --- a/src/app/editor/dungeon/dungeon_editor_v2.h +++ b/src/app/editor/dungeon/dungeon_editor_v2.h @@ -14,7 +14,6 @@ #include "dungeon_object_selector.h" #include "dungeon_room_loader.h" #include "object_editor_card.h" -#include "app/gui/app/editor_card_manager.h" #include "zelda3/dungeon/room.h" #include "zelda3/dungeon/room_entrance.h" #include "app/gui/app/editor_layout.h" diff --git a/src/app/editor/graphics/graphics_editor.h b/src/app/editor/graphics/graphics_editor.h index e1496384..c3589199 100644 --- a/src/app/editor/graphics/graphics_editor.h +++ b/src/app/editor/graphics/graphics_editor.h @@ -7,7 +7,6 @@ #include "app/editor/editor.h" #include "app/editor/palette/palette_editor.h" #include "app/gfx/core/bitmap.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gfx/types/snes_tile.h" #include "app/gui/canvas/canvas.h" #include "app/gui/app/editor_layout.h" diff --git a/src/app/editor/graphics/screen_editor.h b/src/app/editor/graphics/screen_editor.h index 43957d29..5dcbec53 100644 --- a/src/app/editor/graphics/screen_editor.h +++ b/src/app/editor/graphics/screen_editor.h @@ -7,7 +7,6 @@ #include "app/editor/editor.h" #include "app/gfx/core/bitmap.h" #include "app/gfx/types/snes_palette.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gfx/render/tilemap.h" #include "app/gui/canvas/canvas.h" #include "app/rom.h" diff --git a/src/app/editor/message/message_editor.h b/src/app/editor/message/message_editor.h index e8909eef..29172b98 100644 --- a/src/app/editor/message/message_editor.h +++ b/src/app/editor/message/message_editor.h @@ -9,7 +9,6 @@ #include "app/editor/editor.h" #include "app/editor/message/message_data.h" #include "app/editor/message/message_preview.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gui/app/editor_layout.h" #include "app/gfx/core/bitmap.h" #include "app/gui/canvas/canvas.h" diff --git a/src/app/editor/music/music_editor.h b/src/app/editor/music/music_editor.h index 87578497..76c4d4bc 100644 --- a/src/app/editor/music/music_editor.h +++ b/src/app/editor/music/music_editor.h @@ -4,7 +4,6 @@ #include "app/editor/code/assembly_editor.h" #include "app/editor/editor.h" #include "app/emu/audio/apu.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gui/app/editor_layout.h" #include "app/rom.h" #include "zelda3/music/tracker.h" diff --git a/src/app/editor/overworld/overworld_editor.h b/src/app/editor/overworld/overworld_editor.h index 9924f88c..49ef6ab0 100644 --- a/src/app/editor/overworld/overworld_editor.h +++ b/src/app/editor/overworld/overworld_editor.h @@ -5,7 +5,6 @@ #include "app/editor/editor.h" #include "app/editor/graphics/gfx_group_editor.h" #include "app/editor/palette/palette_editor.h" -#include "app/gui/app/editor_card_manager.h" #include "app/editor/overworld/tile16_editor.h" #include "app/editor/overworld/map_properties.h" #include "app/editor/overworld/overworld_entity_renderer.h" diff --git a/src/app/editor/palette/palette_editor.cc b/src/app/editor/palette/palette_editor.cc index 7fd2963c..65859b8c 100644 --- a/src/app/editor/palette/palette_editor.cc +++ b/src/app/editor/palette/palette_editor.cc @@ -7,7 +7,6 @@ #include "app/gfx/debug/performance/performance_profiler.h" #include "app/gfx/types/snes_palette.h" #include "app/gui/core/color.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gui/app/editor_layout.h" #include "app/gui/core/icons.h" #include "imgui/imgui.h" @@ -185,7 +184,7 @@ absl::Status DisplayPalette(gfx::SnesPalette& palette, bool loaded) { } void PaletteEditor::Initialize() { - // Register all cards with EditorCardManager (done once during initialization) + // Register all cards with EditorCardRegistry (done once during initialization) if (!dependencies_.card_registry) return; auto* card_registry = dependencies_.card_registry; @@ -751,9 +750,8 @@ absl::Status PaletteEditor::ResetColorToOriginal( // ============================================================================ void PaletteEditor::DrawToolset() { - // Draw VSCode-style sidebar using EditorCardManager - // auto& card_manager = gui::EditorCardManager::Get(); - // card_manager.DrawSidebar("Palette"); + // Sidebar is drawn by EditorCardRegistry in EditorManager + // Cards registered in Initialize() appear in the sidebar automatically } void PaletteEditor::DrawControlPanel() { @@ -936,10 +934,9 @@ void PaletteEditor::DrawControlPanel() { "%s Palette Card Manager", ICON_MD_PALETTE); ImGui::Separator(); - // Use EditorCardManager to draw the menu - if (!dependencies_.card_registry) return; - auto* card_registry = dependencies_.card_registry; // View menu section now handled by EditorCardRegistry in EditorManager + if (!dependencies_.card_registry) return; + auto* card_registry = dependencies_.card_registry; ImGui::EndPopup(); } diff --git a/src/app/editor/palette/palette_group_card.h b/src/app/editor/palette/palette_group_card.h index 8b644733..a893a8d6 100644 --- a/src/app/editor/palette/palette_group_card.h +++ b/src/app/editor/palette/palette_group_card.h @@ -11,7 +11,6 @@ #include "absl/status/status.h" #include "app/gfx/types/snes_color.h" #include "app/gfx/types/snes_palette.h" -#include "app/gui/app/editor_card_manager.h" #include "app/rom.h" #include "imgui/imgui.h" @@ -61,7 +60,7 @@ struct PaletteGroupMetadata { * - Modified state tracking with visual indicators * - Save/discard workflow * - Common toolbar and color picker UI - * - EditorCardManager integration + * - EditorCardRegistry integration * * Derived classes implement specific grid layouts and palette access. */ @@ -260,9 +259,6 @@ class PaletteGroupCard { bool auto_save_enabled_ = false; // Auto-save to ROM on every change bool show_snes_format_ = true; // Show SNES $xxxx format in info bool show_hex_format_ = true; // Show #xxxxxx hex in info - - // Card registration - gui::CardRegistration card_registration_; }; // ============================================================================ diff --git a/src/app/editor/sprite/sprite_editor.h b/src/app/editor/sprite/sprite_editor.h index 07b04a5b..98b7bad2 100644 --- a/src/app/editor/sprite/sprite_editor.h +++ b/src/app/editor/sprite/sprite_editor.h @@ -8,7 +8,6 @@ #include "app/editor/editor.h" #include "app/editor/sprite/zsprite.h" #include "app/gui/canvas/canvas.h" -#include "app/gui/app/editor_card_manager.h" #include "app/gui/app/editor_layout.h" #include "app/rom.h" diff --git a/src/app/editor/ui/ui_coordinator.cc b/src/app/editor/ui/ui_coordinator.cc index a7e2a69c..18ccc5ac 100644 --- a/src/app/editor/ui/ui_coordinator.cc +++ b/src/app/editor/ui/ui_coordinator.cc @@ -104,8 +104,6 @@ void UICoordinator::DrawAllUI() { // Note: Theme styling is applied by ThemeManager, not here // This is called from EditorManager::Update() - don't call menu bar stuff here - LOG_INFO("UICoordinator", "DrawAllUI() called"); - // Draw UI windows and dialogs // Session dialogs are drawn by SessionCoordinator separately to avoid duplication DrawCommandPalette(); // Ctrl+Shift+P @@ -114,8 +112,6 @@ void UICoordinator::DrawAllUI() { DrawWelcomeScreen(); // Welcome screen DrawProjectHelp(); // Project help DrawWindowManagementUI(); // Window management - - LOG_INFO("UICoordinator", "DrawAllUI() complete"); } void UICoordinator::DrawMenuBarExtras() { @@ -291,26 +287,20 @@ void UICoordinator::DrawWelcomeScreen() { return; } - LOG_INFO("UICoordinator", "Drawing welcome screen (rom_loaded=%s)", - rom_is_loaded ? "true" : "false"); - // Reset first show flag to override ImGui ini state - // This ensures the window appears even if imgui.ini has it hidden welcome_screen_->ResetFirstShow(); // Update recent projects before showing welcome_screen_->RefreshRecentProjects(); - // Show the welcome screen (it manages its own ImGui window) + // Show the welcome screen window bool is_open = true; - bool action_taken = welcome_screen_->Show(&is_open); + welcome_screen_->Show(&is_open); - // If user closed the window via X button, mark as manually closed + // If user closed it via X button, respect that if (!is_open) { - welcome_screen_manually_closed_ = true; show_welcome_screen_ = false; - welcome_screen_->MarkManuallyClosed(); - LOG_INFO("UICoordinator", "Welcome screen manually closed by user (X button)"); + welcome_screen_manually_closed_ = true; } // If an action was taken (ROM loaded, project opened), the welcome screen will auto-hide @@ -533,8 +523,6 @@ void UICoordinator::DrawTestingUI() { void UICoordinator::DrawCommandPalette() { if (!show_command_palette_) return; - LOG_INFO("UICoordinator", "DrawCommandPalette() - rendering command palette"); - using namespace ImGui; auto& theme = gui::ThemeManager::Get().GetCurrentTheme(); diff --git a/src/app/editor/ui/ui_coordinator.h b/src/app/editor/ui/ui_coordinator.h index 81638f8a..ae93ce7d 100644 --- a/src/app/editor/ui/ui_coordinator.h +++ b/src/app/editor/ui/ui_coordinator.h @@ -92,10 +92,7 @@ class UICoordinator { void HideCurrentEditorCards(); void ToggleCardSidebar() { show_card_sidebar_ = !show_card_sidebar_; } void ShowGlobalSearch() { show_global_search_ = true; } - void ShowCommandPalette() { - LOG_INFO("UICoordinator", "ShowCommandPalette() called - setting flag to true"); - show_command_palette_ = true; - } + void ShowCommandPalette() { show_command_palette_ = true; } void ShowCardBrowser() { show_card_browser_ = true; } // Window visibility management diff --git a/src/app/gui/app/editor_card_manager.cc b/src/app/gui/app/editor_card_manager.cc deleted file mode 100644 index 1a6c8f0f..00000000 --- a/src/app/gui/app/editor_card_manager.cc +++ /dev/null @@ -1,1028 +0,0 @@ -#include "editor_card_manager.h" - -#include -#include - -#include "absl/strings/str_format.h" -#include "app/gui/core/icons.h" -#include "app/gui/core/theme_manager.h" -#include "imgui/imgui.h" - -namespace yaze { -namespace gui { - -EditorCardManager& EditorCardManager::Get() { - static EditorCardManager instance; - return instance; -} - -void EditorCardManager::RegisterCard(const CardInfo& info) { - if (info.card_id.empty()) { - return; - } - - // Check if already registered to avoid duplicates - if (cards_.find(info.card_id) != cards_.end()) { - return; - } - - CardInfo new_info = info; - - // If no visibility_flag provided, create centralized one - if (!new_info.visibility_flag) { - centralized_visibility_[info.card_id] = false; // Hidden by default - new_info.visibility_flag = ¢ralized_visibility_[info.card_id]; - } - - cards_[info.card_id] = new_info; -} - -void EditorCardManager::RegisterCard(const std::string& card_id, - const std::string& display_name, - const std::string& icon, - const std::string& category, - const std::string& shortcut_hint, - int priority, - std::function on_show, - std::function on_hide, - bool visible_by_default) { - if (card_id.empty()) { - printf("[EditorCardManager] Warning: Attempted to register card with empty ID\n"); - return; - } - - // Check if already registered - if (cards_.find(card_id) != cards_.end()) { - printf("[EditorCardManager] WARNING: Card '%s' already registered, skipping duplicate\n", - card_id.c_str()); - return; - } - - // Create centralized visibility flag - centralized_visibility_[card_id] = visible_by_default; - - // Register card with pointer to centralized flag - CardInfo info; - info.card_id = card_id; - info.display_name = display_name; - info.icon = icon; - info.category = category; - info.shortcut_hint = shortcut_hint; - info.priority = priority; - info.visibility_flag = ¢ralized_visibility_[card_id]; - info.on_show = on_show; - info.on_hide = on_hide; - - cards_[card_id] = info; - printf("[EditorCardManager] Registered card with centralized visibility: %s (%s) [default: %s]\n", - card_id.c_str(), display_name.c_str(), visible_by_default ? "visible" : "hidden"); -} - -void EditorCardManager::UnregisterCard(const std::string& card_id) { - auto it = cards_.find(card_id); - if (it != cards_.end()) { - printf("[EditorCardManager] Unregistered card: %s\n", card_id.c_str()); - cards_.erase(it); - // Also remove centralized visibility if it exists - centralized_visibility_.erase(card_id); - } -} - -void EditorCardManager::UnregisterCardsWithPrefix(const std::string& prefix) { - std::vector to_remove; - - // Find all cards with the given prefix - for (const auto& [card_id, card_info] : cards_) { - if (card_id.find(prefix) == 0) { // Starts with prefix - to_remove.push_back(card_id); - } - } - - // Remove all found cards - for (const auto& card_id : to_remove) { - UnregisterCard(card_id); - } - - printf("[EditorCardManager] Unregistered %zu cards with prefix: %s\n", - to_remove.size(), prefix.c_str()); -} - -void EditorCardManager::ClearAllCards() { - printf("[EditorCardManager] Clearing all %zu registered cards\n", cards_.size()); - cards_.clear(); -} - -bool EditorCardManager::ShowCard(const std::string& card_id) { - auto it = cards_.find(card_id); - if (it == cards_.end()) { - return false; - } - - if (it->second.visibility_flag) { - *it->second.visibility_flag = true; - - // Set active category when showing a card - SetActiveCategory(it->second.category); - - if (it->second.on_show) { - it->second.on_show(); - } - - return true; - } - - return false; -} - -bool EditorCardManager::HideCard(const std::string& card_id) { - auto it = cards_.find(card_id); - if (it == cards_.end()) { - return false; - } - - if (it->second.visibility_flag) { - *it->second.visibility_flag = false; - - if (it->second.on_hide) { - it->second.on_hide(); - } - - return true; - } - - return false; -} - -bool EditorCardManager::ToggleCard(const std::string& card_id) { - auto it = cards_.find(card_id); - if (it == cards_.end()) { - return false; - } - - if (it->second.visibility_flag) { - bool new_state = !(*it->second.visibility_flag); - *it->second.visibility_flag = new_state; - - if (new_state && it->second.on_show) { - it->second.on_show(); - } else if (!new_state && it->second.on_hide) { - it->second.on_hide(); - } - - return true; - } - - return false; -} - -bool EditorCardManager::IsCardVisible(const std::string& card_id) const { - auto it = cards_.find(card_id); - if (it != cards_.end() && it->second.visibility_flag) { - return *it->second.visibility_flag; - } - return false; -} - -bool* EditorCardManager::GetVisibilityFlag(const std::string& card_id) { - auto it = cards_.find(card_id); - if (it != cards_.end()) { - return it->second.visibility_flag; - } - return nullptr; -} - -void EditorCardManager::ShowAllCardsInCategory(const std::string& category) { - for (auto& [id, info] : cards_) { - if (info.category == category && info.visibility_flag) { - *info.visibility_flag = true; - if (info.on_show) info.on_show(); - } - } -} - -void EditorCardManager::HideAllCardsInCategory(const std::string& category) { - for (auto& [id, info] : cards_) { - if (info.category == category && info.visibility_flag) { - *info.visibility_flag = false; - if (info.on_hide) info.on_hide(); - } - } -} - -void EditorCardManager::ShowOnlyCard(const std::string& card_id) { - auto target = cards_.find(card_id); - if (target == cards_.end()) { - return; - } - - std::string category = target->second.category; - - // Hide all cards in the same category - for (auto& [id, info] : cards_) { - if (info.category == category && info.visibility_flag) { - *info.visibility_flag = (id == card_id); - - if (id == card_id && info.on_show) { - info.on_show(); - } else if (id != card_id && info.on_hide) { - info.on_hide(); - } - } - } -} - -std::vector EditorCardManager::GetCardsInCategory(const std::string& category) const { - std::vector result; - - for (const auto& [id, info] : cards_) { - if (info.category == category) { - result.push_back(info); - } - } - - // Sort by priority - std::sort(result.begin(), result.end(), - [](const CardInfo& a, const CardInfo& b) { - return a.priority < b.priority; - }); - - return result; -} - -std::vector EditorCardManager::GetCardsWithPrefix(const std::string& prefix) const { - std::vector result; - - for (const auto& [id, info] : cards_) { - if (id.find(prefix) == 0) { // Starts with prefix - result.push_back(info); - } - } - - // Sort by priority - std::sort(result.begin(), result.end(), - [](const CardInfo& a, const CardInfo& b) { - return a.priority < b.priority; - }); - - return result; -} - -std::vector EditorCardManager::GetAllCategories() const { - std::vector categories; - - for (const auto& [id, info] : cards_) { - if (std::find(categories.begin(), categories.end(), info.category) == categories.end()) { - categories.push_back(info.category); - } - } - - std::sort(categories.begin(), categories.end()); - return categories; -} - -const CardInfo* EditorCardManager::GetCardInfo(const std::string& card_id) const { - auto it = cards_.find(card_id); - return (it != cards_.end()) ? &it->second : nullptr; -} - -void EditorCardManager::DrawViewMenuSection(const std::string& category) { - auto cards_in_category = GetCardsInCategory(category); - - if (cards_in_category.empty()) { - ImGui::MenuItem("(No cards registered)", nullptr, false, false); - return; - } - - for (const auto& info : cards_in_category) { - if (!info.visibility_flag) continue; - - std::string label = info.icon.empty() - ? info.display_name - : info.icon + " " + info.display_name; - - bool visible = *info.visibility_flag; - - if (ImGui::MenuItem(label.c_str(), - info.shortcut_hint.empty() ? nullptr : info.shortcut_hint.c_str(), - visible)) { - ToggleCard(info.card_id); - } - } -} - -void EditorCardManager::DrawViewMenuAll() { - auto categories = GetAllCategories(); - - if (categories.empty()) { - ImGui::TextDisabled("No cards registered"); - return; - } - - for (const auto& category : categories) { - if (ImGui::BeginMenu(category.c_str())) { - DrawViewMenuSection(category); - ImGui::Separator(); - - // Category-level actions - if (ImGui::MenuItem(absl::StrFormat("%s Show All", ICON_MD_VISIBILITY).c_str())) { - ShowAllCardsInCategory(category); - } - - if (ImGui::MenuItem(absl::StrFormat("%s Hide All", ICON_MD_VISIBILITY_OFF).c_str())) { - HideAllCardsInCategory(category); - } - - ImGui::EndMenu(); - } - } - - ImGui::Separator(); - - // Global actions - if (ImGui::MenuItem(absl::StrFormat("%s Show All Cards", ICON_MD_VISIBILITY).c_str())) { - ShowAll(); - } - - if (ImGui::MenuItem(absl::StrFormat("%s Hide All Cards", ICON_MD_VISIBILITY_OFF).c_str())) { - HideAll(); - } - - ImGui::Separator(); - - if (ImGui::MenuItem(absl::StrFormat("%s Card Browser", ICON_MD_DASHBOARD).c_str(), - "Ctrl+Shift+B")) { - // This will be shown by EditorManager - } -} - -void EditorCardManager::DrawCompactCardControl(const std::string& category) { - DrawCompactCardControlWithSession(category, ""); -} - -void EditorCardManager::DrawCompactCardControlWithSession(const std::string& category, const std::string& session_prefix) { - std::vector cards_in_category; - - if (session_prefix.empty()) { - cards_in_category = GetCardsInCategory(category); - } else { - // Filter cards by session prefix - auto all_cards = GetCardsWithPrefix(session_prefix); - for (const auto& card : all_cards) { - if (card.category == category) { - cards_in_category.push_back(card); - } - } - } - - if (cards_in_category.empty()) { - return; // Nothing to show - } - - // Use theme colors for button - ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_Button)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive)); - - if (ImGui::SmallButton(ICON_MD_VIEW_MODULE)) { - ImGui::OpenPopup("CardControlPopup"); - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered()) { - std::string tooltip = category + " Card Controls"; - if (!session_prefix.empty()) { - tooltip += " (" + session_prefix + ")"; - } - ImGui::SetTooltip("%s", tooltip.c_str()); - } - - // Compact popup with checkboxes - if (ImGui::BeginPopup("CardControlPopup")) { - std::string title = category + " Cards"; - if (!session_prefix.empty()) { - title += " (" + session_prefix + ")"; - } - ImGui::TextColored(ImVec4(0.7f, 0.9f, 1.0f, 1.0f), "%s %s", - ICON_MD_DASHBOARD, title.c_str()); - ImGui::Separator(); - - for (const auto& info : cards_in_category) { - if (!info.visibility_flag) continue; - - std::string label = info.icon.empty() - ? info.display_name - : info.icon + " " + info.display_name; - - bool visible = *info.visibility_flag; - if (ImGui::Checkbox(label.c_str(), &visible)) { - *info.visibility_flag = visible; - if (visible && info.on_show) { - info.on_show(); - } else if (!visible && info.on_hide) { - info.on_hide(); - } - } - - // Show shortcut hint - if (!info.shortcut_hint.empty()) { - ImGui::SameLine(); - ImGui::TextDisabled("(%s)", info.shortcut_hint.c_str()); - } - } - - ImGui::Separator(); - - if (ImGui::MenuItem(absl::StrFormat("%s Show All", ICON_MD_VISIBILITY).c_str())) { - ShowAllCardsInCategory(category); - } - - if (ImGui::MenuItem(absl::StrFormat("%s Hide All", ICON_MD_VISIBILITY_OFF).c_str())) { - HideAllCardsInCategory(category); - } - - ImGui::EndPopup(); - } -} - -void EditorCardManager::DrawInlineCardToggles(const std::string& category) { - auto cards_in_category = GetCardsInCategory(category); - - if (cards_in_category.empty()) { - return; - } - - // Show visible count as indicator - size_t visible_count = 0; - for (const auto& info : cards_in_category) { - if (info.visibility_flag && *info.visibility_flag) { - visible_count++; - } - } - - ImGui::TextDisabled("%s %zu/%zu", ICON_MD_DASHBOARD, visible_count, cards_in_category.size()); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("%s cards: %zu visible, %zu hidden", - category.c_str(), visible_count, - cards_in_category.size() - visible_count); - } -} - -void EditorCardManager::DrawCardBrowser(bool* p_open) { - if (!p_open || !*p_open) return; - - ImGui::SetNextWindowSize(ImVec2(800, 600), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), - ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); - - if (!ImGui::Begin(absl::StrFormat("%s Card Browser", ICON_MD_DASHBOARD).c_str(), - p_open)) { - ImGui::End(); - return; - } - - // Search filter - static char search_filter[256] = ""; - ImGui::SetNextItemWidth(-100); - ImGui::InputTextWithHint("##CardSearch", - absl::StrFormat("%s Search cards...", ICON_MD_SEARCH).c_str(), - search_filter, sizeof(search_filter)); - - ImGui::SameLine(); - if (ImGui::Button(absl::StrFormat("%s Clear", ICON_MD_CLEAR).c_str())) { - search_filter[0] = '\0'; - } - - ImGui::Separator(); - - // Statistics - ImGui::Text("%s Total Cards: %zu | Visible: %zu", - ICON_MD_INFO, GetCardCount(), GetVisibleCardCount()); - - ImGui::Separator(); - - // Category tabs - if (ImGui::BeginTabBar("CardBrowserTabs")) { - - // All Cards tab - if (ImGui::BeginTabItem(absl::StrFormat("%s All", ICON_MD_APPS).c_str())) { - DrawCardBrowserTable(search_filter, ""); - ImGui::EndTabItem(); - } - - // Category tabs - for (const auto& category : GetAllCategories()) { - std::string tab_label = category; - if (ImGui::BeginTabItem(tab_label.c_str())) { - DrawCardBrowserTable(search_filter, category); - ImGui::EndTabItem(); - } - } - - // Presets tab - if (ImGui::BeginTabItem(absl::StrFormat("%s Presets", ICON_MD_BOOKMARK).c_str())) { - DrawPresetsTab(); - ImGui::EndTabItem(); - } - - ImGui::EndTabBar(); - } - - ImGui::End(); -} - -void EditorCardManager::DrawCardBrowserTable(const char* search_filter, - const std::string& category_filter) { - if (ImGui::BeginTable("CardBrowserTable", 4, - ImGuiTableFlags_Borders | - ImGuiTableFlags_RowBg | - ImGuiTableFlags_Resizable | - ImGuiTableFlags_ScrollY)) { - - ImGui::TableSetupColumn("Card", ImGuiTableColumnFlags_WidthStretch, 0.4f); - ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthStretch, 0.2f); - ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthStretch, 0.2f); - ImGui::TableSetupColumn("Visible", ImGuiTableColumnFlags_WidthFixed, 80.0f); - ImGui::TableHeadersRow(); - - // Collect and sort cards - std::vector display_cards; - for (const auto& [id, info] : cards_) { - // Apply filters - if (!category_filter.empty() && info.category != category_filter) { - continue; - } - - if (search_filter && search_filter[0] != '\0') { - std::string search_lower = search_filter; - std::transform(search_lower.begin(), search_lower.end(), - search_lower.begin(), ::tolower); - - std::string name_lower = info.display_name; - std::transform(name_lower.begin(), name_lower.end(), - name_lower.begin(), ::tolower); - - if (name_lower.find(search_lower) == std::string::npos) { - continue; - } - } - - display_cards.push_back(info); - } - - // Sort by category then priority - std::sort(display_cards.begin(), display_cards.end(), - [](const CardInfo& a, const CardInfo& b) { - if (a.category != b.category) return a.category < b.category; - return a.priority < b.priority; - }); - - // Draw rows - for (const auto& info : display_cards) { - ImGui::PushID(info.card_id.c_str()); - - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - - // Card name with icon - std::string label = info.icon.empty() - ? info.display_name - : info.icon + " " + info.display_name; - ImGui::Text("%s", label.c_str()); - - ImGui::TableNextColumn(); - ImGui::TextDisabled("%s", info.category.c_str()); - - ImGui::TableNextColumn(); - if (!info.shortcut_hint.empty()) { - ImGui::TextDisabled("%s", info.shortcut_hint.c_str()); - } - - ImGui::TableNextColumn(); - if (info.visibility_flag) { - bool visible = *info.visibility_flag; - if (ImGui::Checkbox("##Visible", &visible)) { - *info.visibility_flag = visible; - if (visible && info.on_show) { - info.on_show(); - } else if (!visible && info.on_hide) { - info.on_hide(); - } - } - } - - ImGui::PopID(); - } - - ImGui::EndTable(); - } -} - -void EditorCardManager::DrawPresetsTab() { - ImGui::Text("%s Workspace Presets", ICON_MD_BOOKMARK); - ImGui::Separator(); - - // Save current as preset - static char preset_name[256] = ""; - static char preset_desc[512] = ""; - - ImGui::Text("Save Current Layout:"); - ImGui::InputText("Name", preset_name, sizeof(preset_name)); - ImGui::InputText("Description", preset_desc, sizeof(preset_desc)); - - if (ImGui::Button(absl::StrFormat("%s Save Preset", ICON_MD_SAVE).c_str())) { - if (preset_name[0] != '\0') { - SavePreset(preset_name, preset_desc); - preset_name[0] = '\0'; - preset_desc[0] = '\0'; - } - } - - ImGui::Separator(); - ImGui::Text("Saved Presets:"); - - // List presets - auto presets = GetPresets(); - if (presets.empty()) { - ImGui::TextDisabled("No presets saved"); - } else { - for (const auto& preset : presets) { - ImGui::PushID(preset.name.c_str()); - - if (ImGui::Button(absl::StrFormat("%s Load", ICON_MD_FOLDER_OPEN).c_str())) { - LoadPreset(preset.name); - } - - ImGui::SameLine(); - if (ImGui::Button(absl::StrFormat("%s Delete", ICON_MD_DELETE).c_str())) { - DeletePreset(preset.name); - } - - ImGui::SameLine(); - ImGui::Text("%s %s", ICON_MD_BOOKMARK, preset.name.c_str()); - - if (!preset.description.empty()) { - ImGui::SameLine(); - ImGui::TextDisabled("- %s", preset.description.c_str()); - } - - ImGui::SameLine(); - ImGui::TextDisabled("(%zu cards)", preset.visible_cards.size()); - - ImGui::PopID(); - } - } -} - -void EditorCardManager::SavePreset(const std::string& name, const std::string& description) { - WorkspacePreset preset; - preset.name = name; - preset.description = description; - - // Save currently visible cards - for (const auto& [id, info] : cards_) { - if (info.visibility_flag && *info.visibility_flag) { - preset.visible_cards.push_back(id); - } - } - - presets_[name] = preset; - SavePresetsToFile(); - - printf("[EditorCardManager] Saved preset '%s' with %zu cards\n", - name.c_str(), preset.visible_cards.size()); -} - -bool EditorCardManager::LoadPreset(const std::string& name) { - auto it = presets_.find(name); - if (it == presets_.end()) { - return false; - } - - // Hide all cards first - HideAll(); - - // Show cards in preset - for (const auto& card_id : it->second.visible_cards) { - ShowCard(card_id); - } - - printf("[EditorCardManager] Loaded preset '%s' with %zu cards\n", - name.c_str(), it->second.visible_cards.size()); - - return true; -} - -void EditorCardManager::DeletePreset(const std::string& name) { - auto it = presets_.find(name); - if (it != presets_.end()) { - presets_.erase(it); - SavePresetsToFile(); - printf("[EditorCardManager] Deleted preset '%s'\n", name.c_str()); - } -} - -std::vector EditorCardManager::GetPresets() const { - std::vector result; - for (const auto& [name, preset] : presets_) { - result.push_back(preset); - } - return result; -} - -void EditorCardManager::ShowAll() { - for (auto& [id, info] : cards_) { - if (info.visibility_flag) { - *info.visibility_flag = true; - if (info.on_show) info.on_show(); - } - } -} - -void EditorCardManager::HideAll() { - for (auto& [id, info] : cards_) { - if (info.visibility_flag) { - *info.visibility_flag = false; - if (info.on_hide) info.on_hide(); - } - } -} - -void EditorCardManager::ResetToDefaults() { - // Default visibility based on priority - for (auto& [id, info] : cards_) { - if (info.visibility_flag) { - // Show high-priority cards (priority < 50) - *info.visibility_flag = (info.priority < 50); - - if (*info.visibility_flag && info.on_show) { - info.on_show(); - } else if (!*info.visibility_flag && info.on_hide) { - info.on_hide(); - } - } - } -} - -size_t EditorCardManager::GetVisibleCardCount() const { - size_t count = 0; - for (const auto& [id, info] : cards_) { - if (info.visibility_flag && *info.visibility_flag) { - count++; - } - } - return count; -} - -void EditorCardManager::SavePresetsToFile() { - // Save presets to JSON or simple format - // TODO: Implement file I/O - printf("[EditorCardManager] Saving %zu presets to file\n", presets_.size()); -} - -void EditorCardManager::LoadPresetsFromFile() { - // Load presets from file - // TODO: Implement file I/O - printf("[EditorCardManager] Loading presets from file\n"); -} - -void EditorCardManager::SetActiveCategory(const std::string& category) { - if (category.empty()) return; - - active_category_ = category; - - // Update recent categories stack - auto it = std::find(recent_categories_.begin(), recent_categories_.end(), category); - if (it != recent_categories_.end()) { - recent_categories_.erase(it); - } - recent_categories_.insert(recent_categories_.begin(), category); - if (recent_categories_.size() > kMaxRecentCategories) { - recent_categories_.resize(kMaxRecentCategories); - } -} - -void EditorCardManager::DrawSidebar(const std::string& category, - const std::vector& active_categories, - std::function on_category_switch, - std::function on_collapse) { - DrawSidebarWithSessionFilter(category, "", active_categories, on_category_switch, on_collapse); -} - -void EditorCardManager::DrawSidebarWithSessionFilter(const std::string& category, - const std::string& session_prefix, - const std::vector& active_categories, - std::function on_category_switch, - std::function on_collapse) { - // Use ThemeManager for consistent theming - const auto& theme = ThemeManager::Get().GetCurrentTheme(); - - const float sidebar_width = GetSidebarWidth(); - - // Fixed sidebar window on the left edge of screen - ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetFrameHeight())); // Below menu bar - ImGui::SetNextWindowSize(ImVec2(sidebar_width, -1)); // Full height below menu - - ImGuiWindowFlags sidebar_flags = - ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoResize | - ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoDocking | // Don't allow docking over sidebar - ImGuiWindowFlags_NoScrollbar | - ImGuiWindowFlags_NoScrollWithMouse | - ImGuiWindowFlags_NoFocusOnAppearing | // Don't steal focus - ImGuiWindowFlags_NoNavFocus; // Don't participate in nav - - // Make sidebar VERY visible - fully opaque dark background - ImVec4 sidebar_bg = ImVec4(0.18f, 0.18f, 0.20f, 1.0f); // Dark opaque gray - ImVec4 sidebar_border = ImVec4(0.4f, 0.4f, 0.45f, 1.0f); // Visible border - - ImGui::PushStyleColor(ImGuiCol_WindowBg, sidebar_bg); - ImGui::PushStyleColor(ImGuiCol_Border, sidebar_border); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4.0f, 8.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 6.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 2.0f); // Thicker border - - if (ImGui::Begin("##EditorCardSidebar", nullptr, sidebar_flags)) { - // Category switcher buttons at top (if multiple editors active) - if (active_categories.size() > 1) { - ImVec4 accent = ConvertColorToImVec4(theme.accent); - ImVec4 inactive = ConvertColorToImVec4(theme.button); - - for (const auto& cat : active_categories) { - bool is_current = (cat == category); - - if (is_current) { - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(accent.x, accent.y, accent.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(accent.x, accent.y, accent.z, 1.0f)); - } else { - ImGui::PushStyleColor(ImGuiCol_Button, inactive); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ConvertColorToImVec4(theme.button_hovered)); - } - - // Show first letter of category - std::string btn_label = cat.empty() ? "?" : std::string(1, cat[0]); - if (ImGui::Button(btn_label.c_str(), ImVec2(40.0f, 32.0f))) { - // Call callback to switch editor, not just set category - if (on_category_switch) { - on_category_switch(cat); - } else { - SetActiveCategory(cat); - } - } - - ImGui::PopStyleColor(2); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("%s Editor\nClick to switch", cat.c_str()); - } - } - - ImGui::Dummy(ImVec2(0, 2.0f)); - ImGui::Separator(); - ImGui::Spacing(); - } - - // Get cards for this category - auto cards = GetCardsInCategory(category); - - // Set this category as active when showing cards - if (!cards.empty()) { - SetActiveCategory(category); - } - - // Close All button (only if cards exist) - if (!cards.empty()) { - ImVec4 error_color = ConvertColorToImVec4(theme.error); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4( - error_color.x * 0.6f, error_color.y * 0.6f, error_color.z * 0.6f, 0.9f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_color); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4( - error_color.x * 1.2f, error_color.y * 1.2f, error_color.z * 1.2f, 1.0f)); - - if (ImGui::Button(ICON_MD_CLOSE, ImVec2(40.0f, 36.0f))) { - HideAllCardsInCategory(category); - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Close All %s Cards", category.c_str()); - } - - // Show All button - ImVec4 success_color = ConvertColorToImVec4(theme.success); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4( - success_color.x * 0.6f, success_color.y * 0.6f, success_color.z * 0.6f, 0.7f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, success_color); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4( - success_color.x * 1.2f, success_color.y * 1.2f, success_color.z * 1.2f, 1.0f)); - - if (ImGui::Button(ICON_MD_DONE_ALL, ImVec2(40.0f, 36.0f))) { - ShowAllCardsInCategory(category); - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Show All %s Cards", category.c_str()); - } - - ImGui::Dummy(ImVec2(0, 2.0f)); - - // Draw card buttons - ImVec4 accent_color = ConvertColorToImVec4(theme.accent); - ImVec4 button_bg = ConvertColorToImVec4(theme.button); - - for (const auto& card : cards) { - ImGui::PushID(card.card_id.c_str()); - - bool is_active = card.visibility_flag && *card.visibility_flag; - - if (is_active) { - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4( - accent_color.x, accent_color.y, accent_color.z, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4( - accent_color.x, accent_color.y, accent_color.z, 0.7f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, accent_color); - } else { - ImGui::PushStyleColor(ImGuiCol_Button, button_bg); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ConvertColorToImVec4(theme.button_hovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ConvertColorToImVec4(theme.button_active)); - } - - if (ImGui::Button(card.icon.c_str(), ImVec2(40.0f, 40.0f))) { - ToggleCard(card.card_id); - SetActiveCategory(category); - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered() || ImGui::IsItemActive()) { - SetActiveCategory(category); - - ImGui::SetTooltip("%s\n%s", card.display_name.c_str(), - card.shortcut_hint.empty() ? "" : card.shortcut_hint.c_str()); - } - - ImGui::PopID(); - } - } // End if (!cards.empty()) - - // Card Browser and Collapse sidebar buttons at bottom - if (on_collapse) { - ImGui::Dummy(ImVec2(0, 10.0f)); // Add some space - ImGui::Separator(); - ImGui::Spacing(); - - // Card Browser button - ImVec4 browser_color = ConvertColorToImVec4(theme.accent); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(browser_color.x * 0.7f, browser_color.y * 0.7f, browser_color.z * 0.7f, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(browser_color.x, browser_color.y, browser_color.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, browser_color); - - static bool show_card_browser = false; - if (ImGui::Button(ICON_MD_DASHBOARD, ImVec2(40.0f, 36.0f))) { - show_card_browser = true; - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Card Browser\nCtrl+Shift+B"); - } - - // Draw card browser if requested - if (show_card_browser) { - DrawCardBrowser(&show_card_browser); - } - - ImGui::Spacing(); - - // Collapse button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.2f, 0.22f, 0.9f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.3f, 0.3f, 0.32f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.25f, 0.25f, 0.27f, 1.0f)); - - if (ImGui::Button(ICON_MD_KEYBOARD_ARROW_LEFT, ImVec2(40.0f, 36.0f))) { - on_collapse(); - } - - ImGui::PopStyleColor(3); - - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Hide Sidebar\nCtrl+B"); - } - } - } - ImGui::End(); - - ImGui::PopStyleVar(3); // WindowPadding, ItemSpacing, WindowBorderSize - ImGui::PopStyleColor(2); // WindowBg, Border -} - -} // namespace gui -} // namespace yaze - diff --git a/src/app/gui/app/editor_card_manager.h b/src/app/gui/app/editor_card_manager.h deleted file mode 100644 index 59d56d83..00000000 --- a/src/app/gui/app/editor_card_manager.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef YAZE_APP_GUI_EDITOR_CARD_MANAGER_H -#define YAZE_APP_GUI_EDITOR_CARD_MANAGER_H - -#include -#include -#include -#include -#include - -#include "imgui/imgui.h" - -namespace yaze { -namespace gui { - -class EditorCard; // Forward declaration - -/** - * @brief Metadata for an editor card - */ -struct CardInfo { - std::string card_id; // Unique identifier (e.g., "dungeon.room_selector") - std::string display_name; // Human-readable name (e.g., "Room Selector") - std::string icon; // Material icon - std::string category; // Category (e.g., "Dungeon", "Graphics", "Palette") - std::string shortcut_hint; // Display hint (e.g., "Ctrl+Shift+R") - bool* visibility_flag; // Pointer to bool controlling visibility - EditorCard* card_instance; // Pointer to actual card (optional) - std::function on_show; // Callback when card is shown - std::function on_hide; // Callback when card is hidden - int priority; // Display priority for menus (lower = higher) -}; - -/** - * @brief Central registry and manager for all editor cards - * - * This singleton provides: - * - Global card registration across all editors - * - View menu integration - * - Keyboard shortcut management - * - Workspace preset system - * - Quick search/filter - * - Programmatic card control without GUI coupling - * - * Design Philosophy: - * - Cards register themselves on creation - * - Manager provides unified interface for visibility control - * - No direct GUI dependency in card logic - * - Supports dynamic card creation/destruction - * - * Usage: - * ```cpp - * // In editor initialization: - * auto& manager = EditorCardManager::Get(); - * manager.RegisterCard({ - * .card_id = "dungeon.room_selector", - * .display_name = "Room Selector", - * .icon = ICON_MD_LIST, - * .category = "Dungeon", - * .visibility_flag = &show_room_selector_, - * .on_show = []() { printf("Room selector opened\n"); } - * }); - * - * // Programmatic control: - * manager.ShowCard("dungeon.room_selector"); - * manager.HideCard("dungeon.room_selector"); - * manager.ToggleCard("dungeon.room_selector"); - * - * // In View menu: - * manager.DrawViewMenuSection("Dungeon"); - * ``` - */ -class EditorCardManager { - public: - static EditorCardManager& Get(); - - // Registration - void RegisterCard(const CardInfo& info); - - // Register card with centralized visibility management (preferred method) - void RegisterCard(const std::string& card_id, - const std::string& display_name, - const std::string& icon, - const std::string& category, - const std::string& shortcut_hint = "", - int priority = 50, - std::function on_show = nullptr, - std::function on_hide = nullptr, - bool visible_by_default = false); - - void UnregisterCard(const std::string& card_id); - void UnregisterCardsWithPrefix(const std::string& prefix); - void ClearAllCards(); - - // Card control (programmatic, no GUI) - bool ShowCard(const std::string& card_id); - bool HideCard(const std::string& card_id); - bool ToggleCard(const std::string& card_id); - bool IsCardVisible(const std::string& card_id) const; - - // Get visibility flag pointer (for passing to EditorCard::Begin) - bool* GetVisibilityFlag(const std::string& card_id); - - // Batch operations - void ShowAllCardsInCategory(const std::string& category); - void HideAllCardsInCategory(const std::string& category); - void ShowOnlyCard(const std::string& card_id); // Hide all others in category - - // Query - std::vector GetCardsInCategory(const std::string& category) const; - std::vector GetCardsWithPrefix(const std::string& prefix) const; - std::vector GetAllCategories() const; - const CardInfo* GetCardInfo(const std::string& card_id) const; - - // View menu integration - void DrawViewMenuSection(const std::string& category); - void DrawViewMenuAll(); // Draw all categories as submenus - - // VSCode-style sidebar (replaces Toolset) - void DrawSidebar(const std::string& category, - const std::vector& active_categories = {}, - std::function on_category_switch = nullptr, - std::function on_collapse = nullptr); - void DrawSidebarWithSessionFilter(const std::string& category, - const std::string& session_prefix = "", - const std::vector& active_categories = {}, - std::function on_category_switch = nullptr, - std::function on_collapse = nullptr); - static constexpr float GetSidebarWidth() { return 48.0f; } - - // Active editor tracking (based on most recently interacted card) - void SetActiveCategory(const std::string& category); - std::string GetActiveCategory() const { return active_category_; } - bool IsCategoryActive(const std::string& category) const { return active_category_ == category; } - - // Compact inline card control for menu bar - void DrawCompactCardControl(const std::string& category); // Shows only active editor's cards - void DrawCompactCardControlWithSession(const std::string& category, const std::string& session_prefix = ""); - void DrawInlineCardToggles(const std::string& category); // Minimal inline checkboxes - - // Card browser UI - void DrawCardBrowser(bool* p_open); // Visual card browser/toggler - void DrawCardBrowserTable(const char* search_filter, const std::string& category_filter); - void DrawPresetsTab(); - - // Workspace presets - struct WorkspacePreset { - std::string name; - std::vector visible_cards; // Card IDs - std::string description; - }; - - void SavePreset(const std::string& name, const std::string& description = ""); - bool LoadPreset(const std::string& name); - void DeletePreset(const std::string& name); - std::vector GetPresets() const; - - // Quick actions - void ShowAll(); // Show all registered cards - void HideAll(); // Hide all registered cards - void ResetToDefaults(); // Reset to default visibility state - - // Statistics - size_t GetCardCount() const { return cards_.size(); } - size_t GetVisibleCardCount() const; - - private: - EditorCardManager() = default; - ~EditorCardManager() = default; - EditorCardManager(const EditorCardManager&) = delete; - EditorCardManager& operator=(const EditorCardManager&) = delete; - - std::unordered_map cards_; - std::unordered_map centralized_visibility_; // Centralized card visibility flags - std::unordered_map presets_; - std::string active_category_; // Currently active editor category (based on last card interaction) - std::vector recent_categories_; // Stack of recently used categories (max 5) - static constexpr size_t kMaxRecentCategories = 5; - - // Helper methods - void SavePresetsToFile(); - void LoadPresetsFromFile(); -}; - -/** - * @brief RAII helper for auto-registering cards - * - * Usage: - * ```cpp - * class MyEditor { - * CardRegistration room_selector_reg_; - * - * MyEditor() { - * room_selector_reg_ = RegisterCard({ - * .card_id = "myeditor.room_selector", - * .display_name = "Room Selector", - * .visibility_flag = &show_room_selector_ - * }); - * } - * }; - * ``` - */ -class CardRegistration { - public: - CardRegistration() = default; - explicit CardRegistration(const std::string& card_id) : card_id_(card_id) {} - - ~CardRegistration() { - if (!card_id_.empty()) { - EditorCardManager::Get().UnregisterCard(card_id_); - } - } - - // No copy, allow move - CardRegistration(const CardRegistration&) = delete; - CardRegistration& operator=(const CardRegistration&) = delete; - CardRegistration(CardRegistration&& other) noexcept : card_id_(std::move(other.card_id_)) { - other.card_id_.clear(); - } - CardRegistration& operator=(CardRegistration&& other) noexcept { - if (this != &other) { - card_id_ = std::move(other.card_id_); - other.card_id_.clear(); - } - return *this; - } - - private: - std::string card_id_; -}; - -// Convenience function for registration -inline CardRegistration RegisterCard(const CardInfo& info) { - EditorCardManager::Get().RegisterCard(info); - return CardRegistration(info.card_id); -} - -} // namespace gui -} // namespace yaze - -#endif // YAZE_APP_GUI_EDITOR_CARD_MANAGER_H - diff --git a/src/app/gui/gui_library.cmake b/src/app/gui/gui_library.cmake index 3ed04c7e..1cc82a1c 100644 --- a/src/app/gui/gui_library.cmake +++ b/src/app/gui/gui_library.cmake @@ -58,7 +58,6 @@ set(GUI_AUTOMATION_SRC set(GUI_APP_SRC app/gui/app/agent_chat_widget.cc app/gui/app/collaboration_panel.cc - app/gui/app/editor_card_manager.cc app/gui/app/editor_layout.cc )