mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +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 {
|
||||
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_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_y (self) -> Align<Self> { Align::Y(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
|
||||
pub color: Color,
|
||||
}
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Scene {
|
||||
/// Name of scene
|
||||
pub name: Arc<RwLock<String>>,
|
||||
|
|
@ -251,7 +251,9 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementFocus::Track(_) => self.track_width_inc(),
|
||||
ArrangementFocus::Scene(_) => self.scene_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) {
|
||||
|
|
@ -259,7 +261,9 @@ impl<E: Engine> Arrangement<E> {
|
|||
ArrangementFocus::Track(_) => self.track_width_dec(),
|
||||
ArrangementFocus::Scene(_) => self.scene_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 {
|
||||
|
|
@ -675,15 +679,22 @@ impl Scene {
|
|||
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 scenes: Vec<(usize, usize)> = scenes.iter().map(|scene|{
|
||||
let pulses = scene.pulses().max(PPQ);
|
||||
total = total + pulses;
|
||||
(pulses, total - pulses)
|
||||
}).collect();
|
||||
scenes.push((0, total));
|
||||
scenes
|
||||
if factor == 0 {
|
||||
let mut scenes: Vec<(usize, usize)> = scenes.iter().map(|scene|{
|
||||
let pulses = scene.pulses().max(PPQ);
|
||||
total = total + pulses;
|
||||
(pulses, total - pulses)
|
||||
}).collect();
|
||||
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 {
|
||||
scenes.iter()
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ impl Content for ArrangerStatusBar {
|
|||
.bold(true);
|
||||
let commands = match self {
|
||||
Self::ArrangementMix => command(&[
|
||||
["", ",.", "scale rows"],
|
||||
["", "<>", "resize view"],
|
||||
]),
|
||||
Self::ArrangementClip => command(&[
|
||||
|
|
@ -116,14 +117,11 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let Self(state, factor) = self;
|
||||
let cols = state.track_widths();
|
||||
let rows = if *factor == 0 {
|
||||
Scene::ppqs(state.scenes.as_slice())
|
||||
} else {
|
||||
(0..=state.scenes.len()).map(|i|(factor*PPQ, factor*PPQ*i)).collect::<Vec<_>>()
|
||||
};
|
||||
let tracks: &[ArrangementTrack<Tui>] = state.tracks.as_ref();
|
||||
let scenes: &[Scene] = state.scenes.as_ref();
|
||||
let cols = state.track_widths();
|
||||
let rows = Scene::ppqs(state.scenes.as_slice(), *factor);
|
||||
let tracks = state.tracks.as_ref() as &[ArrangementTrack<Tui>];
|
||||
let scenes = state.scenes.as_ref();
|
||||
//panic!("{scenes:#?} {rows:#?}");
|
||||
let offset = 3 + Scene::longest_name(scenes) as u16; // x of 1st track
|
||||
let bg = state.color;
|
||||
let clip_bg = Color::Rgb(40, 50, 30);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue