mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
wip: axis bindings
This commit is contained in:
parent
767f917302
commit
057d09cfdf
9 changed files with 205 additions and 95 deletions
|
|
@ -86,8 +86,8 @@ pub struct Views(pub Arc<RwLock<BTreeMap<
|
|||
|
||||
impl Views {
|
||||
/// Load custom view definition.
|
||||
pub fn add <'a> (views: &Views, expr: impl Language) -> UsuallyRef<'a, ()> {
|
||||
views.0.write().insert(
|
||||
pub fn add <'a> (&self, expr: impl Language) -> UsuallyRef<'a, ()> {
|
||||
self.0.write().insert(
|
||||
expr.head()?.ok_or("view: missing name")?.into(),
|
||||
View::new(expr.tail()?.ok_or("view: missing body")?)?.into()
|
||||
);
|
||||
|
|
@ -373,6 +373,7 @@ impl View<Tui, App> {
|
|||
Some("Beat") => view!(),
|
||||
Some("Bpm") => view!(),
|
||||
Some("BrowseTitle") => view!(|app|view_browse_title(app)),
|
||||
Some("Config") => view!(|app|view_config(app)),
|
||||
Some("Debug") => Box::new(move|_, to|format!("[{:?}]", to.area()).exact_h(1).draw(to)),
|
||||
Some("Device") => view!(|app|view_device(app)),
|
||||
Some("Menu") => view!(|app|view_menu(app)),
|
||||
|
|
@ -381,6 +382,7 @@ impl View<Tui, App> {
|
|||
Some("MetersOut") => view!(|___|bg(Rgb(30, 30, 30), "Output Meters".align_s().full_h())),
|
||||
Some("ModeList") => view!(|app|view_modes(app)),
|
||||
Some("HistoryCount") => view!(|app|app.history.len()),
|
||||
Some("HistoryList") => view!(|app|view_history_list(app)),
|
||||
Some("ScenesClips") => view!(|app|view_scenes_clips(app)),
|
||||
Some("ScenesNames") => view!(|app|app.view_scenes_names()),
|
||||
Some("Sessions") => view!(|___|view_sessions()),
|
||||
|
|
@ -426,6 +428,58 @@ pub fn view_menu (app: &App) -> impl Draw<Tui> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn view_history_list (app: &App) -> impl Draw<Tui> {
|
||||
above(
|
||||
Outer(true, Style::default().fg(Color::Rgb(0, 192, 0))),
|
||||
draw(|to: &mut Tui|{
|
||||
let area = to.area();
|
||||
let XYWH(x0, mut y0, w, h) = area;
|
||||
for (done, undo) in app.history.iter().rev() {
|
||||
to.clip(XYWH(x0 + 1, y0, w, 1), &|to|format!("{done:?}").draw(to))?;
|
||||
y0 += 1;
|
||||
}
|
||||
Ok(Some(area))
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_config (app: &App) -> impl Draw<Tui> {
|
||||
above(
|
||||
Outer(true, Style::default().fg(Color::Rgb(0, 192, 0))),
|
||||
draw(|to: &mut Tui|{
|
||||
let area = to.area();
|
||||
let XYWH(x0, mut y0, w, h) = area;
|
||||
for key in app.modes.read().iter().rev() {
|
||||
if let Some(mode) = app.config.modes.get(key) {
|
||||
to.clip(XYWH(x0 + 1, y0, w, 1), &|to|Split::East.bar(16, key, mode.info.get(0)).draw(to))?;
|
||||
y0 += 1;
|
||||
for bind in mode.keys.iter() {
|
||||
to.clip(XYWH(x0 + 3, y0, w, 1), &|to|bind.draw(to))?;
|
||||
y0 += 1;
|
||||
if let Some(bind) = app.config.binds.find(bind) {
|
||||
for (key, binding) in bind.0.iter() {
|
||||
to.clip(XYWH(x0 + 5, y0, 40, 1),
|
||||
&|to|Split::East.bar(20, format!("{:?}", key.0), "").draw(to))?;
|
||||
y0 += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
y0 += 1;
|
||||
}
|
||||
}
|
||||
//for (index, (key, mode)) in app.config.modes.0.read().iter().enumerate() {
|
||||
//to.clip(XYWH(x0, y0 + index as u16, w, 1), &|to|Split::East.bar(16,
|
||||
//key, mode.info.get(0),
|
||||
//).draw(to))?;
|
||||
//}
|
||||
Ok(Some(area))
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_config_mode (mode: &Mode) -> impl Draw<Tui> {
|
||||
}
|
||||
|
||||
/// ```
|
||||
/// let _ = tek::button_play_pause(true, true);
|
||||
/// let _ = tek::button_play_pause(true, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue