UI component for displaying and editing music tracks as a piano roll. More...
#include <piano_roll_view.h>

Classes | |
| struct | ContextTarget |
| struct | EmptyContextTarget |
Public Member Functions | |
| PianoRollView ()=default | |
| ~PianoRollView ()=default | |
| void | Draw (zelda3::music::MusicSong *song, const zelda3::music::MusicBank *bank=nullptr) |
| Draw the piano roll view for the given song. | |
| void | SetOnEditCallback (std::function< void()> callback) |
| Set callback for when edits occur. | |
| void | SetOnNotePreview (std::function< void(const zelda3::music::TrackEvent &, int, int)> callback) |
| Set callback for note preview. | |
| void | SetOnSegmentPreview (std::function< void(const zelda3::music::MusicSong &, int)> callback) |
| Set callback for segment preview. | |
| int | GetActiveChannel () const |
| void | SetActiveChannel (int channel) |
| int | GetActiveSegment () const |
| void | SetActiveSegment (int segment) |
| int | GetPreviewInstrument () const |
| void | SetPlaybackState (bool is_playing, bool is_paused, uint32_t current_tick) |
| void | SetFollowPlayback (bool follow) |
| bool | IsFollowingPlayback () const |
| bool | IsPlaying () const |
| bool | IsPaused () const |
Private Member Functions | |
| void | DrawToolbar (const zelda3::music::MusicSong *song, const zelda3::music::MusicBank *bank) |
| void | DrawChannelList (const zelda3::music::MusicSong *song) |
| void | DrawStatusBar (const zelda3::music::MusicSong *song) |
| void | DrawRollCanvas (zelda3::music::MusicSong *song, const RollPalette &palette, const ImVec2 &canvas_size) |
| void | DrawPianoKeys (ImDrawList *draw_list, const ImVec2 &key_origin, float total_height, int start_key_idx, int visible_keys, const RollPalette &palette) |
| void | DrawGrid (ImDrawList *draw_list, const ImVec2 &grid_origin, const ImVec2 &canvas_pos, const ImVec2 &canvas_size, float total_height, float clip_bottom, int start_tick, int visible_ticks, int start_key_idx, int visible_keys, float content_width, const RollPalette &palette) |
| void | DrawNotes (ImDrawList *draw_list, const zelda3::music::MusicSong *song, const ImVec2 &grid_origin, float total_height, int start_tick, int end_tick, int start_key_idx, int visible_keys, const RollPalette &palette) |
| void | DrawPlaybackCursor (ImDrawList *draw_list, const ImVec2 &grid_origin, float grid_height, uint32_t segment_start_tick) |
| void | HandleMouseInput (zelda3::music::MusicSong *song, int active_channel, int active_segment, const ImVec2 &grid_origin, const ImVec2 &grid_size, bool is_hovered) |
Static Private Attributes | |
| static constexpr float | kToolbarHeight = 32.0f |
| static constexpr float | kStatusBarHeight = 24.0f |
| static constexpr float | kChannelListWidth = 140.0f |
UI component for displaying and editing music tracks as a piano roll.
Definition at line 32 of file piano_roll_view.h.
|
default |
|
default |
| void yaze::editor::music::PianoRollView::Draw | ( | zelda3::music::MusicSong * | song, |
| const zelda3::music::MusicBank * | bank = nullptr ) |
Draw the piano roll view for the given song.
| song | The song to display and edit. |
| bank | The music bank for instrument names (optional). |
Definition at line 83 of file piano_roll_view.cc.
References active_channel_index_, active_segment_index_, yaze::editor::music::PianoRollView::ContextTarget::channel, yaze::editor::music::PianoRollView::EmptyContextTarget::channel, channel_colors_, context_target_, DrawChannelList(), DrawRollCanvas(), DrawStatusBar(), DrawToolbar(), empty_context_, yaze::editor::music::PianoRollView::ContextTarget::event_index, hovered_channel_index_, hovered_event_index_, hovered_segment_index_, ICON_MD_ADD, ICON_MD_CONTENT_COPY, ICON_MD_DELETE, ICON_MD_MUSIC_NOTE, kChannelListWidth, yaze::zelda3::music::kDurationEighth, yaze::zelda3::music::kDurationQuarter, yaze::zelda3::music::kDurationSixteenth, yaze::zelda3::music::kDurationThirtySecond, key_height_, kStatusBarHeight, kToolbarHeight, yaze::zelda3::music::TrackEvent::MakeNote(), on_edit_, on_note_preview_, yaze::editor::music::PianoRollView::EmptyContextTarget::pitch, yaze::editor::music::PianoRollView::ContextTarget::segment, yaze::editor::music::PianoRollView::EmptyContextTarget::segment, yaze::zelda3::music::MusicSong::segments, yaze::editor::music::PianoRollView::EmptyContextTarget::tick, and yaze::zelda3::music::TrackEvent::tick.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Set callback for when edits occur.
Definition at line 47 of file piano_roll_view.h.
References on_edit_.
Referenced by yaze::editor::MusicEditor::DrawPianoRollView(), and yaze::editor::MusicPianoRollPanel::SetOnEditCallback().
|
inline |
Set callback for note preview.
Definition at line 52 of file piano_roll_view.h.
References on_note_preview_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Set callback for segment preview.
Definition at line 60 of file piano_roll_view.h.
References on_segment_preview_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 65 of file piano_roll_view.h.
References active_channel_index_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 66 of file piano_roll_view.h.
References active_channel_index_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 68 of file piano_roll_view.h.
References active_segment_index_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 69 of file piano_roll_view.h.
References active_segment_index_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 72 of file piano_roll_view.h.
References preview_instrument_index_.
|
inline |
Definition at line 75 of file piano_roll_view.h.
References is_paused_, is_playing_, and playback_tick_.
Referenced by yaze::editor::MusicPianoRollPanel::Draw(), and yaze::editor::MusicEditor::DrawPianoRollView().
|
inline |
Definition at line 81 of file piano_roll_view.h.
References follow_playback_.
|
inline |
Definition at line 82 of file piano_roll_view.h.
References follow_playback_.
|
inline |
Definition at line 83 of file piano_roll_view.h.
References is_playing_.
|
inline |
Definition at line 84 of file piano_roll_view.h.
References is_paused_.
|
private |
Definition at line 560 of file piano_roll_view.cc.
References active_channel_index_, active_segment_index_, yaze::zelda3::music::MusicBank::GetInstrument(), yaze::zelda3::music::MusicBank::GetInstrumentCount(), ICON_MD_GRID_ON, ICON_MD_MUSIC_NOTE, ICON_MD_PIANO, ICON_MD_PLAY_ARROW, ICON_MD_ZOOM_IN, yaze::zelda3::music::kDurationEighth, yaze::zelda3::music::kDurationQuarter, yaze::zelda3::music::kDurationSixteenth, key_height_, yaze::zelda3::music::MusicSong::name, on_segment_preview_, pixels_per_tick_, preview_instrument_index_, yaze::zelda3::music::MusicSong::segments, yaze::gui::SliderFloatWheel(), snap_enabled_, and snap_ticks_.
Referenced by Draw().

|
private |
Definition at line 690 of file piano_roll_view.cc.
References active_channel_index_, active_segment_index_, channel_colors_, channel_muted_, channel_solo_, channel_visible_, yaze::gui::ConvertColorToImVec4(), yaze::gui::ThemeManager::Get(), yaze::gui::ThemeManager::GetCurrentTheme(), ICON_MD_HEARING, ICON_MD_PIANO, ICON_MD_VOLUME_OFF, ICON_MD_VOLUME_UP, and yaze::zelda3::music::MusicSong::segments.
Referenced by Draw().

|
private |
Definition at line 784 of file piano_roll_view.cc.
References ICON_MD_MOUSE, kStatusBarHeight, status_note_name_, status_pitch_, and status_tick_.
Referenced by Draw().
|
private |
Definition at line 310 of file piano_roll_view.cc.
References active_channel_index_, active_segment_index_, yaze::editor::music::RollPalette::background, DrawGrid(), DrawNotes(), DrawPianoKeys(), DrawPlaybackCursor(), follow_playback_, HandleMouseInput(), is_paused_, is_playing_, key_height_, key_width_, yaze::zelda3::music::kNoteMaxPitch, yaze::zelda3::music::kNoteMinPitch, pixels_per_tick_, playback_tick_, scroll_x_px_, scroll_y_px_, and yaze::zelda3::music::MusicSong::segments.
Referenced by Draw().
|
private |
Definition at line 950 of file piano_roll_view.cc.
References yaze::editor::music::RollPalette::background, yaze::editor::music::RollPalette::black_key, yaze::zelda3::music::Note::GetNoteName(), yaze::editor::music::RollPalette::grid_minor, key_height_, yaze::editor::music::RollPalette::key_label, key_width_, yaze::zelda3::music::kNoteMaxPitch, yaze::zelda3::music::kNoteMinPitch, yaze::zelda3::music::Note::pitch, and yaze::editor::music::RollPalette::white_key.
Referenced by DrawRollCanvas().

|
private |
Definition at line 979 of file piano_roll_view.cc.
References yaze::editor::music::RollPalette::beat_marker, yaze::editor::music::RollPalette::grid_major, yaze::editor::music::RollPalette::grid_minor, key_height_, yaze::editor::music::RollPalette::key_label, key_width_, yaze::zelda3::music::kNoteMaxPitch, yaze::zelda3::music::kNoteMinPitch, yaze::editor::music::RollPalette::octave_line, and pixels_per_tick_.
Referenced by DrawRollCanvas().
|
private |
Definition at line 1031 of file piano_roll_view.cc.
References active_channel_index_, active_segment_index_, channel_colors_, channel_muted_, channel_solo_, channel_visible_, yaze::editor::music::RollPalette::grid_major, hovered_channel_index_, hovered_event_index_, hovered_segment_index_, key_height_, yaze::zelda3::music::kNoteMinPitch, yaze::editor::music::RollPalette::note_hover, yaze::editor::music::RollPalette::note_shadow, pixels_per_tick_, and yaze::zelda3::music::MusicSong::segments.
Referenced by DrawRollCanvas().
|
private |
Definition at line 1152 of file piano_roll_view.cc.
References is_paused_, pixels_per_tick_, and playback_tick_.
Referenced by DrawRollCanvas().
|
private |
Definition at line 807 of file piano_roll_view.cc.
References drag_channel_index_, drag_mode_, drag_moved_, drag_original_event_, drag_segment_index_, drag_start_mouse_, dragging_event_index_, yaze::zelda3::music::Note::duration, yaze::zelda3::music::Note::GetNoteName(), hovered_channel_index_, hovered_event_index_, hovered_segment_index_, yaze::zelda3::music::kDurationQuarter, key_height_, yaze::zelda3::music::kNoteMaxPitch, yaze::zelda3::music::kNoteMinPitch, yaze::zelda3::music::TrackEvent::MakeNote(), yaze::zelda3::music::TrackEvent::note, on_edit_, on_note_preview_, yaze::zelda3::music::Note::pitch, pixels_per_tick_, yaze::zelda3::music::MusicSong::segments, snap_enabled_, snap_ticks_, status_note_name_, status_pitch_, status_tick_, and yaze::zelda3::music::TrackEvent::tick.
Referenced by DrawRollCanvas().

|
staticconstexprprivate |
Definition at line 113 of file piano_roll_view.h.
Referenced by Draw().
|
staticconstexprprivate |
Definition at line 114 of file piano_roll_view.h.
Referenced by Draw(), and DrawStatusBar().
|
staticconstexprprivate |
Definition at line 115 of file piano_roll_view.h.
Referenced by Draw().
|
private |
Definition at line 118 of file piano_roll_view.h.
Referenced by Draw(), DrawChannelList(), DrawNotes(), DrawRollCanvas(), DrawToolbar(), GetActiveChannel(), and SetActiveChannel().
|
private |
Definition at line 119 of file piano_roll_view.h.
Referenced by Draw(), DrawChannelList(), DrawNotes(), DrawRollCanvas(), DrawToolbar(), GetActiveSegment(), and SetActiveSegment().
|
private |
Definition at line 120 of file piano_roll_view.h.
Referenced by DrawToolbar(), and GetPreviewInstrument().
|
private |
Definition at line 121 of file piano_roll_view.h.
Referenced by DrawGrid(), DrawNotes(), DrawPlaybackCursor(), DrawRollCanvas(), DrawToolbar(), and HandleMouseInput().
|
private |
Definition at line 122 of file piano_roll_view.h.
Referenced by Draw(), DrawGrid(), DrawNotes(), DrawPianoKeys(), DrawRollCanvas(), DrawToolbar(), and HandleMouseInput().
|
private |
Definition at line 123 of file piano_roll_view.h.
Referenced by DrawGrid(), DrawPianoKeys(), and DrawRollCanvas().
|
private |
Definition at line 124 of file piano_roll_view.h.
Referenced by DrawRollCanvas().
|
private |
Definition at line 125 of file piano_roll_view.h.
Referenced by DrawRollCanvas().
|
private |
Definition at line 126 of file piano_roll_view.h.
Referenced by DrawToolbar(), and HandleMouseInput().
|
private |
Definition at line 127 of file piano_roll_view.h.
Referenced by DrawToolbar(), and HandleMouseInput().
|
private |
Definition at line 128 of file piano_roll_view.h.
Referenced by DrawRollCanvas(), IsFollowingPlayback(), and SetFollowPlayback().
|
private |
Definition at line 131 of file piano_roll_view.h.
Referenced by DrawChannelList(), and DrawNotes().
|
private |
Definition at line 132 of file piano_roll_view.h.
Referenced by DrawChannelList(), and DrawNotes().
|
private |
Definition at line 133 of file piano_roll_view.h.
Referenced by DrawChannelList(), and DrawNotes().
|
private |
Definition at line 134 of file piano_roll_view.h.
Referenced by Draw(), DrawChannelList(), and DrawNotes().
|
private |
Definition at line 137 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 138 of file piano_roll_view.h.
|
private |
Definition at line 139 of file piano_roll_view.h.
|
private |
Definition at line 140 of file piano_roll_view.h.
|
private |
Definition at line 141 of file piano_roll_view.h.
Referenced by Draw(), DrawNotes(), and HandleMouseInput().
|
private |
Definition at line 142 of file piano_roll_view.h.
Referenced by Draw(), DrawNotes(), and HandleMouseInput().
|
private |
Definition at line 143 of file piano_roll_view.h.
Referenced by Draw(), DrawNotes(), and HandleMouseInput().
|
private |
Definition at line 146 of file piano_roll_view.h.
Referenced by DrawStatusBar(), and HandleMouseInput().
|
private |
Definition at line 147 of file piano_roll_view.h.
Referenced by DrawStatusBar(), and HandleMouseInput().
|
private |
Definition at line 148 of file piano_roll_view.h.
Referenced by DrawStatusBar(), and HandleMouseInput().
|
private |
Definition at line 151 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 152 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 153 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 154 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 155 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Definition at line 156 of file piano_roll_view.h.
Referenced by HandleMouseInput().
|
private |
Referenced by Draw().
|
private |
Referenced by Draw().
|
private |
Definition at line 173 of file piano_roll_view.h.
Referenced by Draw(), HandleMouseInput(), and SetOnEditCallback().
|
private |
Definition at line 175 of file piano_roll_view.h.
Referenced by Draw(), HandleMouseInput(), and SetOnNotePreview().
|
private |
Definition at line 176 of file piano_roll_view.h.
Referenced by DrawToolbar(), and SetOnSegmentPreview().
|
private |
Definition at line 179 of file piano_roll_view.h.
Referenced by DrawRollCanvas(), IsPlaying(), and SetPlaybackState().
|
private |
Definition at line 180 of file piano_roll_view.h.
Referenced by DrawPlaybackCursor(), DrawRollCanvas(), IsPaused(), and SetPlaybackState().
|
private |
Definition at line 181 of file piano_roll_view.h.
Referenced by DrawPlaybackCursor(), DrawRollCanvas(), and SetPlaybackState().