mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: refactor pt.28: 16 errors
This commit is contained in:
parent
4522ebaa4b
commit
ceead4131c
7 changed files with 84 additions and 62 deletions
|
|
@ -1,9 +1,15 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub trait StatusBar<E: Engine>: Widget<Engine = E> {
|
pub trait StatusBar<E: Engine, S>: Widget<Engine = E> {
|
||||||
fn hotkey_fg () -> Color;
|
fn hotkey_fg () -> Color where Self: Sized;
|
||||||
|
|
||||||
fn command (commands: &[[impl Widget<Engine = Tui>;3]]) -> impl Widget<Engine = Tui> + '_ {
|
fn update (&mut self, state: &S);
|
||||||
|
|
||||||
|
fn command (commands: &[[impl Widget<Engine = Tui>;3]])
|
||||||
|
-> impl Widget<Engine = Tui> + '_
|
||||||
|
where
|
||||||
|
Self: Sized
|
||||||
|
{
|
||||||
let hotkey_fg = Self::hotkey_fg();
|
let hotkey_fg = Self::hotkey_fg();
|
||||||
Stack::right(move |add|{
|
Stack::right(move |add|{
|
||||||
Ok(for [a, b, c] in commands.iter() {
|
Ok(for [a, b, c] in commands.iter() {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ where
|
||||||
pub cursor: (usize, usize),
|
pub cursor: (usize, usize),
|
||||||
pub entered: bool,
|
pub entered: bool,
|
||||||
pub menu_bar: Option<MenuBar<E, A, C>>,
|
pub menu_bar: Option<MenuBar<E, A, C>>,
|
||||||
pub status_bar: Option<Box<dyn Widget<Engine = E>>>,
|
pub status_bar: Option<Box<dyn StatusBar<E, Self>>>,
|
||||||
pub history: Vec<C>,
|
pub history: Vec<C>,
|
||||||
pub size: Measure<E>,
|
pub size: Measure<E>,
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ where
|
||||||
pub fn new (
|
pub fn new (
|
||||||
app: A,
|
app: A,
|
||||||
menu_bar: Option<MenuBar<E, A, C>>,
|
menu_bar: Option<MenuBar<E, A, C>>,
|
||||||
status_bar: Option<Box<dyn Widget<Engine = E>>>,
|
status_bar: Option<Box<dyn StatusBar<E, Self>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
app,
|
app,
|
||||||
|
|
|
||||||
|
|
@ -12,27 +12,27 @@ pub enum ArrangerStatusBar {
|
||||||
PhraseEdit,
|
PhraseEdit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusBar<Tui> for ArrangerStatusBar {
|
impl StatusBar<Tui, ArrangerApp<Tui>> for ArrangerStatusBar {
|
||||||
fn hotkey_fg () -> Color {
|
fn hotkey_fg () -> Color where Self: Sized {
|
||||||
TuiTheme::hotkey_fg()
|
TuiTheme::hotkey_fg()
|
||||||
}
|
}
|
||||||
}
|
fn update (&mut self, state: &ArrangerApp<Tui>) {
|
||||||
|
use AppViewFocus::*;
|
||||||
impl ArrangerStatusBar {
|
if let Content(focused) = state.focused() {
|
||||||
fn update <E: Engine> (&mut self, state: &ArrangerView<E>) {
|
*self = match focused {
|
||||||
*self = match state.focused() {
|
ArrangerViewFocus::Transport => ArrangerStatusBar::Transport,
|
||||||
ArrangerViewFocus::Transport => ArrangerStatusBar::Transport,
|
ArrangerViewFocus::Arranger => match state.app.selected {
|
||||||
ArrangerViewFocus::Arranger => match state.selected {
|
ArrangerFocus::Mix => ArrangerStatusBar::ArrangerMix,
|
||||||
ArrangerFocus::Mix => ArrangerStatusBar::ArrangerMix,
|
ArrangerFocus::Track(_) => ArrangerStatusBar::ArrangerTrack,
|
||||||
ArrangerFocus::Track(_) => ArrangerStatusBar::ArrangerTrack,
|
ArrangerFocus::Scene(_) => ArrangerStatusBar::ArrangerScene,
|
||||||
ArrangerFocus::Scene(_) => ArrangerStatusBar::ArrangerScene,
|
ArrangerFocus::Clip(_, _) => ArrangerStatusBar::ArrangerClip,
|
||||||
ArrangerFocus::Clip(_, _) => ArrangerStatusBar::ArrangerClip,
|
},
|
||||||
},
|
ArrangerViewFocus::PhrasePool => ArrangerStatusBar::PhrasePool,
|
||||||
ArrangerViewFocus::PhrasePool => ArrangerStatusBar::PhrasePool,
|
ArrangerViewFocus::PhraseEditor => match state.app.sequencer.editor.entered {
|
||||||
ArrangerViewFocus::PhraseEditor => match state.sequencer.editor.entered {
|
true => ArrangerStatusBar::PhraseEdit,
|
||||||
true => ArrangerStatusBar::PhraseEdit,
|
false => ArrangerStatusBar::PhraseView,
|
||||||
false => ArrangerStatusBar::PhraseView,
|
},
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ impl FocusGrid for AppView<Tui, ArrangerView<Tui>, ArrangerViewCommand> {
|
||||||
self.app.sequencer.transport.focused = focused == Content(Transport);
|
self.app.sequencer.transport.focused = focused == Content(Transport);
|
||||||
self.app.sequencer.phrases.focused = focused == Content(PhrasePool);
|
self.app.sequencer.phrases.focused = focused == Content(PhrasePool);
|
||||||
self.app.sequencer.editor.focused = focused == Content(PhraseEditor);
|
self.app.sequencer.editor.focused = focused == Content(PhraseEditor);
|
||||||
|
if let Some(status_bar) = self.status_bar {
|
||||||
|
status_bar.update(&self.app)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,10 @@ impl Handle<Tui> for SequencerView<Tui> {
|
||||||
impl<E: Engine> Command<SequencerView<E>> for SequencerViewCommand {
|
impl<E: Engine> Command<SequencerView<E>> for SequencerViewCommand {
|
||||||
fn execute (self, state: &mut SequencerView<E>) -> Perhaps<Self> {
|
fn execute (self, state: &mut SequencerView<E>) -> Perhaps<Self> {
|
||||||
match self {
|
match self {
|
||||||
Self::Focus(cmd) =>
|
Self::Focus(cmd) => delegate(cmd, Self::Focus, state),
|
||||||
delegate(cmd, Self::Focus, state),
|
Self::Phrases(cmd) => delegate(cmd, Self::Phrases, &mut state.phrases),
|
||||||
Self::Phrases(cmd) =>
|
Self::Editor(cmd) => delegate(cmd, Self::Editor, &mut state.editor),
|
||||||
delegate(cmd, Self::Phrases, &mut state.phrases),
|
Self::Transport(cmd) => delegate(cmd, Self::Transport, &mut state.transport)
|
||||||
Self::Editor(cmd) =>
|
|
||||||
delegate(cmd, Self::Editor, &mut state.editor),
|
|
||||||
Self::Transport(cmd) =>
|
|
||||||
delegate(cmd, Self::Transport, &mut state.transport)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,33 +52,3 @@ impl FocusGrid for AppView<Tui, SequencerView<Tui>, SequencerViewCommand> {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///// Focus layout of sequencer app
|
|
||||||
//impl<E: Engine> FocusGrid for SequencerView<E> {
|
|
||||||
//type Item = SequencerFocus;
|
|
||||||
//fn cursor (&self) -> (usize, usize) {
|
|
||||||
//self.cursor
|
|
||||||
//}
|
|
||||||
//fn cursor_mut (&mut self) -> &mut (usize, usize) {
|
|
||||||
//&mut self.cursor
|
|
||||||
//}
|
|
||||||
//fn layout (&self) -> &[&[SequencerFocus]] { &[
|
|
||||||
//&[SequencerFocus::Transport],
|
|
||||||
//&[SequencerFocus::PhrasePool, SequencerFocus::PhraseEditor],
|
|
||||||
//] }
|
|
||||||
//fn focus_enter (&mut self) {
|
|
||||||
//self.entered = true
|
|
||||||
//}
|
|
||||||
//fn focus_exit (&mut self) {
|
|
||||||
//self.entered = false
|
|
||||||
//}
|
|
||||||
//fn entered (&self) -> Option<Self::Item> {
|
|
||||||
//if self.entered { Some(self.focused()) } else { None }
|
|
||||||
//}
|
|
||||||
//fn update_focus (&mut self) {
|
|
||||||
//let focused = self.focused();
|
|
||||||
//self.transport.focused = focused == SequencerFocus::Transport;
|
|
||||||
//self.phrases.focused = focused == SequencerFocus::PhrasePool;
|
|
||||||
//self.editor.focused = focused == SequencerFocus::PhraseEditor;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,50 @@ pub enum TransportViewFocus {
|
||||||
Clock,
|
Clock,
|
||||||
Quant,
|
Quant,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FocusGrid for AppView<Tui, TransportView<Tui>, TransportViewCommand> {
|
||||||
|
type Item = AppViewFocus<TransportViewFocus>;
|
||||||
|
fn cursor (&self) -> (usize, usize) {
|
||||||
|
self.cursor
|
||||||
|
}
|
||||||
|
fn cursor_mut (&mut self) -> &mut (usize, usize) {
|
||||||
|
&mut self.cursor
|
||||||
|
}
|
||||||
|
fn focus_enter (&mut self) {
|
||||||
|
let focused = self.focused();
|
||||||
|
if !self.entered {
|
||||||
|
self.entered = true;
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn focus_exit (&mut self) {
|
||||||
|
if self.entered {
|
||||||
|
self.entered = false;
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn entered (&self) -> Option<Self::Item> {
|
||||||
|
if self.entered {
|
||||||
|
Some(self.focused())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn layout (&self) -> &[&[Self::Item]] {
|
||||||
|
use AppViewFocus::*;
|
||||||
|
use TransportViewFocus::*;
|
||||||
|
&[
|
||||||
|
&[Menu],
|
||||||
|
&[
|
||||||
|
Content(Bpm),
|
||||||
|
Content(Sync),
|
||||||
|
Content(PlayPause),
|
||||||
|
Content(Clock),
|
||||||
|
Content(Quant),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
fn update_focus (&mut self) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue