mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
editor: move to device crate
This commit is contained in:
parent
7f255eaea8
commit
4127c141cc
12 changed files with 534 additions and 510 deletions
126
crates/device/src/editor/editor_api.rs
Normal file
126
crates/device/src/editor/editor_api.rs
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
use crate::*;
|
||||
|
||||
#[tengri_proc::expose] impl MidiEditor {
|
||||
fn _todo_opt_clip_stub (&self) -> Option<Arc<RwLock<MidiClip>>> {
|
||||
todo!()
|
||||
}
|
||||
fn time_lock (&self) -> bool {
|
||||
self.get_time_lock()
|
||||
}
|
||||
fn time_lock_toggled (&self) -> bool {
|
||||
!self.get_time_lock()
|
||||
}
|
||||
|
||||
fn note_length (&self) -> usize {
|
||||
self.get_note_len()
|
||||
}
|
||||
|
||||
fn note_pos (&self) -> usize {
|
||||
self.get_note_pos()
|
||||
}
|
||||
fn note_pos_next (&self) -> usize {
|
||||
self.get_note_pos() + 1
|
||||
}
|
||||
fn note_pos_next_octave (&self) -> usize {
|
||||
self.get_note_pos() + 12
|
||||
}
|
||||
fn note_pos_prev (&self) -> usize {
|
||||
self.get_note_pos().saturating_sub(1)
|
||||
}
|
||||
fn note_pos_prev_octave (&self) -> usize {
|
||||
self.get_note_pos().saturating_sub(12)
|
||||
}
|
||||
|
||||
fn note_len (&self) -> usize {
|
||||
self.get_note_len()
|
||||
}
|
||||
fn note_len_next (&self) -> usize {
|
||||
self.get_note_len() + 1
|
||||
}
|
||||
fn note_len_prev (&self) -> usize {
|
||||
self.get_note_len().saturating_sub(1)
|
||||
}
|
||||
|
||||
fn note_range (&self) -> usize {
|
||||
self.get_note_axis()
|
||||
}
|
||||
fn note_range_next (&self) -> usize {
|
||||
self.get_note_axis() + 1
|
||||
}
|
||||
fn note_range_prev (&self) -> usize {
|
||||
self.get_note_axis().saturating_sub(1)
|
||||
}
|
||||
|
||||
fn time_pos (&self) -> usize {
|
||||
self.get_time_pos()
|
||||
}
|
||||
fn time_pos_next (&self) -> usize {
|
||||
self.get_time_pos() + self.time_zoom()
|
||||
}
|
||||
fn time_pos_prev (&self) -> usize {
|
||||
self.get_time_pos().saturating_sub(self.time_zoom())
|
||||
}
|
||||
|
||||
fn time_zoom (&self) -> usize {
|
||||
self.get_time_zoom()
|
||||
}
|
||||
fn time_zoom_next (&self) -> usize {
|
||||
self.get_time_zoom() + 1
|
||||
}
|
||||
fn time_zoom_prev (&self) -> usize {
|
||||
self.get_time_zoom().saturating_sub(1).max(1)
|
||||
}
|
||||
}
|
||||
|
||||
#[tengri_proc::command(MidiEditor)] impl MidiEditCommand {
|
||||
// TODO: 1-9 seek markers that by default start every 8th of the clip
|
||||
fn note_append (editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||
editor.put_note(true);
|
||||
Ok(None)
|
||||
}
|
||||
fn note_put (editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||
editor.put_note(false);
|
||||
Ok(None)
|
||||
}
|
||||
fn note_del (editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
|
||||
editor.set_note_pos(pos.min(127));
|
||||
Ok(None)
|
||||
}
|
||||
fn note_len (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
//let note_len = editor.get_note_len();
|
||||
//let time_zoom = editor.get_time_zoom();
|
||||
editor.set_note_len(value);
|
||||
//if note_len / time_zoom != x / time_zoom {
|
||||
editor.redraw();
|
||||
//}
|
||||
Ok(None)
|
||||
}
|
||||
fn note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_note_lo(value.min(127));
|
||||
Ok(None)
|
||||
}
|
||||
fn time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_time_pos(value);
|
||||
Ok(None)
|
||||
}
|
||||
fn time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_time_start(value);
|
||||
Ok(None)
|
||||
}
|
||||
fn time_zoom (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_time_zoom(value);
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn time_lock (editor: &mut MidiEditor, value: bool) -> Perhaps<Self> {
|
||||
editor.set_time_lock(value);
|
||||
Ok(None)
|
||||
}
|
||||
fn show (editor: &mut MidiEditor, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
|
||||
editor.set_clip(clip.as_ref());
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue