mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
somehow it is now aligned
This commit is contained in:
parent
d9f1875c03
commit
ba0ff4af98
5 changed files with 49 additions and 40 deletions
|
|
@ -75,6 +75,13 @@ fn match_exp <'a, E: Output + 'a, State: EdnViewData<E>> (
|
||||||
) -> Box<dyn Render<E> + 'a> {
|
) -> Box<dyn Render<E> + 'a> {
|
||||||
match (head, tail) {
|
match (head, tail) {
|
||||||
|
|
||||||
|
(Key("when"), [c, a]) => When(s.get_bool(c.to_ref()),
|
||||||
|
s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
|
(Key("either"),[c, a, b]) => Either(s.get_bool(c.to_ref()),
|
||||||
|
s.get_content(a.to_ref()),
|
||||||
|
s.get_content(b.to_ref())).boxed(),
|
||||||
|
|
||||||
(Key("align/c"), [a]) => Align::c(s.get_content(a.to_ref())).boxed(),
|
(Key("align/c"), [a]) => Align::c(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
|
(Key("align/x"), [a]) => Align::x(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("align/y"), [a]) => Align::y(s.get_content(a.to_ref())).boxed(),
|
(Key("align/y"), [a]) => Align::y(s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
@ -94,12 +101,12 @@ fn match_exp <'a, E: Output + 'a, State: EdnViewData<E>> (
|
||||||
(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
|
(Key("bsp/s"), [a, b]) => Bsp::s(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
|
||||||
(Key("bsp/w"), [a, b]) => Bsp::w(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
|
(Key("bsp/w"), [a, b]) => Bsp::w(s.get_content(a.to_ref()), s.get_content(b.to_ref()),).boxed(),
|
||||||
|
|
||||||
(Key("fill/x"), [a]) => Fill::x(s.get_content(a.to_ref())).boxed(),
|
(Key("fill/x"), [a]) => Fill::x(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("fill/y"), [a]) => Fill::y(s.get_content(a.to_ref())).boxed(),
|
(Key("fill/y"), [a]) => Fill::y(s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("fill/xy"), [a]) => Fill::xy(s.get_content(a.to_ref())).boxed(),
|
(Key("fill/xy"), [a]) => Fill::xy(s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
(Key("fixed/x"), [x, a]) => Fixed::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("fixed/x"), [x, a]) => Fixed::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("fixed/y"), [y, a]) => Fixed::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("fixed/y"), [y, a]) => Fixed::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("fixed/xy"), [x, y, a]) => Fixed::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("fixed/xy"), [x, y, a]) => Fixed::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
(Key("max/x"), [x, a]) => Max::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("max/x"), [x, a]) => Max::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
@ -108,7 +115,13 @@ fn match_exp <'a, E: Output + 'a, State: EdnViewData<E>> (
|
||||||
(Key("push/x"), [x, a]) => Push::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("push/x"), [x, a]) => Push::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
(Key("push/y"), [y, a]) => Push::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("push/y"), [y, a]) => Push::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
(Key("when"), [c, a]) => When(s.get_bool(c.to_ref()), s.get_content(a.to_ref())).boxed(),
|
(Key("pad/x"), [x, a]) => Padding::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
(Key("pad/y"), [y, a]) => Padding::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
(Key("pad/xy"), [x, y, a]) => Padding::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
|
(Key("grow/x"), [x, a]) => Margin::x(s.get_unit(x.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
(Key("grow/y"), [y, a]) => Margin::y(s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
(Key("grow/xy"), [x, y, a]) => Margin::xy(s.get_unit(x.to_ref()), s.get_unit(y.to_ref()), s.get_content(a.to_ref())).boxed(),
|
||||||
|
|
||||||
_ => todo!("{:?} {:?}", &head, &tail)
|
_ => todo!("{:?} {:?}", &head, &tail)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ const EDN: &'static [&'static str] = &[
|
||||||
include_str!("edn10.edn"),
|
include_str!("edn10.edn"),
|
||||||
include_str!("edn11.edn"),
|
include_str!("edn11.edn"),
|
||||||
include_str!("edn12.edn"),
|
include_str!("edn12.edn"),
|
||||||
|
include_str!("edn13.edn"),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn main () -> Usually<()> {
|
fn main () -> Usually<()> {
|
||||||
|
|
|
||||||
11
tek/examples/edn13.edn
Normal file
11
tek/examples/edn13.edn
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
(bsp/s
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/nw :hello)))
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/n :hello)))
|
||||||
|
(grow/xy 1 1 (fixed/xy 8 5 (align/ne :hello)))))
|
||||||
|
(bsp/s
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/w :hello)))
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/c :hello)))
|
||||||
|
(grow/xy 1 1 (fixed/xy 8 5 (align/e :hello)))))
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/sw :hello)))
|
||||||
|
(bsp/e (grow/xy 1 1 (fixed/xy 8 5 (align/s :hello)))
|
||||||
|
(grow/xy 1 1 (fixed/xy 8 5 (align/se :hello)))))))
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
(bsp/s :toolbar
|
(bsp/s :toolbar
|
||||||
(fill/x (align/c (bsp/w :pool
|
(bsp/w :pool (fill/x (align/c
|
||||||
(bsp/n :outputs (bsp/n :inputs (bsp/n :tracks :scenes)))))))
|
(bsp/s :outputs (bsp/s :inputs (bsp/s :tracks :scenes)))))))
|
||||||
|
|
|
||||||
|
|
@ -309,28 +309,24 @@ impl Arranger {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scene_row (&self, tracks_w: u16) -> impl Content<TuiOut> + '_ {
|
fn scene_row (&self, tracks_w: u16) -> impl Content<TuiOut> + '_ {
|
||||||
let h = self.size.h() as u16;
|
let h = (self.size.h() as u16).saturating_sub(8).max(8);
|
||||||
let border = |x|Skinny(Style::default().fg(Color::Rgb(0,0,0)).bg(Color::Reset)).enclose2(x);
|
let border = |x|Skinny(Style::default().fg(Color::Rgb(0,0,0)).bg(Color::Reset)).enclose2(x);
|
||||||
Fill::y(Bsp::e(
|
Bsp::e(
|
||||||
Tui::bg(Color::Reset, Fixed::x(self.sidebar_w() as u16, self.scene_headers())),
|
Tui::bg(Color::Reset, Fixed::xy(self.sidebar_w() as u16, h, self.scene_headers())),
|
||||||
Tui::bg(Color::Reset, Fill::x(Align::c(Fixed::xy(tracks_w, h, border(self.scene_cells())))))
|
Tui::bg(Color::Reset, Fill::x(Align::c(Fixed::xy(tracks_w, h, border(self.scene_cells())))))
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
fn scene_headers <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
fn scene_headers <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
||||||
(||{
|
(||{
|
||||||
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
|
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
|
||||||
let selected_scene = match self.selected {
|
let selected = self.selected.scene();
|
||||||
ArrangerSelection::Scene(s) => Some(s),
|
|
||||||
_ => None
|
|
||||||
};
|
|
||||||
Fill::y(Align::c(Map::new(||self.scenes_with_sizes(2), move|(_, scene, y1, y2), i| {
|
Fill::y(Align::c(Map::new(||self.scenes_with_sizes(2), move|(_, scene, y1, y2), i| {
|
||||||
let h = (y2 - y1) as u16;
|
let h = (y2 - y1) as u16;
|
||||||
let name = format!("🭬{}", &scene.name);
|
let name = format!("🭬{}", &scene.name);
|
||||||
let color = scene.color();
|
let color = scene.color();
|
||||||
let top = (selected_scene.map(|s|s + 1) == Some(i))
|
let active = selected == Some(i);
|
||||||
.then(||last_color.read().unwrap().base.rgb);
|
|
||||||
let active = selected_scene == Some(i);
|
|
||||||
let mid = if active { color.light } else { color.base };
|
let mid = if active { color.light } else { color.base };
|
||||||
|
let top = Some(last_color.read().unwrap().base.rgb);
|
||||||
let cell = phat_sel_3(
|
let cell = phat_sel_3(
|
||||||
active,
|
active,
|
||||||
Tui::bold(true, name.clone()),
|
Tui::bold(true, name.clone()),
|
||||||
|
|
@ -346,12 +342,10 @@ impl Arranger {
|
||||||
}
|
}
|
||||||
fn scene_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
fn scene_cells <'a> (&'a self) -> BoxThunk<'a, TuiOut> {
|
||||||
let editing = self.is_editing();
|
let editing = self.is_editing();
|
||||||
let (selected_track, selected_scene) = match self.selected {
|
let tracks = move||self.tracks_with_sizes();
|
||||||
ArrangerSelection::Clip(t, s) => (Some(t), Some(s)),
|
let scenes = ||self.scenes_with_sizes(2);
|
||||||
_ => (None, None)
|
let selected_track = self.selected.track();
|
||||||
};
|
let selected_scene = self.selected.scene();
|
||||||
let tracks = move||self.tracks_with_sizes();
|
|
||||||
let scenes = ||self.scenes_with_sizes(2);
|
|
||||||
(move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
|
(move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
|
||||||
let w = (x2 - x1) as u16;
|
let w = (x2 - x1) as u16;
|
||||||
let color: ItemPalette = track.color().dark.into();
|
let color: ItemPalette = track.color().dark.into();
|
||||||
|
|
@ -391,7 +385,7 @@ impl Arranger {
|
||||||
map_south(
|
map_south(
|
||||||
y1 as u16,
|
y1 as u16,
|
||||||
h + 1,
|
h + 1,
|
||||||
Fill::x(cell)
|
Fill::x(Fixed::y(h + 1, cell))
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let column = Fixed::x(w, Tui::bg(Color::Reset, Align::y(cells)).boxed());
|
let column = Fixed::x(w, Tui::bg(Color::Reset, Align::y(cells)).boxed());
|
||||||
|
|
@ -654,7 +648,6 @@ impl Arranger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)] pub enum ArrangerCommand {
|
#[derive(Clone, Debug)] pub enum ArrangerCommand {
|
||||||
History(isize),
|
History(isize),
|
||||||
Color(ItemPalette),
|
Color(ItemPalette),
|
||||||
|
|
@ -669,7 +662,6 @@ impl Arranger {
|
||||||
StopAll,
|
StopAll,
|
||||||
Clear,
|
Clear,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum ArrangerClipCommand {
|
pub enum ArrangerClipCommand {
|
||||||
Get(usize, usize),
|
Get(usize, usize),
|
||||||
|
|
@ -679,10 +671,6 @@ pub enum ArrangerClipCommand {
|
||||||
SetLoop(usize, usize, bool),
|
SetLoop(usize, usize, bool),
|
||||||
SetColor(usize, usize, ItemPalette),
|
SetColor(usize, usize, ItemPalette),
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle!(TuiIn: |self: Arranger, input|ArrangerCommand::execute_with_state(self, input.event()));
|
|
||||||
//input_to_command!(ArrangerCommand: |state: Arranger, input: Event|{KEYS_ARRANGER.handle(state, input)?});
|
|
||||||
|
|
||||||
keymap!(KEYS_ARRANGER = |state: Arranger, input: Event| ArrangerCommand {
|
keymap!(KEYS_ARRANGER = |state: Arranger, input: Event| ArrangerCommand {
|
||||||
key(Char('u')) => Cmd::History(-1),
|
key(Char('u')) => Cmd::History(-1),
|
||||||
key(Char('U')) => Cmd::History(1),
|
key(Char('U')) => Cmd::History(1),
|
||||||
|
|
@ -713,14 +701,10 @@ keymap!(KEYS_ARRANGER = |state: Arranger, input: Event| ArrangerCommand {
|
||||||
kpat!(Char('0')) => Some(Cmd::StopAll),
|
kpat!(Char('0')) => Some(Cmd::StopAll),
|
||||||
kpat!(Char('c')) => Some(Cmd::Color(ItemPalette::random())),
|
kpat!(Char('c')) => Some(Cmd::Color(ItemPalette::random())),
|
||||||
|
|
||||||
kpat!(Up) =>
|
kpat!(Up) => return None,
|
||||||
return None,
|
kpat!(Down) => Some( Cmd::Select(Selected::Scene(0))),
|
||||||
kpat!(Down) => Some(
|
kpat!(Left) => return None,
|
||||||
Cmd::Select(Selected::Scene(0))),
|
kpat!(Right) => Some( Cmd::Select(Selected::Track(0))),
|
||||||
kpat!(Left) =>
|
|
||||||
return None,
|
|
||||||
kpat!(Right) => Some(
|
|
||||||
Cmd::Select(Selected::Track(0))),
|
|
||||||
|
|
||||||
_ => None
|
_ => None
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue