yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
music_piano_roll_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
2#define YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
3
4#include <functional>
5#include <string>
6#include "util/i18n/tr.h"
7
11#include "app/gui/core/icons.h"
13
14namespace yaze {
15namespace editor {
16
24 public:
26 int* current_song_index, int* current_segment_index,
27 int* current_channel_index,
28 music::PianoRollView* piano_roll_view,
29 music::MusicPlayer* music_player)
30 : music_bank_(music_bank),
31 current_song_index_(current_song_index),
32 current_segment_index_(current_segment_index),
33 current_channel_index_(current_channel_index),
34 piano_roll_view_(piano_roll_view),
35 music_player_(music_player) {}
36
37 // ==========================================================================
38 // WindowContent Identity
39 // ==========================================================================
40
41 std::string GetId() const override { return "music.piano_roll"; }
42 std::string GetDisplayName() const override { return "Piano Roll"; }
43 std::string GetIcon() const override { return ICON_MD_PIANO; }
44 std::string GetEditorCategory() const override { return "Music"; }
48 int GetPriority() const override { return 15; }
49
50 // ==========================================================================
51 // Callback Setters
52 // ==========================================================================
53
54 void SetOnEditCallback(std::function<void()> callback) {
55 on_edit_ = callback;
58 }
59
60 // ==========================================================================
61 // WindowContent Drawing
62 // ==========================================================================
63
64 void Draw(bool* p_open) override {
66 ImGui::TextDisabled(tr("Music bank not loaded"));
67 return;
68 }
69
71 if (song &&
72 *current_segment_index_ >= static_cast<int>(song->segments.size())) {
74 }
75
78
79 // Set up note preview callback
81 [this, song_index = *current_song_index_](
82 const zelda3::music::TrackEvent& evt, int segment_idx,
83 int channel_idx) {
84 auto* target = music_bank_->GetSong(song_index);
85 if (!target || !music_player_)
86 return;
87 music_player_->PreviewNote(*target, evt, segment_idx, channel_idx);
88 });
89
91 [this, song_index = *current_song_index_](
92 const zelda3::music::MusicSong& /*unused*/, int segment_idx) {
93 auto* target = music_bank_->GetSong(song_index);
94 if (!target || !music_player_)
95 return;
96 music_player_->PreviewSegment(*target, segment_idx);
97 });
98
99 // Update playback state for cursor visualization
100 auto state =
102 piano_roll_view_->SetPlaybackState(state.is_playing, state.is_paused,
103 state.current_tick);
104
106
107 // Update indices from view state
110 }
111
112 private:
114 int* current_song_index_ = nullptr;
119 std::function<void()> on_edit_;
120};
121
122} // namespace editor
123} // namespace yaze
124
125#endif // YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
WindowContent wrapper for the piano roll view.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
int GetPriority() const override
Get display priority for menu ordering.
MusicPianoRollPanel(zelda3::music::MusicBank *music_bank, int *current_song_index, int *current_segment_index, int *current_channel_index, music::PianoRollView *piano_roll_view, music::MusicPlayer *music_player)
std::string GetIcon() const override
Material Design icon for this panel.
WindowPresentationPolicy GetPresentationPolicy() const override
How this content is hosted and advertised by workspace chrome.
void SetOnEditCallback(std::function< void()> callback)
void Draw(bool *p_open) override
Draw the panel content.
std::string GetId() const override
Unique identifier for this panel.
Base interface for all logical window content components.
Handles audio playback for the music editor using the SNES APU emulator.
void PreviewSegment(const zelda3::music::MusicSong &song, int segment_index)
Preview a specific segment of a song.
void PreviewNote(const zelda3::music::MusicSong &song, const zelda3::music::TrackEvent &event, int segment_index, int channel_index)
Preview a single note with the current instrument.
PlaybackState GetState() const
UI component for displaying and editing music tracks as a piano roll.
void SetPlaybackState(bool is_playing, bool is_paused, uint32_t current_tick)
void Draw(zelda3::music::MusicSong *song, const zelda3::music::MusicBank *bank=nullptr)
Draw the piano roll view for the given song.
void SetOnNotePreview(std::function< void(const zelda3::music::TrackEvent &, int, int)> callback)
Set callback for note preview.
void SetOnEditCallback(std::function< void()> callback)
Set callback for when edits occur.
void SetOnSegmentPreview(std::function< void(const zelda3::music::MusicSong &, int)> callback)
Set callback for segment preview.
Manages the collection of songs, instruments, and samples from a ROM.
Definition music_bank.h:27
MusicSong * GetSong(int index)
Get a song by index.
#define ICON_MD_PIANO
Definition icons.h:1462
static WindowPresentationPolicy CoreWorkspace()
Represents the current playback state of the music player.
A complete song composed of segments.
Definition song_data.h:334
A single event in a music track (note, command, or control).
Definition song_data.h:247