From f33215094726012d06cc3498f37234d365c01cb7 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 14 Nov 2026 21:59:52 +0100 Subject: [PATCH] Place import destination warning beside scope selector --- crates/midra-layout/src/gui.rs | 25 +++++++++++++++++-------- docs/midra-layout/changelog.md | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/crates/midra-layout/src/gui.rs b/crates/midra-layout/src/gui.rs index 7458b89..3754455 100644 --- a/crates/midra-layout/src/gui.rs +++ b/crates/midra-layout/src/gui.rs @@ -240,6 +240,14 @@ impl Paste { }; layout.apply_mapped_import_with_zoom(&values, &zooms) } + fn destination_count_warning(&self, layout: &Layout) -> Option { + let count = self.ignored.iter().filter(|ignored| !**ignored).count(); + let available = self.candidates(layout).len(); + (count > available).then(|| format!( + "Not enough destinations: {available} available, {count} detected ({} excluded). Widen the scope or exclude items.", + self.shapes.len() - count + )) + } fn values(&self, layout: &Layout) -> Result, String> { if !self.include_size && !self.include_position @@ -253,13 +261,8 @@ impl Paste { if count == 0 { return Err("No rectangles to import. Include at least one rectangle.".into()); } - if count > self.candidates(layout).len() { - return Err(format!( - "Not enough destinations: {} available, {} detected ({} excluded). Widen the scope or exclude items.", - self.candidates(layout).len(), - count, - self.shapes.len() - count - )); + if let Some(error) = self.destination_count_warning(layout) { + return Err(error); } if self .targets @@ -1075,6 +1078,9 @@ impl Editor { } }); if scope != p.scope { p.set_scope(scope, &self.layout); } + if let Some(warning) = p.destination_count_warning(&self.layout) { + ui.colored_label(palette.amber, warning); + } ui.small(format!("{} available destinations ยท hidden and locked layers are excluded", p.candidates(&self.layout).len())); ui.small("Choose a destination for each item below. Other layers stay unchanged."); ui.add_space(8.0); @@ -1153,7 +1159,10 @@ impl Editor { if !p.shapes.is_empty() { let mut preview=self.layout.clone(); let valid=p.apply(&mut preview); - if let Err(e)=&valid {ui.colored_label(palette.amber,e);} + if let Err(e)=&valid + && p.destination_count_warning(&self.layout).as_ref() != Some(e) { + ui.colored_label(palette.amber,e); + } ui.horizontal(|ui| { if apply_button(ui,"Import mapped values", valid.is_ok() && (preview.layers()!=self.layout.layers() || preview.formats()!=self.layout.formats())).clicked() { match p.apply(&mut self.layout) {Ok(())=>{self.sync();close=true;},Err(e)=>p.error=e} diff --git a/docs/midra-layout/changelog.md b/docs/midra-layout/changelog.md index 7454e92..74ca3fa 100644 --- a/docs/midra-layout/changelog.md +++ b/docs/midra-layout/changelog.md @@ -4,6 +4,8 @@ ## Unreleased +- Place insufficient import-destination warnings directly below the destination scope selector instead of repeating them near the Import button. + - Simplify geometry/clipboard import into a shared review without repeated acquisition controls. Collapse clipboard and before/after details, emphasize destination mapping, and add independent All / Selected / Folder scopes plus per-item exclusion. Preserve compatible mappings and canvas selection; regression tests cover scope filtering, atomic import and review visibility. - Route supported geometry file drops through the regular asynchronous import/mapping review, including SVG/draw.io and native formats when available. Keep raster drops as references; support path/data drops and multiple documents through the file/page chooser, with a combined 16 MiB limit and atomic failure. Regression tests cover codecs, case-insensitive names, batches and invalid/oversized inputs.