mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
add getter/setters to note cursor traits
This commit is contained in:
parent
a6100ab1d6
commit
a8be2e9dad
8 changed files with 214 additions and 188 deletions
|
|
@ -39,7 +39,7 @@ impl Tek {
|
|||
self.sampler().map(|s|s.view_grid())
|
||||
}
|
||||
fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.sampler().map(|s|s.view_sample(self.editor().unwrap().note_pos()))
|
||||
self.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
|
||||
}
|
||||
fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
When::new(self.dialog.is_some(), Bsp::b(
|
||||
|
|
@ -115,69 +115,6 @@ impl Tek {
|
|||
/// Default editor height.
|
||||
pub(crate) const H_EDITOR: usize = 15;
|
||||
|
||||
/// Width of display
|
||||
pub(crate) fn w (&self) -> u16 {
|
||||
self.size.w() as u16
|
||||
}
|
||||
|
||||
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 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)
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
pub(crate) fn inputs_with_sizes (&self) -> impl PortsSizes<'_> {
|
||||
let mut y = 0;
|
||||
self.midi_ins.iter().enumerate().map(move|(i, input)|{
|
||||
|
|
@ -1118,9 +1055,9 @@ impl PianoHorizontal {
|
|||
}
|
||||
}
|
||||
fn notes (&self) -> impl Content<TuiOut> {
|
||||
let time_start = self.time_start().get();
|
||||
let note_lo = self.note_lo().get();
|
||||
let note_hi = self.note_hi();
|
||||
let time_start = self.get_time_start();
|
||||
let note_lo = self.get_note_lo();
|
||||
let note_hi = self.get_note_hi();
|
||||
let buffer = self.buffer.clone();
|
||||
ThunkRender::new(move|to: &mut TuiOut|{
|
||||
let source = buffer.read().unwrap();
|
||||
|
|
@ -1149,14 +1086,14 @@ impl PianoHorizontal {
|
|||
})
|
||||
}
|
||||
fn cursor (&self) -> impl Content<TuiOut> {
|
||||
let style = Some(Style::default().fg(self.color.lightest.rgb));
|
||||
let note_hi = self.note_hi();
|
||||
let note_lo = self.note_lo().get();
|
||||
let note_pos = self.note_pos();
|
||||
let note_len = self.note_len();
|
||||
let time_pos = self.time_pos();
|
||||
let time_start = self.time_start().get();
|
||||
let time_zoom = self.time_zoom().get();
|
||||
let note_hi = self.get_note_hi();
|
||||
let note_lo = self.get_note_lo();
|
||||
let note_pos = self.get_note_pos();
|
||||
let note_len = self.get_note_len();
|
||||
let time_pos = self.get_time_pos();
|
||||
let time_start = self.get_time_start();
|
||||
let time_zoom = self.get_time_zoom();
|
||||
let style = Some(Style::default().fg(self.color.lightest.rgb));
|
||||
ThunkRender::new(move|to: &mut TuiOut|{
|
||||
let [x0, y0, w, _] = to.area().xywh();
|
||||
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
|
|
@ -1182,9 +1119,9 @@ impl PianoHorizontal {
|
|||
fn keys (&self) -> impl Content<TuiOut> {
|
||||
let state = self;
|
||||
let color = state.color;
|
||||
let note_lo = state.note_lo().get();
|
||||
let note_hi = state.note_hi();
|
||||
let note_pos = state.note_pos();
|
||||
let note_lo = state.get_note_lo();
|
||||
let note_hi = state.get_note_hi();
|
||||
let note_pos = state.get_note_pos();
|
||||
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(Tui::g(255)));
|
||||
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.rgb).bold());
|
||||
|
|
@ -1234,15 +1171,12 @@ impl NoteRange for PianoHorizontal {
|
|||
}
|
||||
|
||||
impl NotePoint for PianoHorizontal {
|
||||
fn note_len (&self) -> usize { self.point.note_len() }
|
||||
fn set_note_len (&self, x: usize) -> usize { self.point.set_note_len(x) }
|
||||
fn note_pos (&self) -> usize { self.point.note_pos() }
|
||||
fn set_note_pos (&self, x: usize) -> usize { self.point.set_note_pos(x) }
|
||||
fn note_len (&self) -> &AtomicUsize { self.point.note_len() }
|
||||
fn note_pos (&self) -> &AtomicUsize { self.point.note_pos() }
|
||||
}
|
||||
|
||||
impl TimePoint for PianoHorizontal {
|
||||
fn time_pos (&self) -> usize { self.point.time_pos() }
|
||||
fn set_time_pos (&self, x: usize) -> usize { self.point.set_time_pos(x) }
|
||||
fn time_pos (&self) -> &AtomicUsize { self.point.time_pos() }
|
||||
}
|
||||
|
||||
impl MidiViewer for PianoHorizontal {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue