Clarify shared Midra links and block overlapping send scopes
This commit is contained in:
parent
508f2344f0
commit
ba67f21c83
|
|
@ -5,6 +5,54 @@ use midra_layout::{
|
|||
};
|
||||
use std::sync::mpsc::{self, Receiver, TryRecvError};
|
||||
|
||||
fn linked_layer_label(layout: &midra_layout::Layout, id: usize) -> String {
|
||||
(0..layout.layers().len())
|
||||
.find(|&i| layout.layer_info(i).id == id)
|
||||
.map(|i| {
|
||||
let info = layout.layer_info(i);
|
||||
let folder = if info.folder.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" [{}]", info.folder)
|
||||
};
|
||||
format!("{}{}", layout.layer_label(i), folder)
|
||||
})
|
||||
.unwrap_or_else(|| format!("Removed layer {id}"))
|
||||
}
|
||||
|
||||
fn shared_link_warning(
|
||||
layout: &midra_layout::Layout,
|
||||
index: usize,
|
||||
link: &midra_layout::MidraLink,
|
||||
) -> Option<String> {
|
||||
let others: Vec<_> = (0..layout.layers().len())
|
||||
.filter(|&i| i != index && layout.layer_info(i).midra_link.as_ref() == Some(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(", ")))
|
||||
}
|
||||
|
||||
fn link_conflicts(
|
||||
layout: &midra_layout::Layout,
|
||||
links: &[(usize, midra_layout::MidraLink)],
|
||||
) -> Option<String> {
|
||||
let mut groups = std::collections::BTreeMap::<(&str, &str), Vec<String>>::new();
|
||||
for (id, link) in links {
|
||||
groups
|
||||
.entry((&link.screen, &link.layer))
|
||||
.or_default()
|
||||
.push(linked_layer_label(layout, *id));
|
||||
}
|
||||
let conflicts: Vec<_> = groups
|
||||
.into_iter()
|
||||
.filter(|(_, layers)| layers.len() > 1)
|
||||
.map(|((screen, layer), layers)| {
|
||||
format!("Screen {screen} · Layer {layer}: {}", layers.join(", "))
|
||||
})
|
||||
.collect();
|
||||
(!conflicts.is_empty()).then(|| format!("Cannot send overlapping destinations:\n{}\nChoose one folder, use Only selected layers, or remap/skip the conflicting layers.", conflicts.join("\n")))
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub(super) enum TransferScope {
|
||||
#[default]
|
||||
|
|
@ -111,12 +159,11 @@ impl DeviceUi {
|
|||
.into(),
|
||||
);
|
||||
}
|
||||
if let Some(error) = link_conflicts(layout, &links) {
|
||||
return Err(error);
|
||||
}
|
||||
let mut groups = std::collections::BTreeMap::<String, Vec<(usize, String)>>::new();
|
||||
let mut used = std::collections::BTreeSet::new();
|
||||
for (id, link) in links {
|
||||
if !used.insert((link.screen.clone(), link.layer.clone())) {
|
||||
return Err("Several layers in this scope share a Midra destination. Choose one folder, use Only selected layers, or remap the conflicting links.".into());
|
||||
}
|
||||
groups
|
||||
.entry(link.screen)
|
||||
.or_default()
|
||||
|
|
@ -361,6 +408,11 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(mapped) = &link
|
||||
&& let Some(warning) = shared_link_warning(&self.layout, i, mapped)
|
||||
{
|
||||
ui.colored_label(ui.visuals().warn_fg_color, warning);
|
||||
}
|
||||
if link != original {
|
||||
match self.layout.set_midra_link(i, link) {
|
||||
Ok(()) => {
|
||||
|
|
@ -497,8 +549,11 @@ impl Editor {
|
|||
}
|
||||
pub(super) fn midra_send_button(&mut self, ui: &mut egui::Ui) {
|
||||
let plans = self.device.linked_plans(&self.layout);
|
||||
let enabled = self.device.online() && self.device.pending.is_none();
|
||||
let tooltip = if self.device.sending {
|
||||
let conflicts = link_conflicts(&self.layout, &self.device.scoped_links(&self.layout));
|
||||
let enabled = self.device.online() && self.device.pending.is_none() && conflicts.is_none();
|
||||
let tooltip = if let Some(error) = conflicts {
|
||||
error
|
||||
} else if self.device.sending {
|
||||
"Sending and checking readback…".into()
|
||||
} else if !self.device.message.is_empty() {
|
||||
self.device.message.clone()
|
||||
|
|
@ -848,7 +903,6 @@ fn send_review(
|
|||
if selected.is_empty() {
|
||||
ui.label("No layers in this scope. Choose All layers, select layers, or choose a folder.");
|
||||
}
|
||||
let mut used = std::collections::BTreeSet::new();
|
||||
for &i in selected {
|
||||
let info = layout.layer_info(i);
|
||||
let id = info.id;
|
||||
|
|
@ -879,13 +933,19 @@ fn send_review(
|
|||
}
|
||||
});
|
||||
});
|
||||
if !target.is_empty()
|
||||
&& let Some(warning) = shared_link_warning(
|
||||
layout,
|
||||
i,
|
||||
&midra_layout::MidraLink {
|
||||
screen: screen.id.clone(),
|
||||
layer: target.clone(),
|
||||
},
|
||||
)
|
||||
{
|
||||
ui.colored_label(ui.visuals().warn_fg_color, warning);
|
||||
}
|
||||
if let Some(layer) = screen.layers.iter().find(|layer| layer.id == *target) {
|
||||
if !used.insert(target.clone()) {
|
||||
ui.colored_label(
|
||||
ui.visuals().error_fg_color,
|
||||
"Each editor layer needs a different Midra destination.",
|
||||
);
|
||||
}
|
||||
ui.label(format!(
|
||||
"Preview snapshot container: {}",
|
||||
container_label(layer.container)
|
||||
|
|
@ -913,6 +973,23 @@ fn send_review(
|
|||
.filter(|(_, destination)| !destination.is_empty())
|
||||
.map(|(id, destination)| (*id, destination.clone()))
|
||||
.collect();
|
||||
let links: Vec<_> = mappings
|
||||
.iter()
|
||||
.map(|(id, layer)| {
|
||||
(
|
||||
*id,
|
||||
midra_layout::MidraLink {
|
||||
screen: screen.id.clone(),
|
||||
layer: layer.clone(),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
if let Some(error) = link_conflicts(layout, &links) {
|
||||
ui.colored_label(ui.visuals().error_fg_color, error);
|
||||
apply_button(ui, "Send mapped layers", false);
|
||||
return None;
|
||||
}
|
||||
match Plan::prepare(
|
||||
snapshot,
|
||||
layout,
|
||||
|
|
@ -1567,6 +1644,79 @@ mod tests {
|
|||
assert!(matches!(app.device.destinations[1], Destination::Skip));
|
||||
}
|
||||
|
||||
#[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).midra_link.clone().unwrap();
|
||||
app.layout.set_midra_link(1, Some(link.clone())).unwrap();
|
||||
let warning = shared_link_warning(&app.layout, 0, &link).unwrap();
|
||||
assert!(warning.contains(&app.layout.layer_label(1)));
|
||||
assert!(warning.contains("[Talk]"));
|
||||
let error = app.device.linked_plans(&app.layout).unwrap_err();
|
||||
for i in 0..2 {
|
||||
assert!(error.contains(&app.layout.layer_label(i)));
|
||||
}
|
||||
assert!(error.contains("Screen 1 · Layer 1"));
|
||||
let ctx = egui::Context::default();
|
||||
super::super::tests::click_text(&mut app, &ctx, "Send all linked layers");
|
||||
assert!(app.device.pending.is_none());
|
||||
assert!(!app.device.open);
|
||||
let mut targets = std::collections::BTreeMap::from([
|
||||
(app.layout.layer_info(0).id, "1".into()),
|
||||
(app.layout.layer_info(1).id, "1".into()),
|
||||
]);
|
||||
let output = ctx.run(egui::RawInput::default(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
app.layer_mapping_controls(ui, 0);
|
||||
assert!(
|
||||
send_review(
|
||||
ui,
|
||||
&app.layout,
|
||||
&[0, 1],
|
||||
app.device.snapshot.as_ref().unwrap(),
|
||||
0,
|
||||
&mut targets,
|
||||
&mut Target::Preview,
|
||||
&mut Sizing::OutputBox,
|
||||
false,
|
||||
false,
|
||||
&input_ui::InputEdits::default()
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
});
|
||||
});
|
||||
assert!(
|
||||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == warning))
|
||||
);
|
||||
for i in 0..2 {
|
||||
app.layout.select(Some(i));
|
||||
app.device.scope = TransferScope::Selected;
|
||||
assert!(app.device.linked_plans(&app.layout).is_ok());
|
||||
}
|
||||
app.layout.set_selection([true; 2]);
|
||||
assert!(app.device.linked_plans(&app.layout).is_err());
|
||||
let ids: Vec<_> = (0..2).map(|i| app.layout.layer_info(i).id).collect();
|
||||
app.layout.assign_folder(&ids, "Combined").unwrap();
|
||||
app.device.scope = TransferScope::Folder("Combined".into());
|
||||
assert!(app.device.linked_plans(&app.layout).is_err());
|
||||
// Same layer number on another screen is a different destination.
|
||||
app.layout
|
||||
.set_midra_link(
|
||||
1,
|
||||
Some(midra_layout::MidraLink {
|
||||
screen: "2".into(),
|
||||
layer: "1".into(),
|
||||
}),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(shared_link_warning(&app.layout, 0, &link).is_none());
|
||||
assert!(link_conflicts(&app.layout, &app.device.scoped_links(&app.layout)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_memories_reuse_destinations_without_overwriting_other_links() {
|
||||
let mut app = linked_folders();
|
||||
|
|
|
|||
|
|
@ -140,8 +140,12 @@ another scope. The scope is omitted from project/settings/export representations
|
|||
Direct send/load captures stable layer IDs and their saved `(screen, layer)` links
|
||||
when clicked. Switching scope while a read is pending cannot redirect that import.
|
||||
Direct sends validate destination uniqueness within the chosen scope, across each
|
||||
screen. Duplicate destinations across different folders are valid persistent links,
|
||||
but those folders cannot be sent together. Loading the same device layer into multiple
|
||||
screen. Duplicate destinations within or across folders are valid persistent links.
|
||||
Mapping warnings list other linked editor layers and folders, without preventing
|
||||
link edits. Conflicting sends are disabled before any writes and list every
|
||||
conflicting screen/layer and editor layer in the chosen scope. A conflict-free
|
||||
folder/selection or remapped/skipped review rows can send; out-of-scope links do
|
||||
not block that send. Loading the same device layer into multiple
|
||||
local linked copies is allowed; destination editor IDs must still be unique, visible,
|
||||
and unlocked. Existing geometry validation and atomic import guarantees are unchanged.
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ exchange-interface revision and importer tests. Update this document and its exa
|
|||
with every schema or semantic change, including additive fields under the strict
|
||||
unknown-field policy. Never silently interpret a future version as a supported version.
|
||||
|
||||
Midra links belong to layer identity and survive selection changes, refresh, rename, reorder and project round trips. Link edits support Undo/Redo. New layers and older projects start unlinked. Links refer to the currently connected device; Preview/Program and sizing remain session choices, and Program permission remains an application preference. Duplicate destinations can be stored, but a send containing duplicates is rejected before any writes. Unavailable screens/layers are reported without deleting the saved links. Geometry exports omit links.
|
||||
Midra links belong to layer identity and survive selection changes, refresh, rename, reorder and project round trips. Link edits support Undo/Redo. New layers and older projects start unlinked. Links refer to the currently connected device; Preview/Program and sizing remain session choices, and Program permission remains an application preference. Duplicate destinations can be stored within or across folders. Mapping warnings list the other linked layers/folders; a send scope containing duplicates is rejected before any writes, while conflict-free folders/selections remain valid. Unavailable screens/layers are reported without deleting the saved links. Geometry exports omit links.
|
||||
|
||||
Midra destinations are identified by the pair **screen ID + layer ID**: Screen 1
|
||||
Layer 1 and Screen 2 Layer 1 are distinct links. Both IDs are already persisted
|
||||
|
|
|
|||
|
|
@ -55,8 +55,11 @@ To prepare several layouts that reuse the same device layers:
|
|||
4. **Load folder links** reads fresh Preview geometry/cropping into that folder.
|
||||
Loading requires visible, unlocked destinations and supports Undo.
|
||||
|
||||
Different folders may link to the same device destinations. One send cannot
|
||||
include conflicting destinations: choose a single folder/selection or remap them.
|
||||
Multiple editor layers may link to the same device destination, within or across
|
||||
folders. Mapping shows a warning listing the other linked layers and their folders.
|
||||
Sending is disabled when the chosen scope contains overlapping **screen + layer**
|
||||
destinations, with a list of the conflicts. Choose a conflict-free folder or selection,
|
||||
or remap/skip rows; links outside that send scope do not block it.
|
||||
Linked send/load skip unlinked layers. An empty selection or missing folder never
|
||||
falls back to All. Transfers already started retain the links captured at click time.
|
||||
These are local geometry layouts, not device preset recalls or source-routing memories.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Clarify shared Midra links: warn with other linked layer/folder names while allowing link edits; disable conflicting scoped sends and list all overlapping destinations. Preserve conflict-free folder/selection sends and remapping. Remove nested-folder/additional-codec backlog items and replace the extra-links proposal with this shared-destination workflow. Regression tests cover warning text, send blocking and scope isolation.
|
||||
|
||||
- Remove duplicate overlay-grid controls from snapping menus; keep them in the adjacent Grid toolbar menu and a separate section in Editing preferences.
|
||||
|
||||
- Move the background grid out of the sample artwork into a full-output overlay above reference images. Add a Grid toolbar menu, independent visibility/snapping, and 1–64 columns/rows (default 8 × 6). Persist these preferences in settings v7 with migration from v1–v6; share fractional grid positions across movement, resizing and pivot snapping. Regression tests cover rendering order, toggles, snapping and settings compatibility.
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ device readback and physical-screen acceptance.
|
|||
Unmapped rows skip; duplicate destinations within a send scope are rejected.
|
||||
- [x] Persistent per-layer screen/layer links, Mapping properties and Unmap.
|
||||
Reordering/visibility do not alter links; alternative folders can reuse targets.
|
||||
- [x] Multiple editor layers may share one Midra destination. Mapping warns with
|
||||
other linked layer names/folders; sends reject overlaps only within the chosen
|
||||
scope. This replaces the earlier extra-links-per-layer proposal. Nested folders
|
||||
and additional file codecs have been removed from scope at the user's request.
|
||||
- [x] Both device sizing strategies, Centered-crop imports, required preset apply
|
||||
pulse, rounding/reconstruction checks and readback. Preview/Program protocol
|
||||
checks on Eikos 3.3.10 are recorded; Program availability is a user preference.
|
||||
|
|
@ -63,14 +67,8 @@ device readback and physical-screen acceptance.
|
|||
|
||||
## Remaining feature work
|
||||
|
||||
- [ ] **Multiple saved links per layer and link picking.** Add extra destinations
|
||||
without replacing the existing link; every link includes screen and layer.
|
||||
Organization, active-link choice and send/load behavior need user specifications.
|
||||
Version project interfaces and add migration tests when that schema is defined.
|
||||
- [ ] **Further export/workflow cleanup.** Shared transfer scopes, mapping review
|
||||
and direct linked send/load are implemented; further changes await specifications.
|
||||
- [ ] **Nested folders and inherited visibility/locking.** Preserve member flags
|
||||
across ancestor hide/show or lock/unlock rather than overwriting them.
|
||||
- [ ] **Additional native clipboard adapters.** Obtain actual software/version
|
||||
clipboard samples before implementing or claiming Inkscape, Illustrator, Figma,
|
||||
etc. clipboard support. File import is not native clipboard compatibility.
|
||||
|
|
@ -81,8 +79,6 @@ device readback and physical-screen acceptance.
|
|||
capture saving and persistence of layer-preview assignments are not implemented.
|
||||
Captures can be session-only layer textures or saved fixed reference images;
|
||||
low device load remains a requirement for any refresh extension.
|
||||
- [ ] **Additional file codecs, if requested.** PDF, PSD, VSDX and ODG are outside
|
||||
the current geometry contract, not promised existing import/export features.
|
||||
|
||||
## Remaining acceptance and release checks
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue