Separate load mappings from extensible send destinations
This commit is contained in:
parent
f27baa3f41
commit
3f299b1d5f
|
|
@ -602,7 +602,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.48"
|
||||
version = "0.9.49"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.9.48"
|
||||
version = "0.9.49"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ impl Editor {
|
|||
let inputs = device_capture::inputs(snapshot);
|
||||
for i in 0..self.layout.layers().len() {
|
||||
let info = self.layout.layer_info(i);
|
||||
let Some(link) = &info.device_link else {
|
||||
let Some(link) = &info.load_mapping else {
|
||||
continue;
|
||||
};
|
||||
if link.family != snapshot.profile.family() {
|
||||
|
|
|
|||
|
|
@ -272,11 +272,10 @@ pub(super) fn prepare(
|
|||
target,
|
||||
changes: vec![],
|
||||
};
|
||||
let mut locals = BTreeSet::new();
|
||||
let mut destinations = BTreeSet::new();
|
||||
for (id, destination) in mappings {
|
||||
if !locals.insert(id) || !destinations.insert(destination) {
|
||||
return Err("Map each editor layer to a different device layer.".into());
|
||||
if !destinations.insert(destination) {
|
||||
return Err("Map each device destination only once.".into());
|
||||
}
|
||||
if !screen.layers.iter().any(|l| &l.id == destination) {
|
||||
return Err("Destination is not allocated.".into());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
//! Directional routing, independent of controls and device protocol paths.
|
||||
use crate::DeviceLink;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Connection scope is explicit, but only the current connection exists today.
|
||||
/// A future saved-connection identity can be added without changing fan-out shape.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ConnectionTarget {
|
||||
Current,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct SendDestination {
|
||||
pub connection: ConnectionTarget,
|
||||
pub layer: DeviceLink,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct SendMapping {
|
||||
pub destinations: Vec<SendDestination>,
|
||||
}
|
||||
|
||||
impl SendMapping {
|
||||
pub fn linked(link: Option<DeviceLink>) -> Self {
|
||||
Self {
|
||||
destinations: link
|
||||
.into_iter()
|
||||
.map(|layer| SendDestination {
|
||||
connection: ConnectionTarget::Current,
|
||||
layer,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> Result<(), String> {
|
||||
for (i, destination) in self.destinations.iter().enumerate() {
|
||||
destination.layer.validate()?;
|
||||
if self.destinations[..i].contains(destination) {
|
||||
return Err("A send mapping contains a duplicate destination.".into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn current_links(&self) -> impl Iterator<Item = &DeviceLink> {
|
||||
self.destinations
|
||||
.iter()
|
||||
.map(|destination| match destination.connection {
|
||||
ConnectionTarget::Current => &destination.layer,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -118,11 +118,10 @@ impl Plan {
|
|||
target,
|
||||
changes: vec![],
|
||||
};
|
||||
let mut locals = BTreeSet::new();
|
||||
let mut destinations = BTreeSet::new();
|
||||
for (id, destination) in mappings {
|
||||
if !locals.insert(*id) || !destinations.insert(destination.clone()) {
|
||||
return Err("Map each editor layer to a different device layer.".into());
|
||||
if !destinations.insert(destination.clone()) {
|
||||
return Err("Map each device destination only once.".into());
|
||||
}
|
||||
if !screen.layers.iter().any(|l| l.id == *destination) {
|
||||
return Err("Choose a device destination for every editor layer.".into());
|
||||
|
|
|
|||
|
|
@ -26,7 +26,14 @@ fn shared_link_warning(
|
|||
link: &canvas_pilot::DeviceLink,
|
||||
) -> Option<String> {
|
||||
let others: Vec<_> = (0..layout.layers().len())
|
||||
.filter(|&i| i != index && layout.layer_info(i).device_link.as_ref() == Some(link))
|
||||
.filter(|&i| {
|
||||
i != index
|
||||
&& layout
|
||||
.layer_info(i)
|
||||
.send_mapping
|
||||
.current_links()
|
||||
.any(|target| target == link)
|
||||
})
|
||||
.map(|i| linked_layer_label(layout, layout.layer_info(i).id))
|
||||
.collect();
|
||||
(!others.is_empty()).then(|| format!("Screen {} · Layer {} is also linked to: {}. Shared links are allowed; send a folder or selection without overlapping destinations.", link.screen, link.layer, others.join(", ")))
|
||||
|
|
@ -136,7 +143,7 @@ impl DeviceUi {
|
|||
..Self::default()
|
||||
}
|
||||
}
|
||||
fn scoped_links(
|
||||
fn scoped_load_links(
|
||||
&self,
|
||||
layout: &canvas_pilot::Layout,
|
||||
) -> Vec<(usize, canvas_pilot::DeviceLink)> {
|
||||
|
|
@ -145,7 +152,23 @@ impl DeviceUi {
|
|||
.into_iter()
|
||||
.filter_map(|i| {
|
||||
let info = layout.layer_info(i);
|
||||
info.device_link.clone().map(|link| (info.id, link))
|
||||
info.load_mapping.clone().map(|link| (info.id, link))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
fn scoped_send_links(
|
||||
&self,
|
||||
layout: &canvas_pilot::Layout,
|
||||
) -> Vec<(usize, canvas_pilot::DeviceLink)> {
|
||||
self.scope
|
||||
.indices(layout)
|
||||
.into_iter()
|
||||
.flat_map(|i| {
|
||||
let info = layout.layer_info(i);
|
||||
info.send_mapping
|
||||
.current_links()
|
||||
.cloned()
|
||||
.map(move |link| (info.id, link))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -165,7 +188,7 @@ impl DeviceUi {
|
|||
}
|
||||
fn linked_plans(&self, layout: &canvas_pilot::Layout) -> Result<Vec<Plan>, String> {
|
||||
let snapshot = self.snapshot.as_ref().ok_or("Connect to a device first.")?;
|
||||
let links = self.scoped_links(layout);
|
||||
let links = self.scoped_send_links(layout);
|
||||
if links.is_empty() {
|
||||
return Err(
|
||||
"No linked layers in this scope. Choose a scope and map its device destinations."
|
||||
|
|
@ -243,7 +266,7 @@ impl DeviceUi {
|
|||
&& !layout.locked(i)
|
||||
&& layout
|
||||
.layer_info(i)
|
||||
.device_link
|
||||
.load_mapping
|
||||
.as_ref()
|
||||
.is_some_and(|link| {
|
||||
link.family == snapshot.profile.family()
|
||||
|
|
@ -371,13 +394,17 @@ impl Editor {
|
|||
self.device.input_edits.show(
|
||||
ui,
|
||||
self.device.snapshot.as_ref(),
|
||||
self.layout.layer_info(i).device_link.as_ref(),
|
||||
self.layout
|
||||
.layer_info(i)
|
||||
.send_mapping
|
||||
.current_links()
|
||||
.next(),
|
||||
self.layout.layer_info(i).id,
|
||||
);
|
||||
}
|
||||
|
||||
pub(super) fn layer_mapping_controls(&mut self, ui: &mut egui::Ui, i: usize) {
|
||||
let original = self.layout.layer_info(i).device_link.clone();
|
||||
let original = self.layout.layer_info(i).load_mapping.clone();
|
||||
let mut link = original.clone();
|
||||
ui.label(tr(ui.ctx(), "ui.device-screen-layer"));
|
||||
ui.small(tr(ui.ctx(), "ui.saved-with-this-layer-linked-sends-and-loads-use-this-screen-and-layer-editing-the-li"));
|
||||
|
|
@ -566,7 +593,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
fn start_scoped_load(&mut self, ctx: &egui::Context) {
|
||||
let links = self.device.scoped_links(&self.layout);
|
||||
let links = self.device.scoped_load_links(&self.layout);
|
||||
if links.is_empty() {
|
||||
self.device.error =
|
||||
"No linked layers in this scope. Map their destinations first.".into();
|
||||
|
|
@ -638,7 +665,12 @@ impl Editor {
|
|||
.indices(&self.layout)
|
||||
.iter()
|
||||
.find_map(|&i| {
|
||||
let link = self.layout.layer_info(i).device_link.as_ref()?;
|
||||
let link = self
|
||||
.layout
|
||||
.layer_info(i)
|
||||
.send_mapping
|
||||
.current_links()
|
||||
.next()?;
|
||||
snapshot
|
||||
.screens
|
||||
.iter()
|
||||
|
|
@ -665,7 +697,7 @@ impl Editor {
|
|||
}
|
||||
pub(super) fn device_send_button(&mut self, ui: &mut egui::Ui) {
|
||||
let plans = self.device.linked_plans(&self.layout);
|
||||
let conflicts = link_conflicts(&self.layout, &self.device.scoped_links(&self.layout));
|
||||
let conflicts = link_conflicts(&self.layout, &self.device.scoped_send_links(&self.layout));
|
||||
let enabled = self.device.online() && self.device.pending.is_none() && conflicts.is_none();
|
||||
let tooltip = if let Some(error) = conflicts {
|
||||
error
|
||||
|
|
@ -833,7 +865,7 @@ impl Editor {
|
|||
}
|
||||
let scope_indices = self.device.scope.indices(&self.layout);
|
||||
if self.device.online() {
|
||||
ui.weak(format!("{} editor layers in scope · {} saved links. Unlinked layers are skipped by linked send/load.", scope_indices.len(), self.device.scoped_links(&self.layout).len()));
|
||||
ui.weak(format!("{} editor layers in scope · {} saved links. Unlinked layers are skipped by linked send/load.", scope_indices.len(), self.device.scoped_load_links(&self.layout).len()));
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button(tr(ui.ctx(), "ui.connection-settings")).clicked() { self.device.connection_open = true; }
|
||||
|
|
@ -868,7 +900,7 @@ impl Editor {
|
|||
let screen_id = screen.id.clone();
|
||||
let mut targets: std::collections::BTreeMap<_, _> = scope_indices.iter().copied().map(|i| {
|
||||
let info = self.layout.layer_info(i);
|
||||
(info.id, info.device_link.as_ref().filter(|link| link.family == snapshot.profile.family() && link.screen == screen_id).map(|link| link.layer.clone()).unwrap_or_default())
|
||||
(info.id, info.send_mapping.current_links().find(|link| link.family == snapshot.profile.family() && link.screen == screen_id).map(|link| link.layer.clone()).unwrap_or_default())
|
||||
}).collect();
|
||||
let previous = targets.clone();
|
||||
let prepared_plan = send_review(ui, &self.layout, &scope_indices, snapshot, self.device.screen, &mut targets,
|
||||
|
|
@ -1131,7 +1163,7 @@ fn send_review(
|
|||
for &i in selected {
|
||||
let info = layout.layer_info(i);
|
||||
let id = info.id;
|
||||
if let Some(link) = &info.device_link {
|
||||
if let Some(link) = info.send_mapping.current_links().next() {
|
||||
ui.weak(format!(
|
||||
"Saved link: screen {} · layer {}",
|
||||
link.screen, link.layer
|
||||
|
|
@ -1345,6 +1377,70 @@ mod tests {
|
|||
)
|
||||
.unwrap()
|
||||
}
|
||||
#[test]
|
||||
fn directional_routes_load_separately_and_send_one_source_to_multiple_layers() {
|
||||
let snapshot = linked_test_snapshot();
|
||||
let mut layout = canvas_pilot::Layout::default();
|
||||
let link = |layer: &str| canvas_pilot::DeviceLink {
|
||||
family: device::Family::Midra4k,
|
||||
screen: "1".into(),
|
||||
layer: layer.into(),
|
||||
};
|
||||
layout
|
||||
.set_device_mappings(
|
||||
0,
|
||||
Some(link("1")),
|
||||
canvas_pilot::SendMapping::linked(Some(link("2"))),
|
||||
)
|
||||
.unwrap();
|
||||
let state = DeviceUi {
|
||||
snapshot: Some(snapshot.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(
|
||||
state.scoped_load_links(&layout),
|
||||
vec![(layout.layer_info(0).id, link("1"))]
|
||||
);
|
||||
assert_eq!(
|
||||
state.scoped_send_links(&layout),
|
||||
vec![(layout.layer_info(0).id, link("2"))]
|
||||
);
|
||||
let plan = state.linked_plans(&layout).unwrap();
|
||||
assert!(
|
||||
plan[0]
|
||||
.changes
|
||||
.iter()
|
||||
.any(|change| change.path.join("/").contains("/liveLayerList/items/2/"))
|
||||
);
|
||||
assert!(
|
||||
!plan[0]
|
||||
.changes
|
||||
.iter()
|
||||
.any(|change| change.path.join("/").contains("/liveLayerList/items/1/"))
|
||||
);
|
||||
let before = layout.layer_info(0).clone();
|
||||
let loads = state.scoped_load_links(&layout);
|
||||
load_linked_layers(&mut layout, &snapshot, &loads).unwrap();
|
||||
assert_eq!(layout.layer_info(0), &before);
|
||||
let mut send = canvas_pilot::SendMapping::linked(Some(link("1")));
|
||||
send.destinations
|
||||
.extend(canvas_pilot::SendMapping::linked(Some(link("2"))).destinations);
|
||||
layout
|
||||
.set_device_mappings(0, Some(link("1")), send)
|
||||
.unwrap();
|
||||
let plans = state.linked_plans(&layout).unwrap();
|
||||
for destination in ["1", "2"] {
|
||||
assert!(plans[0].observed.iter().any(|(path, _)| path.ends_with(&format!("/liveLayerList/items/{destination}"))));
|
||||
}
|
||||
layout.set_device_link(1, Some(link("2"))).unwrap();
|
||||
assert!(
|
||||
state
|
||||
.linked_plans(&layout)
|
||||
.unwrap_err()
|
||||
.contains("overlapping")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connection_history_tracks_successes_and_keeps_four_distinct_endpoints() {
|
||||
let mut device = DeviceUi::default();
|
||||
|
|
@ -1406,7 +1502,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
app.layout
|
||||
.layer_info(i)
|
||||
.device_link
|
||||
.load_mapping
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.screen,
|
||||
|
|
@ -1417,17 +1513,22 @@ mod tests {
|
|||
assert_eq!(
|
||||
app.layout
|
||||
.layer_info(i)
|
||||
.device_link
|
||||
.load_mapping
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.screen,
|
||||
"2"
|
||||
);
|
||||
assert_eq!(app.device.scoped_links(&app.layout).len(), 1);
|
||||
assert_eq!(app.device.scoped_load_links(&app.layout).len(), 1);
|
||||
assert_eq!(
|
||||
app.device.scoped_send_links(&app.layout),
|
||||
app.device.scoped_load_links(&app.layout)
|
||||
);
|
||||
let project = canvas_pilot::project::Project::from_layout(&app.layout);
|
||||
click_text(&mut app, &ctx, "Unmap");
|
||||
assert!(app.layout.layer_info(i).device_link.is_none());
|
||||
assert!(app.device.scoped_links(&app.layout).is_empty());
|
||||
assert!(app.layout.layer_info(i).load_mapping.is_none());
|
||||
assert!(app.device.scoped_load_links(&app.layout).is_empty());
|
||||
assert!(app.device.scoped_send_links(&app.layout).is_empty());
|
||||
assert_eq!(*app.layout.layers(), before);
|
||||
assert!(!app.device.sending);
|
||||
assert!(app.device.pending.is_none());
|
||||
|
|
@ -1537,7 +1638,7 @@ mod tests {
|
|||
load_linked_layers(&mut layout, &snapshot, &[(id, link.clone())]).unwrap();
|
||||
assert_eq!(layout.layers()[0], snapshot.screens[0].layers[1].geometry);
|
||||
assert_eq!(layout.layers()[1], before[1]);
|
||||
assert_eq!(layout.layer_info(0).device_link, Some(link.clone()));
|
||||
assert_eq!(layout.layer_info(0).load_mapping, Some(link.clone()));
|
||||
layout.undo();
|
||||
assert_eq!(*layout.layers(), before);
|
||||
layout.set_locked(0, true);
|
||||
|
|
@ -2109,7 +2210,7 @@ mod tests {
|
|||
let mut app = linked_folders();
|
||||
assert_eq!(app.device.scope, TransferScope::All);
|
||||
app.layout.select(Some(1));
|
||||
assert_eq!(app.device.scoped_links(&app.layout).len(), 2);
|
||||
assert_eq!(app.device.scoped_load_links(&app.layout).len(), 2);
|
||||
assert_eq!(app.device.linked_plans(&app.layout).unwrap().len(), 1);
|
||||
app.device.seed_import_mapping(&app.layout);
|
||||
assert!(matches!(
|
||||
|
|
@ -2126,7 +2227,7 @@ mod tests {
|
|||
app.device.seed_import_mapping(&app.layout);
|
||||
assert!(matches!(app.device.destinations[0], Destination::Skip));
|
||||
app.device.scope = TransferScope::Selected;
|
||||
assert!(app.device.scoped_links(&app.layout).is_empty());
|
||||
assert!(app.device.scoped_load_links(&app.layout).is_empty());
|
||||
assert!(app.device.linked_plans(&app.layout).is_err());
|
||||
app.layout.select(Some(0));
|
||||
app.device.seed_import_mapping(&app.layout);
|
||||
|
|
@ -2140,7 +2241,7 @@ mod tests {
|
|||
#[test]
|
||||
fn shared_links_warn_by_name_and_only_overlapping_send_scopes_are_blocked() {
|
||||
let mut app = linked_folders();
|
||||
let link = app.layout.layer_info(0).device_link.clone().unwrap();
|
||||
let link = app.layout.layer_info(0).load_mapping.clone().unwrap();
|
||||
app.layout.set_device_link(1, Some(link.clone())).unwrap();
|
||||
let warning = shared_link_warning(&app.layout, 0, &link).unwrap();
|
||||
assert!(warning.contains(&app.layout.layer_label(1)));
|
||||
|
|
@ -2208,13 +2309,13 @@ mod tests {
|
|||
)
|
||||
.unwrap();
|
||||
assert!(shared_link_warning(&app.layout, 0, &link).is_none());
|
||||
assert!(link_conflicts(&app.layout, &app.device.scoped_links(&app.layout)).is_none());
|
||||
assert!(link_conflicts(&app.layout, &app.device.scoped_load_links(&app.layout)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_memories_reuse_destinations_without_overwriting_other_links() {
|
||||
let mut app = linked_folders();
|
||||
let link = app.layout.layer_info(0).device_link.clone();
|
||||
let link = app.layout.layer_info(0).load_mapping.clone();
|
||||
app.layout.set_device_link(1, link).unwrap();
|
||||
let before = canvas_pilot::project::Project::from_layout(&app.layout);
|
||||
assert!(
|
||||
|
|
@ -2225,10 +2326,10 @@ mod tests {
|
|||
);
|
||||
app.device.scope = TransferScope::Folder("Intro".into());
|
||||
let first = app.device.linked_plans(&app.layout).unwrap();
|
||||
assert_eq!(app.device.scoped_links(&app.layout)[0].0, 2);
|
||||
assert_eq!(app.device.scoped_load_links(&app.layout)[0].0, 2);
|
||||
app.device.follow_folder("Talk");
|
||||
let second = app.device.linked_plans(&app.layout).unwrap();
|
||||
assert_eq!(app.device.scoped_links(&app.layout)[0].0, 1);
|
||||
assert_eq!(app.device.scoped_load_links(&app.layout)[0].0, 1);
|
||||
let values = |plan: &Plan| {
|
||||
plan.changes
|
||||
.iter()
|
||||
|
|
@ -2241,7 +2342,7 @@ mod tests {
|
|||
before
|
||||
);
|
||||
app.device.follow_folder("Removed");
|
||||
assert!(app.device.scoped_links(&app.layout).is_empty());
|
||||
assert!(app.device.scoped_load_links(&app.layout).is_empty());
|
||||
assert!(app.device.linked_plans(&app.layout).is_err());
|
||||
}
|
||||
|
||||
|
|
@ -2269,12 +2370,22 @@ mod tests {
|
|||
app.device.destinations = vec![Destination::Existing(1), Destination::New];
|
||||
app.apply_device_import().unwrap();
|
||||
assert_eq!(
|
||||
app.layout.layer_info(1).device_link.as_ref().unwrap().layer,
|
||||
app.layout
|
||||
.layer_info(1)
|
||||
.load_mapping
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.layer,
|
||||
"1"
|
||||
);
|
||||
assert_eq!(app.layout.layer_info(2).folder, "Talk");
|
||||
assert_eq!(
|
||||
app.layout.layer_info(2).device_link.as_ref().unwrap().layer,
|
||||
app.layout
|
||||
.layer_info(2)
|
||||
.load_mapping
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.layer,
|
||||
"2"
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
@ -2292,7 +2403,7 @@ mod tests {
|
|||
fn changing_folder_during_read_keeps_the_original_load_destinations() {
|
||||
let mut app = linked_folders();
|
||||
app.device.scope = TransferScope::Folder("Intro".into());
|
||||
let links = app.device.scoped_links(&app.layout);
|
||||
let links = app.device.scoped_load_links(&app.layout);
|
||||
let before_other = app.layout.layers()[1];
|
||||
app.device.loading = Some(links);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
|
@ -2386,7 +2497,7 @@ mod tests {
|
|||
let link = app
|
||||
.layout
|
||||
.layer_info(app.layout.layers().len() - 1)
|
||||
.device_link
|
||||
.load_mapping
|
||||
.clone()
|
||||
.unwrap();
|
||||
assert_eq!(link.family, device::Family::Aquilon);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//! Layer geometry, reversible edits and bounded imports.
|
||||
mod device_mapping;
|
||||
pub use device_mapping::{ConnectionTarget, SendDestination, SendMapping};
|
||||
pub mod clipboard;
|
||||
pub mod device;
|
||||
pub mod device_capture;
|
||||
|
|
@ -473,7 +475,8 @@ impl DeviceLink {
|
|||
#[serde(deny_unknown_fields)]
|
||||
pub struct LayerInfo {
|
||||
pub pivot: [f64; 2],
|
||||
pub device_link: Option<DeviceLink>,
|
||||
pub load_mapping: Option<DeviceLink>,
|
||||
pub send_mapping: SendMapping,
|
||||
pub id: usize,
|
||||
pub name: String,
|
||||
pub folder: String,
|
||||
|
|
@ -568,14 +571,16 @@ impl Default for Layout {
|
|||
info: vec![
|
||||
LayerInfo {
|
||||
pivot: [0.5; 2],
|
||||
device_link: None,
|
||||
load_mapping: None,
|
||||
send_mapping: Default::default(),
|
||||
id: 2,
|
||||
name: "Slides".into(),
|
||||
folder: String::new(),
|
||||
},
|
||||
LayerInfo {
|
||||
pivot: [0.5; 2],
|
||||
device_link: None,
|
||||
load_mapping: None,
|
||||
send_mapping: Default::default(),
|
||||
id: 1,
|
||||
name: "Presenter".into(),
|
||||
folder: String::new(),
|
||||
|
|
@ -643,19 +648,33 @@ impl Layout {
|
|||
self.layers = s.layers;
|
||||
self.formats = s.formats;
|
||||
}
|
||||
/// Current UI contract: change both directions together, with one send target.
|
||||
pub fn set_device_link(&mut self, i: usize, link: Option<DeviceLink>) -> Result<(), String> {
|
||||
let send = SendMapping::linked(link.clone());
|
||||
self.set_device_mappings(i, link, send)
|
||||
}
|
||||
|
||||
/// Independent routing model; the current UI only uses `set_device_link`.
|
||||
pub fn set_device_mappings(
|
||||
&mut self,
|
||||
i: usize,
|
||||
load: Option<DeviceLink>,
|
||||
send: SendMapping,
|
||||
) -> Result<(), String> {
|
||||
if i >= self.info.len() {
|
||||
return Err("Layer no longer exists.".into());
|
||||
}
|
||||
if let Some(link) = &link {
|
||||
if let Some(link) = &load {
|
||||
link.validate()?;
|
||||
}
|
||||
if self.info[i].device_link == link {
|
||||
send.validate()?;
|
||||
if self.info[i].load_mapping == load && self.info[i].send_mapping == send {
|
||||
return Ok(());
|
||||
}
|
||||
self.finish_drag();
|
||||
let before = self.snapshot();
|
||||
self.info[i].device_link = link;
|
||||
self.info[i].load_mapping = load;
|
||||
self.info[i].send_mapping = send;
|
||||
self.remember(before);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -738,7 +757,8 @@ impl Layout {
|
|||
self.layers.push(g);
|
||||
self.info.push(LayerInfo {
|
||||
pivot: [0.5; 2],
|
||||
device_link: None,
|
||||
load_mapping: None,
|
||||
send_mapping: Default::default(),
|
||||
id: self.next_id,
|
||||
name: format!("Layer {}", self.next_id),
|
||||
folder: String::new(),
|
||||
|
|
@ -1502,7 +1522,8 @@ impl Layout {
|
|||
draft.info[i].folder = new_folder.trim().into();
|
||||
i
|
||||
};
|
||||
draft.info[i].device_link = Some(link.clone());
|
||||
draft.info[i].load_mapping = Some(link.clone());
|
||||
draft.info[i].send_mapping = SendMapping::linked(Some(link.clone()));
|
||||
}
|
||||
self.finish_drag();
|
||||
let before = self.snapshot();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ pub struct Input {
|
|||
pub struct Layer {
|
||||
pub pivot: [f64; 2],
|
||||
#[serde(deserialize_with = "deserialize_link")]
|
||||
pub device_link: Option<crate::DeviceLink>,
|
||||
pub load_mapping: Option<crate::DeviceLink>,
|
||||
pub send_mapping: crate::SendMapping,
|
||||
pub name: String,
|
||||
pub folder: String,
|
||||
pub id: usize,
|
||||
|
|
@ -181,7 +182,7 @@ impl Project {
|
|||
folders: layout.folders.clone(),
|
||||
workspace: Workspace::default(),
|
||||
format: FORMAT.into(),
|
||||
version: 18,
|
||||
version: 19,
|
||||
input_proposals: Vec::new(),
|
||||
next_layer_id: layout.next_id,
|
||||
output_resolution: layout.formats.output.into(),
|
||||
|
|
@ -199,7 +200,8 @@ impl Project {
|
|||
layers: (0..layout.layers.len())
|
||||
.map(|i| Layer {
|
||||
pivot: layout.info[i].pivot,
|
||||
device_link: layout.info[i].device_link.clone(),
|
||||
load_mapping: layout.info[i].load_mapping.clone(),
|
||||
send_mapping: layout.info[i].send_mapping.clone(),
|
||||
name: layout.info[i].name.clone(),
|
||||
folder: layout.info[i].folder.clone(),
|
||||
id: layout.info[i].id,
|
||||
|
|
@ -233,9 +235,9 @@ impl Project {
|
|||
}
|
||||
/// Build a fresh document only after validating the entire file. No history is restored.
|
||||
pub fn layout(&self) -> Result<Layout, String> {
|
||||
if self.format != FORMAT || self.version != 18 {
|
||||
if self.format != FORMAT || self.version != 19 {
|
||||
return Err(
|
||||
"Unsupported project format/version; expected beffroi.midra-layout version 18."
|
||||
"Unsupported project format/version; expected beffroi.midra-layout version 19."
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
|
@ -248,7 +250,9 @@ impl Project {
|
|||
if !proposal_layers.insert(proposal.layer_id)
|
||||
|| !self.layers.iter().any(|l| {
|
||||
l.id == proposal.layer_id
|
||||
&& l.device_link.as_ref() == Some(&proposal.device_link)
|
||||
&& l.send_mapping
|
||||
.current_links()
|
||||
.any(|link| link == &proposal.device_link)
|
||||
})
|
||||
{
|
||||
return Err(
|
||||
|
|
@ -337,13 +341,15 @@ impl Project {
|
|||
{
|
||||
return Err("Invalid layer identity, name, folder or source ID.".into());
|
||||
}
|
||||
if let Some(link) = &layer.device_link {
|
||||
layer.send_mapping.validate()?;
|
||||
if let Some(link) = &layer.load_mapping {
|
||||
link.validate()?;
|
||||
}
|
||||
crate::validate_pivot(layer.pivot)?;
|
||||
layout.info.push(crate::LayerInfo {
|
||||
pivot: layer.pivot,
|
||||
device_link: layer.device_link.clone(),
|
||||
load_mapping: layer.load_mapping.clone(),
|
||||
send_mapping: layer.send_mapping.clone(),
|
||||
id: layer.id,
|
||||
name: layer.name.clone(),
|
||||
folder: layer.folder.clone(),
|
||||
|
|
@ -447,8 +453,8 @@ impl Project {
|
|||
}
|
||||
let header: Header =
|
||||
serde_json::from_str(text).map_err(|e| format!("Invalid project JSON: {e}"))?;
|
||||
if !(1..=18).contains(&header.version) {
|
||||
return Err("Unsupported project version; expected versions 1–18.".into());
|
||||
if !(1..=19).contains(&header.version) {
|
||||
return Err("Unsupported project version; expected versions 1–19.".into());
|
||||
}
|
||||
let mut migrated: serde_json::Value = if header.version == 1 || header.version == 2 {
|
||||
let mut value: serde_json::Value =
|
||||
|
|
@ -699,6 +705,26 @@ impl Project {
|
|||
snapping.insert("mask_edges".into(), false.into());
|
||||
migrated["version"] = 18.into();
|
||||
}
|
||||
if header.version <= 18 {
|
||||
for layer in migrated["layers"].as_array_mut().ok_or("Missing layers")? {
|
||||
let layer = layer.as_object_mut().ok_or("Invalid project layer")?;
|
||||
if layer.contains_key("load_mapping") || layer.contains_key("send_mapping") {
|
||||
return Err("Unexpected directional mapping in legacy project.".into());
|
||||
}
|
||||
let link = layer.remove("device_link").ok_or("Missing device_link")?;
|
||||
let destinations = if link.is_null() {
|
||||
serde_json::json!([])
|
||||
} else {
|
||||
serde_json::json!([{ "connection": "current", "layer": link.clone() }])
|
||||
};
|
||||
layer.insert("load_mapping".into(), link);
|
||||
layer.insert(
|
||||
"send_mapping".into(),
|
||||
serde_json::json!({ "destinations": destinations }),
|
||||
);
|
||||
}
|
||||
migrated["version"] = 19.into();
|
||||
}
|
||||
let p: Self =
|
||||
serde_json::from_value(migrated).map_err(|e| format!("Invalid project JSON: {e}"))?;
|
||||
p.layout()?;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,9 @@ impl Editor {
|
|||
.filter(|proposal| {
|
||||
p.layers.iter().any(|l| {
|
||||
l.id == proposal.layer_id
|
||||
&& l.device_link.as_ref() == Some(&proposal.device_link)
|
||||
&& l.send_mapping
|
||||
.current_links()
|
||||
.any(|link| link == &proposal.device_link)
|
||||
})
|
||||
})
|
||||
.cloned()
|
||||
|
|
|
|||
|
|
@ -231,6 +231,18 @@ mod tests {
|
|||
},
|
||||
)
|
||||
.unwrap();
|
||||
let load = canvas_pilot::DeviceLink {
|
||||
family: Default::default(),
|
||||
screen: "1".into(),
|
||||
layer: "1".into(),
|
||||
};
|
||||
let mut target = load.clone();
|
||||
target.layer = "2".into();
|
||||
let mut send = canvas_pilot::SendMapping::linked(Some(target.clone()));
|
||||
target.screen = "2".into();
|
||||
send.destinations
|
||||
.extend(canvas_pilot::SendMapping::linked(Some(target)).destinations);
|
||||
app.layout.set_device_mappings(0, Some(load), send).unwrap();
|
||||
app.layout.set_layer_pivots(&[(1, [0.2, 0.7])]).unwrap();
|
||||
app.corner = PositionPoint::BottomRight;
|
||||
app.position_layer_point = Some(PositionPoint::Center);
|
||||
|
|
|
|||
|
|
@ -240,12 +240,12 @@ fn family_links_save_migrate_recover_and_validate() {
|
|||
let mut old: Value = serde_json::from_str(old).unwrap();
|
||||
old["layers"][0]["midra_link"] = json!({"screen":"001","layer":"02"});
|
||||
let p = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(p.version, 18);
|
||||
assert_eq!(p.version, 19);
|
||||
assert_eq!(
|
||||
p.layers[0].device_link.as_ref().unwrap().family,
|
||||
p.layers[0].load_mapping.as_ref().unwrap().family,
|
||||
Family::Midra4k
|
||||
);
|
||||
assert_eq!(p.layers[0].device_link.as_ref().unwrap().screen, "1");
|
||||
assert_eq!(p.layers[0].load_mapping.as_ref().unwrap().screen, "1");
|
||||
let mut layout = p.layout().unwrap();
|
||||
let link = DeviceLink {
|
||||
family: Family::Aquilon,
|
||||
|
|
@ -255,15 +255,15 @@ fn family_links_save_migrate_recover_and_validate() {
|
|||
layout.set_device_link(0, Some(link.clone())).unwrap();
|
||||
let p = Project::from_layout(&layout);
|
||||
let text = p.to_json().unwrap();
|
||||
assert!(text.contains("device_link"));
|
||||
assert!(text.contains("load_mapping"));
|
||||
assert!(!text.contains("midra_link"));
|
||||
assert_eq!(
|
||||
Project::from_json(&text).unwrap().layers[0].device_link,
|
||||
Project::from_json(&text).unwrap().layers[0].load_mapping,
|
||||
Some(link)
|
||||
);
|
||||
layout.undo();
|
||||
assert_eq!(
|
||||
layout.layer_info(0).device_link.as_ref().unwrap().family,
|
||||
layout.layer_info(0).load_mapping.as_ref().unwrap().family,
|
||||
Family::Midra4k
|
||||
);
|
||||
for (family, screen) in [
|
||||
|
|
@ -300,8 +300,8 @@ fn documented_v13_example_contains_native_aquilon_link() {
|
|||
"../../../docs/interfaces/canvas-pilot-v13.example.json"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(p.version, 18);
|
||||
let link = p.layers[0].device_link.as_ref().unwrap();
|
||||
assert_eq!(p.version, 19);
|
||||
let link = p.layers[0].load_mapping.as_ref().unwrap();
|
||||
assert_eq!(link.family, Family::Aquilon);
|
||||
assert_eq!(link.screen, "S1");
|
||||
assert_eq!(Project::from_json(&p.to_json().unwrap()).unwrap(), p);
|
||||
|
|
@ -635,3 +635,37 @@ fn captured_rs1_mask_import_preserves_visible_geometry_and_reveal_bounds() {
|
|||
assert_eq!(layer.source, "LIVE_1");
|
||||
assert_eq!(layer.mask.origin, canvas_pilot::formats::MaskOrigin::Layer);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_editor_layer_can_prepare_multiple_distinct_aquilon_destinations() {
|
||||
let snapshot = Snapshot::parse(&identity(), &routed()).unwrap();
|
||||
let layout = Layout::default();
|
||||
let mappings = vec![(1, "1".into()), (1, "2".into())];
|
||||
let plan = Plan::prepare(
|
||||
&snapshot,
|
||||
&layout,
|
||||
0,
|
||||
&mappings,
|
||||
Target::Preview,
|
||||
Sizing::OutputBox,
|
||||
)
|
||||
.unwrap();
|
||||
for layer in ["1", "2"] {
|
||||
assert!(
|
||||
plan.observed
|
||||
.iter()
|
||||
.any(|(path, _)| path.ends_with(&format!("/layerList/items/{layer}")))
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
Plan::prepare(
|
||||
&snapshot,
|
||||
&layout,
|
||||
0,
|
||||
&[(1, "1".into()), (2, "1".into())],
|
||||
Target::Preview,
|
||||
Sizing::OutputBox
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn every_fit_roundtrips_exact_crop_mask_and_offset_with_atomic_undo() {
|
|||
}
|
||||
assert_eq!(after.inputs, before.inputs);
|
||||
assert_eq!(after.layers[1].source_id, before.layers[1].source_id);
|
||||
assert_eq!(after.layers[1].device_link, before.layers[1].device_link);
|
||||
assert_eq!(after.layers[1].load_mapping, before.layers[1].load_mapping);
|
||||
assert_eq!(after.layers[1].name, before.layers[1].name);
|
||||
let second = clipboard::encode(&layout, &[1], "Second copy").unwrap();
|
||||
assert_eq!(parse_values(&second).unwrap().shapes[0].appearance, Some(a));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
use canvas_pilot::{
|
||||
ConnectionTarget, DeviceLink, Layout, SendDestination, SendMapping, project::Project,
|
||||
};
|
||||
|
||||
fn link(screen: &str, layer: &str) -> DeviceLink {
|
||||
DeviceLink {
|
||||
family: Default::default(),
|
||||
screen: screen.into(),
|
||||
layer: layer.into(),
|
||||
}
|
||||
}
|
||||
fn sends() -> SendMapping {
|
||||
SendMapping {
|
||||
destinations: vec![link("1", "2"), link("2", "3")]
|
||||
.into_iter()
|
||||
.map(|layer| SendDestination {
|
||||
connection: ConnectionTarget::Current,
|
||||
layer,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn independent_directions_roundtrip_and_undo_together() {
|
||||
let mut layout = Layout::default();
|
||||
let before = Project::from_layout(&layout);
|
||||
layout
|
||||
.set_device_mappings(0, Some(link("1", "1")), sends())
|
||||
.unwrap();
|
||||
let project = Project::from_layout(&layout);
|
||||
assert_eq!(project.layers[0].load_mapping, Some(link("1", "1")));
|
||||
assert_eq!(project.layers[0].send_mapping, sends());
|
||||
let reopened = Project::from_json(&project.to_json().unwrap()).unwrap();
|
||||
assert_eq!(Project::from_layout(&reopened.layout().unwrap()), project);
|
||||
layout.undo();
|
||||
assert_eq!(Project::from_layout(&layout), before);
|
||||
layout.redo();
|
||||
assert_eq!(Project::from_layout(&layout), project);
|
||||
layout.set_device_link(0, Some(link("3", "4"))).unwrap();
|
||||
assert_eq!(layout.layer_info(0).load_mapping, Some(link("3", "4")));
|
||||
assert_eq!(
|
||||
layout.layer_info(0).send_mapping,
|
||||
SendMapping::linked(Some(link("3", "4")))
|
||||
);
|
||||
layout.set_device_link(0, None).unwrap();
|
||||
assert!(layout.layer_info(0).load_mapping.is_none());
|
||||
assert!(layout.layer_info(0).send_mapping.destinations.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v18_migration_synchronizes_links_and_v19_requires_both_directions() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v18.example.json");
|
||||
let project = Project::from_json(old).unwrap();
|
||||
assert_eq!(project.version, 19);
|
||||
for layer in &project.layers {
|
||||
assert_eq!(
|
||||
layer.send_mapping,
|
||||
SendMapping::linked(layer.load_mapping.clone())
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
project,
|
||||
Project::from_json(include_str!(
|
||||
"../../../docs/interfaces/canvas-pilot-v19.example.json"
|
||||
))
|
||||
.unwrap()
|
||||
);
|
||||
let json = serde_json::to_value(&project).unwrap();
|
||||
for key in ["load_mapping", "send_mapping"] {
|
||||
let mut bad = json.clone();
|
||||
bad["layers"][0].as_object_mut().unwrap().remove(key);
|
||||
assert!(Project::from_json(&bad.to_string()).is_err());
|
||||
}
|
||||
let mut bad = json.clone();
|
||||
bad["version"] = 18.into();
|
||||
assert!(Project::from_json(&bad.to_string()).is_err());
|
||||
let mut bad = json;
|
||||
bad["layers"][0]["send_mapping"]["destinations"][0]["connection"] = "other-machine".into();
|
||||
assert!(Project::from_json(&bad.to_string()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_destinations_are_atomic_and_repeated_load_sources_are_allowed() {
|
||||
let mut layout = Layout::default();
|
||||
layout.set_device_link(0, Some(link("1", "1"))).unwrap();
|
||||
layout.set_device_link(1, Some(link("1", "1"))).unwrap();
|
||||
let before = Project::from_layout(&layout);
|
||||
let mut duplicate = sends();
|
||||
duplicate
|
||||
.destinations
|
||||
.push(duplicate.destinations[0].clone());
|
||||
assert!(layout.set_device_mappings(0, None, duplicate).is_err());
|
||||
let mut invalid = sends();
|
||||
invalid.destinations[0].layer.screen = "../1".into();
|
||||
assert!(layout.set_device_mappings(0, None, invalid).is_err());
|
||||
assert!(layout.set_device_mappings(99, None, sends()).is_err());
|
||||
assert_eq!(Project::from_layout(&layout), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_snapshot_codec_preserves_independent_directions_and_fanout() {
|
||||
use canvas_pilot::{
|
||||
exchange::Options,
|
||||
exchange_metadata as metadata,
|
||||
interchange::{self, Codec},
|
||||
};
|
||||
let mut layout = Layout::default();
|
||||
layout
|
||||
.set_device_mappings(0, Some(link("3", "1")), sends())
|
||||
.unwrap();
|
||||
let project = Project::from_layout(&layout);
|
||||
let ids = [project.layers[0].id];
|
||||
let expected = metadata::snapshot(&project, &ids).unwrap();
|
||||
for codec in Codec::available()
|
||||
.into_iter()
|
||||
.filter(|&c| metadata::supported(c))
|
||||
{
|
||||
let bytes = interchange::export(
|
||||
&project,
|
||||
&ids,
|
||||
codec,
|
||||
Options {
|
||||
extra_parameters: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
metadata::extract(&bytes, codec).unwrap(),
|
||||
Some(expected.clone()),
|
||||
"{codec:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,11 +20,12 @@ fn fixture() -> Project {
|
|||
let mut p = Project::from_layout(&layout);
|
||||
p.layers[0].name = "<Speaker> & \"guest\"".into();
|
||||
p.layers[0].folder = "Memory A".into();
|
||||
p.layers[0].device_link = Some(canvas_pilot::DeviceLink {
|
||||
p.layers[0].load_mapping = Some(canvas_pilot::DeviceLink {
|
||||
family: Default::default(),
|
||||
screen: "2".into(),
|
||||
layer: "1".into(),
|
||||
});
|
||||
p.layers[0].send_mapping = canvas_pilot::SendMapping::linked(p.layers[0].load_mapping.clone());
|
||||
p.workspace.collapsed_folders = vec!["Memory A".into()];
|
||||
p
|
||||
}
|
||||
|
|
@ -397,11 +398,13 @@ fn every_snapshot_codec_roundtrips_all_fit_modes_masks_sources_links_and_proposa
|
|||
p.layers[0].folder = "Scene".into();
|
||||
p.folders = vec!["Scene".into(), "Unused".into()];
|
||||
p.layers[0].pivot = [0.25, 0.75];
|
||||
p.layers[0].device_link = Some(canvas_pilot::DeviceLink {
|
||||
p.layers[0].load_mapping = Some(canvas_pilot::DeviceLink {
|
||||
family: Default::default(),
|
||||
screen: "1".into(),
|
||||
layer: "3".into(),
|
||||
});
|
||||
p.layers[0].send_mapping =
|
||||
canvas_pilot::SendMapping::linked(p.layers[0].load_mapping.clone());
|
||||
p.layers[1].source_id = p.layers[0].source_id;
|
||||
let native = &p.inputs[0].native_resolution;
|
||||
let input = p.inputs[0]
|
||||
|
|
@ -440,7 +443,7 @@ fn every_snapshot_codec_roundtrips_all_fit_modes_masks_sources_links_and_proposa
|
|||
|
||||
p.input_proposals.push(InputProposal {
|
||||
layer_id: p.layers[0].id,
|
||||
device_link: p.layers[0].device_link.clone().unwrap(),
|
||||
device_link: p.layers[0].load_mapping.clone().unwrap(),
|
||||
input: "INPUT_4".into(),
|
||||
plug: "2".into(),
|
||||
settings: serde_json::from_value(serde_json::json!({
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn explicit_empty_folders_survive_history_save_rename_and_membership_changes() {
|
|||
fn version_12_explicit_folder_validation_and_v11_migration() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v11.example.json");
|
||||
let p = Project::from_json(old).unwrap();
|
||||
assert_eq!(p.version, 18);
|
||||
assert_eq!(p.version, 19);
|
||||
assert!(p.folders.is_empty());
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v12.example.json");
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() {
|
|||
layout.apply(0, box_geometry()).unwrap();
|
||||
assert_eq!(layout.formats().advanced[0], crop);
|
||||
let before = Project::from_layout(&layout);
|
||||
assert_eq!(before.version, 18);
|
||||
assert_eq!(before.version, 19);
|
||||
let loaded = Project::from_json(&before.to_json().unwrap()).unwrap();
|
||||
assert_eq!(loaded, before);
|
||||
assert_eq!(
|
||||
|
|
@ -107,7 +107,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() {
|
|||
fn v13_migration_defaults_to_normal_crop_and_v14_requires_valid_fit() {
|
||||
let text = include_str!("../../../docs/interfaces/canvas-pilot-v13.example.json");
|
||||
let migrated = Project::from_json(text).unwrap();
|
||||
assert_eq!(migrated.version, 18);
|
||||
assert_eq!(migrated.version, 19);
|
||||
assert!(migrated.layers.iter().all(|l| l.layer_fit.is_none()));
|
||||
let mut json = serde_json::to_value(&migrated).unwrap();
|
||||
json["layers"][0]
|
||||
|
|
@ -125,7 +125,7 @@ fn current_documented_example_is_valid() {
|
|||
"../../../docs/interfaces/canvas-pilot-v14.example.json"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(p.version, 18);
|
||||
assert_eq!(p.version, 19);
|
||||
p.layout().unwrap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ fn mask_schema_migration_validation_reorder_resize_and_atomic_import() {
|
|||
assert_eq!(Project::from_json(&p.to_json().unwrap()).unwrap(), p);
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v14.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert_eq!(migrated.version, 18);
|
||||
assert_eq!(migrated.version, 19);
|
||||
assert!(migrated.layers.iter().all(|l| l.mask == Mask::default()));
|
||||
let mut json = serde_json::to_value(&p).unwrap();
|
||||
json["layers"][0].as_object_mut().unwrap().remove("mask");
|
||||
|
|
|
|||
|
|
@ -221,30 +221,30 @@ fn persistent_device_links_roundtrip_migrate_and_undo() {
|
|||
.unwrap()
|
||||
.layout()
|
||||
.unwrap();
|
||||
assert_eq!(restored.layer_info(0).device_link, Some(first_link));
|
||||
assert_eq!(restored.layer_info(1).device_link, Some(link.clone()));
|
||||
assert_eq!(restored.layer_info(0).load_mapping, Some(first_link));
|
||||
assert_eq!(restored.layer_info(1).load_mapping, Some(link.clone()));
|
||||
layout.undo();
|
||||
assert!(layout.layer_info(1).device_link.is_none());
|
||||
assert!(layout.layer_info(1).load_mapping.is_none());
|
||||
layout.redo();
|
||||
assert_eq!(layout.layer_info(1).device_link, Some(link));
|
||||
assert_eq!(layout.layer_info(1).load_mapping, Some(link));
|
||||
layout.set_device_link(1, None).unwrap();
|
||||
assert!(layout.layer_info(1).device_link.is_none());
|
||||
assert!(layout.layer_info(1).load_mapping.is_none());
|
||||
for text in [
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-v4.example.json"),
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-v5.example.json"),
|
||||
] {
|
||||
let p = Project::from_json(text).unwrap();
|
||||
assert_eq!(p.version, 18);
|
||||
assert!(p.layers.iter().all(|l| l.device_link.is_none()));
|
||||
assert_eq!(p.version, 19);
|
||||
assert!(p.layers.iter().all(|l| l.load_mapping.is_none()));
|
||||
}
|
||||
let mut value = serde_json::to_value(&project).unwrap();
|
||||
value["layers"][1]["device_link"]["screen"] = "../2".into();
|
||||
value["layers"][1]["load_mapping"]["screen"] = "../2".into();
|
||||
assert!(Project::from_json(&value.to_string()).is_err());
|
||||
value["layers"][1]["device_link"] = serde_json::Value::Null;
|
||||
value["layers"][1]["load_mapping"] = serde_json::Value::Null;
|
||||
value["layers"][1]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("device_link");
|
||||
.remove("load_mapping");
|
||||
assert!(Project::from_json(&value.to_string()).is_err());
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
|
|||
.unwrap();
|
||||
old["editor"]["position_corner"] = name.into();
|
||||
let loaded = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(loaded.version, 18);
|
||||
assert_eq!(loaded.version, 19);
|
||||
assert_eq!(loaded.editor.position_point, expected);
|
||||
old["editor"]["position_corner"] = "center".into();
|
||||
assert!(Project::from_json(&old.to_string()).is_err());
|
||||
|
|
@ -320,7 +320,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
|
|||
assert!(Project::from_json(&old.to_string()).is_err());
|
||||
}
|
||||
let value: serde_json::Value = serde_json::from_str(¤t.to_json().unwrap()).unwrap();
|
||||
for version in [0, 19] {
|
||||
for version in [0, 20] {
|
||||
let mut invalid = value.clone();
|
||||
invalid["version"] = version.into();
|
||||
assert!(
|
||||
|
|
@ -361,7 +361,7 @@ fn backdrop_title_roundtrips_and_older_projects_gain_the_default() {
|
|||
}
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v6.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert_eq!(migrated.version, 18);
|
||||
assert_eq!(migrated.version, 19);
|
||||
assert_eq!(migrated.editor.backdrop_title, DEFAULT_BACKDROP_TITLE);
|
||||
let mut invalid: serde_json::Value = serde_json::from_str(old).unwrap();
|
||||
invalid["editor"]["backdrop_title"] = "Unexpected".into();
|
||||
|
|
@ -432,7 +432,7 @@ fn saved_pivots_roundtrip_and_old_projects_default_to_center() {
|
|||
assert_eq!(loaded.layer_info(0).pivot, custom);
|
||||
assert_eq!(loaded.layer_info(1).pivot, [0.5; 2]);
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v9.example.json");
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 18);
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 19);
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v8.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert!(migrated.layers.iter().all(|l| l.pivot == [0.5; 2]));
|
||||
|
|
@ -464,7 +464,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
|
|||
let reference = serde_json::json!({"name":"guide.png","image_base64":STANDARD.encode(b"image bytes"),"visible":false,"opacity":0.4,"preserve_ratio":true,"native_size":false,"offset":[0.0,0.0]});
|
||||
old["reference"] = reference.clone();
|
||||
let migrated = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(migrated.version, 18);
|
||||
assert_eq!(migrated.version, 19);
|
||||
assert_eq!(migrated.references.len(), 1);
|
||||
assert!(!migrated.references[0].visible);
|
||||
assert_eq!(migrated.references[0].opacity, 0.4);
|
||||
|
|
@ -484,7 +484,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
|
|||
gallery.references = vec![migrated.references[0].clone(); 33];
|
||||
assert!(gallery.to_json().unwrap_err().contains("32 reference"));
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v10.example.json");
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 18);
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 19);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -611,7 +611,7 @@ fn workspace_roundtrip_migration_and_validation() {
|
|||
fn input_proposals_migrate_validate_and_require_explicit_version_16() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v15.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert_eq!(migrated.version, 18);
|
||||
assert_eq!(migrated.version, 19);
|
||||
assert!(migrated.input_proposals.is_empty());
|
||||
let fixture = include_str!("../../../docs/interfaces/canvas-pilot-v16.example.json");
|
||||
let project = Project::from_json(fixture).unwrap();
|
||||
|
|
@ -674,7 +674,7 @@ fn mask_snapping_migration_and_strict_round_trip() {
|
|||
let mut value = serde_json::to_value(project).unwrap();
|
||||
value["version"] = 17.into();
|
||||
assert!(Project::from_json(&value.to_string()).is_err());
|
||||
value["version"] = 18.into();
|
||||
value["version"] = 19.into();
|
||||
value["workspace"]["snapping"]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.9.49
|
||||
|
||||
- Split load sources from send destination collections internally, keeping existing
|
||||
controls synchronized with one destination and unchanged visuals. Send destinations
|
||||
explicitly name the current connection scope; both adapters can prepare fan-out
|
||||
to distinct layers while retaining collision checks. Project v19 migrates old
|
||||
mappings into both directions; recovery and embedded snapshots retain the split.
|
||||
Added routing, undo, migration and exchange round-trip regression checks.
|
||||
|
||||
### v0.9.48
|
||||
|
||||
- Keep the four layer-header buttons inside the sidebar content area so their
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ it does not interrupt an in-process render already underway. External conversion
|
|||
has a 60-second process timeout and uses temporary files; LibreOffice gets a fresh
|
||||
isolated profile. Password-required PDFs report an error rather than prompting.
|
||||
|
||||
The project schema remains version 18: the existing reference `image_base64`
|
||||
The project schema is version 19: the existing reference `image_base64`
|
||||
contains the generated PNG, and its name includes the source filename and chosen
|
||||
page label. No document bytes, source paths, converter settings or live links are
|
||||
persisted. Reopening a project only decodes that PNG. Source editability, resolution
|
||||
|
|
@ -490,7 +490,7 @@ Normal geometry import continues to use the artwork's current boxes, including a
|
|||
external edits. Third-party editors may strip metadata. DWG, FIG and Illustrator are not
|
||||
enabled until their current codec paths can preserve it reliably.
|
||||
|
||||
Embedded project snapshots now contain project version 16 and family-aware `device_link` objects. Geometry representation versions are unchanged. Existing embedded versions 1–15 migrate using the [project contract](canvas-pilot.md); plain geometry continues to omit device destinations.
|
||||
Embedded project snapshots contain project version 19 with separate `load_mapping` and `send_mapping` fields. Geometry representation versions are unchanged. Existing embedded versions 1–18 migrate using the [project contract](canvas-pilot.md); plain geometry continues to omit device destinations.
|
||||
|
||||
Project v14 additionally preserves `layer_fit` in embedded snapshots. Geometry
|
||||
alone describes the layer container when explicit fit is enabled and omits crop
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ not every control should become document data.
|
|||
| Input format, native dimensions, custom input crop, shared input slot | Project: `inputs` and layer `source_id`, already saved. |
|
||||
| Layer format, dynamic crop, zoom and offset, explicit fit modes and blanking masks | Project: final bounds and advanced crop, already saved. Zoom/offset/aspect are derived from these authoritative values. |
|
||||
| Names, stable IDs, next ID, folder membership, visibility, lock, pivot | Project, already saved. Folder visibility/locking acts on members, so there is no separate state to save. Explicit folder names are saved separately in project v12 and may have no members. |
|
||||
| Device screen/layer mapping | Project, already saved per layer. Physical source routing is separate and is not silently changed by a geometry send. |
|
||||
| Device screen/layer mapping | Project v19 stores `load_mapping` and the `send_mapping` destination collection separately. Existing controls edit both together; older projects migrate to synchronized mappings. Physical source routing is separate and is not silently changed by a geometry send. |
|
||||
| Reference images, order, visibility, opacity, fit/native sizing, offset | Project, already embedded. Focused reference row is temporary. |
|
||||
| Selected layers, viewport zoom/pan, positioning origins | Project, already saved. Selection is validated against visible/unlocked IDs. |
|
||||
| Backdrop title, source guide pattern, outline mode, aspect-ratio lock, icon captions | Project, already saved. Pattern/ratio lock/captions also have application defaults. |
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ not a named project export. Headless/default editors never access this path.
|
|||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `version` | Integer `1`; other versions rejected |
|
||||
| `project` | Complete [project v18](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
|
||||
| `project` | Complete [project v19](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
|
||||
| `project_path` | Last opened/successfully saved named JSON path, or null; geometry exports do not change it |
|
||||
| `manual_saved_at` | Unix UTC seconds of the last successful explicit project save, or null when unknown; recovery and measurement-point autosaves do not update it |
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ last successful writer wins.
|
|||
Recovery retains applied values only: no undo history, pending text/format/import
|
||||
drafts, transient tools, or credentials. A normal exit cancels unfinished canvas
|
||||
gestures before the final checkpoint. The schema does not replace named project
|
||||
JSON: Save continues to emit a bare project v18 document. Opening/New replaces the
|
||||
JSON: Save continues to emit a bare project v19 document. Opening/New replaces the
|
||||
single recovery slot; New warns with the manual-save age and Save/Discard/Cancel.
|
||||
A failed or cancelled manual save never completes Save-and-create-new.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,184 @@
|
|||
{
|
||||
"format": "beffroi.midra-layout",
|
||||
"version": 19,
|
||||
"output_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"id": 1,
|
||||
"source_format": "sixteen_nine",
|
||||
"native_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
},
|
||||
"input_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"source_format": "sixteen_nine",
|
||||
"native_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
},
|
||||
"input_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
}
|
||||
}
|
||||
],
|
||||
"layers": [
|
||||
{
|
||||
"id": 2,
|
||||
"source_id": 1,
|
||||
"bounds": {
|
||||
"x": 120.0,
|
||||
"y": 180.0,
|
||||
"width": 640.0,
|
||||
"height": 360.0
|
||||
},
|
||||
"advanced_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
},
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"name": "Slides",
|
||||
"folder": "",
|
||||
"pivot": [
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"layer_fit": null,
|
||||
"mask": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0,
|
||||
"origin": "source"
|
||||
},
|
||||
"load_mapping": {
|
||||
"family": "midra4k",
|
||||
"screen": "1",
|
||||
"layer": "1"
|
||||
},
|
||||
"send_mapping": {
|
||||
"destinations": [
|
||||
{
|
||||
"connection": "current",
|
||||
"layer": {
|
||||
"family": "midra4k",
|
||||
"screen": "1",
|
||||
"layer": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"source_id": 2,
|
||||
"bounds": {
|
||||
"x": 1160.0,
|
||||
"y": 180.0,
|
||||
"width": 640.0,
|
||||
"height": 360.0
|
||||
},
|
||||
"advanced_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
},
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"name": "Presenter",
|
||||
"folder": "",
|
||||
"pivot": [
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"layer_fit": "fullscreen",
|
||||
"mask": {
|
||||
"left": 0.1,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0,
|
||||
"origin": "layer"
|
||||
},
|
||||
"load_mapping": null,
|
||||
"send_mapping": {
|
||||
"destinations": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"editor": {
|
||||
"backdrop_title": "Example Conference Name",
|
||||
"selected_layer_ids": [
|
||||
1
|
||||
],
|
||||
"position_point": "top_left",
|
||||
"keep_aspect_ratio": true,
|
||||
"viewport_zoom": 1.0,
|
||||
"viewport_pan": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"show_source_pattern": false,
|
||||
"show_toolbar_icon_names": false,
|
||||
"outline_layers": false,
|
||||
"position_layer_point": null
|
||||
},
|
||||
"next_layer_id": 3,
|
||||
"references": [],
|
||||
"workspace": {
|
||||
"snapping": {
|
||||
"enabled": false,
|
||||
"pixels": true,
|
||||
"screen_edges": true,
|
||||
"layer_edges": true,
|
||||
"grid": false,
|
||||
"show_grid": true,
|
||||
"grid_divisions": [
|
||||
8,
|
||||
6
|
||||
],
|
||||
"mask_edges": false
|
||||
},
|
||||
"resize_mode": "individual",
|
||||
"grid_spacing": null,
|
||||
"collapsed_folders": [],
|
||||
"capture_interval_seconds": 10,
|
||||
"show_empty_inputs": false,
|
||||
"previews": []
|
||||
},
|
||||
"folders": [
|
||||
"Memory A"
|
||||
],
|
||||
"input_proposals": [
|
||||
{
|
||||
"layer_id": 2,
|
||||
"device_link": {
|
||||
"family": "midra4k",
|
||||
"screen": "1",
|
||||
"layer": "1"
|
||||
},
|
||||
"input": "INPUT_4",
|
||||
"plug": "2",
|
||||
"settings": {
|
||||
"aspect/pp/transformTo": "CUSTOM",
|
||||
"aspect/pp/customRatio": 1778
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ These are offline editor formats, not Analog Way REST payloads. Implementation:
|
|||
[`project.rs`](../../crates/canvas-pilot/tests/project.rs). Update this contract,
|
||||
examples and tests in the same change as any save/export schema change.
|
||||
|
||||
## Project JSON, version 18
|
||||
## Project JSON, version 19
|
||||
|
||||
Suggested filename: `layout.pilot.json`. **Open project** accepts any `.json`
|
||||
filename, including legacy `.midra.json` projects, and validates the project
|
||||
|
|
@ -27,10 +27,10 @@ and `next_layer_id: 3`; other values are preserved.
|
|||
The [version 1 example](canvas-pilot-v1.example.json) remains a migration fixture.
|
||||
Version 4 adds `editor.outline_layers: false`, and reference `native_size: false`
|
||||
and `offset: [0, 0]` when migrating versions 1–3. Old fitting behavior is preserved.
|
||||
Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Version 11 adds required `workspace` settings and embedded layer previews. Versions 1–10 gain the documented workspace defaults, with no captures or collapsed folders; supplying `workspace` in an older schema is rejected. Version 12 adds required `folders`, the explicit folder names that survive without members. Versions 1–11 gain `folders: []`, preserving their existing implicit layer grouping; supplying this field under an older version is rejected. Version 13 replaces `midra_link` with required `device_link`, adding the explicit device family. Versions 1–12 migrate numeric links to `family: "midra4k"`; null remains null, and legacy decimal IDs with leading zeros are canonicalized. Unknown legacy fields are rejected. Version 14 adds required `layers[].layer_fit`: versions 1–13 migrate to null, preserving normal crop/zoom behavior; supplying this field under an older schema is rejected. Version 15 adds required `layers[].mask`; versions 1–14 migrate with four zero edges and reject masks supplied under an older version. Version 16 adds required root `input_proposals`; versions 1–15 migrate to an empty array and reject this field if supplied under an older version. Version 17 adds required `mask.origin` (`layer` or `source`). Versions 1–16 migrate to `layer`; older versions containing `origin` are rejected. See the [version 17 example](canvas-pilot-v17.example.json); v16 remains a migration fixture. Version 18 adds required `workspace.snapping.mask_edges` (default false). Versions 1–17 migrate with this option disabled; supplying it under an older schema is rejected. See the [version 18 example](canvas-pilot-v18.example.json). Saving always writes version 18; older applications reject it.
|
||||
Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Version 11 adds required `workspace` settings and embedded layer previews. Versions 1–10 gain the documented workspace defaults, with no captures or collapsed folders; supplying `workspace` in an older schema is rejected. Version 12 adds required `folders`, the explicit folder names that survive without members. Versions 1–11 gain `folders: []`, preserving their existing implicit layer grouping; supplying this field under an older version is rejected. Version 13 replaces `midra_link` with required `device_link`, adding the explicit device family. Versions 1–12 migrate numeric links to `family: "midra4k"`; null remains null, and legacy decimal IDs with leading zeros are canonicalized. Unknown legacy fields are rejected. Version 14 adds required `layers[].layer_fit`: versions 1–13 migrate to null, preserving normal crop/zoom behavior; supplying this field under an older schema is rejected. Version 15 adds required `layers[].mask`; versions 1–14 migrate with four zero edges and reject masks supplied under an older version. Version 16 adds required root `input_proposals`; versions 1–15 migrate to an empty array and reject this field if supplied under an older version. Version 17 adds required `mask.origin` (`layer` or `source`). Versions 1–16 migrate to `layer`; older versions containing `origin` are rejected. See the [version 17 example](canvas-pilot-v17.example.json); v16 remains a migration fixture. Version 18 adds required `workspace.snapping.mask_edges` (default false). Versions 1–17 migrate with this option disabled; supplying it under an older schema is rejected. See the [version 18 example](canvas-pilot-v18.example.json). Version 19 replaces each layer’s `device_link` with required `load_mapping` and `send_mapping`. Versions 1–18 migrate the old link to the load source and a single send destination on the current connection (or null and an empty destination list when unlinked). Older schemas containing the new fields are rejected. Saving always writes version 19; older applications reject it.
|
||||
Incompatible files are never partially applied.
|
||||
|
||||
[Complete example](canvas-pilot-v17.example.json) is a valid project with an empty `Memory A` folder, a Midra link and an inactive input correction proposal,
|
||||
[Complete example](canvas-pilot-v19.example.json) is a valid project with an empty `Memory A` folder, a Midra link and an inactive input correction proposal,
|
||||
with an unlinked Fullscreen example layer and no reference image. New projects label the lower layer `02 / Slides` and
|
||||
the upper layer `01 / Presenter`; existing projects retain their saved IDs/names.
|
||||
It is loaded by the regression tests.
|
||||
|
|
@ -38,8 +38,8 @@ It is loaded by the regression tests.
|
|||
| Root field | Representation / meaning |
|
||||
| --- | --- |
|
||||
| `format` | Exactly `"beffroi.midra-layout"` |
|
||||
| `version` | Integer `18` |
|
||||
| `input_proposals` | Required array, 0–256 inactive correction proposals; at most one per existing layer, with an exactly matching `device_link`. See below. |
|
||||
| `version` | Integer `19` |
|
||||
| `input_proposals` | Required array, 0–256 inactive correction proposals; at most one per existing layer, with a `device_link` matching one of its send destinations. See below. |
|
||||
| `folders` | Required array of 0–256 unique explicit folder names, each trimmed and 1–128 characters. Explicit folders remain even with no members; layer folder labels also form implicit groups. |
|
||||
| `next_layer_id` | Positive integer strictly greater than every layer ID; not rewound by undo |
|
||||
| `output_resolution` | `{ "width": integer, "height": integer }`, screen pixels |
|
||||
|
|
@ -51,8 +51,8 @@ It is loaded by the regression tests.
|
|||
|
||||
### Inactive input correction proposals
|
||||
|
||||
Each object has exactly `layer_id` (stable layer ID), `device_link` (the layer's
|
||||
Midra link), `input` (`INPUT_` plus a canonical positive decimal ID), `plug`
|
||||
Each object has exactly `layer_id` (stable layer ID), `device_link` (one of the layer's
|
||||
Midra send destinations), `input` (`INPUT_` plus a canonical positive decimal ID), `plug`
|
||||
(canonical positive decimal ID) and `settings` (1–9 whitelisted suffix/value pairs).
|
||||
IDs have at most 16 digits; only the Midra adapter currently supports proposals.
|
||||
Unknown fields, paths, values, duplicates or mismatched links are rejected.
|
||||
|
|
@ -96,7 +96,8 @@ Layer objects:
|
|||
| `id` | Unique positive stable editor layer ID; independent of list position and Midra mapping |
|
||||
| `name` | Nonblank display name, at most 128 characters |
|
||||
| `layer_fit` | Required: null for normal visible-box crop/zoom, or `"one_to_one"`, `"centered"`, `"fullscreen"`, `"cropped"`. Explicit modes treat bounds as the container; crop is applied before fitting. Unknown modes are rejected. Full-precision crop and container values survive project, recovery and embedded-project round trips. |
|
||||
| `device_link` | Required: null (unlinked) or `{ "family": "midra4k", "screen": "2", "layer": "1" }` / `{ "family": "aquilon", "screen": "S1", "layer": "1" }`. Family is required; unknown fields/families rejected. Layer IDs and Midra screen IDs are canonical positive decimal strings, at most 16 digits; Aquilon screens require `S` (screen) or `A` (auxiliary) plus that numeric ID. No host, bank, credentials or unit identity: linked Aquilon systems are unsupported. |
|
||||
| `send_mapping` | Required `{ "destinations": [...] }`; each destination has exactly `{ "connection": "current", "layer": <DeviceLink> }`, where the link uses the same family/screen/layer representation as `load_mapping`. Empty means no send destination; exact duplicate destinations within a layer are rejected. Only the current connection is supported; unknown connection kinds are rejected. |
|
||||
| `load_mapping` | Required: null (unlinked) or `{ "family": "midra4k", "screen": "2", "layer": "1" }` / `{ "family": "aquilon", "screen": "S1", "layer": "1" }`. Family is required; unknown fields/families rejected. Layer IDs and Midra screen IDs are canonical positive decimal strings, at most 16 digits; Aquilon screens require `S` (screen) or `A` (auxiliary) plus that numeric ID. This is the load source. No host, bank, credentials or unit identity: linked Aquilon systems are unsupported. |
|
||||
| `pivot` | Required `[x, y]` gravity point relative to the layer top-left, in fractions of width/height. Center is `[0.5, 0.5]`; outside points are allowed. Finite doubles within ±1,000,000, preserved without rounding. Placement/reset is undoable; follows layer movement/reordering. Omitted from SVG and device writes. |
|
||||
| `folder` | Local folder name, at most 128 characters; empty means ungrouped |
|
||||
| `source_id` | Existing input slot ID; multiple layers may share an input |
|
||||
|
|
@ -263,7 +264,7 @@ and `viewBox="0 0 W H"` equal to the output screen. The root carries
|
|||
|
||||
## Compatibility changes
|
||||
|
||||
Project version 18 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
|
||||
Project version 19 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
|
||||
`version` and either implement a tested migration or clearly reject older/newer
|
||||
files. Changing rectangle/marker semantics requires a corresponding documented
|
||||
exchange-interface revision and importer tests. Update this document and its example
|
||||
|
|
@ -281,17 +282,17 @@ retarget existing links; choosing a destination there explicitly replaces that
|
|||
layer's saved link. Direct send/load actions use each layer's saved screen,
|
||||
independently of the screen currently displayed in the configuration window.
|
||||
|
||||
Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 18.
|
||||
Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 19.
|
||||
|
||||
## Folder-scoped Midra transfers
|
||||
|
||||
The shared Midra transfer scope is session-only and is not saved. Defaults use all
|
||||
layers; Selected/Folder modes filter by the existing selection or `folder` fields.
|
||||
Folders may store alternative layouts whose `device_link` values reuse the same screen
|
||||
Folders may store alternative layouts whose send destinations reuse the same screen
|
||||
and layer; each individual send requires unique destinations within its scope.
|
||||
Manual device import now saves the reviewed `device_link` with imported geometry/crops
|
||||
Manual device import now saves the reviewed link in both directions with imported geometry/crops
|
||||
in one Undo step. New layers inherit the chosen folder; existing folder names remain.
|
||||
All these values use the existing layer fields (unchanged in version 10). See
|
||||
Version 19 stores these directions separately. See
|
||||
[device transfer scopes](midra-device-send.md#shared-transfer-scopes-and-folder-layouts).
|
||||
|
||||
|
||||
|
|
@ -347,7 +348,7 @@ background export behavior.
|
|||
For the complete persistence audit and the reasons for keeping other controls
|
||||
out of project files, see [Project persistence audit](canvas-pilot-persistence-audit.md).
|
||||
|
||||
Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 18 and use the same migration on import.
|
||||
Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 19 and use the same migration on import.
|
||||
|
||||
### Explicit layer fit (v14)
|
||||
|
||||
|
|
@ -380,3 +381,28 @@ Numeric UI fields show output-pixel distances for layer mode and usable-source
|
|||
pixel distances for source mode. Switching modes keeps the fractions, so the
|
||||
visible result can change. Reset clears edges while keeping the mode. Mask helper movement changes opposite edges by
|
||||
equal amounts, clamped to the selected reference, preserving reveal size.
|
||||
|
||||
### Directional device mapping (version 19)
|
||||
|
||||
`LayerInfo` and project layers hold one optional `load_mapping` and a `SendMapping`
|
||||
containing a list of `SendDestination` values. Each send destination explicitly
|
||||
identifies its connection scope and family/screen/layer. `current` means the
|
||||
currently connected device, not a saved hostname or credential. Named connections
|
||||
are future work and are not accepted yet.
|
||||
|
||||
The current controls are unchanged: selecting or clearing a link updates both
|
||||
load and send together, and creates at most one send destination. Device import
|
||||
also establishes this synchronized mapping in its existing atomic undo operation.
|
||||
The core `set_device_mappings` API can represent independent directions and fan-out;
|
||||
`set_device_link` remains the synchronized operation used by the UI. Loading linked
|
||||
geometry preserves both mappings. Undo/redo, project saves, recovery and embedded
|
||||
exchange snapshots retain the complete directional state. Ordinary geometry and
|
||||
layer clipboard payloads still omit device routing.
|
||||
|
||||
Linked send planning reads only send destinations; load/capture reads the load
|
||||
source. Send plans may reuse a local layer across distinct destinations, but a
|
||||
scope cannot write to the same device destination twice. Family, availability,
|
||||
resolution, preflight and explicit-write requirements remain unchanged. Program/
|
||||
Preview and sizing are still session choices, not fields on these destinations.
|
||||
The single-destination review UI is not a multi-target editor; broader connection
|
||||
and mapping controls are intentionally deferred.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ framing, optional explicit crop-first fit, and unsupported-mode explanations. It
|
|||
The small profile registry selects family implementations; UI, scopes, history,
|
||||
transport and editor geometry do not contain native path substitutions.
|
||||
|
||||
Persistent destinations use [project version 15](canvas-pilot.md): family +
|
||||
Persistent destinations use [project version 19](canvas-pilot.md): family +
|
||||
screen + layer. Midra links migrate explicitly from versions 1–12. Neither bank
|
||||
roles nor credentials nor raw device state are persisted. Current standalone
|
||||
profiles do not support linked-unit identity; linked Aquilon devices are refused.
|
||||
|
|
@ -184,3 +184,14 @@ rollback. The explicitly invoked diagnostic backs up its baseline to a temporary
|
|||
JSON file before writes, exercises both banks, origins, sizing strategies and
|
||||
mask/reset cases, then restores routing, geometry, crop and masks and verifies
|
||||
all targeted screen/auxiliary state. It is never a CI/hardware test.
|
||||
|
||||
## Directional routing model
|
||||
|
||||
Load sources and send destinations are separate in the layout model. Send targets
|
||||
use `SendMapping` / `SendDestination` with an explicit `ConnectionTarget::Current`
|
||||
and a family/screen/layer link. Future named connections belong at this routing
|
||||
boundary; protocol paths remain inside adapters. Both adapter planners accept a
|
||||
local layer more than once for distinct destinations and reject duplicate device
|
||||
destinations. No new network connections or automatic writes are introduced.
|
||||
Current mapping controls still synchronize one load source and one send target.
|
||||
See the [project contract](canvas-pilot.md#directional-device-mapping-version-19).
|
||||
|
|
|
|||
|
|
@ -276,3 +276,15 @@ change routing, input settings or crop values. The device stores blanking only,
|
|||
a later device load returns a layer-relative mask; retain the project to preserve
|
||||
source-relative editing intent. Aquilon uses the same editor reveal bounds with
|
||||
its own container-relative conversion.
|
||||
|
||||
## Separate load and send mappings
|
||||
|
||||
The underlying layout stores `load_mapping` separately from `send_mapping`.
|
||||
Linked sends flatten the scoped send destinations, check destination collisions,
|
||||
and group by screen for adapter preparation. Loading uses only the load source.
|
||||
One local layer can be planned for several distinct device layers; both Midra and
|
||||
Aquilon still reject overlapping destination writes. This is an internal capability:
|
||||
current controls keep both directions synchronized with one destination, and the
|
||||
current connection is the only accepted connection scope. No UI or transfer defaults
|
||||
change. Persistence and migrations are specified in the
|
||||
[project contract](canvas-pilot.md#directional-device-mapping-version-19).
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ external editor moves/resizes a shape without updating the embedded snapshot.
|
|||
| FigCraft FIGCRAFT | First page node `plugin_data.beffroi_midra_parameters` in native v1 `document.json` | ZIP and bare JSON restore supported. Native FigCraft 0.5.1 load/save preserves the field. Duplicate payloads are rejected; document JSON reads are bounded to 16 MiB. Other ZIP members are preserved. |
|
||||
| Figma FIG | Not enabled | Figma has plugin data, but the installed FigCraft 0.5.1 native exporter explicitly warns `plugin data was left out`. Its model field is not evidence of native preservation. |
|
||||
| Illustrator | Not enabled | PDF-compatible Illustrator can have document metadata, but the current VectorCraft SVG↔Illustrator conversion path has no verified application-payload preservation. No unverified PDF/Illustrator trailer changes are made. |
|
||||
| Midra project JSON | Already complete | Project v18 remains the authoritative full-fidelity save. |
|
||||
| Midra project JSON | Already complete | Project v19 remains the authoritative full-fidelity save. |
|
||||
|
||||
Unsupported codecs disable the option with an explanation. Programmatic attempts
|
||||
to request the extension on those codecs fail explicitly, never silently discard
|
||||
|
|
@ -36,7 +36,7 @@ it. Vendor availability and the `no_proprietary` build flag still apply.
|
|||
## Payload contract (extension version 1)
|
||||
|
||||
`BASE64` is standard padded RFC 4648 base64 of UTF-8, pretty-printed
|
||||
[project JSON](canvas-pilot.md), currently version 18. It is inert data, not an
|
||||
[project JSON](canvas-pilot.md), currently version 19. It is inert data, not an
|
||||
executable instruction, URL or file path. Project format/version and validation
|
||||
remain authoritative. Future incompatible carrier/payload meanings require a new
|
||||
extension version and explicit migration or rejection.
|
||||
|
|
|
|||
Loading…
Reference in New Issue