feat: add per-fader display sizes
Persist slim, standard, and thick mixer densities and expose them through the guided fader editor. Render slim faders on one line and make mixer scrolling account for variable row heights. Tests: cargo fmt --all -- --check; cargo check --workspace --all-targets --all-features; cargo test --workspace --all-targets --all-features; cargo test --workspace --doc --all-features; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo build --workspace --release --all-features; default/no-default/backend feature checks.
This commit is contained in:
parent
e55ed59f5b
commit
bcba3e96eb
12
README.md
12
README.md
|
|
@ -49,11 +49,13 @@ The mixer is also the primary configuration surface. Shift+Up/Down reorders the
|
|||
selected fader or separator; A adds a separator; E edits a selected fader or
|
||||
separator; D removes a selected separator; and `h` hides a fader. Fader editing
|
||||
provides capture Field/Exact-or-Regex/Pattern controls, group membership and
|
||||
mode, separate Volume and Mute Learn/Unset actions, and visibility. The Config
|
||||
tab is a settings/status page: change the session theme, restore individual
|
||||
hidden faders, inspect backend and MIDI-device state, and apply or save the
|
||||
server-owned draft. The old `Shift+h` hidden-list mode and pipe-delimited object
|
||||
editors are no longer used.
|
||||
mode, separate Volume and Mute Learn/Unset actions, per-fader Size (`Slim`,
|
||||
`Standard`, or `Thick`), and visibility. Slim faders occupy one terminal row;
|
||||
Standard remains the compatible default. The Config tab is a settings/status
|
||||
page: change the session theme, restore individual hidden faders, inspect
|
||||
backend and MIDI-device state, and apply or save the server-owned draft. The
|
||||
old `Shift+h` hidden-list mode and pipe-delimited object editors are no longer
|
||||
used.
|
||||
|
||||
# References
|
||||
|
||||
|
|
|
|||
|
|
@ -401,7 +401,10 @@ hidden; hiding is presentation-only and never deletes the target, selectors,
|
|||
MIDI bindings, or saved state. Profiles without an explicit layout synthesize
|
||||
one visible entry for every declared fader in declaration order. Validation
|
||||
rejects duplicate layout IDs, duplicate fader references, and dangling fader
|
||||
references.
|
||||
references. Each fader layout entry also stores a `slim`, `standard`, or `thick`
|
||||
vertical density. Omitted density defaults to `standard` for existing profiles;
|
||||
`slim` is a single terminal row while the other modes retain progressively more
|
||||
vertical detail.
|
||||
|
||||
The selected main-list entry can be moved directly, and separators can be
|
||||
added, renamed, moved, or removed. Editing a fader presents domain fields
|
||||
|
|
@ -411,6 +414,7 @@ rather than a serialized command:
|
|||
faders instead present member faders and the currently available group mode.
|
||||
- **Volume control:** current surface/message assignment with Learn and Unset.
|
||||
- **Mute control:** current surface/message assignment with Learn and Unset.
|
||||
- **Size:** Slim, Standard, or Thick vertical presentation for this fader.
|
||||
- **Visibility:** Hide from mixer or Show in mixer without changing routing.
|
||||
|
||||
Groups select application-targeting faders in the UI; the server stores their
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::str::FromStr;
|
|||
|
||||
use toml_edit::{Array, ArrayOfTables, DocumentMut, InlineTable, Item, Table, Value, value};
|
||||
|
||||
use crate::{Action, ConfigError, MessageKind, Profile, SelectorField, TargetKind};
|
||||
use crate::{Action, ConfigError, FaderDensity, MessageKind, Profile, SelectorField, TargetKind};
|
||||
|
||||
/// Match expression used when creating an application selector.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
|
@ -321,6 +321,32 @@ impl ProfileDocument {
|
|||
})
|
||||
}
|
||||
|
||||
/// Changes one fader's vertical presentation density.
|
||||
pub fn set_fader_density(
|
||||
&mut self,
|
||||
id: &str,
|
||||
density: FaderDensity,
|
||||
) -> Result<(), ConfigError> {
|
||||
self.transaction(|document| {
|
||||
let tables = materialize_mixer_layout(document)?;
|
||||
let table = tables
|
||||
.iter_mut()
|
||||
.find(|table| {
|
||||
table.get("kind").and_then(Item::as_str) == Some("fader")
|
||||
&& table.get("fader").and_then(Item::as_str) == Some(id)
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
ConfigError::validation("mixer_layout", format!("unknown fader {id:?}"))
|
||||
})?;
|
||||
table["density"] = value(match density {
|
||||
FaderDensity::Slim => "slim",
|
||||
FaderDensity::Standard => "standard",
|
||||
FaderDensity::Thick => "thick",
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// Moves a fader or separator, preserving the complete table and its comments.
|
||||
pub fn move_layout_entry(&mut self, id: &str, position: usize) -> Result<(), ConfigError> {
|
||||
self.transaction(|document| {
|
||||
|
|
@ -520,6 +546,7 @@ fn materialize_mixer_layout(document: &mut DocumentMut) -> Result<&mut ArrayOfTa
|
|||
table["kind"] = value("fader");
|
||||
table["fader"] = value(fader);
|
||||
table["hidden"] = value(false);
|
||||
table["density"] = value("standard");
|
||||
tables.push(table);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ pub use error::ConfigError;
|
|||
pub use files::{AtomicFile, MigrationError, PersistenceError, StateLoad, migrate_profile};
|
||||
pub use paths::{XdgEnvironment, XdgPaths};
|
||||
pub use profile::{
|
||||
Action, Adapter, Application, Audio, Binding, Fader, Group, MessageKind, MixerLayoutEntry,
|
||||
NewStreamPolicy, Profile, Selector, SelectorField, StartupPolicy, Surface, TargetKind,
|
||||
Action, Adapter, Application, Audio, Binding, Fader, FaderDensity, Group, MessageKind,
|
||||
MixerLayoutEntry, NewStreamPolicy, Profile, Selector, SelectorField, StartupPolicy, Surface,
|
||||
TargetKind,
|
||||
};
|
||||
pub use state::{
|
||||
CachedObservation, DesiredWrite, PersistedState, ProfileState, StartupState, UiView,
|
||||
|
|
|
|||
|
|
@ -187,6 +187,16 @@ pub struct Fader {
|
|||
pickup_tolerance: f64,
|
||||
}
|
||||
|
||||
/// Vertical presentation density for one mixer fader.
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FaderDensity {
|
||||
Slim,
|
||||
#[default]
|
||||
Standard,
|
||||
Thick,
|
||||
}
|
||||
|
||||
/// One durable entry in the user-arranged mixer presentation.
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
|
||||
|
|
@ -196,11 +206,17 @@ pub enum MixerLayoutEntry {
|
|||
fader: String,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
hidden: bool,
|
||||
#[serde(default, skip_serializing_if = "is_standard_density")]
|
||||
density: FaderDensity,
|
||||
},
|
||||
/// A presentation-only named divider.
|
||||
Separator { id: String, label: String },
|
||||
}
|
||||
|
||||
fn is_standard_density(density: &FaderDensity) -> bool {
|
||||
*density == FaderDensity::Standard
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Action {
|
||||
|
|
@ -811,6 +827,7 @@ fn effective_mixer_layout(raw: &RawProfile) -> Vec<MixerLayoutEntry> {
|
|||
.map(|fader| MixerLayoutEntry::Fader {
|
||||
fader: fader.id.clone(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}),
|
||||
);
|
||||
layout
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ fn mixer_layout_draft_reorders_separators_and_retains_hidden_faders() {
|
|||
draft
|
||||
.set_fader_hidden("media-fader", true)
|
||||
.expect("fader must be hidden without deletion");
|
||||
draft
|
||||
.set_fader_density("media-fader", fader_config::FaderDensity::Thick)
|
||||
.expect("fader density must be editable");
|
||||
draft
|
||||
.move_layout_entry("media-fader", 0)
|
||||
.expect("hidden fader must remain reorderable");
|
||||
|
|
@ -181,6 +184,7 @@ fn mixer_layout_draft_reorders_separators_and_retains_hidden_faders() {
|
|||
MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".to_owned(),
|
||||
hidden: true,
|
||||
density: fader_config::FaderDensity::Thick,
|
||||
},
|
||||
MixerLayoutEntry::Separator {
|
||||
id: "outputs".to_owned(),
|
||||
|
|
@ -202,6 +206,7 @@ fn mixer_layout_draft_reorders_separators_and_retains_hidden_faders() {
|
|||
[MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".to_owned(),
|
||||
hidden: false,
|
||||
density: fader_config::FaderDensity::Thick,
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ fn mixer_layout_defaults_to_declared_faders_and_validates_explicit_entries() {
|
|||
[MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".to_owned(),
|
||||
hidden: false,
|
||||
density: fader_config::FaderDensity::Standard,
|
||||
}]
|
||||
);
|
||||
|
||||
|
|
@ -69,7 +70,19 @@ fn mixer_layout_defaults_to_declared_faders_and_validates_explicit_entries() {
|
|||
assert_eq!(profile.mixer_layout().len(), 2);
|
||||
assert!(matches!(
|
||||
&profile.mixer_layout()[1],
|
||||
MixerLayoutEntry::Fader { fader, hidden } if fader == "media-fader" && *hidden
|
||||
MixerLayoutEntry::Fader { fader, hidden, density }
|
||||
if fader == "media-fader"
|
||||
&& *hidden
|
||||
&& *density == fader_config::FaderDensity::Standard
|
||||
));
|
||||
|
||||
let slim = explicit.replace("hidden = true", "hidden = true\ndensity = \"slim\"");
|
||||
assert!(matches!(
|
||||
&Profile::parse(&slim).unwrap().mixer_layout()[1],
|
||||
MixerLayoutEntry::Fader {
|
||||
density: fader_config::FaderDensity::Slim,
|
||||
..
|
||||
}
|
||||
));
|
||||
|
||||
let duplicate = explicit.replace(
|
||||
|
|
|
|||
|
|
@ -196,6 +196,14 @@ impl ConfigurationEditor {
|
|||
ConfigurationEdit::SetFaderHidden { id, hidden } => {
|
||||
self.document.set_fader_hidden(&id, hidden)?
|
||||
}
|
||||
ConfigurationEdit::SetFaderDensity { id, density } => self.document.set_fader_density(
|
||||
&id,
|
||||
match density {
|
||||
crate::ipc::FaderDensity::Slim => fader_config::FaderDensity::Slim,
|
||||
crate::ipc::FaderDensity::Standard => fader_config::FaderDensity::Standard,
|
||||
crate::ipc::FaderDensity::Thick => fader_config::FaderDensity::Thick,
|
||||
},
|
||||
)?,
|
||||
ConfigurationEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
|
|
@ -360,7 +368,7 @@ mod tests {
|
|||
},
|
||||
)
|
||||
.unwrap();
|
||||
let profile = editor
|
||||
editor
|
||||
.apply(
|
||||
1,
|
||||
ConfigurationEdit::SetFaderHidden {
|
||||
|
|
@ -369,9 +377,25 @@ mod tests {
|
|||
},
|
||||
)
|
||||
.unwrap();
|
||||
let profile = editor
|
||||
.apply(
|
||||
2,
|
||||
ConfigurationEdit::SetFaderDensity {
|
||||
id: "media-fader".into(),
|
||||
density: crate::ipc::FaderDensity::Slim,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(profile.faders().len(), 1);
|
||||
assert_eq!(profile.mixer_layout().len(), 2);
|
||||
assert_eq!(editor.revision(), 2);
|
||||
assert!(matches!(
|
||||
&profile.mixer_layout()[1],
|
||||
fader_config::MixerLayoutEntry::Fader {
|
||||
density: fader_config::FaderDensity::Slim,
|
||||
..
|
||||
}
|
||||
));
|
||||
assert_eq!(editor.revision(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::io::{self, Read, Write};
|
|||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
use thiserror::Error;
|
||||
|
||||
pub const PROTOCOL_VERSION: u16 = 11;
|
||||
pub const PROTOCOL_VERSION: u16 = 12;
|
||||
pub const MAX_FRAME_BYTES: usize = 64 * 1024;
|
||||
|
||||
/// Kind of mixer object addressed by a client.
|
||||
|
|
@ -157,6 +157,10 @@ pub enum ConfigurationEdit {
|
|||
id: String,
|
||||
hidden: bool,
|
||||
},
|
||||
SetFaderDensity {
|
||||
id: String,
|
||||
density: FaderDensity,
|
||||
},
|
||||
AddSeparator {
|
||||
id: String,
|
||||
label: String,
|
||||
|
|
@ -214,8 +218,23 @@ pub struct ConfigurationSnapshot {
|
|||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case")]
|
||||
pub enum MixerLayoutEntry {
|
||||
Fader { fader: String, hidden: bool },
|
||||
Separator { id: String, label: String },
|
||||
Fader {
|
||||
fader: String,
|
||||
hidden: bool,
|
||||
density: FaderDensity,
|
||||
},
|
||||
Separator {
|
||||
id: String,
|
||||
label: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FaderDensity {
|
||||
Slim,
|
||||
Standard,
|
||||
Thick,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
|
|
|
|||
|
|
@ -170,9 +170,18 @@ pub(crate) fn configuration_snapshot(
|
|||
.mixer_layout()
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
fader_config::MixerLayoutEntry::Fader { fader, hidden } => IpcLayoutEntry::Fader {
|
||||
fader_config::MixerLayoutEntry::Fader {
|
||||
fader,
|
||||
hidden,
|
||||
density,
|
||||
} => IpcLayoutEntry::Fader {
|
||||
fader: fader.clone(),
|
||||
hidden: *hidden,
|
||||
density: match density {
|
||||
fader_config::FaderDensity::Slim => crate::ipc::FaderDensity::Slim,
|
||||
fader_config::FaderDensity::Standard => crate::ipc::FaderDensity::Standard,
|
||||
fader_config::FaderDensity::Thick => crate::ipc::FaderDensity::Thick,
|
||||
},
|
||||
},
|
||||
fader_config::MixerLayoutEntry::Separator { id, label } => {
|
||||
IpcLayoutEntry::Separator {
|
||||
|
|
|
|||
|
|
@ -156,9 +156,21 @@ impl IpcMixerClient {
|
|||
.mixer_layout
|
||||
.into_iter()
|
||||
.map(|entry| match entry {
|
||||
crate::ipc::MixerLayoutEntry::Fader { fader, hidden } => {
|
||||
tui::MixerLayoutEntry::Fader { fader, hidden }
|
||||
}
|
||||
crate::ipc::MixerLayoutEntry::Fader {
|
||||
fader,
|
||||
hidden,
|
||||
density,
|
||||
} => tui::MixerLayoutEntry::Fader {
|
||||
fader,
|
||||
hidden,
|
||||
density: match density {
|
||||
crate::ipc::FaderDensity::Slim => tui::FaderDensity::Slim,
|
||||
crate::ipc::FaderDensity::Standard => {
|
||||
tui::FaderDensity::Standard
|
||||
}
|
||||
crate::ipc::FaderDensity::Thick => tui::FaderDensity::Thick,
|
||||
},
|
||||
},
|
||||
crate::ipc::MixerLayoutEntry::Separator { id, label } => {
|
||||
tui::MixerLayoutEntry::Separator { id, label }
|
||||
}
|
||||
|
|
@ -334,6 +346,14 @@ fn configuration_edit(edit: TuiConfigurationEdit) -> crate::ipc::ConfigurationEd
|
|||
TuiConfigurationEdit::SetFaderHidden { id, hidden } => {
|
||||
IpcEdit::SetFaderHidden { id, hidden }
|
||||
}
|
||||
TuiConfigurationEdit::SetFaderDensity { id, density } => IpcEdit::SetFaderDensity {
|
||||
id,
|
||||
density: match density {
|
||||
tui::FaderDensity::Slim => crate::ipc::FaderDensity::Slim,
|
||||
tui::FaderDensity::Standard => crate::ipc::FaderDensity::Standard,
|
||||
tui::FaderDensity::Thick => crate::ipc::FaderDensity::Thick,
|
||||
},
|
||||
},
|
||||
TuiConfigurationEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
|
|
|
|||
3
task.md
3
task.md
|
|
@ -381,6 +381,9 @@ Dependencies: M8, M2, M1.
|
|||
mode. Volume and Mute show their assignments and provide surface-scoped Learn
|
||||
and action-scoped Unset. Visibility uses the same form. Relearning atomically
|
||||
replaces only the chosen action, and validation conflicts retain the draft.
|
||||
The form also persists a per-fader Slim, Standard, or Thick size in the mixer
|
||||
layout. Existing profiles default to Standard, while Slim renders in one
|
||||
terminal row.
|
||||
- [ ] **M9.6 Single-screen configuration workflow:** remove the normalized
|
||||
Config table browser once all its operations are reachable from the mixer,
|
||||
keep Apply/Save and draft/live/durable status visible, and expose hidden-item
|
||||
|
|
|
|||
271
tui/src/lib.rs
271
tui/src/lib.rs
|
|
@ -92,8 +92,41 @@ pub struct ConfigurationSnapshot {
|
|||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum MixerLayoutEntry {
|
||||
Fader { fader: String, hidden: bool },
|
||||
Separator { id: String, label: String },
|
||||
Fader {
|
||||
fader: String,
|
||||
hidden: bool,
|
||||
density: FaderDensity,
|
||||
},
|
||||
Separator {
|
||||
id: String,
|
||||
label: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum FaderDensity {
|
||||
Slim,
|
||||
#[default]
|
||||
Standard,
|
||||
Thick,
|
||||
}
|
||||
|
||||
impl FaderDensity {
|
||||
const fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Slim => "Slim",
|
||||
Self::Standard => "Standard",
|
||||
Self::Thick => "Thick",
|
||||
}
|
||||
}
|
||||
|
||||
const fn next(self) -> Self {
|
||||
match self {
|
||||
Self::Slim => Self::Standard,
|
||||
Self::Standard => Self::Thick,
|
||||
Self::Thick => Self::Slim,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
|
@ -184,6 +217,10 @@ pub enum ConfigurationEdit {
|
|||
id: String,
|
||||
hidden: bool,
|
||||
},
|
||||
SetFaderDensity {
|
||||
id: String,
|
||||
density: FaderDensity,
|
||||
},
|
||||
AddSeparator {
|
||||
id: String,
|
||||
label: String,
|
||||
|
|
@ -797,12 +834,16 @@ enum FaderEditorRow {
|
|||
Visibility {
|
||||
hidden: bool,
|
||||
},
|
||||
Density {
|
||||
density: FaderDensity,
|
||||
},
|
||||
}
|
||||
|
||||
enum MixerRow<'a> {
|
||||
Fader {
|
||||
layout_id: Option<&'a str>,
|
||||
item: &'a MixerItem,
|
||||
density: FaderDensity,
|
||||
},
|
||||
Separator {
|
||||
id: &'a str,
|
||||
|
|
@ -821,6 +862,24 @@ impl MixerRow<'_> {
|
|||
Self::Fader { item, .. } => &item.id.id,
|
||||
}
|
||||
}
|
||||
|
||||
const fn height(&self) -> u16 {
|
||||
match self {
|
||||
Self::Fader {
|
||||
density: FaderDensity::Slim,
|
||||
..
|
||||
} => 1,
|
||||
Self::Fader {
|
||||
density: FaderDensity::Standard,
|
||||
..
|
||||
}
|
||||
| Self::Separator { .. } => 4,
|
||||
Self::Fader {
|
||||
density: FaderDensity::Thick,
|
||||
..
|
||||
} => 6,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: MixerClient> LiveTui<C> {
|
||||
|
|
@ -894,6 +953,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.map(|item| MixerRow::Fader {
|
||||
layout_id: None,
|
||||
item,
|
||||
density: FaderDensity::Standard,
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
|
@ -906,6 +966,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
MixerLayoutEntry::Fader {
|
||||
fader,
|
||||
hidden: false,
|
||||
density,
|
||||
} => {
|
||||
let target = self
|
||||
.snapshot
|
||||
|
|
@ -918,6 +979,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
Some(MixerRow::Fader {
|
||||
layout_id: Some(fader),
|
||||
item,
|
||||
density: *density,
|
||||
})
|
||||
}
|
||||
MixerLayoutEntry::Separator { id, label } => {
|
||||
|
|
@ -1128,6 +1190,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
MixerLayoutEntry::Fader {
|
||||
fader,
|
||||
hidden: true,
|
||||
..
|
||||
} => {
|
||||
let label = self
|
||||
.snapshot
|
||||
|
|
@ -1325,18 +1388,21 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
},
|
||||
});
|
||||
}
|
||||
let hidden = self
|
||||
let (hidden, density) = self
|
||||
.snapshot
|
||||
.configuration
|
||||
.mixer_layout
|
||||
.iter()
|
||||
.find_map(|entry| match entry {
|
||||
MixerLayoutEntry::Fader { fader: id, hidden } if id == &editor.fader => {
|
||||
Some(*hidden)
|
||||
}
|
||||
MixerLayoutEntry::Fader {
|
||||
fader: id,
|
||||
hidden,
|
||||
density,
|
||||
} if id == &editor.fader => Some((*hidden, *density)),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or(false);
|
||||
.unwrap_or((false, FaderDensity::Standard));
|
||||
rows.push(FaderEditorRow::Density { density });
|
||||
rows.push(FaderEditorRow::Visibility { hidden });
|
||||
rows
|
||||
}
|
||||
|
|
@ -1437,6 +1503,12 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
hidden: !hidden,
|
||||
});
|
||||
}
|
||||
FaderEditorRow::Density { density } if !unset => {
|
||||
self.apply_layout_edit(ConfigurationEdit::SetFaderDensity {
|
||||
id: fader,
|
||||
density: density.next(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -1953,6 +2025,9 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
if *hidden { "Hidden" } else { "Shown" },
|
||||
if *hidden { "show" } else { "hide" }
|
||||
),
|
||||
FaderEditorRow::Density { density } => {
|
||||
format!("{marker} Size {} [Enter to cycle]", density.label())
|
||||
}
|
||||
};
|
||||
Line::from(text).style(if index == editor.selected {
|
||||
Style::default().fg(theme.accent).bold()
|
||||
|
|
@ -2184,32 +2259,33 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.render(area, buf);
|
||||
return;
|
||||
}
|
||||
let visible = usize::from(area.height / 4).max(1);
|
||||
let start = self.selected.saturating_sub(visible.saturating_sub(1));
|
||||
for (row, (index, layout_row)) in rows
|
||||
.iter()
|
||||
.enumerate()
|
||||
.skip(start)
|
||||
.take(visible)
|
||||
.enumerate()
|
||||
{
|
||||
let y = area
|
||||
.y
|
||||
.saturating_add(u16::try_from(row * 4).unwrap_or(u16::MAX));
|
||||
let row_area = Rect::new(
|
||||
area.x,
|
||||
y,
|
||||
area.width,
|
||||
4.min(area.bottom().saturating_sub(y)),
|
||||
);
|
||||
if row_area.height < 2 {
|
||||
let selected = self.selected.min(rows.len().saturating_sub(1));
|
||||
let mut start = selected;
|
||||
let mut occupied = rows[selected].height();
|
||||
while start > 0 {
|
||||
let previous_height = rows[start - 1].height();
|
||||
if occupied.saturating_add(previous_height) > area.height {
|
||||
break;
|
||||
}
|
||||
start -= 1;
|
||||
occupied = occupied.saturating_add(previous_height);
|
||||
}
|
||||
let mut y = area.y;
|
||||
for (index, layout_row) in rows.iter().enumerate().skip(start) {
|
||||
let remaining = area.bottom().saturating_sub(y);
|
||||
if remaining == 0 {
|
||||
break;
|
||||
}
|
||||
let row_area = Rect::new(area.x, y, area.width, layout_row.height().min(remaining));
|
||||
y = y.saturating_add(row_area.height);
|
||||
let selected = index == self.selected;
|
||||
let MixerRow::Fader { item, .. } = layout_row else {
|
||||
let MixerRow::Fader { item, density, .. } = layout_row else {
|
||||
let MixerRow::Separator { label, .. } = layout_row else {
|
||||
continue;
|
||||
};
|
||||
if row_area.height < 2 {
|
||||
break;
|
||||
}
|
||||
Paragraph::new(format!("── {label} ──"))
|
||||
.alignment(Alignment::Center)
|
||||
.style(if selected {
|
||||
|
|
@ -2225,6 +2301,48 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.render(row_area, buf);
|
||||
continue;
|
||||
};
|
||||
let percent = item
|
||||
.gain
|
||||
.map_or(0, |gain| (gain.clamp(0.0, 1.0) * 100.0).round() as u16);
|
||||
let state = if item.gain.is_none() {
|
||||
"OFFLINE"
|
||||
} else if item.mute_mixed || item.gain_mixed {
|
||||
"MIXED"
|
||||
} else if item.muted == Some(true) {
|
||||
"MUTED"
|
||||
} else if !item.writable {
|
||||
"READ ONLY"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let meter_style = Style::default()
|
||||
.bg(theme.meter_track)
|
||||
.fg(if item.error.is_some() {
|
||||
theme.error
|
||||
} else if item.muted == Some(true) {
|
||||
theme.warning
|
||||
} else {
|
||||
theme.secondary
|
||||
});
|
||||
if *density == FaderDensity::Slim {
|
||||
let status = item.error.as_deref().map_or_else(
|
||||
|| format!("{percent}% {state}"),
|
||||
|error| format!("ERROR: {error}"),
|
||||
);
|
||||
Gauge::default()
|
||||
.gauge_style(meter_style)
|
||||
.percent(percent)
|
||||
.label(format!(
|
||||
"{} {} {status}",
|
||||
if selected { "▶" } else { " " },
|
||||
item.label
|
||||
))
|
||||
.render(row_area, buf);
|
||||
continue;
|
||||
}
|
||||
if row_area.height < 2 {
|
||||
break;
|
||||
}
|
||||
let title = format!(
|
||||
"{} {} [{} · {}]{}{}",
|
||||
if selected { "▶" } else { " " },
|
||||
|
|
@ -2251,36 +2369,12 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
});
|
||||
let meter = block.inner(row_area);
|
||||
block.render(row_area, buf);
|
||||
let percent = item
|
||||
.gain
|
||||
.map_or(0, |gain| (gain.clamp(0.0, 1.0) * 100.0).round() as u16);
|
||||
let state = if item.gain.is_none() {
|
||||
"OFFLINE"
|
||||
} else if item.mute_mixed || item.gain_mixed {
|
||||
"MIXED"
|
||||
} else if item.muted == Some(true) {
|
||||
"MUTED"
|
||||
} else if !item.writable {
|
||||
"READ ONLY"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let label = item.error.as_deref().map_or_else(
|
||||
|| format!("{percent}% {state}"),
|
||||
|error| format!("ERROR: {error}"),
|
||||
);
|
||||
Gauge::default()
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.bg(theme.meter_track)
|
||||
.fg(if item.error.is_some() {
|
||||
theme.error
|
||||
} else if item.muted == Some(true) {
|
||||
theme.warning
|
||||
} else {
|
||||
theme.secondary
|
||||
}),
|
||||
)
|
||||
.gauge_style(meter_style)
|
||||
.percent(percent)
|
||||
.label(label)
|
||||
.render(meter, buf);
|
||||
|
|
@ -2426,6 +2520,15 @@ mod tests {
|
|||
*current = *hidden;
|
||||
}
|
||||
}
|
||||
ConfigurationEdit::SetFaderDensity { id, density } => {
|
||||
if let Some(MixerLayoutEntry::Fader {
|
||||
density: current, ..
|
||||
}) = self.snapshot.configuration.mixer_layout.iter_mut().find(
|
||||
|entry| matches!(entry, MixerLayoutEntry::Fader { fader, .. } if fader == id),
|
||||
) {
|
||||
*current = *density;
|
||||
}
|
||||
}
|
||||
ConfigurationEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
|
|
@ -2664,10 +2767,12 @@ mod tests {
|
|||
MixerLayoutEntry::Fader {
|
||||
fader: "music-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
},
|
||||
MixerLayoutEntry::Fader {
|
||||
fader: "browser-fader".into(),
|
||||
hidden: true,
|
||||
density: FaderDensity::Standard,
|
||||
},
|
||||
];
|
||||
let edits = Arc::new(Mutex::new(Vec::new()));
|
||||
|
|
@ -2755,6 +2860,7 @@ mod tests {
|
|||
snapshot.configuration.mixer_layout = vec![MixerLayoutEntry::Fader {
|
||||
fader: "music-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}];
|
||||
snapshot.configuration.bindings = vec![ConfiguredBinding {
|
||||
surface: "desk".into(),
|
||||
|
|
@ -2789,6 +2895,7 @@ mod tests {
|
|||
assert!(rendered.contains("Capture 1"));
|
||||
assert!(rendered.contains("Volume control"));
|
||||
assert!(rendered.contains("Mute control"));
|
||||
assert!(rendered.contains("Size Standard"));
|
||||
assert!(rendered.contains("Visibility"));
|
||||
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
|
|
@ -2835,6 +2942,64 @@ mod tests {
|
|||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fader_density_cycles_and_slim_rows_use_one_terminal_line() {
|
||||
let mut snapshot = DemoClient::default().view();
|
||||
snapshot.items[0].id.id = "music".into();
|
||||
snapshot.items[0].label = "Music".into();
|
||||
snapshot.configuration.applications = vec![ConfiguredApplication {
|
||||
id: "music".into(),
|
||||
label: "Music".into(),
|
||||
selectors: Vec::new(),
|
||||
}];
|
||||
snapshot.configuration.faders = vec![ConfiguredFader {
|
||||
id: "music-fader".into(),
|
||||
target: snapshot.items[0].id.clone(),
|
||||
pickup: true,
|
||||
pickup_tolerance: 0.02,
|
||||
}];
|
||||
snapshot.configuration.mixer_layout = vec![MixerLayoutEntry::Fader {
|
||||
fader: "music-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}];
|
||||
let edits = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut app = LiveTui::new(LayoutClient {
|
||||
snapshot,
|
||||
edits: Arc::clone(&edits),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
app.handle_key_event(press(KeyCode::Char('e')));
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
assert!(edits.lock().unwrap().iter().any(|edit| matches!(
|
||||
edit,
|
||||
ConfigurationEdit::SetFaderDensity {
|
||||
id,
|
||||
density: FaderDensity::Thick
|
||||
} if id == "music-fader"
|
||||
)));
|
||||
|
||||
app.fader_editor = None;
|
||||
if let MixerLayoutEntry::Fader { density, .. } =
|
||||
&mut app.snapshot.configuration.mixer_layout[0]
|
||||
{
|
||||
*density = FaderDensity::Slim;
|
||||
}
|
||||
let area = Rect::new(0, 0, 80, 1);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
app.render_streams(area, &mut buffer);
|
||||
let rendered = buffer
|
||||
.content
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rendered.contains("Music"));
|
||||
assert!(rendered.contains("65%"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_fader_form_selects_application_faders_and_shows_mode() {
|
||||
let mut snapshot = DemoClient::default().view();
|
||||
|
|
@ -2890,6 +3055,7 @@ mod tests {
|
|||
snapshot.configuration.mixer_layout = vec![MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}];
|
||||
let edits = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut app = LiveTui::new(LayoutClient {
|
||||
|
|
@ -2958,6 +3124,7 @@ mod tests {
|
|||
mixer_layout: vec![MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}],
|
||||
bindings: vec![ConfiguredBinding {
|
||||
surface: "desk-left".into(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue