mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +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 {
|
pub const NOT_DIM_GREEN: Style = Style {
|
||||||
fg: Some(Color::Green),
|
fg: Some(Color::Rgb(96, 255, 32)),
|
||||||
bg: None,
|
bg: Some(COLOR_BG1),
|
||||||
underline_color: None,
|
underline_color: None,
|
||||||
add_modifier: Modifier::BOLD,
|
add_modifier: Modifier::empty(),
|
||||||
sub_modifier: Modifier::DIM,
|
sub_modifier: Modifier::DIM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,4 +64,22 @@ impl Arranger {
|
||||||
//self.sequencer.show(phrase)
|
//self.sequencer.show(phrase)
|
||||||
Ok(())
|
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
|
/// Focus identification methods
|
||||||
impl ArrangerFocus {
|
impl ArrangerFocus {
|
||||||
|
pub fn is_mix (&self) -> bool {
|
||||||
|
match self { Self::Mix => true, _ => false }
|
||||||
|
}
|
||||||
pub fn is_track (&self) -> bool {
|
pub fn is_track (&self) -> bool {
|
||||||
match self { Self::Track(_) => true, _ => false }
|
match self { Self::Track(_) => true, _ => false }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ impl ArrangerStandalone {
|
||||||
pub fn from_args () -> Usually<Self> {
|
pub fn from_args () -> Usually<Self> {
|
||||||
let args = ArrangerCli::parse();
|
let args = ArrangerCli::parse();
|
||||||
let mut arranger = Arranger::new("");
|
let mut arranger = Arranger::new("");
|
||||||
let transport = match args.transport {
|
let mut transport = match args.transport {
|
||||||
Some(true) => Some(TransportToolbar::new(None)),
|
Some(true) => Some(TransportToolbar::new(None)),
|
||||||
_ => None
|
_ => None
|
||||||
};
|
};
|
||||||
|
|
@ -65,6 +65,7 @@ impl ArrangerStandalone {
|
||||||
//scene.clips[i] = Some(i);
|
//scene.clips[i] = Some(i);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
transport.set_focused(true);
|
||||||
Ok(ArrangerStandalone {
|
Ok(ArrangerStandalone {
|
||||||
transport,
|
transport,
|
||||||
show_sequencer: Some(tek_core::Direction::Down),
|
show_sequencer: Some(tek_core::Direction::Down),
|
||||||
|
|
@ -81,7 +82,7 @@ impl Render for ArrangerStandalone {
|
||||||
.add_ref(&self.transport)
|
.add_ref(&self.transport)
|
||||||
.add_ref(&self.arranger)
|
.add_ref(&self.arranger)
|
||||||
.add_ref(&sequencer)
|
.add_ref(&sequencer)
|
||||||
.focus(Some(self.focus))
|
//.focus(Some(self.focus))
|
||||||
.render(buf, area)?;
|
.render(buf, area)?;
|
||||||
if let Some(ref modal) = self.arranger.modal {
|
if let Some(ref modal) = self.arranger.modal {
|
||||||
fill_bg(buf, area, Nord::bg_lo(false, false));
|
fill_bg(buf, area, Nord::bg_lo(false, false));
|
||||||
|
|
@ -95,9 +96,7 @@ impl Render for ArrangerStandalone {
|
||||||
impl Handle for ArrangerStandalone {
|
impl Handle for ArrangerStandalone {
|
||||||
fn handle (&mut self, e: &AppEvent) -> Usually<bool> {
|
fn handle (&mut self, e: &AppEvent) -> Usually<bool> {
|
||||||
match e {
|
match e {
|
||||||
AppEvent::Input(Event::Key(KeyEvent {
|
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Char(' '), .. })) => {
|
||||||
code: KeyCode::Char(' '), ..
|
|
||||||
})) => {
|
|
||||||
if let Some(ref mut transport) = self.transport {
|
if let Some(ref mut transport) = self.transport {
|
||||||
transport.toggle_play()?;
|
transport.toggle_play()?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|
@ -105,18 +104,32 @@ impl Handle for ArrangerStandalone {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AppEvent::Input(Event::Key(KeyEvent {
|
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Tab, .. })) => {
|
||||||
code: KeyCode::Tab, ..
|
|
||||||
})) => {
|
|
||||||
self.focus_next();
|
self.focus_next();
|
||||||
Ok(true)
|
Ok(true)
|
||||||
},
|
},
|
||||||
AppEvent::Input(Event::Key(KeyEvent {
|
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::BackTab, .. })) => {
|
||||||
code: KeyCode::BackTab, ..
|
|
||||||
})) => {
|
|
||||||
self.focus_prev();
|
self.focus_prev();
|
||||||
Ok(true)
|
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)
|
_ => self.focused_mut().handle(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,12 +90,8 @@ impl TransportToolbar {
|
||||||
pub fn new (transport: Option<Transport>) -> Self {
|
pub fn new (transport: Option<Transport>) -> Self {
|
||||||
let timebase = Arc::new(Timebase::default());
|
let timebase = Arc::new(Timebase::default());
|
||||||
Self {
|
Self {
|
||||||
metronome: false,
|
focused: false,
|
||||||
focused: false,
|
focus: 0,
|
||||||
focus: 0,
|
|
||||||
started: None,
|
|
||||||
jack: None,
|
|
||||||
transport,
|
|
||||||
|
|
||||||
playing: TransportPlayPauseButton {
|
playing: TransportPlayPauseButton {
|
||||||
value: Some(TransportState::Stopped),
|
value: Some(TransportState::Stopped),
|
||||||
|
|
@ -121,7 +117,11 @@ impl TransportToolbar {
|
||||||
focused: false
|
focused: false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
transport,
|
||||||
timebase,
|
timebase,
|
||||||
|
metronome: false,
|
||||||
|
started: None,
|
||||||
|
jack: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,18 @@ const CORNERS: Corners = Corners(NOT_DIM_GREEN);
|
||||||
render!(TransportToolbar |self, buf, area| {
|
render!(TransportToolbar |self, buf, area| {
|
||||||
let mut area = area;
|
let mut area = area;
|
||||||
area.height = 2;
|
area.height = 2;
|
||||||
fill_bg(buf, area, Nord::BG0);
|
let area = Split::right()
|
||||||
Split::right()
|
|
||||||
.add_ref(&self.playing)
|
.add_ref(&self.playing)
|
||||||
.add_ref(&self.bpm)
|
.add_ref(&self.bpm)
|
||||||
.add_ref(&self.quant)
|
.add_ref(&self.quant)
|
||||||
.add_ref(&self.sync)
|
.add_ref(&self.sync)
|
||||||
.add_ref(&self.clock)
|
.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| {
|
render!(TransportPlayPauseButton |self, buf, area| {
|
||||||
|
|
@ -32,8 +36,11 @@ render!(TransportPlayPauseButton |self, buf, area| {
|
||||||
};
|
};
|
||||||
let mut area = label.blit(buf, x + 1, y, style)?;
|
let mut area = label.blit(buf, x + 1, y, style)?;
|
||||||
area.width = area.width + 1;
|
area.width = area.width + 1;
|
||||||
|
area.height = area.height + 1;
|
||||||
if *focused {
|
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)
|
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 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 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
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)
|
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 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 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
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)
|
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 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 };
|
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
|
||||||
if *focused {
|
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)
|
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))?;
|
timer.blit(buf, x + width - timer.len() as u16 - 1, y + 0, Some(NOT_DIM))?;
|
||||||
let timer = format!("{minutes}:{seconds:02}:{msecs:03}");
|
let timer = format!("{minutes}:{seconds:02}:{msecs:03}");
|
||||||
timer.blit(buf, x + width - timer.len() as u16 - 1, y + 1, Some(NOT_DIM))?;
|
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)
|
Ok(area)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue