mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
implement has_size
This commit is contained in:
parent
aa8a1a3bd9
commit
c27a4a5232
3 changed files with 17 additions and 21 deletions
|
|
@ -4,19 +4,13 @@ pub trait HasSize<E: Engine> {
|
|||
fn size (&self) -> &Measure<E>;
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! implementor {
|
||||
($name:ident => $Trait:ident) => {
|
||||
#[macro_export] macro_rules! $name {
|
||||
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? $Trait for $Struct $(<$($L),*$($T),*>)? {
|
||||
fn clock (&$self) -> &ClockModel { $cb }
|
||||
#[macro_export] macro_rules! has_size {
|
||||
(<$E:ty>|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? HasSize<$E> for $Struct $(<$($L),*$($T),*>)? {
|
||||
fn size (&$self) -> &Measure<$E> { $cb } // TODO provide trait body
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
implementor!(has_size => HasSize);
|
||||
|
||||
impl<E: Engine> LayoutDebug<E> for E {}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ impl Default for PhraseEditorModel {
|
|||
|
||||
render!(|self: PhraseEditorModel|self.mode);
|
||||
|
||||
pub trait PhraseViewMode: Render<Tui> + MIDIRange + MIDIPoint + Debug + Send + Sync {
|
||||
pub trait PhraseViewMode: Render<Tui> + HasSize<Tui> + MIDIRange + MIDIPoint + Debug + Send + Sync {
|
||||
fn buffer_size (&self, phrase: &Phrase) -> (usize, usize);
|
||||
fn redraw (&mut self);
|
||||
fn phrase (&self) -> &Option<Arc<RwLock<Phrase>>>;
|
||||
|
|
@ -124,7 +124,7 @@ pub trait PhraseViewMode: Render<Tui> + MIDIRange + MIDIPoint + Debug + Send + S
|
|||
|
||||
impl MIDIViewport<Tui> for PhraseEditorModel {}
|
||||
|
||||
has_size!(|self:PhraseEditorModel|&self.size);
|
||||
has_size!(<Tui>|self:PhraseEditorModel|self.mode.size());
|
||||
|
||||
impl MIDIRange for PhraseEditorModel {
|
||||
fn time_zoom (&self) -> usize { self.mode.time_zoom() }
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ impl PianoHorizontal {
|
|||
}
|
||||
}
|
||||
|
||||
has_size!(<Tui>|self:PianoHorizontal|&self.size);
|
||||
|
||||
impl MIDIRange for PianoHorizontal {
|
||||
fn time_zoom (&self) -> usize { self.range.time_zoom() }
|
||||
fn set_time_zoom (&self, x: usize) { self.range.set_time_zoom(x); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue