diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index dd580c5..343fd4c 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -1151,13 +1151,14 @@ impl Editor { ui.horizontal(|ui| { ui.checkbox(&mut p.include_size,"Format (width / height)"); ui.checkbox(&mut p.include_position,"Position"); - let available=p.zoom_available(); - let mut zoom=p.include_zoom && available; - if ui.add_enabled(available,egui::Checkbox::new(&mut zoom,"Crop zoom")).changed() {p.include_zoom=zoom;} + if p.zoom_available() { ui.checkbox(&mut p.include_zoom,"Crop zoom"); } }); - if !p.zoom_available() {ui.small("Crop zoom is not included in this data.");} ui.small("Unchecked values keep the destination settings. Format changes may adjust existing crops to fit."); - ui.add_enabled(p.include_size && p.shapes.iter().any(|s|s.outline.iter().any(|v|*v>0.0)),egui::Checkbox::new(&mut p.include_outline,"Include outline in bounds")); + if p.shapes.iter().any(|s|s.outline.iter().any(|v|*v>0.0)) { + ui.indent("outline-option", |ui| { + ui.add_enabled(p.include_size,egui::Checkbox::new(&mut p.include_outline,"Include outline in bounds")); + }); + } egui::CollapsingHeader::new("Import details").show(ui, |ui| { ui.label(&p.note); ui.small("Source format, crop offsets, colors and outline appearance are not imported."); diff --git a/crates/canvas-pilot/src/project_ui.rs b/crates/canvas-pilot/src/project_ui.rs index f8a562e..fa465ec 100644 --- a/crates/canvas-pilot/src/project_ui.rs +++ b/crates/canvas-pilot/src/project_ui.rs @@ -12,6 +12,25 @@ type LoadedProject = (PreparedProject, Option, Option); type ProjectJob = std::sync::mpsc::Receiver, String>>; type ExportJob = std::sync::mpsc::Receiver), String>>; +#[derive(Clone, Copy, Default, PartialEq, Eq)] +enum ExportScope { + #[default] + Selected, + All, + Visible, + Specific, +} +impl ExportScope { + fn label(self) -> &'static str { + match self { + Self::Selected => "Selected layers", + Self::All => "All layers", + Self::Visible => "Visible layers only", + Self::Specific => "Specific layer", + } + } +} + #[derive(Default)] pub(super) struct FileUi { pub(super) project_path: Option, @@ -26,6 +45,8 @@ pub(super) struct FileUi { pub(super) message: Option, exchange_options: canvas_pilot::exchange::Options, export_open: bool, + export_scope: ExportScope, + export_layer: Option, export_codec: canvas_pilot::interchange::Codec, export_job: Option, } @@ -401,94 +422,114 @@ impl Editor { ui.close_menu(); } } + fn export_layer_ids(&self) -> Vec { + (0..self.layout.layers().len()) + .filter(|&i| match self.files.export_scope { + ExportScope::Selected => self.layout.selected_indices().contains(&i), + ExportScope::All => true, + ExportScope::Visible => self.layout.visible(i), + ExportScope::Specific => { + self.files.export_layer == Some(self.layout.layer_info(i).id) + } + }) + .map(|i| self.layout.layer_info(i).id) + .collect() + } fn exchange_menu(&mut self, ui: &mut egui::Ui, format: canvas_pilot::interchange::Codec) { + egui::ComboBox::from_label("Layers") + .selected_text(self.files.export_scope.label()) + .show_ui(ui, |ui| { + for scope in [ + ExportScope::Selected, + ExportScope::All, + ExportScope::Visible, + ExportScope::Specific, + ] { + ui.selectable_value(&mut self.files.export_scope, scope, scope.label()); + } + }); + if self.files.export_scope == ExportScope::Selected { + self.transfer_layer_picker(ui, "Choose layers…"); + } + if self.files.export_scope == ExportScope::Specific { + if !self + .layout + .layers() + .iter() + .enumerate() + .any(|(i, _)| Some(self.layout.layer_info(i).id) == self.files.export_layer) + { + self.files.export_layer = (0..self.layout.layers().len()) + .next() + .map(|i| self.layout.layer_info(i).id); + } + let label = (0..self.layout.layers().len()) + .find(|&i| Some(self.layout.layer_info(i).id) == self.files.export_layer) + .map(|i| self.layout.layer_label(i)) + .unwrap_or_default(); + egui::ComboBox::from_label("Layer") + .selected_text(label) + .show_ui(ui, |ui| { + for i in 0..self.layout.layers().len() { + ui.selectable_value( + &mut self.files.export_layer, + Some(self.layout.layer_info(i).id), + self.layout.layer_label(i), + ); + } + }); + } let metadata = canvas_pilot::exchange_metadata::supported(format); if !metadata { self.files.exchange_options.extra_parameters = false; } - ui.add_enabled( - metadata, - egui::Checkbox::new( - &mut self.files.exchange_options.extra_parameters, - "Include extra Canvas Pilot parameters (experimental)", - ), - ); - ui.small(if metadata { - "Embeds the exported layers’ source/crop settings, names, folders, links and workspace settings. No image bytes or capture bindings. Other apps may remove it. Restore the original snapshot through Project > Restore parameters from export; geometry import still uses the artwork." - } else { - "Extra parameters are not yet supported for this format. Save a Canvas Pilot project alongside it." - }); - ui.checkbox( - &mut self.files.exchange_options.background, - "Include background layer", - ) - .on_hover_text(if format.artwork() { - "Composite the visible reference images on a screen-sized background, or a plain backdrop when none is visible." - } else { - "Include a screen-sized background rectangle. This format cannot embed its picture." - }); - ui.add_enabled( - format.artwork(), - egui::Checkbox::new( - &mut self.files.exchange_options.placeholders, - "Include placeholder pictures", - ), - ) - .on_hover_text(if format.artwork() { - "Embed source-pattern pictures showing current cropping. These are placeholders, not live source captures." - } else { - "This format carries rectangle geometry but cannot embed placeholder pictures." - }); + if !format.artwork() { + self.files.exchange_options.placeholders = false; + } + let options = &mut self.files.exchange_options; + let pictures = match (options.background, options.placeholders) { + (true, true) => "Pictures · background and placeholders", + (true, false) => "Pictures · background included", + (false, true) => "Pictures · placeholders included", + (false, false) => "Pictures · none", + }; + egui::CollapsingHeader::new(if format.artwork() { pictures } else if options.background { "Background · included" } else { "Background · none" }) + .id_salt("export-pictures").show(ui, |ui| { + ui.checkbox(&mut options.background, "Include background layer") + .on_hover_text(if format.artwork() { "Use the visible reference images, or a plain background when none is visible." } else { "Include a screen-sized rectangle. This format cannot embed pictures." }); + if format.artwork() { + ui.checkbox(&mut options.placeholders, "Include placeholder pictures") + .on_hover_text("Show source patterns with the current crop and mask. These are not live captures."); + } + }); + egui::CollapsingHeader::new(if options.extra_parameters { "Canvas Pilot settings · included" } else { "Canvas Pilot settings · not included" }) + .id_salt("export-settings").show(ui, |ui| { + if metadata { + ui.checkbox(&mut options.extra_parameters, "Include extra Canvas Pilot parameters (experimental)"); + ui.small("Keep an editable snapshot of these layers. Restore it from the Project menu; other editors may remove it."); + ui.label("What is saved?").on_hover_text("Source settings, crop, fit, blanking, mappings, inactive input proposals and workspace settings. Reference images and captured previews are excluded. The snapshot stays at its original values if artwork is edited elsewhere."); + } else { + ui.small("This format cannot carry editable settings. Save a .pilot.json project alongside it."); + } + }); ui.separator(); - let current = self.layout.selected().map(|i| self.layout.layer_info(i).id); + let ids = self.export_layer_ids(); + ui.small(format!( + "{} {} to export", + ids.len(), + if ids.len() == 1 { "layer" } else { "layers" } + )); if ui - .add_enabled(current.is_some(), egui::Button::new("Current layer…")) - .on_disabled_hover_text("Select exactly one layer.") + .add_enabled(!ids.is_empty(), egui::Button::new("Export…")) + .on_disabled_hover_text("Choose at least one layer to export.") .clicked() { - ui.close_menu(); - self.export_exchange(format, &[current.unwrap()], "layer"); + self.export_exchange( + format, + &ids, + if ids.len() == 1 { "layer" } else { "layout" }, + ); } - self.transfer_layer_picker(ui, "Choose layers to export…"); - ui.menu_button("Specific layer…", |ui| { - egui::ScrollArea::vertical() - .max_height(320.0) - .show(ui, |ui| { - for i in 0..self.layout.layers().len() { - if ui.button(self.layout.layer_label(i)).clicked() { - let id = self.layout.layer_info(i).id; - ui.close_menu(); - self.export_exchange(format, &[id], "layer"); - } - } - }); - }); - let selected: Vec<_> = self - .layout - .selected_indices() - .iter() - .map(|&i| self.layout.layer_info(i).id) - .collect(); - if ui - .add_enabled(!selected.is_empty(), egui::Button::new("Selected layers…")) - .clicked() - { - ui.close_menu(); - self.export_exchange(format, &selected, "selection"); - } - for (label, visible) in [("All layers…", false), ("Visible layers only…", true)] { - if ui.button(label).clicked() { - let ids: Vec<_> = (0..self.layout.layers().len()) - .filter(|&i| !visible || self.layout.visible(i)) - .map(|i| self.layout.layer_info(i).id) - .collect(); - ui.close_menu(); - self.export_exchange(format, &ids, "layout"); - } - } - ui.small( - "Round-trip layer boxes in screen pixels. Project JSON preserves full source/crop settings.", - ); } fn export_exchange( &mut self, @@ -640,32 +681,67 @@ impl Editor { mod tests { use super::*; #[test] - fn all_exchange_menus_offer_current_layer_and_format_artwork_options() { + fn export_scope_is_explicit_and_unavailable_options_are_cleared() { let ctx = egui::Context::default(); let mut app = Editor::default(); - // Render the real submenu directly so file-dialog actions remain untouched. + app.files.export_scope = ExportScope::All; + let all = app.export_layer_ids(); + assert_eq!(all.len(), app.layout.layers().len()); + app.files.export_scope = ExportScope::Specific; + app.files.export_layer = Some(all[1]); + assert_eq!(app.export_layer_ids(), vec![all[1]]); + app.files.export_layer = Some(usize::MAX); + assert!(app.export_layer_ids().is_empty()); + app.files.export_scope = ExportScope::Selected; + let expected: Vec<_> = app + .layout + .selected_indices() + .iter() + .map(|&i| app.layout.layer_info(i).id) + .collect(); + assert_eq!(app.export_layer_ids(), expected); for format in canvas_pilot::interchange::Codec::available() { + app.files.exchange_options.extra_parameters = true; + app.files.exchange_options.placeholders = true; let output = ctx.run(egui::RawInput::default(), |ctx| { egui::CentralPanel::default().show(ctx, |ui| app.exchange_menu(ui, format)); }); - for label in [ - "Current layer…", - "Include background layer", - "Include placeholder pictures", - "Selected layers…", - "All layers…", - "Visible layers only…", - ] { - assert!( - output.shapes.iter().any( - |s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == label) - ), - "{label}" - ); - } + assert_eq!( + app.files.exchange_options.extra_parameters, + canvas_pilot::exchange_metadata::supported(format) + ); + assert_eq!(app.files.exchange_options.placeholders, format.artwork()); + assert!( + output.shapes.iter().any( + |s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Export…") + ) + ); + assert!(!output.shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Include placeholder pictures"))); } } + #[test] + fn optional_export_groups_expand_without_exporting_or_changing_layers() { + use super::super::tests::{click_text, frame}; + let ctx = egui::Context::default(); + let mut app = Editor::default(); + app.files.export_open = true; + let before = app.project(); + click_text(&mut app, &ctx, "Pictures · none"); + click_text(&mut app, &ctx, "Include placeholder pictures"); + assert!(app.files.exchange_options.placeholders); + click_text(&mut app, &ctx, "Canvas Pilot settings · not included"); + click_text( + &mut app, + &ctx, + "Include extra Canvas Pilot parameters (experimental)", + ); + assert!(app.files.exchange_options.extra_parameters); + frame(&mut app, &ctx, vec![]); + assert!(app.files.export_job.is_none()); + assert_eq!(app.project(), before); + } + #[test] fn new_after_save_requires_success_and_does_not_count_autosave() { let dir = tempfile::tempdir().unwrap(); diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 54b1efe..9fc6c21 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,10 @@ ## Unreleased +- Simplified export to a layer-scope dropdown and one Export button. Pictures and + editable snapshots live in collapsed groups with visible inclusion summaries. + Import shows crop zoom and outline options only when supported by the data. + - Name the format Illustrator throughout the interface and documentation, avoiding the ambiguous former abbreviation while retaining `.ai` files and codec compatibility. diff --git a/docs/canvas-pilot/guide/editing.md b/docs/canvas-pilot/guide/editing.md index 511ab26..fd45809 100644 --- a/docs/canvas-pilot/guide/editing.md +++ b/docs/canvas-pilot/guide/editing.md @@ -156,8 +156,8 @@ Stable IDs survive removal and are independent of Midra layer numbers. Group movement, alignment and Same-handles resizing work across the selection; Mirror/Opposite resizing still require exactly two layers. -Project JSON is version 12, with tested migration from older supported versions. -Every format’s **Selected layers…** action exports just the current selection, +Projects support migration from older supported versions. +Every format’s **Selected layers** scope exports just the current selection, including a single layer. All/visible export remains available. ## Viewport context menu diff --git a/docs/canvas-pilot/guide/files.md b/docs/canvas-pilot/guide/files.md index e6a757c..ea1caaa 100644 --- a/docs/canvas-pilot/guide/files.md +++ b/docs/canvas-pilot/guide/files.md @@ -155,14 +155,20 @@ undo history. Existing files require confirmation before replacement. The [starter-file catalog](../../templates/canvas-pilot/catalog.md) contains all eleven exchange formats, with two layers for 1920 × 1080 and 3840 × 2160 canvases. -**Project → Export → Export layers…** opens one shared window. Choose SVG, -draw.io, JSON, CSV, DXF/DWG, HTML, PPTX, Figma FIG, FigCraft or Illustrator, then -**Current layer…**, -**Selected layers…**, **Specific layer…**, **All layers…** and **Visible layers -only…**. A current-layer export keeps its original screen position and full-screen -canvas. The window offers **Include background layer**. SVG, draw.io, geometry -JSON, HTML, PPTX, FIG, FIGCRAFT and Illustrator also offer **Include placeholder pictures** with embedded source-grid -imagery; CSV and DXF explicitly disable pictures and carry rectangle geometry. +**Project → Export → Export layers…** opens one shared window: + +1. Choose the **Format**. +2. Choose **Layers**: Selected layers, All layers, Visible layers only, or Specific + layer. With Selected layers, **Choose layers…** lets you adjust the selection. +3. Click **Export…** and choose a file. The layer count previews the scope; + selecting one layer keeps its original screen position and full-screen canvas. + +Optional groups start collapsed. **Pictures** contains **Include background layer** +and **Include placeholder pictures**. Their heading shows what is included even +when collapsed. CSV and DXF offer only a background rectangle, with no picture +controls. **Canvas Pilot settings** contains the optional editable snapshot; +its heading also shows whether inclusion is enabled. For everyday geometry +exchange, leave both groups at their defaults. Import a supported format with **Import → Geometry file…** or paste its text, then choose a slide/page/frame where applicable, then map detected layers to destinations. @@ -193,7 +199,7 @@ The toolbar’s **Import** button uses a downward arrow into a tray. Hover for i label; its dropdown contains SVG, clipboard values, and reference-image actions. -![Export layers dialog showing SVG, extra parameters, picture options and layer scopes](../images/08-guide-export.png) +![Export layers dialog showing SVG, selected-layer scope, collapsed optional groups and one Export button](../images/08-guide-export.png) *Choose a format, artwork options and which layers to export in one window. The header still uses the former Midra Layout name.* @@ -207,8 +213,8 @@ You can choose layers without returning to the viewport: layer using its destination dropdown. When using a selection, there must be at least as many chosen destinations as imported rectangles after ignoring a background. Map to any subset of them; other layers stay unchanged. Duplicate mappings and empty imports remain invalid. -- A format’s **Choose layers to export…** selects the group for - **Selected layers…**. **Specific layer…** remains available for individual layers, +- In Export layers, choose **Selected layers** and use **Choose layers…** to select + the group. **Specific layer** remains available for individual layers, including hidden layers. - Midra send preparation has **Choose editor layers to send…**, followed by a device-destination dropdown for each chosen layer. It can open online with @@ -340,7 +346,8 @@ and [versioned project contract](../../interfaces/canvas-pilot.md). See [which editing features survive](#which-editing-features-survive) for a comparison of project saves, plain geometry import and snapshot restoration. -In **Export layers**, enable **Include extra Canvas Pilot parameters (experimental)** to +In **Export layers**, expand **Canvas Pilot settings** and enable +**Include extra Canvas Pilot parameters (experimental)** to store the exported layers' source/crop settings, fit modes, masks, saved input proposals, names, folders, links and workspace setup alongside the geometry. It is available for SVG, draw.io, JSON, CSV, DXF, HTML, PPTX and FigCraft. Images/capture assignments are excluded from this snapshot; the diff --git a/docs/canvas-pilot/guide/quickstart.md b/docs/canvas-pilot/guide/quickstart.md index f80438b..f0761d6 100644 --- a/docs/canvas-pilot/guide/quickstart.md +++ b/docs/canvas-pilot/guide/quickstart.md @@ -58,8 +58,8 @@ Use **Project → Open project…** to load it later. ## 5. Export the layer geometry -Choose **Project → Export → Export layers…**, select **SVG** and **All layers…**, -and save the export. For plain layer boxes, leave the background and placeholder +Choose **Project → Export → Export layers…**, select **SVG** and **All layers**, +then click **Export…** and save the file. For plain layer boxes, leave the background and placeholder pictures disabled. The SVG can be opened in a vector editor. Compare file and clipboard capabilities in the diff --git a/docs/canvas-pilot/images/08-guide-export.png b/docs/canvas-pilot/images/08-guide-export.png index a76e4d3..b03e28e 100644 Binary files a/docs/canvas-pilot/images/08-guide-export.png and b/docs/canvas-pilot/images/08-guide-export.png differ diff --git a/docs/canvas-pilot/images/capture.md b/docs/canvas-pilot/images/capture.md index 84116c9..a1f9d0b 100644 --- a/docs/canvas-pilot/images/capture.md +++ b/docs/canvas-pilot/images/capture.md @@ -115,10 +115,14 @@ client window. XTest pointer events operated only the isolated session. | `05-guide-layer-properties.png` | Click the selected layer's resolution card and leave the Layer tab open. | | `06-guide-crop.png` | Switch to Crop; retain normal fit, 100% zoom and zero offsets. | | `07-guide-mask.png` | Switch to Mask, then drag the left magenta edge inward about 61 display pixels (116.19 output pixels). Keep the layer bounds unchanged. | -| `08-guide-export.png` | Reset the mask and close properties. Select Slides; open Project → Export → Export layers. Leave SVG and all optional checkboxes at their defaults. | +| `08-guide-export.png` | Start a clean session with Presenter selected; open Project → Export → Export layers. Leave SVG, Selected layers, and both optional groups collapsed at their defaults. | | `09-guide-settings.png` | Close export; open the toolbar settings cog → Open all settings. Leave Appearance selected. | | `10-guide-grid.png` | With Slides selected and other dialogs closed, open the overlay-grid control; keep the default eight columns and six rows, visibility on and grid snapping off. | Verify each full-size capture before replacing it. Keep its guide caption, alt text and actual control state consistent. The original three introduction images remain unchanged and retain their earlier provenance above. + +The export capture was refreshed on 2026-11-16 after simplifying the dialog: +one scope dropdown, one Export button and collapsed optional groups. The capture +uses a fresh isolated offline session and unchanged default geometry.