mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
always redraw grid on note length change
This commit is contained in:
parent
bcd747280c
commit
aa8eaf2e2b
5 changed files with 33 additions and 22 deletions
|
|
@ -30,21 +30,16 @@ impl<'a> ArrangerView<'a> {
|
|||
Tryptich::center(*scenes_height)
|
||||
.left(*width_side, Map::new(||self.scenes_with_scene_colors(),
|
||||
move|(index, scene, y1, y2, previous): SceneWithColor, _|{
|
||||
let name = Some(scene.name.clone());
|
||||
let color = scene.color;
|
||||
let prev_color = previous;
|
||||
let is_last = *scene_last == index;
|
||||
let selected = *scene_selected;
|
||||
let same_track = true;
|
||||
let scene = index;
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let name = Some(scene.name.clone());
|
||||
Fill::x(map_south(y1 as u16, (1 + y2 - y1) as u16, Fixed::y(height, Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⯈ ", name)))),
|
||||
colors: Tek::colors(
|
||||
&color,
|
||||
prev_color,
|
||||
&scene.color,
|
||||
previous,
|
||||
same_track && *scene_selected == Some(index),
|
||||
same_track && index > 0 && *scene_selected == Some(index - 1),
|
||||
*scene_last == index
|
||||
|
|
@ -68,7 +63,7 @@ impl<'a> ArrangerView<'a> {
|
|||
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name)))),
|
||||
colors: Tek::colors(
|
||||
&bg,
|
||||
None,
|
||||
Some(bg),
|
||||
same_track && *scene_selected == Some(scene_index),
|
||||
same_track && scene_index > 0 && *scene_selected == Some(scene_index - 1),
|
||||
*scene_last == scene_index
|
||||
|
|
|
|||
|
|
@ -232,9 +232,9 @@ impl Command<MidiEditor> for MidiEditCommand {
|
|||
let note_len = state.note_len();
|
||||
let time_zoom = state.time_zoom().get();
|
||||
state.set_note_len(x);
|
||||
if note_len / time_zoom != x / time_zoom {
|
||||
//if note_len / time_zoom != x / time_zoom {
|
||||
state.redraw();
|
||||
}
|
||||
//}
|
||||
},
|
||||
SetTimeCursor(x) => { state.set_time_pos(x); },
|
||||
SetNoteCursor(note) => { state.set_note_pos(note.min(127)); },
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
//! MIDI player
|
||||
use crate::*;
|
||||
|
||||
pub trait HasPlayer {
|
||||
fn player (&self) -> &impl MidiPlayerApi;
|
||||
fn player_mut (&mut self) -> &mut impl MidiPlayerApi;
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! has_player {
|
||||
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? HasPlayer for $Struct $(<$($L),*$($T),*>)? {
|
||||
|
|
@ -12,8 +14,11 @@ pub trait HasPlayer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MidiPlayerApi: MidiRecordApi + MidiPlaybackApi + Send + Sync {}
|
||||
|
||||
impl MidiPlayerApi for MidiPlayer {}
|
||||
|
||||
/// Contains state for playing a clip
|
||||
pub struct MidiPlayer {
|
||||
/// State of clock and playhead
|
||||
|
|
@ -41,6 +46,7 @@ pub struct MidiPlayer {
|
|||
/// MIDI output buffer
|
||||
pub note_buf: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Default for MidiPlayer {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
|
|
@ -61,6 +67,7 @@ impl Default for MidiPlayer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MidiPlayer {
|
||||
pub fn new (
|
||||
name: impl AsRef<str>,
|
||||
|
|
@ -88,6 +95,7 @@ impl MidiPlayer {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for MidiPlayer {
|
||||
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||
f.debug_struct("MidiPlayer")
|
||||
|
|
@ -97,16 +105,20 @@ impl std::fmt::Debug for MidiPlayer {
|
|||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
has_clock!(|self: MidiPlayer|self.clock);
|
||||
|
||||
impl HasMidiIns for MidiPlayer {
|
||||
fn midi_ins (&self) -> &Vec<JackMidiIn> { &self.midi_ins }
|
||||
fn midi_ins_mut (&mut self) -> &mut Vec<JackMidiIn> { &mut self.midi_ins }
|
||||
}
|
||||
|
||||
impl HasMidiOuts for MidiPlayer {
|
||||
fn midi_outs (&self) -> &Vec<JackMidiOut> { &self.midi_outs }
|
||||
fn midi_outs_mut (&mut self) -> &mut Vec<JackMidiOut> { &mut self.midi_outs }
|
||||
fn midi_note (&mut self) -> &mut Vec<u8> { &mut self.note_buf }
|
||||
}
|
||||
|
||||
/// Hosts the JACK callback for a single MIDI player
|
||||
pub struct PlayerAudio<'a, T: MidiPlayerApi>(
|
||||
/// Player
|
||||
|
|
@ -116,6 +128,7 @@ pub struct PlayerAudio<'a, T: MidiPlayerApi>(
|
|||
/// Note chunk buffer
|
||||
pub &'a mut Vec<Vec<Vec<u8>>>,
|
||||
);
|
||||
|
||||
/// JACK process callback for a sequencer's clip player/recorder.
|
||||
impl<T: MidiPlayerApi> Audio for PlayerAudio<'_, T> {
|
||||
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
|
|
@ -142,6 +155,7 @@ impl<T: MidiPlayerApi> Audio for PlayerAudio<'_, T> {
|
|||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
||||
impl MidiRecordApi for MidiPlayer {
|
||||
fn recording (&self) -> bool {
|
||||
self.recording
|
||||
|
|
@ -165,11 +179,13 @@ impl MidiRecordApi for MidiPlayer {
|
|||
&self.notes_in
|
||||
}
|
||||
}
|
||||
|
||||
impl MidiPlaybackApi for MidiPlayer {
|
||||
fn notes_out (&self) -> &Arc<RwLock<[bool; 128]>> {
|
||||
&self.notes_out
|
||||
}
|
||||
}
|
||||
|
||||
impl HasPlayClip for MidiPlayer {
|
||||
fn reset (&self) -> bool {
|
||||
self.reset
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue