switch around ownership of pool and editort

This commit is contained in:
🪞👃🪞 2025-05-17 13:23:31 +03:00
parent 3f1a2fee80
commit c7e7c9f68c
8 changed files with 157 additions and 150 deletions

View file

@ -103,12 +103,24 @@ impl MidiViewer for MidiEditor {
fn set_clip (&mut self, p: Option<&Arc<RwLock<MidiClip>>>) { self.mode.set_clip(p) }
}
pub trait HasEditor {
fn editor (&self) -> Option<&MidiEditor>;
fn editor_mut (&mut self) -> Option<&mut MidiEditor>;
fn is_editing (&self) -> bool { self.editor().is_some() }
fn editor_w (&self) -> usize { 0 }
fn editor_h (&self) -> usize { 0 }
impl<T: Has<Option<MidiEditor>>> HasEditor for T {}
pub trait HasEditor: Has<Option<MidiEditor>> {
fn editor (&self) -> Option<&MidiEditor> {
self.get().as_ref()
}
fn editor_mut (&mut self) -> Option<&mut MidiEditor> {
self.get_mut().as_mut()
}
fn is_editing (&self) -> bool {
self.editor().is_some()
}
fn editor_w (&self) -> usize {
self.editor().map(|e|e.size.w()).unwrap_or(0)
}
fn editor_h (&self) -> usize {
self.editor().map(|e|e.size.h()).unwrap_or(0)
}
}
#[macro_export] macro_rules! has_editor {