feat(editor): enhance card management

- Implemented initialization for music-related editor cards, including Music Tracker and Instrument Editor, with appropriate registration and default visibility settings.
- Updated MusicEditor to manage card visibility dynamically and added methods for drawing specific editor views.
- Improved EditorCardManager to handle recent category tracking, enhancing user navigation through editor categories.

Benefits:
- Streamlines access to music editing tools, improving user experience and workflow efficiency within the editor environment.
This commit is contained in:
scawful
2025-10-12 21:12:20 -04:00
parent a2e219c33b
commit 19cc46614a
7 changed files with 103 additions and 37 deletions

View File

@@ -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()) {

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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"

View File

@@ -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();

View File

@@ -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));

View File

@@ -165,6 +165,8 @@ class EditorCardManager {
std::unordered_map<std::string, bool> centralized_visibility_; // Centralized card visibility flags
std::unordered_map<std::string, WorkspacePreset> presets_;
std::string active_category_; // Currently active editor category (based on last card interaction)
std::vector<std::string> recent_categories_; // Stack of recently used categories (max 5)
static constexpr size_t kMaxRecentCategories = 5;
// Helper methods
void SavePresetsToFile();