diff --git a/src/app/editor/agent/agent_chat_history_popup.cc b/src/app/editor/agent/agent_chat_history_popup.cc index 85353c06..5212b6a2 100644 --- a/src/app/editor/agent/agent_chat_history_popup.cc +++ b/src/app/editor/agent/agent_chat_history_popup.cc @@ -258,13 +258,14 @@ void AgentChatHistoryPopup::DrawHeader() { ImGui::SameLine(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 75.0f); // Compact mode toggle with pulse - if (blink_counter_ == 0 && compact_mode_) { + bool should_highlight = (blink_counter_ == 0 && compact_mode_); + if (should_highlight) { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.4f, 0.6f, 0.7f)); } if (ImGui::SmallButton(compact_mode_ ? ICON_MD_UNFOLD_MORE : ICON_MD_UNFOLD_LESS)) { compact_mode_ = !compact_mode_; } - if (blink_counter_ == 0 && compact_mode_) { + if (should_highlight) { ImGui::PopStyleColor(); } if (ImGui::IsItemHovered()) { diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index 34b3df82..86d02b47 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -105,8 +105,9 @@ bool EditorManager::IsCardBasedEditor(EditorType type) { case EditorType::kMessage: // ✅ Message editor cards case EditorType::kHex: // ✅ Memory/Hex editor case EditorType::kAssembly: // ✅ Assembly editor + case EditorType::kMusic: // ✅ Music tracker + instrument editor return true; - // Music: Traditional UI - needs wrapper + // Settings, Agent: Traditional UI - needs wrapper default: return false; } diff --git a/src/app/editor/music/music_editor.cc b/src/app/editor/music/music_editor.cc index 6036ca59..ef5bab86 100644 --- a/src/app/editor/music/music_editor.cc +++ b/src/app/editor/music/music_editor.cc @@ -12,7 +12,22 @@ namespace yaze { namespace editor { -void MusicEditor::Initialize() {} +void MusicEditor::Initialize() { + auto& card_manager = gui::EditorCardManager::Get(); + + card_manager.RegisterCard({.card_id = "music.tracker", .display_name = "Music Tracker", + .icon = ICON_MD_MUSIC_NOTE, .category = "Music", + .shortcut_hint = "Ctrl+Shift+M", .priority = 10}); + card_manager.RegisterCard({.card_id = "music.instrument_editor", .display_name = "Instrument Editor", + .icon = ICON_MD_PIANO, .category = "Music", + .shortcut_hint = "Ctrl+Shift+I", .priority = 20}); + card_manager.RegisterCard({.card_id = "music.assembly", .display_name = "Assembly View", + .icon = ICON_MD_CODE, .category = "Music", + .shortcut_hint = "Ctrl+Shift+A", .priority = 30}); + + // Show tracker by default + card_manager.ShowCard("music.tracker"); +} absl::Status MusicEditor::Load() { gfx::ScopedTimer timer("MusicEditor::Load"); @@ -20,22 +35,32 @@ absl::Status MusicEditor::Load() { } absl::Status MusicEditor::Update() { - if (ImGui::BeginTable("MusicEditorColumns", 2, music_editor_flags_, - ImVec2(0, 0))) { - ImGui::TableSetupColumn("Assembly"); - ImGui::TableSetupColumn("Composition"); - ImGui::TableHeadersRow(); - ImGui::TableNextRow(); - - ImGui::TableNextColumn(); + auto& card_manager = gui::EditorCardManager::Get(); + + static gui::EditorCard tracker_card("Music Tracker", ICON_MD_MUSIC_NOTE); + static gui::EditorCard instrument_card("Instrument Editor", ICON_MD_PIANO); + static gui::EditorCard assembly_card("Assembly View", ICON_MD_CODE); + + tracker_card.SetDefaultSize(900, 700); + instrument_card.SetDefaultSize(600, 500); + assembly_card.SetDefaultSize(700, 600); + + // Music Tracker Card + if (tracker_card.Begin(card_manager.GetVisibilityFlag("music.tracker"))) { + DrawTrackerView(); + tracker_card.End(); + } + + // Instrument Editor Card + if (instrument_card.Begin(card_manager.GetVisibilityFlag("music.instrument_editor"))) { + DrawInstrumentEditor(); + instrument_card.End(); + } + + // Assembly View Card + if (assembly_card.Begin(card_manager.GetVisibilityFlag("music.assembly"))) { assembly_editor_.InlineUpdate(); - - ImGui::TableNextColumn(); - DrawToolset(); - // TODO: Add music channel view - ImGui::Text("Music channels coming soon..."); - - ImGui::EndTable(); + assembly_card.End(); } return absl::OkStatus(); @@ -146,6 +171,21 @@ static void DrawPianoRoll() { ImGui::PopStyleVar(); } +void MusicEditor::DrawTrackerView() { + DrawToolset(); + DrawPianoRoll(); + DrawPianoStaff(); + // TODO: Add music channel view + ImGui::Text("Music channels coming soon..."); +} + +void MusicEditor::DrawInstrumentEditor() { + ImGui::Text("Instrument Editor"); + ImGui::Separator(); + // TODO: Implement instrument editor UI + ImGui::Text("Coming soon..."); +} + void MusicEditor::DrawToolset() { static bool is_playing = false; static int selected_option = 0; diff --git a/src/app/editor/music/music_editor.h b/src/app/editor/music/music_editor.h index bf6cb129..248f15ec 100644 --- a/src/app/editor/music/music_editor.h +++ b/src/app/editor/music/music_editor.h @@ -4,6 +4,8 @@ #include "app/editor/code/assembly_editor.h" #include "app/editor/editor.h" #include "app/emu/audio/apu.h" +#include "app/gui/editor_card_manager.h" +#include "app/gui/editor_layout.h" #include "app/rom.h" #include "app/zelda3/music/tracker.h" #include "imgui/imgui.h" diff --git a/src/app/editor/palette/palette_group_card.cc b/src/app/editor/palette/palette_group_card.cc index adfc11a7..3abecb09 100644 --- a/src/app/editor/palette/palette_group_card.cc +++ b/src/app/editor/palette/palette_group_card.cc @@ -1095,29 +1095,12 @@ void SpritesAux1PaletteCard::DrawPaletteGrid() { ImGui::PushID(i); - // Draw transparent color indicator for index 0 - if (i == 0) { - ImGui::BeginGroup(); if (yaze::gui::PaletteColorButton(absl::StrFormat("##color%d", i).c_str(), (*palette)[i], is_selected, is_modified, ImVec2(button_size, button_size))) { selected_color_ = i; editing_color_ = (*palette)[i]; } - // Draw "T" for transparent - ImVec2 pos = ImGui::GetItemRectMin(); - ImGui::GetWindowDrawList()->AddText( - ImVec2(pos.x + button_size / 2 - 4, pos.y + button_size / 2 - 8), - IM_COL32(255, 255, 255, 200), "T"); - ImGui::EndGroup(); - } else { - if (yaze::gui::PaletteColorButton(absl::StrFormat("##color%d", i).c_str(), - (*palette)[i], is_selected, is_modified, - ImVec2(button_size, button_size))) { - selected_color_ = i; - editing_color_ = (*palette)[i]; - } - } ImGui::PopID(); diff --git a/src/app/gui/editor_card_manager.cc b/src/app/gui/editor_card_manager.cc index 91b7de17..55702cc4 100644 --- a/src/app/gui/editor_card_manager.cc +++ b/src/app/gui/editor_card_manager.cc @@ -727,7 +727,19 @@ void EditorCardManager::LoadPresetsFromFile() { } 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, @@ -890,12 +902,37 @@ void EditorCardManager::DrawSidebar(const std::string& category, } } // End if (!cards.empty()) - // Collapse sidebar button at bottom + // 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)); diff --git a/src/app/gui/editor_card_manager.h b/src/app/gui/editor_card_manager.h index 7d20862b..89e33c33 100644 --- a/src/app/gui/editor_card_manager.h +++ b/src/app/gui/editor_card_manager.h @@ -165,6 +165,8 @@ class EditorCardManager { 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();