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

UI component for displaying and editing music tracks. More...

#include <tracker_view.h>

Public Member Functions

 TrackerView ()=default
 
 ~TrackerView ()=default
 
void Draw (MusicSong *song, const MusicBank *bank=nullptr)
 Draw the tracker view for the given song.
 
void SetOnEditCallback (std::function< void()> callback)
 Set callback for when edits occur (to trigger undo save)
 

Private Member Functions

void DrawToolbar (MusicSong *song)
 
void DrawGrid (MusicSong *song, const MusicBank *bank)
 
void DrawChannelHeader (int channel_idx)
 
void DrawEventCell (MusicTrack &track, int event_index, int channel_idx, uint16_t tick, const MusicBank *bank)
 
void HandleKeyboardInput (MusicSong *song)
 
void HandleNavigation ()
 
void HandleEditShortcuts (MusicSong *song)
 

Private Attributes

int current_tick_ = 0
 
float row_height_ = 20.0f
 
bool follow_playback_ = false
 
int ticks_per_row_ = 18
 
int selected_row_ = 0
 
int selected_col_ = 0
 
int selection_anchor_row_ = -1
 
int selection_anchor_col_ = -1
 
std::function< void()> on_edit_
 

Detailed Description

UI component for displaying and editing music tracks.

Renders an 8-channel tracker view where rows represent time (ticks) and columns represent audio channels.

Definition at line 21 of file tracker_view.h.

Constructor & Destructor Documentation

◆ TrackerView()

yaze::editor::music::TrackerView::TrackerView ( )
default

◆ ~TrackerView()

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

Member Function Documentation

◆ Draw()

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

Draw the tracker view for the given song.

Parameters
songThe song to display and edit (can be nullptr).
bankThe music bank for resolving instrument names (optional).

Definition at line 112 of file tracker_view.cc.

References DrawGrid(), DrawToolbar(), HandleEditShortcuts(), HandleKeyboardInput(), and HandleNavigation().

Referenced by yaze::editor::MusicEditor::DrawSongTrackerWindow(), and yaze::editor::MusicEditor::DrawTrackerView().

◆ SetOnEditCallback()

void yaze::editor::music::TrackerView::SetOnEditCallback ( std::function< void()> callback)
inline

Set callback for when edits occur (to trigger undo save)

Definition at line 36 of file tracker_view.h.

References on_edit_.

◆ DrawToolbar()

void yaze::editor::music::TrackerView::DrawToolbar ( MusicSong * song)
private

Definition at line 133 of file tracker_view.cc.

References yaze::zelda3::music::MusicSong::bank, yaze::zelda3::music::MusicSong::GetTotalDuration(), yaze::zelda3::music::MusicSong::name, and ticks_per_row_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawGrid()

void yaze::editor::music::TrackerView::DrawGrid ( MusicSong * song,
const MusicBank * bank )
private
Todo
Handle multiple segments)

Definition at line 150 of file tracker_view.cc.

References DrawEventCell(), row_height_, yaze::zelda3::music::MusicSong::segments, selected_col_, selected_row_, selection_anchor_col_, selection_anchor_row_, and ticks_per_row_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawChannelHeader()

void yaze::editor::music::TrackerView::DrawChannelHeader ( int channel_idx)
private

◆ DrawEventCell()

◆ HandleKeyboardInput()

void yaze::editor::music::TrackerView::HandleKeyboardInput ( MusicSong * song)
private
Todo
Implement range deletion logic
Todo
Check existing and set to Rest (0xC9) or insert Rest

Definition at line 526 of file tracker_view.cc.

References yaze::zelda3::music::kDurationSixteenth, yaze::zelda3::music::kNoteMinPitch, yaze::zelda3::music::TrackEvent::MakeNote(), on_edit_, yaze::zelda3::music::MusicSong::segments, selected_col_, selected_row_, selection_anchor_row_, and ticks_per_row_.

Referenced by Draw().

Here is the call graph for this function:

◆ HandleNavigation()

void yaze::editor::music::TrackerView::HandleNavigation ( )
private

Definition at line 469 of file tracker_view.cc.

References selected_col_, selected_row_, selection_anchor_col_, and selection_anchor_row_.

Referenced by Draw().

◆ HandleEditShortcuts()

void yaze::editor::music::TrackerView::HandleEditShortcuts ( MusicSong * song)
private

Definition at line 626 of file tracker_view.cc.

References yaze::zelda3::music::TrackEvent::MakeCommand(), on_edit_, yaze::zelda3::music::MusicSong::segments, selected_col_, selected_row_, and ticks_per_row_.

Referenced by Draw().

Here is the call graph for this function:

Member Data Documentation

◆ current_tick_

int yaze::editor::music::TrackerView::current_tick_ = 0
private

Definition at line 46 of file tracker_view.h.

◆ row_height_

float yaze::editor::music::TrackerView::row_height_ = 20.0f
private

Definition at line 47 of file tracker_view.h.

Referenced by DrawGrid().

◆ follow_playback_

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

Definition at line 48 of file tracker_view.h.

◆ ticks_per_row_

int yaze::editor::music::TrackerView::ticks_per_row_ = 18
private

Definition at line 49 of file tracker_view.h.

Referenced by DrawGrid(), DrawToolbar(), HandleEditShortcuts(), and HandleKeyboardInput().

◆ selected_row_

int yaze::editor::music::TrackerView::selected_row_ = 0
private

◆ selected_col_

int yaze::editor::music::TrackerView::selected_col_ = 0
private

◆ selection_anchor_row_

int yaze::editor::music::TrackerView::selection_anchor_row_ = -1
private

Definition at line 54 of file tracker_view.h.

Referenced by DrawGrid(), HandleKeyboardInput(), and HandleNavigation().

◆ selection_anchor_col_

int yaze::editor::music::TrackerView::selection_anchor_col_ = -1
private

Definition at line 55 of file tracker_view.h.

Referenced by DrawGrid(), and HandleNavigation().

◆ on_edit_

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

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