mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
move cpu indicator into status bar
This commit is contained in:
parent
935b5b7720
commit
b2386b2992
3 changed files with 26 additions and 19 deletions
|
|
@ -293,7 +293,7 @@ pub trait FocusWrap<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait StatusBar: Copy + Widget<Engine = Tui> {
|
pub trait StatusBar: Widget<Engine = Tui> {
|
||||||
type State;
|
type State;
|
||||||
fn hotkey_fg () -> Color where Self: Sized;
|
fn hotkey_fg () -> Color where Self: Sized;
|
||||||
fn update (&mut self, state: &Self::State) where Self: Sized;
|
fn update (&mut self, state: &Self::State) where Self: Sized;
|
||||||
|
|
@ -314,6 +314,12 @@ pub trait StatusBar: Copy + Widget<Engine = Tui> {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn with <'a> (state: &'a Self::State, content: impl Widget<Engine=Tui>) -> impl Widget<Engine=Tui>
|
||||||
|
where Self: Sized, &'a Self::State: Into<Self>
|
||||||
|
{
|
||||||
|
Split::up(1, state.into(), content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content_with_menu_and_status <'a, A, S, C> (
|
fn content_with_menu_and_status <'a, A, S, C> (
|
||||||
|
|
|
||||||
|
|
@ -77,27 +77,25 @@ impl_focus!(SequencerTui SequencerFocus [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/// Status bar for sequencer app
|
/// Status bar for sequencer app
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Clone)]
|
||||||
pub enum SequencerStatusBar {
|
pub struct SequencerStatusBar {
|
||||||
Transport,
|
pub(crate) cpu: Option<String>
|
||||||
PhrasePool,
|
|
||||||
PhraseEditor,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusBar for SequencerStatusBar {
|
impl StatusBar for SequencerStatusBar {
|
||||||
type State = ();
|
type State = SequencerTui;
|
||||||
fn hotkey_fg () -> Color {
|
fn hotkey_fg () -> Color {
|
||||||
TuiTheme::hotkey_fg()
|
TuiTheme::hotkey_fg()
|
||||||
}
|
}
|
||||||
fn update (&mut self, state: &()) {
|
fn update (&mut self, state: &SequencerTui) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content for SequencerStatusBar {
|
impl From<&SequencerTui> for SequencerStatusBar {
|
||||||
type Engine = Tui;
|
fn from (state: &SequencerTui) -> Self {
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
Self {
|
||||||
todo!();
|
cpu: state.perf.percentage().map(|cpu|format!("{cpu:.03}%"))
|
||||||
""
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::*;
|
||||||
impl Content for SequencerTui {
|
impl Content for SequencerTui {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
lay!(
|
SequencerStatusBar::with(self, lay!(
|
||||||
col!(
|
col!(
|
||||||
TransportView::from(self),
|
TransportView::from(self),
|
||||||
Split::right(20,
|
Split::right(20,
|
||||||
|
|
@ -11,10 +11,13 @@ impl Content for SequencerTui {
|
||||||
widget(&PhraseView2::from(self)),
|
widget(&PhraseView2::from(self)),
|
||||||
).min_y(20)
|
).min_y(20)
|
||||||
),
|
),
|
||||||
self.perf.percentage()
|
))
|
||||||
.map(|cpu|format!("{cpu:.03}%"))
|
}
|
||||||
.fg(Color::Rgb(255,128,0))
|
}
|
||||||
.align_sw(),
|
|
||||||
)
|
impl Content for SequencerStatusBar {
|
||||||
|
type Engine = Tui;
|
||||||
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
|
widget(&self.cpu).fg(Color::Rgb(255,128,0)).align_se().fill_x()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue