mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
add Arranger::is_first_row/is_last_row for arrow focus
This commit is contained in:
parent
a4bd99c117
commit
7bd2a70e85
6 changed files with 81 additions and 27 deletions
|
|
@ -135,10 +135,10 @@ pub const NOT_DIM: Style = Style {
|
|||
};
|
||||
|
||||
pub const NOT_DIM_GREEN: Style = Style {
|
||||
fg: Some(Color::Green),
|
||||
bg: None,
|
||||
fg: Some(Color::Rgb(96, 255, 32)),
|
||||
bg: Some(COLOR_BG1),
|
||||
underline_color: None,
|
||||
add_modifier: Modifier::BOLD,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::DIM,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,4 +64,22 @@ impl Arranger {
|
|||
//self.sequencer.show(phrase)
|
||||
Ok(())
|
||||
}
|
||||
pub fn is_first_row (&self) -> bool {
|
||||
let selected = self.selected;
|
||||
selected.is_mix() || selected.is_track() || match selected {
|
||||
ArrangerFocus::Clip(_, s) =>
|
||||
s == 0,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
pub fn is_last_row (&self) -> bool {
|
||||
let selected = self.selected;
|
||||
match selected {
|
||||
ArrangerFocus::Scene(s) =>
|
||||
s == self.scenes.len() - 1,
|
||||
ArrangerFocus::Clip(_, s) =>
|
||||
s == self.scenes.len() - 1,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ pub enum ArrangerFocus {
|
|||
|
||||
/// Focus identification methods
|
||||
impl ArrangerFocus {
|
||||
pub fn is_mix (&self) -> bool {
|
||||
match self { Self::Mix => true, _ => false }
|
||||
}
|
||||
pub fn is_track (&self) -> bool {
|
||||
match self { Self::Track(_) => true, _ => false }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl ArrangerStandalone {
|
|||
pub fn from_args () -> Usually<Self> {
|
||||
let args = ArrangerCli::parse();
|
||||
let mut arranger = Arranger::new("");
|
||||
let transport = match args.transport {
|
||||
let mut transport = match args.transport {
|
||||
Some(true) => Some(TransportToolbar::new(None)),
|
||||
_ => None
|
||||
};
|
||||
|
|
@ -65,6 +65,7 @@ impl ArrangerStandalone {
|
|||
//scene.clips[i] = Some(i);
|
||||
//}
|
||||
}
|
||||
transport.set_focused(true);
|
||||
Ok(ArrangerStandalone {
|
||||
transport,
|
||||
show_sequencer: Some(tek_core::Direction::Down),
|
||||
|
|
@ -81,7 +82,7 @@ impl Render for ArrangerStandalone {
|
|||
.add_ref(&self.transport)
|
||||
.add_ref(&self.arranger)
|
||||
.add_ref(&sequencer)
|
||||
.focus(Some(self.focus))
|
||||
//.focus(Some(self.focus))
|
||||
.render(buf, area)?;
|
||||
if let Some(ref modal) = self.arranger.modal {
|
||||
fill_bg(buf, area, Nord::bg_lo(false, false));
|
||||
|
|
@ -95,9 +96,7 @@ impl Render for ArrangerStandalone {
|
|||
impl Handle for ArrangerStandalone {
|
||||
fn handle (&mut self, e: &AppEvent) -> Usually<bool> {
|
||||
match e {
|
||||
AppEvent::Input(Event::Key(KeyEvent {
|
||||
code: KeyCode::Char(' '), ..
|
||||
})) => {
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Char(' '), .. })) => {
|
||||
if let Some(ref mut transport) = self.transport {
|
||||
transport.toggle_play()?;
|
||||
Ok(true)
|
||||
|
|
@ -105,18 +104,32 @@ impl Handle for ArrangerStandalone {
|
|||
Ok(false)
|
||||
}
|
||||
},
|
||||
AppEvent::Input(Event::Key(KeyEvent {
|
||||
code: KeyCode::Tab, ..
|
||||
})) => {
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Tab, .. })) => {
|
||||
self.focus_next();
|
||||
Ok(true)
|
||||
},
|
||||
AppEvent::Input(Event::Key(KeyEvent {
|
||||
code: KeyCode::BackTab, ..
|
||||
})) => {
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::BackTab, .. })) => {
|
||||
self.focus_prev();
|
||||
Ok(true)
|
||||
},
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Down, .. })) => {
|
||||
if self.focus == 0 || (
|
||||
self.focus == 1 && self.arranger.is_last_row()
|
||||
) {
|
||||
self.focus_next();
|
||||
Ok(true)
|
||||
} else {
|
||||
self.focused_mut().handle(e)
|
||||
}
|
||||
},
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Up, .. })) => {
|
||||
if self.focus == 1 && self.arranger.is_first_row() {
|
||||
self.focus_prev();
|
||||
Ok(true)
|
||||
} else {
|
||||
self.focused_mut().handle(e)
|
||||
}
|
||||
},
|
||||
_ => self.focused_mut().handle(e)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,12 +90,8 @@ impl TransportToolbar {
|
|||
pub fn new (transport: Option<Transport>) -> Self {
|
||||
let timebase = Arc::new(Timebase::default());
|
||||
Self {
|
||||
metronome: false,
|
||||
focused: false,
|
||||
focus: 0,
|
||||
started: None,
|
||||
jack: None,
|
||||
transport,
|
||||
focused: false,
|
||||
focus: 0,
|
||||
|
||||
playing: TransportPlayPauseButton {
|
||||
value: Some(TransportState::Stopped),
|
||||
|
|
@ -121,7 +117,11 @@ impl TransportToolbar {
|
|||
focused: false
|
||||
},
|
||||
|
||||
transport,
|
||||
timebase,
|
||||
metronome: false,
|
||||
started: None,
|
||||
jack: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,18 @@ const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
|||
render!(TransportToolbar |self, buf, area| {
|
||||
let mut area = area;
|
||||
area.height = 2;
|
||||
fill_bg(buf, area, Nord::BG0);
|
||||
Split::right()
|
||||
let area = Split::right()
|
||||
.add_ref(&self.playing)
|
||||
.add_ref(&self.bpm)
|
||||
.add_ref(&self.quant)
|
||||
.add_ref(&self.sync)
|
||||
.add_ref(&self.clock)
|
||||
.render(buf, area)
|
||||
.render(buf, area)?;
|
||||
//if self.is_focused() {
|
||||
//fill_bg(buf, area, COLOR_BG0);
|
||||
//CORNERS_DIM.draw(buf, area)?;
|
||||
//}
|
||||
Ok(area)
|
||||
});
|
||||
|
||||
render!(TransportPlayPauseButton |self, buf, area| {
|
||||
|
|
@ -32,8 +36,11 @@ render!(TransportPlayPauseButton |self, buf, area| {
|
|||
};
|
||||
let mut area = label.blit(buf, x + 1, y, style)?;
|
||||
area.width = area.width + 1;
|
||||
area.height = area.height + 1;
|
||||
if *focused {
|
||||
CORNERS.draw(buf, Rect { x: area.x - 1, ..area })?;
|
||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||
CORNERS.draw(buf, area)?;
|
||||
fill_bg(buf, area, COLOR_BG1);
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
|
@ -45,7 +52,9 @@ render!(TransportBPM |self, buf, area| {
|
|||
let width = format!("{}.{:03}", value, (value * 1000.0) % 1000.0).blit(buf, x, y + 1, Some(NOT_DIM_BOLD))?.width;
|
||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||
if *focused {
|
||||
CORNERS.draw(buf, Rect { x: area.x - 1, ..area })?;
|
||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||
CORNERS.draw(buf, area)?;
|
||||
fill_bg(buf, area, COLOR_BG1);
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
|
@ -57,7 +66,9 @@ render!(TransportQuantize |self, buf, area| {
|
|||
let width = ppq_to_name(*value as usize).blit(buf, x, y + 1, Some(NOT_DIM_BOLD))?.width;
|
||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||
if *focused {
|
||||
CORNERS.draw(buf, Rect { x: area.x - 1, ..area })?;
|
||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||
CORNERS.draw(buf, area)?;
|
||||
fill_bg(buf, area, COLOR_BG1);
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
|
@ -69,7 +80,9 @@ render!(TransportSync |self, buf, area| {
|
|||
let width = ppq_to_name(*value as usize).blit(buf, x, y + 1, Some(NOT_DIM_BOLD))?.width;
|
||||
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||
if *focused {
|
||||
CORNERS.draw(buf, Rect { x: area.x - 1, ..area })?;
|
||||
let area = Rect { x: area.x - 1, width: area.width - 1, ..area };
|
||||
CORNERS.draw(buf, area)?;
|
||||
fill_bg(buf, area, COLOR_BG1);
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
|
@ -85,5 +98,12 @@ render!(TransportClock |self, buf, area| {
|
|||
timer.blit(buf, x + width - timer.len() as u16 - 1, y + 0, Some(NOT_DIM))?;
|
||||
let timer = format!("{minutes}:{seconds:02}:{msecs:03}");
|
||||
timer.blit(buf, x + width - timer.len() as u16 - 1, y + 1, Some(NOT_DIM))?;
|
||||
let mut area = area;
|
||||
area.width = area.width + 1;
|
||||
if *focused {
|
||||
let area = Rect { x: area.x - 1, ..area };
|
||||
CORNERS.draw(buf, area)?;
|
||||
fill_bg(buf, area, COLOR_BG1);
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue