yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::music::PianoRollView Class Reference

UI component for displaying and editing music tracks as a piano roll. More...

#include <piano_roll_view.h>

Collaboration diagram for yaze::editor::music::PianoRollView:

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)
 

Private Attributes

int active_channel_index_ = 0
 
int active_segment_index_ = 0
 
int preview_instrument_index_ = 0
 
float pixels_per_tick_ = 2.0f
 
float key_height_ = 12.0f
 
float key_width_ = 40.0f
 
float scroll_x_px_ = 0.0f
 
float scroll_y_px_ = 0.0f
 
bool snap_enabled_ = true
 
int snap_ticks_ = zelda3::music::kDurationSixteenth
 
bool follow_playback_ = false
 
std::vector< bool > channel_visible_ = std::vector<bool>(8, true)
 
std::vector< bool > channel_muted_ = std::vector<bool>(8, false)
 
std::vector< bool > channel_solo_ = std::vector<bool>(8, false)
 
std::vector< ImU32 > channel_colors_
 
int drag_mode_ = 0
 
int drag_start_tick_ = 0
 
int drag_start_duration_ = 0
 
int drag_event_index_ = -1
 
int hovered_event_index_ = -1
 
int hovered_channel_index_ = -1
 
int hovered_segment_index_ = -1
 
int status_tick_ = -1
 
int status_pitch_ = -1
 
std::string status_note_name_
 
int dragging_event_index_ = -1
 
int drag_segment_index_ = -1
 
int drag_channel_index_ = -1
 
bool drag_moved_ = false
 
zelda3::music::TrackEvent drag_original_event_
 
ImVec2 drag_start_mouse_
 
struct yaze::editor::music::PianoRollView::ContextTarget context_target_
 
struct yaze::editor::music::PianoRollView::EmptyContextTarget empty_context_
 
std::function< void()> on_edit_
 
std::function< void(const zelda3::music::TrackEvent &, int segment_index, int channel_index) on_note_preview_ )
 
std::function< void(const zelda3::music::MusicSong &, int segment_index) on_segment_preview_ )
 
bool is_playing_ = false
 
bool is_paused_ = false
 
uint32_t playback_tick_ = 0
 

Static Private Attributes

static constexpr float kToolbarHeight = 32.0f
 
static constexpr float kStatusBarHeight = 24.0f
 
static constexpr float kChannelListWidth = 140.0f
 

Detailed Description

UI component for displaying and editing music tracks as a piano roll.

Definition at line 32 of file piano_roll_view.h.

Constructor & Destructor Documentation

◆ PianoRollView()

yaze::editor::music::PianoRollView::PianoRollView ( )
default

◆ ~PianoRollView()

yaze::editor::music::PianoRollView::~PianoRollView ( )
default

Member Function Documentation

◆ Draw()

void yaze::editor::music::PianoRollView::Draw ( zelda3::music::MusicSong * song,
const zelda3::music::MusicBank * bank = nullptr )

◆ SetOnEditCallback()

void yaze::editor::music::PianoRollView::SetOnEditCallback ( std::function< void()> callback)
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().

◆ SetOnNotePreview()

void yaze::editor::music::PianoRollView::SetOnNotePreview ( std::function< void(const zelda3::music::TrackEvent &, int, int)> callback)
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().

◆ SetOnSegmentPreview()

void yaze::editor::music::PianoRollView::SetOnSegmentPreview ( std::function< void(const zelda3::music::MusicSong &, int)> callback)
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().

◆ GetActiveChannel()

int yaze::editor::music::PianoRollView::GetActiveChannel ( ) const
inline

◆ SetActiveChannel()

void yaze::editor::music::PianoRollView::SetActiveChannel ( int channel)
inline

◆ GetActiveSegment()

int yaze::editor::music::PianoRollView::GetActiveSegment ( ) const
inline

◆ SetActiveSegment()

void yaze::editor::music::PianoRollView::SetActiveSegment ( int segment)
inline

◆ GetPreviewInstrument()

int yaze::editor::music::PianoRollView::GetPreviewInstrument ( ) const
inline

Definition at line 72 of file piano_roll_view.h.

References preview_instrument_index_.

◆ SetPlaybackState()

void yaze::editor::music::PianoRollView::SetPlaybackState ( bool is_playing,
bool is_paused,
uint32_t current_tick )
inline

◆ SetFollowPlayback()

void yaze::editor::music::PianoRollView::SetFollowPlayback ( bool follow)
inline

Definition at line 81 of file piano_roll_view.h.

References follow_playback_.

◆ IsFollowingPlayback()

bool yaze::editor::music::PianoRollView::IsFollowingPlayback ( ) const
inline

Definition at line 82 of file piano_roll_view.h.

References follow_playback_.

◆ IsPlaying()

bool yaze::editor::music::PianoRollView::IsPlaying ( ) const
inline

Definition at line 83 of file piano_roll_view.h.

References is_playing_.

◆ IsPaused()

bool yaze::editor::music::PianoRollView::IsPaused ( ) const
inline

Definition at line 84 of file piano_roll_view.h.

References is_paused_.

◆ DrawToolbar()

◆ DrawChannelList()

◆ DrawStatusBar()

void yaze::editor::music::PianoRollView::DrawStatusBar ( const zelda3::music::MusicSong * song)
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().

◆ DrawRollCanvas()

◆ DrawPianoKeys()

void yaze::editor::music::PianoRollView::DrawPianoKeys ( ImDrawList * draw_list,
const ImVec2 & key_origin,
float total_height,
int start_key_idx,
int visible_keys,
const RollPalette & palette )
private

◆ DrawGrid()

void yaze::editor::music::PianoRollView::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 )
private

◆ DrawNotes()

void yaze::editor::music::PianoRollView::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 )
private

◆ DrawPlaybackCursor()

void yaze::editor::music::PianoRollView::DrawPlaybackCursor ( ImDrawList * draw_list,
const ImVec2 & grid_origin,
float grid_height,
uint32_t segment_start_tick )
private

Definition at line 1152 of file piano_roll_view.cc.

References is_paused_, pixels_per_tick_, and playback_tick_.

Referenced by DrawRollCanvas().

◆ HandleMouseInput()

Member Data Documentation

◆ kToolbarHeight

constexpr float yaze::editor::music::PianoRollView::kToolbarHeight = 32.0f
staticconstexprprivate

Definition at line 113 of file piano_roll_view.h.

Referenced by Draw().

◆ kStatusBarHeight

constexpr float yaze::editor::music::PianoRollView::kStatusBarHeight = 24.0f
staticconstexprprivate

Definition at line 114 of file piano_roll_view.h.

Referenced by Draw(), and DrawStatusBar().

◆ kChannelListWidth

constexpr float yaze::editor::music::PianoRollView::kChannelListWidth = 140.0f
staticconstexprprivate

Definition at line 115 of file piano_roll_view.h.

Referenced by Draw().

◆ active_channel_index_

int yaze::editor::music::PianoRollView::active_channel_index_ = 0
private

◆ active_segment_index_

int yaze::editor::music::PianoRollView::active_segment_index_ = 0
private

◆ preview_instrument_index_

int yaze::editor::music::PianoRollView::preview_instrument_index_ = 0
private

Definition at line 120 of file piano_roll_view.h.

Referenced by DrawToolbar(), and GetPreviewInstrument().

◆ pixels_per_tick_

float yaze::editor::music::PianoRollView::pixels_per_tick_ = 2.0f
private

◆ key_height_

float yaze::editor::music::PianoRollView::key_height_ = 12.0f
private

◆ key_width_

float yaze::editor::music::PianoRollView::key_width_ = 40.0f
private

Definition at line 123 of file piano_roll_view.h.

Referenced by DrawGrid(), DrawPianoKeys(), and DrawRollCanvas().

◆ scroll_x_px_

float yaze::editor::music::PianoRollView::scroll_x_px_ = 0.0f
private

Definition at line 124 of file piano_roll_view.h.

Referenced by DrawRollCanvas().

◆ scroll_y_px_

float yaze::editor::music::PianoRollView::scroll_y_px_ = 0.0f
private

Definition at line 125 of file piano_roll_view.h.

Referenced by DrawRollCanvas().

◆ snap_enabled_

bool yaze::editor::music::PianoRollView::snap_enabled_ = true
private

Definition at line 126 of file piano_roll_view.h.

Referenced by DrawToolbar(), and HandleMouseInput().

◆ snap_ticks_

int yaze::editor::music::PianoRollView::snap_ticks_ = zelda3::music::kDurationSixteenth
private

Definition at line 127 of file piano_roll_view.h.

Referenced by DrawToolbar(), and HandleMouseInput().

◆ follow_playback_

bool yaze::editor::music::PianoRollView::follow_playback_ = false
private

Definition at line 128 of file piano_roll_view.h.

Referenced by DrawRollCanvas(), IsFollowingPlayback(), and SetFollowPlayback().

◆ channel_visible_

std::vector<bool> yaze::editor::music::PianoRollView::channel_visible_ = std::vector<bool>(8, true)
private

Definition at line 131 of file piano_roll_view.h.

Referenced by DrawChannelList(), and DrawNotes().

◆ channel_muted_

std::vector<bool> yaze::editor::music::PianoRollView::channel_muted_ = std::vector<bool>(8, false)
private

Definition at line 132 of file piano_roll_view.h.

Referenced by DrawChannelList(), and DrawNotes().

◆ channel_solo_

std::vector<bool> yaze::editor::music::PianoRollView::channel_solo_ = std::vector<bool>(8, false)
private

Definition at line 133 of file piano_roll_view.h.

Referenced by DrawChannelList(), and DrawNotes().

◆ channel_colors_

std::vector<ImU32> yaze::editor::music::PianoRollView::channel_colors_
private

Definition at line 134 of file piano_roll_view.h.

Referenced by Draw(), DrawChannelList(), and DrawNotes().

◆ drag_mode_

int yaze::editor::music::PianoRollView::drag_mode_ = 0
private

Definition at line 137 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_start_tick_

int yaze::editor::music::PianoRollView::drag_start_tick_ = 0
private

Definition at line 138 of file piano_roll_view.h.

◆ drag_start_duration_

int yaze::editor::music::PianoRollView::drag_start_duration_ = 0
private

Definition at line 139 of file piano_roll_view.h.

◆ drag_event_index_

int yaze::editor::music::PianoRollView::drag_event_index_ = -1
private

Definition at line 140 of file piano_roll_view.h.

◆ hovered_event_index_

int yaze::editor::music::PianoRollView::hovered_event_index_ = -1
private

Definition at line 141 of file piano_roll_view.h.

Referenced by Draw(), DrawNotes(), and HandleMouseInput().

◆ hovered_channel_index_

int yaze::editor::music::PianoRollView::hovered_channel_index_ = -1
private

Definition at line 142 of file piano_roll_view.h.

Referenced by Draw(), DrawNotes(), and HandleMouseInput().

◆ hovered_segment_index_

int yaze::editor::music::PianoRollView::hovered_segment_index_ = -1
private

Definition at line 143 of file piano_roll_view.h.

Referenced by Draw(), DrawNotes(), and HandleMouseInput().

◆ status_tick_

int yaze::editor::music::PianoRollView::status_tick_ = -1
private

Definition at line 146 of file piano_roll_view.h.

Referenced by DrawStatusBar(), and HandleMouseInput().

◆ status_pitch_

int yaze::editor::music::PianoRollView::status_pitch_ = -1
private

Definition at line 147 of file piano_roll_view.h.

Referenced by DrawStatusBar(), and HandleMouseInput().

◆ status_note_name_

std::string yaze::editor::music::PianoRollView::status_note_name_
private

Definition at line 148 of file piano_roll_view.h.

Referenced by DrawStatusBar(), and HandleMouseInput().

◆ dragging_event_index_

int yaze::editor::music::PianoRollView::dragging_event_index_ = -1
private

Definition at line 151 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_segment_index_

int yaze::editor::music::PianoRollView::drag_segment_index_ = -1
private

Definition at line 152 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_channel_index_

int yaze::editor::music::PianoRollView::drag_channel_index_ = -1
private

Definition at line 153 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_moved_

bool yaze::editor::music::PianoRollView::drag_moved_ = false
private

Definition at line 154 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_original_event_

zelda3::music::TrackEvent yaze::editor::music::PianoRollView::drag_original_event_
private

Definition at line 155 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ drag_start_mouse_

ImVec2 yaze::editor::music::PianoRollView::drag_start_mouse_
private

Definition at line 156 of file piano_roll_view.h.

Referenced by HandleMouseInput().

◆ context_target_

struct yaze::editor::music::PianoRollView::ContextTarget yaze::editor::music::PianoRollView::context_target_
private

Referenced by Draw().

◆ empty_context_

struct yaze::editor::music::PianoRollView::EmptyContextTarget yaze::editor::music::PianoRollView::empty_context_
private

Referenced by Draw().

◆ on_edit_

std::function<void()> yaze::editor::music::PianoRollView::on_edit_
private

Definition at line 173 of file piano_roll_view.h.

Referenced by Draw(), HandleMouseInput(), and SetOnEditCallback().

◆ on_note_preview_

std::function<void(const zelda3::music::TrackEvent&, int segment_index, int channel_index) yaze::editor::music::PianoRollView::on_note_preview_)
private

Definition at line 175 of file piano_roll_view.h.

Referenced by Draw(), HandleMouseInput(), and SetOnNotePreview().

◆ on_segment_preview_

std::function<void(const zelda3::music::MusicSong&, int segment_index) yaze::editor::music::PianoRollView::on_segment_preview_)
private

Definition at line 176 of file piano_roll_view.h.

Referenced by DrawToolbar(), and SetOnSegmentPreview().

◆ is_playing_

bool yaze::editor::music::PianoRollView::is_playing_ = false
private

Definition at line 179 of file piano_roll_view.h.

Referenced by DrawRollCanvas(), IsPlaying(), and SetPlaybackState().

◆ is_paused_

bool yaze::editor::music::PianoRollView::is_paused_ = false
private

Definition at line 180 of file piano_roll_view.h.

Referenced by DrawPlaybackCursor(), DrawRollCanvas(), IsPaused(), and SetPlaybackState().

◆ playback_tick_

uint32_t yaze::editor::music::PianoRollView::playback_tick_ = 0
private

Definition at line 181 of file piano_roll_view.h.

Referenced by DrawPlaybackCursor(), DrawRollCanvas(), and SetPlaybackState().


The documentation for this class was generated from the following files: