mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56: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;
|
||||
fn hotkey_fg () -> Color 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> (
|
||||
|
|
|
|||
|
|
@ -77,27 +77,25 @@ impl_focus!(SequencerTui SequencerFocus [
|
|||
]);
|
||||
|
||||
/// Status bar for sequencer app
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum SequencerStatusBar {
|
||||
Transport,
|
||||
PhrasePool,
|
||||
PhraseEditor,
|
||||
#[derive(Clone)]
|
||||
pub struct SequencerStatusBar {
|
||||
pub(crate) cpu: Option<String>
|
||||
}
|
||||
|
||||
impl StatusBar for SequencerStatusBar {
|
||||
type State = ();
|
||||
type State = SequencerTui;
|
||||
fn hotkey_fg () -> Color {
|
||||
TuiTheme::hotkey_fg()
|
||||
}
|
||||
fn update (&mut self, state: &()) {
|
||||
fn update (&mut self, state: &SequencerTui) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Content for SequencerStatusBar {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
todo!();
|
||||
""
|
||||
impl From<&SequencerTui> for SequencerStatusBar {
|
||||
fn from (state: &SequencerTui) -> Self {
|
||||
Self {
|
||||
cpu: state.perf.percentage().map(|cpu|format!("{cpu:.03}%"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::*;
|
|||
impl Content for SequencerTui {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
lay!(
|
||||
SequencerStatusBar::with(self, lay!(
|
||||
col!(
|
||||
TransportView::from(self),
|
||||
Split::right(20,
|
||||
|
|
@ -11,10 +11,13 @@ impl Content for SequencerTui {
|
|||
widget(&PhraseView2::from(self)),
|
||||
).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