mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
scale grid rows; one/two still missing
This commit is contained in:
parent
9cd9131d5d
commit
ec81cbf2f1
3 changed files with 34 additions and 25 deletions
|
|
@ -135,14 +135,14 @@ impl<N: Number> Area<N> for [N;4] {
|
||||||
|
|
||||||
pub trait Layout<E: Engine>: Widget<Engine = E> + Sized {
|
pub trait Layout<E: Engine>: Widget<Engine = E> + Sized {
|
||||||
fn align_center (self) -> Align<Self> { Align::Center(self) }
|
fn align_center (self) -> Align<Self> { Align::Center(self) }
|
||||||
fn align_nw (self) -> Align<Self> { Align::NW(self) }
|
|
||||||
fn align_w (self) -> Align<Self> { Align::W(self) }
|
|
||||||
fn align_sw (self) -> Align<Self> { Align::SW(self) }
|
|
||||||
fn align_ne (self) -> Align<Self> { Align::NE(self) }
|
|
||||||
fn align_e (self) -> Align<Self> { Align::E(self) }
|
|
||||||
fn align_se (self) -> Align<Self> { Align::SE(self) }
|
|
||||||
fn align_n (self) -> Align<Self> { Align::N(self) }
|
fn align_n (self) -> Align<Self> { Align::N(self) }
|
||||||
fn align_s (self) -> Align<Self> { Align::S(self) }
|
fn align_s (self) -> Align<Self> { Align::S(self) }
|
||||||
|
fn align_e (self) -> Align<Self> { Align::E(self) }
|
||||||
|
fn align_w (self) -> Align<Self> { Align::W(self) }
|
||||||
|
fn align_nw (self) -> Align<Self> { Align::NW(self) }
|
||||||
|
fn align_sw (self) -> Align<Self> { Align::SW(self) }
|
||||||
|
fn align_ne (self) -> Align<Self> { Align::NE(self) }
|
||||||
|
fn align_se (self) -> Align<Self> { Align::SE(self) }
|
||||||
fn align_x (self) -> Align<Self> { Align::X(self) }
|
fn align_x (self) -> Align<Self> { Align::X(self) }
|
||||||
fn align_y (self) -> Align<Self> { Align::Y(self) }
|
fn align_y (self) -> Align<Self> { Align::Y(self) }
|
||||||
fn fixed_x (self, x: E::Unit) -> Fixed<E::Unit, Self> { Fixed::X(x, self) }
|
fn fixed_x (self, x: E::Unit) -> Fixed<E::Unit, Self> { Fixed::X(x, self) }
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ pub struct ArrangementTrack<E: Engine> {
|
||||||
/// Identifying color of track
|
/// Identifying color of track
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
}
|
}
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
pub struct Scene {
|
pub struct Scene {
|
||||||
/// Name of scene
|
/// Name of scene
|
||||||
pub name: Arc<RwLock<String>>,
|
pub name: Arc<RwLock<String>>,
|
||||||
|
|
@ -251,7 +251,9 @@ impl<E: Engine> Arrangement<E> {
|
||||||
ArrangementFocus::Track(_) => self.track_width_inc(),
|
ArrangementFocus::Track(_) => self.track_width_inc(),
|
||||||
ArrangementFocus::Scene(_) => self.scene_next(),
|
ArrangementFocus::Scene(_) => self.scene_next(),
|
||||||
ArrangementFocus::Clip(_, _) => self.phrase_next(),
|
ArrangementFocus::Clip(_, _) => self.phrase_next(),
|
||||||
_ => {}
|
ArrangementFocus::Mix => if let ArrangementViewMode::Vertical(factor) = self.mode {
|
||||||
|
self.mode = ArrangementViewMode::Vertical(factor + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn decrement (&mut self) {
|
pub fn decrement (&mut self) {
|
||||||
|
|
@ -259,7 +261,9 @@ impl<E: Engine> Arrangement<E> {
|
||||||
ArrangementFocus::Track(_) => self.track_width_dec(),
|
ArrangementFocus::Track(_) => self.track_width_dec(),
|
||||||
ArrangementFocus::Scene(_) => self.scene_prev(),
|
ArrangementFocus::Scene(_) => self.scene_prev(),
|
||||||
ArrangementFocus::Clip(_, _) => self.phrase_prev(),
|
ArrangementFocus::Clip(_, _) => self.phrase_prev(),
|
||||||
_ => {}
|
ArrangementFocus::Mix => if let ArrangementViewMode::Vertical(factor) = self.mode {
|
||||||
|
self.mode = ArrangementViewMode::Vertical(factor.saturating_sub(1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn is_first_row (&self) -> bool {
|
pub fn is_first_row (&self) -> bool {
|
||||||
|
|
@ -675,15 +679,22 @@ impl Scene {
|
||||||
None => true
|
None => true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn ppqs (scenes: &[Self]) -> Vec<(usize, usize)> {
|
pub fn ppqs (scenes: &[Self], factor: usize) -> Vec<(usize, usize)> {
|
||||||
let mut total = 0;
|
let mut total = 0;
|
||||||
let mut scenes: Vec<(usize, usize)> = scenes.iter().map(|scene|{
|
if factor == 0 {
|
||||||
let pulses = scene.pulses().max(PPQ);
|
let mut scenes: Vec<(usize, usize)> = scenes.iter().map(|scene|{
|
||||||
total = total + pulses;
|
let pulses = scene.pulses().max(PPQ);
|
||||||
(pulses, total - pulses)
|
total = total + pulses;
|
||||||
}).collect();
|
(pulses, total - pulses)
|
||||||
scenes.push((0, total));
|
}).collect();
|
||||||
scenes
|
scenes.push((0, total));
|
||||||
|
scenes
|
||||||
|
} else {
|
||||||
|
let scenes: Vec<(usize, usize)> = (0..=scenes.len()).map(|i|{
|
||||||
|
(factor*PPQ, factor*PPQ*i)
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
scenes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn longest_name (scenes: &[Self]) -> usize {
|
pub fn longest_name (scenes: &[Self]) -> usize {
|
||||||
scenes.iter()
|
scenes.iter()
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ impl Content for ArrangerStatusBar {
|
||||||
.bold(true);
|
.bold(true);
|
||||||
let commands = match self {
|
let commands = match self {
|
||||||
Self::ArrangementMix => command(&[
|
Self::ArrangementMix => command(&[
|
||||||
|
["", ",.", "scale rows"],
|
||||||
["", "<>", "resize view"],
|
["", "<>", "resize view"],
|
||||||
]),
|
]),
|
||||||
Self::ArrangementClip => command(&[
|
Self::ArrangementClip => command(&[
|
||||||
|
|
@ -116,14 +117,11 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let Self(state, factor) = self;
|
let Self(state, factor) = self;
|
||||||
let cols = state.track_widths();
|
let cols = state.track_widths();
|
||||||
let rows = if *factor == 0 {
|
let rows = Scene::ppqs(state.scenes.as_slice(), *factor);
|
||||||
Scene::ppqs(state.scenes.as_slice())
|
let tracks = state.tracks.as_ref() as &[ArrangementTrack<Tui>];
|
||||||
} else {
|
let scenes = state.scenes.as_ref();
|
||||||
(0..=state.scenes.len()).map(|i|(factor*PPQ, factor*PPQ*i)).collect::<Vec<_>>()
|
//panic!("{scenes:#?} {rows:#?}");
|
||||||
};
|
|
||||||
let tracks: &[ArrangementTrack<Tui>] = state.tracks.as_ref();
|
|
||||||
let scenes: &[Scene] = state.scenes.as_ref();
|
|
||||||
let offset = 3 + Scene::longest_name(scenes) as u16; // x of 1st track
|
let offset = 3 + Scene::longest_name(scenes) as u16; // x of 1st track
|
||||||
let bg = state.color;
|
let bg = state.color;
|
||||||
let clip_bg = Color::Rgb(40, 50, 30);
|
let clip_bg = Color::Rgb(40, 50, 30);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue