Skip to content

Commit

Permalink
Reset the piano roll mode, the selection, and the undo/redo stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
subalterngames committed Jan 8, 2024
1 parent 3d3853c commit 6a3d726
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ impl View {
self.dt = [0, dt];
// Reset the notes.
self.dn = self.initial_dn;
// Single track view.
self.single_track = true;
}

/// Returns the note delta.
Expand Down
7 changes: 7 additions & 0 deletions io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,22 @@ impl IO {
}
// New file.
if input.happened(&InputEvent::NewFile) {
// This prevents the previous file from being overwritten.
paths_state.saves.filename = None;
// Stop playing music.
conn.on_new_file(state);
// Reset the music.
state.music = Music::default();
// Clear the selection.
state.select_mode = SelectMode::Single(None);
// Reset the view.
state.view.reset();
// Reset the time.
state.time.reset();
// Clear the undo/redo stacks.
self.undo.clear();
self.redo.clear();
state.unsaved_changes = false;
}
// Open file.
else if input.happened(&InputEvent::OpenFile) {
Expand Down

0 comments on commit 6a3d726

Please sign in to comment.