feat: expose revisioned mixer layout edits
Carry effective mixer layouts through snapshots and IPC, and apply reorder, visibility, and separator mutations through the server-owned configuration draft.\n\nTests: cargo test --locked -p fader_master --lib\nTests: cargo check --locked --workspace --all-targets --all-features\nTests: cargo fmt --all -- --check
This commit is contained in:
parent
7790951c22
commit
b9d52a3d5e
|
|
@ -161,6 +161,21 @@ impl ConfigurationEditor {
|
|||
channel,
|
||||
number,
|
||||
)?,
|
||||
ConfigurationEdit::MoveLayoutEntry { id, position } => {
|
||||
self.document.move_layout_entry(&id, position)?
|
||||
}
|
||||
ConfigurationEdit::SetFaderHidden { id, hidden } => {
|
||||
self.document.set_fader_hidden(&id, hidden)?
|
||||
}
|
||||
ConfigurationEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
position,
|
||||
} => self.document.add_separator(&id, &label, position)?,
|
||||
ConfigurationEdit::SetSeparatorLabel { id, label } => {
|
||||
self.document.set_separator_label(&id, &label)?
|
||||
}
|
||||
ConfigurationEdit::RemoveSeparator { id } => self.document.remove_separator(&id)?,
|
||||
}
|
||||
self.revision = self.revision.saturating_add(1);
|
||||
self.dirty = true;
|
||||
|
|
@ -276,6 +291,38 @@ mod tests {
|
|||
assert_eq!(editor.profile().unwrap().faders().len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layout_edits_are_revisioned_without_changing_fader_routing() {
|
||||
let root = tempdir().unwrap();
|
||||
let path = root.path().join("desktop.toml");
|
||||
fs::write(&path, PROFILE).unwrap();
|
||||
let document = ProfileDocument::parse(PROFILE).unwrap();
|
||||
let mut editor = ConfigurationEditor::new(document, path);
|
||||
|
||||
editor
|
||||
.apply(
|
||||
0,
|
||||
ConfigurationEdit::AddSeparator {
|
||||
id: "media-heading".into(),
|
||||
label: "Media".into(),
|
||||
position: 0,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let profile = editor
|
||||
.apply(
|
||||
1,
|
||||
ConfigurationEdit::SetFaderHidden {
|
||||
id: "media-fader".into(),
|
||||
hidden: true,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(profile.faders().len(), 1);
|
||||
assert_eq!(profile.mixer_layout().len(), 2);
|
||||
assert_eq!(editor.revision(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_is_atomic_and_refuses_external_changes() {
|
||||
let root = tempdir().unwrap();
|
||||
|
|
|
|||
|
|
@ -130,6 +130,26 @@ pub enum ConfigurationEdit {
|
|||
channel: u16,
|
||||
number: u16,
|
||||
},
|
||||
MoveLayoutEntry {
|
||||
id: String,
|
||||
position: usize,
|
||||
},
|
||||
SetFaderHidden {
|
||||
id: String,
|
||||
hidden: bool,
|
||||
},
|
||||
AddSeparator {
|
||||
id: String,
|
||||
label: String,
|
||||
position: usize,
|
||||
},
|
||||
SetSeparatorLabel {
|
||||
id: String,
|
||||
label: String,
|
||||
},
|
||||
RemoveSeparator {
|
||||
id: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||
|
|
@ -168,9 +188,17 @@ pub struct ConfigurationSnapshot {
|
|||
pub applications: Vec<ConfiguredApplication>,
|
||||
pub groups: Vec<ConfiguredGroup>,
|
||||
pub faders: Vec<ConfiguredFader>,
|
||||
pub mixer_layout: Vec<MixerLayoutEntry>,
|
||||
pub bindings: Vec<ConfiguredBinding>,
|
||||
}
|
||||
|
||||
#[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 },
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct ConfiguredApplication {
|
||||
pub id: String,
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ use volume_lib::WorkerEvent;
|
|||
use crate::ipc::{
|
||||
ClientRequest, ConfigurationSnapshot, ConfiguredApplication as IpcApplication,
|
||||
ConfiguredBinding as IpcBinding, ConfiguredFader as IpcFader, ConfiguredGroup as IpcGroup,
|
||||
MidiDevice, MixerObject, MixerObjectKey, MixerObjectKind, MixerSnapshot, PROTOCOL_VERSION,
|
||||
PickupStatus, RequestCommand, ResponseResult, ServerResponse,
|
||||
MidiDevice, MixerLayoutEntry as IpcLayoutEntry, MixerObject, MixerObjectKey, MixerObjectKind,
|
||||
MixerSnapshot, PROTOCOL_VERSION, PickupStatus, RequestCommand, ResponseResult, ServerResponse,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -148,6 +148,22 @@ pub(crate) fn configuration_snapshot(
|
|||
pickup: fader.pickup(),
|
||||
})
|
||||
.collect(),
|
||||
mixer_layout: profile
|
||||
.mixer_layout()
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
fader_config::MixerLayoutEntry::Fader { fader, hidden } => IpcLayoutEntry::Fader {
|
||||
fader: fader.clone(),
|
||||
hidden: *hidden,
|
||||
},
|
||||
fader_config::MixerLayoutEntry::Separator { id, label } => {
|
||||
IpcLayoutEntry::Separator {
|
||||
id: id.clone(),
|
||||
label: label.clone(),
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
bindings: profile
|
||||
.bindings()
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -133,6 +133,19 @@ impl IpcMixerClient {
|
|||
pickup: fader.pickup,
|
||||
})
|
||||
.collect(),
|
||||
mixer_layout: snapshot
|
||||
.configuration
|
||||
.mixer_layout
|
||||
.into_iter()
|
||||
.map(|entry| match entry {
|
||||
crate::ipc::MixerLayoutEntry::Fader { fader, hidden } => {
|
||||
tui::MixerLayoutEntry::Fader { fader, hidden }
|
||||
}
|
||||
crate::ipc::MixerLayoutEntry::Separator { id, label } => {
|
||||
tui::MixerLayoutEntry::Separator { id, label }
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
bindings: snapshot
|
||||
.configuration
|
||||
.bindings
|
||||
|
|
@ -297,6 +310,25 @@ fn configuration_edit(edit: TuiConfigurationEdit) -> crate::ipc::ConfigurationEd
|
|||
"fader" => IpcEdit::RemoveFader { id },
|
||||
_ => IpcEdit::RemoveApplication { id },
|
||||
},
|
||||
TuiConfigurationEdit::MoveLayoutEntry { id, position } => {
|
||||
IpcEdit::MoveLayoutEntry { id, position }
|
||||
}
|
||||
TuiConfigurationEdit::SetFaderHidden { id, hidden } => {
|
||||
IpcEdit::SetFaderHidden { id, hidden }
|
||||
}
|
||||
TuiConfigurationEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
position,
|
||||
} => IpcEdit::AddSeparator {
|
||||
id,
|
||||
label,
|
||||
position,
|
||||
},
|
||||
TuiConfigurationEdit::SetSeparatorLabel { id, label } => {
|
||||
IpcEdit::SetSeparatorLabel { id, label }
|
||||
}
|
||||
TuiConfigurationEdit::RemoveSeparator { id } => IpcEdit::RemoveSeparator { id },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,16 @@ pub struct ConfigurationSnapshot {
|
|||
pub applications: Vec<ConfiguredApplication>,
|
||||
pub groups: Vec<ConfiguredGroup>,
|
||||
pub faders: Vec<ConfiguredFader>,
|
||||
pub mixer_layout: Vec<MixerLayoutEntry>,
|
||||
pub bindings: Vec<ConfiguredBinding>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum MixerLayoutEntry {
|
||||
Fader { fader: String, hidden: bool },
|
||||
Separator { id: String, label: String },
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct ConfiguredApplication {
|
||||
pub id: String,
|
||||
|
|
@ -144,6 +151,26 @@ pub enum ConfigurationEdit {
|
|||
kind: String,
|
||||
id: String,
|
||||
},
|
||||
MoveLayoutEntry {
|
||||
id: String,
|
||||
position: usize,
|
||||
},
|
||||
SetFaderHidden {
|
||||
id: String,
|
||||
hidden: bool,
|
||||
},
|
||||
AddSeparator {
|
||||
id: String,
|
||||
label: String,
|
||||
position: usize,
|
||||
},
|
||||
SetSeparatorLabel {
|
||||
id: String,
|
||||
label: String,
|
||||
},
|
||||
RemoveSeparator {
|
||||
id: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
@ -1666,6 +1693,10 @@ mod tests {
|
|||
},
|
||||
pickup: true,
|
||||
}],
|
||||
mixer_layout: vec![MixerLayoutEntry::Fader {
|
||||
fader: "media-fader".into(),
|
||||
hidden: false,
|
||||
}],
|
||||
bindings: vec![ConfiguredBinding {
|
||||
surface: "desk-left".into(),
|
||||
fader: "media-fader".into(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue