mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-02-01 00:36:40 +01:00
down to 3 errors
This commit is contained in:
parent
ebdb8881e9
commit
8df49850ae
7 changed files with 84 additions and 81 deletions
|
|
@ -1,40 +1,17 @@
|
|||
use crate::*;
|
||||
|
||||
impl<T: Has<Selection>> HasSelection for T {}
|
||||
impl<T: Has<Option<Selection>>> HasSelection for T {}
|
||||
|
||||
pub trait HasSelection: Has<Selection> {
|
||||
fn selection (&self) -> &Selection {
|
||||
self.get()
|
||||
pub trait HasSelection: Has<Option<Selection>> {
|
||||
fn selection (&self) -> Option<&Selection> {
|
||||
self.get().as_ref()
|
||||
}
|
||||
fn selection_mut (&mut self) -> &mut Selection {
|
||||
fn selection_mut (&mut self) -> &mut Option<Selection> {
|
||||
self.get_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Has<Option<Track>> for Arrangement {
|
||||
fn get (&self) -> &Option<Track> {
|
||||
let selection: Selection = Has::<Option<Track>>::get(self)?;
|
||||
let index: Option<usize> = selection.track()?;
|
||||
let track: Track = Has::<Vec<Track>>::get(self).get(index)?;
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Track> {
|
||||
Has::<Option<Selection>>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Track>>::get_mut(self).get_mut(index))
|
||||
}
|
||||
}
|
||||
|
||||
impl Has<Option<Scene>> for Arrangement {
|
||||
fn get (&self) -> &Option<Scene> {
|
||||
Has::<Option<Selection>>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get(self).get(index))
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Scene> {
|
||||
Has::<Option<Selection>>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get_mut(self).get_mut(index).as_deref())
|
||||
}
|
||||
impl Arrangement {
|
||||
}
|
||||
|
||||
/// Represents the current user selection in the arranger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue