Keep unassigned Midra layers available for geometry transfers

This commit is contained in:
Dandaedre 2026-11-14 18:13:02 +01:00
parent db42916959
commit 06ee4e8cf8
5 changed files with 92 additions and 16 deletions

View File

@ -93,10 +93,12 @@ impl Snapshot {
.ok_or("Invalid layer list")?;
let mut layers = Vec::new();
for (id, layer) in entries {
let source = text(layer, "/source/pp/input")?;
if source == "NONE" || source.is_empty() {
continue;
}
// Routing does not determine whether a live-layer slot exists.
let source = layer
.pointer("/source/pp/input")
.and_then(Value::as_str)
.unwrap_or("NONE")
.to_owned();
let width = number(layer, "/size/pp/sizeH")?;
let height = number(layer, "/size/pp/sizeV")?;
let geometry = Geometry {
@ -136,6 +138,9 @@ impl Snapshot {
framing = Some((source, crop));
unsupported = None;
}
// An unrouted input can report no content dimensions. With
// no crop the container is still usable geometry.
Err(_) if unsupported.is_none() && !has_content_size(layer) => {}
Err(error) => unsupported = Some(error),
}
}
@ -165,6 +170,15 @@ impl Snapshot {
})
}
}
/// Reported content dimensions are optional for unrouted/no-signal layers.
pub(crate) fn has_content_size(layer: &Value) -> bool {
["contentWidth", "contentHeight"].iter().all(|key| {
layer
.pointer(&format!("/status/pp/{key}"))
.and_then(Value::as_f64)
.is_some_and(|value| value.is_finite() && value > 0.0)
})
}
fn centered_framing(
layer: &Value,
container: Geometry,

View File

@ -109,11 +109,18 @@ impl Plan {
];
let native = source.native.map(f64::from);
let layer = format!("{base}/presetList/items/{bank}/liveLayerList/items/{destination}");
let device_layer = field(&snapshot.raw, &layer)?;
let content = [
field(&snapshot.raw, &format!("{layer}/status/pp/contentWidth"))?.as_f64(),
field(&snapshot.raw, &format!("{layer}/status/pp/contentHeight"))?.as_f64(),
device_layer
.pointer("/status/pp/contentWidth")
.and_then(Value::as_f64),
device_layer
.pointer("/status/pp/contentHeight")
.and_then(Value::as_f64),
];
if content != [Some(native[0]), Some(native[1])] {
if crate::device::has_content_size(device_layer)
&& content != [Some(native[0]), Some(native[1])]
{
return Err(format!(
"Layer {destination}: editor native source {} × {} differs from device content {} × {}. Match source resolution before sending.",
native[0],
@ -355,6 +362,40 @@ mod tests {
l
}
#[test]
fn unassigned_existing_layers_accept_geometry_without_routing_changes() {
let identity = json!({"type":"Eikos 4K","version":{"major":3,"minor":3,"patch":10}});
for input in ["NONE", ""] {
for size in [json!(0), Value::Null] {
let mut raw = snapshot().raw;
for bank in ["UP", "DOWN"] {
let layer = raw.pointer_mut(&format!("/device/screenList/items/1/presetList/items/{bank}/liveLayerList/items/1")).unwrap();
layer["source"]["pp"]["input"] = json!(input);
layer["status"]["pp"]["contentWidth"] = size.clone();
layer["status"]["pp"]["contentHeight"] = size.clone();
}
let state = Snapshot::parse(&identity, &raw).unwrap();
let editor = layout();
for target in [Target::Preview, Target::Program] {
for sizing in [Sizing::OutputBox, Sizing::SourceAspect] {
let plan =
Plan::prepare(&state, &editor, 0, &[(2, "1".into())], target, sizing)
.unwrap();
assert!(!plan.changes.is_empty());
assert!(
plan.changes
.iter()
.all(|c| !c.path.iter().any(|key| key == "source"))
);
assert!(
Plan::prepare(&state, &editor, 0, &[(2, "99".into())], target, sizing)
.is_err()
);
}
}
}
}
}
#[test]
fn both_strategies_include_crop_aspect_size_and_center_only() {
let s = snapshot();
let l = layout();

View File

@ -141,15 +141,25 @@ fn invalid_mapping_never_partially_imports() {
}
#[test]
fn empty_source_slots_are_omitted_but_assigned_off_layers_remain() {
fn existing_layers_remain_available_without_source_assignment() {
let (identity, mut raw) = fixture();
let entries = raw
.pointer_mut("/device/screenList/items/2/presetList/items/UP/liveLayerList/items")
.unwrap();
entries["1"]["status"] = json!({"pp": {"state": "OFF"}});
entries["2"] = json!({"source": {"pp": {"input": "NONE"}}});
entries["3"] = json!({"source": {"pp": {"input": ""}}});
for (id, input) in [("2", "NONE"), ("3", "")] {
entries[id] = entries["1"].clone();
entries[id]["source"]["pp"]["input"] = json!(input);
entries[id]["crop"]["pp"]["aspectOverride"] = json!("CENTERED");
entries[id]["status"]["pp"]["contentWidth"] = json!(0);
entries[id]["status"]["pp"]["contentHeight"] = json!(0);
}
entries["4"] = entries["1"].clone();
entries["4"].as_object_mut().unwrap().remove("source");
let snapshot = Snapshot::parse(&identity, &raw).unwrap();
assert_eq!(snapshot.screens[0].layers.len(), 1);
assert_eq!(snapshot.screens[0].layers[0].id, "1");
let screen = &snapshot.screens[0];
assert_eq!(screen.layers.len(), 4);
assert!(screen.layers.iter().all(|l| l.unsupported.is_none()));
assert_eq!(screen.import(&[0, 1, 2, 3]).unwrap().shapes.len(), 4);
assert!(!screen.layers.iter().any(|l| l.id == "5"));
}

View File

@ -26,9 +26,12 @@ are omitted unless explicitly opted into and edited as described below.
## Conversion
The editor native source dimensions must equal the destination layer's reported
`status.pp.contentWidth/contentHeight`. These describe the incoming content used
for this layer, not an instruction to change input hardware configuration.
When the destination reports positive content dimensions, the editor native
source dimensions must equal `status.pp.contentWidth/contentHeight`. Missing or
zero dimensions (for example, an unassigned input) use the editor's native
dimensions for crop conversion and do not block sending. Reported dimensions
describe the incoming content used for this layer, not an instruction to change
input hardware configuration.
Combine each local input crop edge with its advanced layer crop edge, in native
source pixels. Quantize each combined edge to `round(edge / native_axis * 65535)`.
@ -75,7 +78,13 @@ validation remains separate from the successful device-field and import round tr
The status-bar and Export-menu **Midra mapping & transfer…** actions only open export configuration, even when current layers have valid saved links. They never start a write. The user chooses a transfer scope, mappings, target and sizing, then explicitly clicks **Send mapped layers** for the displayed screen. Empty/unlinked rows are skipped. The load button uses all saved links in the scope, including links to other screens. Busy/offline actions are disabled. **Send all linked layers** remains a separate direct-send action using saved links. No persistent schema changes are involved.
Snapshot layer lists omit unassigned source slots (`NONE` or empty), before geometry validation. Assigned layers remain available even when OFF.
Snapshot layer lists include every existing live-layer entry, independently of
input assignment (`NONE`, empty or absent) and OFF state. Missing layer IDs are
not synthesized. Input routing is informational and is never changed by geometry
transfers. A Centered layer without usable content dimensions and with zero crop/
mask imports its container geometry without inferred source framing; nonzero crops
still require valid dimensions for visible-bound reconstruction. This changes
device discovery/transfer behavior only; project and export schemas are unchanged.
The direct send button uses the shared transfer scope. Its default **All layers** includes all linked document layers, even unselected, hidden or locked ones. **Only selected layers** uses exactly the current selection (an empty selection does not mean All); **Folder: …** uses all members of the named folder, independently of selection/visibility/locks. Unlinked layers are skipped. Plans are grouped by saved screen ID and all groups are validated before starting. Screen groups send sequentially with readback; on failure later groups are not sent, and the result reports the failed screen and completed-group count. Links never auto-send and are not tied to an IP address.

View File

@ -4,6 +4,8 @@
## Unreleased
- Keep existing Midra layers available for mapping, import and send regardless of input assignment or OFF state. Uncropped layers without content dimensions import their container; sends use editor dimensions when hardware content dimensions are unavailable, preserving routing. Regression tests cover unassigned layers and both send strategies/targets.
- Use absolute Gitea main-branch URLs for repository file links in the root README; verify linked files exist.
## v0.6.0 — 2026-11-14