mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
enter phrase length set mode
This commit is contained in:
parent
83dafe3e81
commit
26d75340f6
3 changed files with 43 additions and 17 deletions
|
|
@ -34,7 +34,10 @@ pub struct PhrasePool<E: Engine> {
|
|||
pub mode: Option<PhrasePoolMode>,
|
||||
}
|
||||
/// Modes for phrase pool
|
||||
pub enum PhrasePoolMode { Rename(usize, String) }
|
||||
pub enum PhrasePoolMode {
|
||||
Rename(usize, String),
|
||||
Length(usize, usize, PhraseLengthFocus),
|
||||
}
|
||||
/// A MIDI sequence.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Phrase {
|
||||
|
|
@ -188,8 +191,17 @@ impl<E: Engine> PhrasePool<E> {
|
|||
phrase.color = random_color();
|
||||
}
|
||||
pub fn begin_rename (&mut self) {
|
||||
let phrase = self.phrases[self.phrase].read().unwrap();
|
||||
self.mode = Some(PhrasePoolMode::Rename(self.phrase, phrase.name.clone()));
|
||||
self.mode = Some(PhrasePoolMode::Rename(
|
||||
self.phrase,
|
||||
self.phrases[self.phrase].read().unwrap().name.clone()
|
||||
));
|
||||
}
|
||||
pub fn begin_length (&mut self) {
|
||||
self.mode = Some(PhrasePoolMode::Length(
|
||||
self.phrase,
|
||||
self.phrases[self.phrase].read().unwrap().length,
|
||||
PhraseLengthFocus::Bar
|
||||
));
|
||||
}
|
||||
pub fn move_up (&mut self) {
|
||||
if self.phrase > 1 {
|
||||
|
|
@ -314,18 +326,16 @@ pub struct PhraseLength<E: Engine> {
|
|||
pub ppq: usize,
|
||||
pub bpb: usize,
|
||||
pub pulses: usize,
|
||||
pub focused: bool,
|
||||
pub focus: PhraseLengthFocus
|
||||
pub focus: Option<PhraseLengthFocus>,
|
||||
}
|
||||
impl<E: Engine> PhraseLength<E> {
|
||||
fn new (pulses: usize) -> Self {
|
||||
pub fn new (pulses: usize, focus: Option<PhraseLengthFocus>) -> Self {
|
||||
Self {
|
||||
_engine: Default::default(),
|
||||
ppq: PPQ,
|
||||
bpb: 4,
|
||||
pulses,
|
||||
focused: false,
|
||||
focus: PhraseLengthFocus::Bar
|
||||
focus
|
||||
}
|
||||
}
|
||||
pub fn bars (&self) -> usize {
|
||||
|
|
@ -344,7 +354,7 @@ impl<E: Engine> PhraseLength<E> {
|
|||
format!("{}", self.beats())
|
||||
}
|
||||
pub fn ticks_string (&self) -> String {
|
||||
format!("{}", self.ticks())
|
||||
format!("{:>02}", self.ticks())
|
||||
}
|
||||
}
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue