mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
rename some view structs
This commit is contained in:
parent
b2386b2992
commit
83e2a285dd
4 changed files with 17 additions and 19 deletions
|
|
@ -35,8 +35,8 @@ impl Content for ArrangerTui {
|
||||||
),
|
),
|
||||||
Split::right(
|
Split::right(
|
||||||
self.splits[1],
|
self.splits[1],
|
||||||
PhrasesView(self),
|
PhraseListView(self),
|
||||||
PhraseView2::from(self),
|
PhraseView::from(self),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub struct PhraseView2<'a> {
|
pub struct PhraseView<'a> {
|
||||||
pub(crate) focused: bool,
|
pub(crate) focused: bool,
|
||||||
pub(crate) entered: bool,
|
pub(crate) entered: bool,
|
||||||
pub(crate) phrase: &'a Option<Arc<RwLock<Phrase>>>,
|
pub(crate) phrase: &'a Option<Arc<RwLock<Phrase>>>,
|
||||||
|
|
@ -13,7 +13,7 @@ pub struct PhraseView2<'a> {
|
||||||
pub(crate) now: &'a Arc<Pulse>,
|
pub(crate) now: &'a Arc<Pulse>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: HasEditor> From<&'a T> for PhraseView2<'a> {
|
impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> {
|
||||||
fn from (state: &'a T) -> Self {
|
fn from (state: &'a T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
focused: state.editor_focused(),
|
focused: state.editor_focused(),
|
||||||
|
|
@ -30,7 +30,7 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView2<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Content for PhraseView2<'a> {
|
impl<'a> Content for PhraseView<'a> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self {
|
let Self {
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@ use crate::*;
|
||||||
impl Widget for PhrasesModel {
|
impl Widget for PhrasesModel {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||||
PhrasesView(self).layout(to)
|
PhraseListView(self).layout(to)
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||||
PhrasesView(self).render(to)
|
PhraseListView(self).render(to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PhrasesView<'a, T: PhrasesViewState>(pub &'a T);
|
pub struct PhraseListView<'a, T: PhraseListViewState>(pub &'a T);
|
||||||
|
|
||||||
// TODO: Display phrases always in order of appearance
|
// TODO: Display phrases always in order of appearance
|
||||||
impl<'a, T: PhrasesViewState> Content for PhrasesView<'a, T> {
|
impl<'a, T: PhraseListViewState> Content for PhraseListView<'a, T> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let focused = self.0.phrases_focused();
|
let focused = self.0.phrases_focused();
|
||||||
|
|
@ -72,7 +72,7 @@ impl<'a, T: PhrasesViewState> Content for PhrasesView<'a, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PhrasesViewState: Send + Sync {
|
pub trait PhraseListViewState: Send + Sync {
|
||||||
fn phrases_focused (&self) -> bool;
|
fn phrases_focused (&self) -> bool;
|
||||||
fn phrases_entered (&self) -> bool;
|
fn phrases_entered (&self) -> bool;
|
||||||
fn phrases (&self) -> &Vec<Arc<RwLock<Phrase>>>;
|
fn phrases (&self) -> &Vec<Arc<RwLock<Phrase>>>;
|
||||||
|
|
@ -82,7 +82,7 @@ pub trait PhrasesViewState: Send + Sync {
|
||||||
|
|
||||||
macro_rules! impl_phrases_view_state {
|
macro_rules! impl_phrases_view_state {
|
||||||
($Struct:ident $(:: $field:ident)* [$self1:ident: $focus:expr] [$self2:ident: $enter:expr]) => {
|
($Struct:ident $(:: $field:ident)* [$self1:ident: $focus:expr] [$self2:ident: $enter:expr]) => {
|
||||||
impl PhrasesViewState for $Struct {
|
impl PhraseListViewState for $Struct {
|
||||||
fn phrases_focused (&$self1) -> bool {
|
fn phrases_focused (&$self1) -> bool {
|
||||||
$focus
|
$focus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@ 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> {
|
||||||
SequencerStatusBar::with(self, lay!(
|
SequencerStatusBar::with(self, col!(
|
||||||
col!(
|
TransportView::from(self),
|
||||||
TransportView::from(self),
|
Split::right(20,
|
||||||
Split::right(20,
|
PhraseListView(self),
|
||||||
widget(&PhrasesView(self)),
|
PhraseView::from(self),
|
||||||
widget(&PhraseView2::from(self)),
|
).min_y(20)
|
||||||
).min_y(20)
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue