2026-10-04 10:29:39 +02:00
|
|
|
use crate::{Command, FileId, SelectMode, Selection};
|
2026-10-03 16:40:17 +02:00
|
|
|
|
|
|
|
|
/// Everything the frontend can ask the engine to do.
|
|
|
|
|
///
|
|
|
|
|
/// Only [`Action::Edit`] changes the files (and records an undo step); the others act on the
|
2026-10-03 17:42:26 +02:00
|
|
|
/// history, on the selection or on the file order.
|
2026-10-03 16:40:17 +02:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum Action<'a> {
|
|
|
|
|
Edit(Command<'a>),
|
|
|
|
|
Undo,
|
|
|
|
|
Redo,
|
2026-10-04 09:50:34 +02:00
|
|
|
/// Selects files, tracks, segments or waypoints (or the waypoints node of one file),
|
|
|
|
|
/// ignoring what does not exist: a selection left with nothing is empty, which deselects
|
2026-10-04 10:29:39 +02:00
|
|
|
/// everything. See [`SelectMode`] for how it combines with the current selection.
|
2026-10-03 17:42:26 +02:00
|
|
|
Select {
|
2026-10-04 09:50:34 +02:00
|
|
|
selection: Selection,
|
2026-10-04 10:29:39 +02:00
|
|
|
mode: SelectMode,
|
2026-10-03 17:42:26 +02:00
|
|
|
},
|
2026-10-04 14:49:53 +02:00
|
|
|
/// Selects all the elements of the same kind as the selected ones, in the same place (see
|
|
|
|
|
/// [`Selection::all_at_level`]). Does nothing when there is nothing more to select.
|
|
|
|
|
SelectAll,
|
|
|
|
|
/// Moves the selection to the next (`down`) or previous element of the same kind, like the
|
|
|
|
|
/// arrow keys do in the file list (see [`Selection::neighbour`]). With `add`, the element is
|
|
|
|
|
/// added to the selection (shift + arrow), otherwise it replaces it.
|
|
|
|
|
ArrowSelect {
|
|
|
|
|
down: bool,
|
|
|
|
|
add: bool,
|
|
|
|
|
},
|
2026-10-04 15:03:37 +02:00
|
|
|
/// Puts the selected elements in the clipboard, to be pasted by [`crate::Paste`]. Does
|
|
|
|
|
/// nothing when nothing is selected.
|
|
|
|
|
Copy,
|
|
|
|
|
/// Like `Copy`, but the elements are moved instead of copied when they are pasted.
|
|
|
|
|
Cut,
|
2026-10-03 17:42:26 +02:00
|
|
|
/// Moves the files to `index` among the other files, in the given order. Not undoable.
|
|
|
|
|
Reorder {
|
|
|
|
|
file_ids: Vec<FileId>,
|
|
|
|
|
index: usize,
|
|
|
|
|
},
|
2026-10-03 16:40:17 +02:00
|
|
|
}
|