mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
redraw editor sooner
This commit is contained in:
parent
9cbe805c46
commit
059b4c0aa8
4 changed files with 30 additions and 81 deletions
|
|
@ -138,8 +138,12 @@ impl<E: Engine> Arranger<E> {
|
|||
Ok(Some(true))
|
||||
}
|
||||
/// Focus the editor with the current phrase
|
||||
pub fn show_phrase (&mut self) {
|
||||
self.editor.show(self.arrangement.phrase().as_ref());
|
||||
}
|
||||
/// Focus the editor with the current phrase
|
||||
pub fn edit_phrase (&mut self) {
|
||||
self.editor.phrase = self.arrangement.phrase().clone();
|
||||
self.show_phrase();
|
||||
self.focus(ArrangerFocus::PhraseEditor);
|
||||
}
|
||||
/// Rename the selected track, scene, or clip
|
||||
|
|
@ -237,7 +241,6 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementFocus::Clip(_, _) => self.phrase_del(),
|
||||
_ => {}
|
||||
}
|
||||
self.show_phrase()
|
||||
}
|
||||
pub fn increment (&mut self) {
|
||||
match self.selected {
|
||||
|
|
@ -246,7 +249,6 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementFocus::Clip(_, _) => self.phrase_next(),
|
||||
_ => {}
|
||||
}
|
||||
self.show_phrase()
|
||||
}
|
||||
pub fn decrement (&mut self) {
|
||||
match self.selected {
|
||||
|
|
@ -255,7 +257,6 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementFocus::Clip(_, _) => self.phrase_prev(),
|
||||
_ => {}
|
||||
}
|
||||
self.show_phrase()
|
||||
}
|
||||
pub fn is_first_row (&self) -> bool {
|
||||
let selected = self.selected;
|
||||
|
|
@ -279,28 +280,24 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementViewMode::Horizontal => self.track_prev(),
|
||||
_ => self.scene_prev(),
|
||||
};
|
||||
self.show_phrase();
|
||||
}
|
||||
pub fn go_down (&mut self) {
|
||||
match self.mode {
|
||||
ArrangementViewMode::Horizontal => self.track_next(),
|
||||
_ => self.scene_next(),
|
||||
};
|
||||
self.show_phrase();
|
||||
}
|
||||
pub fn go_left (&mut self) {
|
||||
match self.mode {
|
||||
ArrangementViewMode::Horizontal => self.scene_prev(),
|
||||
_ => self.track_prev(),
|
||||
};
|
||||
self.show_phrase();
|
||||
}
|
||||
pub fn go_right (&mut self) {
|
||||
match self.mode {
|
||||
ArrangementViewMode::Horizontal => self.scene_next(),
|
||||
_ => self.track_next(),
|
||||
};
|
||||
self.show_phrase();
|
||||
}
|
||||
pub fn move_back (&mut self) {
|
||||
match self.selected {
|
||||
|
|
@ -442,16 +439,6 @@ impl<E: Engine> Arrangement<E> {
|
|||
.map(|track|self.tracks.get_mut(track))
|
||||
.flatten()
|
||||
}
|
||||
pub fn show_phrase (&mut self) {
|
||||
let (scene, track) = (self.selected.scene(), self.selected.track());
|
||||
if let (Some(scene_index), Some(track_index)) = (scene, track) {
|
||||
let scene = self.scenes.get(scene_index);
|
||||
let track = self.tracks.get_mut(track_index);
|
||||
if let (Some(scene), Some(track)) = (scene, track) {
|
||||
track.player.phrase = scene.clips[track_index].clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn phrase (&self) -> Option<Arc<RwLock<Phrase>>> {
|
||||
self.scene()?.clips.get(self.selected.track()?)?.clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ impl Arranger<Tui> {
|
|||
},
|
||||
_ => return self.arrangement.handle(from)
|
||||
}
|
||||
self.show_phrase();
|
||||
Ok(Some(true))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,13 +137,10 @@ impl<E: Engine> FocusGrid<SequencerFocus> for Sequencer<E> {
|
|||
fn update_focus (&mut self) {
|
||||
let focused = *self.focused();
|
||||
if let Some(transport) = self.transport.as_ref() {
|
||||
transport.write().unwrap().focused =
|
||||
focused == SequencerFocus::Transport
|
||||
transport.write().unwrap().focused = focused == SequencerFocus::Transport
|
||||
}
|
||||
self.phrases.write().unwrap().focused =
|
||||
focused == SequencerFocus::PhrasePool;
|
||||
self.editor.focused =
|
||||
focused == SequencerFocus::PhraseEditor;
|
||||
self.phrases.write().unwrap().focused = focused == SequencerFocus::PhrasePool;
|
||||
self.editor.focused = focused == SequencerFocus::PhraseEditor;
|
||||
}
|
||||
}
|
||||
impl<E: Engine> PhrasePool<E> {
|
||||
|
|
@ -157,31 +154,21 @@ impl<E: Engine> PhrasePool<E> {
|
|||
mode: None,
|
||||
}
|
||||
}
|
||||
pub fn phrase (&self) -> &Arc<RwLock<Phrase>> {
|
||||
&self.phrases[self.phrase]
|
||||
}
|
||||
pub fn index_of (&self, phrase: &Phrase) -> Option<usize> {
|
||||
for i in 0..self.phrases.len() {
|
||||
if *self.phrases[i].read().unwrap() == *phrase {
|
||||
return Some(i)
|
||||
}
|
||||
}
|
||||
return None
|
||||
}
|
||||
pub fn len (&self) -> usize {
|
||||
self.phrases.len()
|
||||
}
|
||||
pub fn len (&self) -> usize { self.phrases.len() }
|
||||
pub fn phrase (&self) -> &Arc<RwLock<Phrase>> { &self.phrases[self.phrase] }
|
||||
pub fn select_prev (&mut self) { self.phrase = self.index_before(self.phrase) }
|
||||
pub fn select_next (&mut self) { self.phrase = self.index_after(self.phrase) }
|
||||
pub fn index_before (&self, index: usize) -> usize {
|
||||
index.overflowing_sub(1).0.min(self.len() - 1)
|
||||
}
|
||||
pub fn index_after (&self, index: usize) -> usize {
|
||||
(index + 1) % self.len()
|
||||
}
|
||||
pub fn select_prev (&mut self) {
|
||||
self.phrase = self.index_before(self.phrase)
|
||||
}
|
||||
pub fn select_next (&mut self) {
|
||||
self.phrase = self.index_after(self.phrase)
|
||||
pub fn index_of (&self, phrase: &Phrase) -> Option<usize> {
|
||||
for i in 0..self.phrases.len() {
|
||||
if *self.phrases[i].read().unwrap() == *phrase { return Some(i) }
|
||||
}
|
||||
return None
|
||||
}
|
||||
pub fn append_new (&mut self, name: Option<&str>, color: Option<Color>) {
|
||||
let mut phrase = Phrase::default();
|
||||
|
|
@ -312,9 +299,7 @@ impl Default for Phrase {
|
|||
fn default () -> Self { Self::new("(empty)", false, 0, None, Some(Color::Rgb(0, 0, 0))) }
|
||||
}
|
||||
impl std::cmp::PartialEq for Phrase {
|
||||
fn eq (&self, other: &Self) -> bool {
|
||||
self.uuid == other.uuid
|
||||
}
|
||||
fn eq (&self, other: &Self) -> bool { self.uuid == other.uuid }
|
||||
}
|
||||
impl Eq for Phrase {}
|
||||
impl<E: Engine> PhrasePlayer<E> {
|
||||
|
|
@ -333,15 +318,9 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
now: 0,
|
||||
}
|
||||
}
|
||||
pub fn toggle_monitor (&mut self) {
|
||||
self.monitoring = !self.monitoring;
|
||||
}
|
||||
pub fn toggle_record (&mut self) {
|
||||
self.recording = !self.recording;
|
||||
}
|
||||
pub fn toggle_overdub (&mut self) {
|
||||
self.overdub = !self.overdub;
|
||||
}
|
||||
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
|
||||
pub fn toggle_record (&mut self) { self.recording = !self.recording; }
|
||||
pub fn toggle_overdub (&mut self) { self.overdub = !self.overdub; }
|
||||
}
|
||||
/// Displays and edits phrase length
|
||||
pub struct PhraseLength<E: Engine> {
|
||||
|
|
@ -357,32 +336,14 @@ pub struct PhraseLength<E: Engine> {
|
|||
}
|
||||
impl<E: Engine> PhraseLength<E> {
|
||||
pub fn new (pulses: usize, focus: Option<PhraseLengthFocus>) -> Self {
|
||||
Self {
|
||||
_engine: Default::default(),
|
||||
ppq: PPQ,
|
||||
bpb: 4,
|
||||
pulses,
|
||||
focus
|
||||
}
|
||||
}
|
||||
pub fn bars (&self) -> usize {
|
||||
self.pulses / (self.bpb * self.ppq)
|
||||
}
|
||||
pub fn beats (&self) -> usize {
|
||||
(self.pulses % (self.bpb * self.ppq)) / self.ppq
|
||||
}
|
||||
pub fn ticks (&self) -> usize {
|
||||
self.pulses % self.ppq
|
||||
}
|
||||
pub fn bars_string (&self) -> String {
|
||||
format!("{}", self.bars())
|
||||
}
|
||||
pub fn beats_string (&self) -> String {
|
||||
format!("{}", self.beats())
|
||||
}
|
||||
pub fn ticks_string (&self) -> String {
|
||||
format!("{:>02}", self.ticks())
|
||||
Self { _engine: Default::default(), ppq: PPQ, bpb: 4, pulses, focus }
|
||||
}
|
||||
pub fn bars (&self) -> usize { self.pulses / (self.bpb * self.ppq) }
|
||||
pub fn beats (&self) -> usize { (self.pulses % (self.bpb * self.ppq)) / self.ppq }
|
||||
pub fn ticks (&self) -> usize { self.pulses % self.ppq }
|
||||
pub fn bars_string (&self) -> String { format!("{}", self.bars()) }
|
||||
pub fn beats_string (&self) -> String { format!("{}", self.beats()) }
|
||||
pub fn ticks_string (&self) -> String { format!("{:>02}", self.ticks()) }
|
||||
}
|
||||
#[derive(Copy,Clone)]
|
||||
pub enum PhraseLengthFocus {
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ impl Content for PhraseEditor<Tui> {
|
|||
)
|
||||
}
|
||||
}
|
||||
impl PhraseEditor<Tui> {
|
||||
impl<E: Engine> PhraseEditor<E> {
|
||||
const H_KEYS_OFFSET: usize = 5;
|
||||
pub fn put (&mut self) {
|
||||
if let (Some(phrase), Some(time), Some(note)) = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue