add getter/setters to note cursor traits

This commit is contained in:
🪞👃🪞 2025-05-08 03:19:47 +03:00
parent a6100ab1d6
commit a8be2e9dad
8 changed files with 214 additions and 188 deletions

View file

@ -53,12 +53,62 @@ impl Tek {
matches!(self.pool.as_ref().map(|p|p.mode.as_ref()).flatten(), Some(PoolMode::Length(..)))
}
fn editor_pitch (&self) -> Option<u7> {
(self.editor().map(|e|e.note_pos()).unwrap() as u8).into()
Some((self.editor().map(|e|e.note_pos()).unwrap() as u8).into())
}
fn w_sidebar (&self) -> Option<u7> {
self.w_sidebar()
/// Width of display
pub(crate) fn w (&self) -> u16 {
self.size.w() as u16
}
fn scene_count (&self) -> Option<usize> {
/// Width allocated for sidebar.
pub(crate) fn w_sidebar (&self) -> u16 {
self.w() / if self.is_editing() { 16 } else { 8 } as u16
}
/// Width taken by all tracks.
pub(crate) fn w_tracks (&self) -> u16 {
self.tracks_with_sizes().last().map(|(_, _, _, x)|x as u16).unwrap_or(0)
}
/// Width available to display tracks.
pub(crate) fn w_tracks_area (&self) -> u16 {
self.w().saturating_sub(2 * self.w_sidebar())
}
/// Height of display
pub(crate) fn h (&self) -> u16 {
self.size.h() as u16
}
/// Height available to display track headers.
pub(crate) fn h_tracks_area (&self) -> u16 {
5 // FIXME
//self.h().saturating_sub(self.h_inputs() + self.h_outputs())
}
/// Height available to display tracks.
pub(crate) fn h_scenes_area (&self) -> u16 {
//15
self.h().saturating_sub(
self.h_inputs() +
self.h_outputs() +
self.h_devices() +
13 // FIXME
)
}
/// Height taken by all scenes.
pub(crate) fn h_scenes (&self) -> u16 {
self.scenes_with_sizes(self.is_editing(), Self::H_SCENE, Self::H_EDITOR).last()
.map(|(_, _, _, y)|y as u16).unwrap_or(0)
}
/// Height taken by all inputs.
pub(crate) fn h_inputs (&self) -> u16 {
self.inputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
}
/// Height taken by all outputs.
pub(crate) fn h_outputs (&self) -> u16 {
self.outputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
}
/// Height taken by visible device slots.
pub(crate) fn h_devices (&self) -> u16 {
2
//1 + self.devices_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
}
fn scene_count (&self) -> usize {
self.scenes.len()
}
fn scene_selected (&self) -> Option<usize> {
@ -70,7 +120,7 @@ impl Tek {
fn scene_select_prev (&self) -> Selection {
self.selected.scene_prev()
}
fn track_count (&self) -> Option<usize> {
fn track_count (&self) -> usize {
self.tracks.len()
}
fn track_selected (&self) -> Option<usize> {
@ -139,64 +189,70 @@ impl MidiPool {
#[tengri_proc::expose]
impl MidiEditor {
fn time_lock (&self) -> bool {
self.time_lock().get()
self.get_time_lock()
}
fn time_lock_toggle (&self) -> bool {
!self.time_lock().get()
fn time_lock_toggled (&self) -> bool {
!self.get_time_lock()
}
fn note_length (&self) -> usize {
self.note_len()
self.get_note_len()
}
fn note_pos (&self) -> usize {
self.note_pos()
self.get_note_pos()
}
fn note_pos_next (&self) -> usize {
self.note_pos() + 1
self.get_note_pos() + 1
}
fn note_pos_next_octave (&self) -> usize {
self.note_pos() + 12
self.get_note_pos() + 12
}
fn note_pos_prev (&self) -> usize {
self.note_pos().saturating_sub(1)
self.get_note_pos().saturating_sub(1)
}
fn note_pos_prev_octave (&self) -> usize {
self.note_pos().saturating_sub(12)
self.get_note_pos().saturating_sub(12)
}
fn note_len (&self) -> usize {
self.note_len()
self.get_note_len()
}
fn note_len_next (&self) -> usize {
self.note_len() + 1
self.get_note_len() + 1
}
fn note_len_prev (&self) -> usize {
self.note_len().saturating_sub(1)
self.get_note_len().saturating_sub(1)
}
fn note_range (&self) -> usize {
self.note_axis()
self.get_note_axis()
}
fn note_range_next (&self) -> usize {
self.note_axis() + 1
self.get_note_axis() + 1
}
fn note_range_prev (&self) -> usize {
self.note_axis().saturating_sub(1)
self.get_note_axis().saturating_sub(1)
}
fn time_pos (&self) -> usize {
self.time_pos()
self.get_time_pos()
}
fn time_pos_next (&self) -> usize {
self.time_pos() + self.time_zoom().get()
self.get_time_pos() + self.time_zoom()
}
fn time_pos_prev (&self) -> usize {
self.time_pos().saturating_sub(self.time_zoom().get())
self.get_time_pos().saturating_sub(self.time_zoom())
}
fn time_zoom (&self) -> usize {
self.time_zoom()
self.get_time_zoom()
}
fn time_zoom_next (&self) -> usize {
self.time_zoom() + 1
self.get_time_zoom() + 1
}
fn time_zoom_prev (&self) -> usize {
self.time_zoom().get().saturating_sub(1).max(1)
self.get_time_zoom().saturating_sub(1).max(1)
}
}
@ -277,17 +333,17 @@ impl TekCommand {
#[tengri_proc::command(Tek)]
impl InputCommand {
fn add (&self, state: &mut tek) -> option<self> {
fn add (&self, state: &mut Tek) -> Option<Self> {
state.midi_in_add()?;
none
None
}
}
#[tengri_proc::command(Tek)]
impl OutputCommand {
fn add (&self, state: &mut tek) -> option<self> {
fn add (&self, state: &mut Tek) -> Option<Self> {
state.midi_out_add()?;
none
None
}
}