Add two-layer Full HD and 4K exchange templates

This commit is contained in:
Dandaedre 2026-11-14 14:51:11 +01:00
parent 90fb8ad7dc
commit 8769caec00
10 changed files with 142 additions and 4 deletions

View File

@ -33,6 +33,16 @@ The reporter needs FFprobe (included in portable bundles); PDF generation is
built in. The exporter needs DeckCraft for PPTX or PdfCraft for PDF input.
Run source commands from the repository root; CLI tools support `--help`.
## Midra Layout templates
These starter files contain two named 16:9 layers on an exact pixel canvas.
They can be opened in draw.io or imported into Midra Layout.
| Output canvas | SVG | draw.io |
| --- | --- | --- |
| Full HD — 1920 × 1080 | [Download SVG](docs/templates/midra-layout/midra-layout-1080p-2-layers.svg) | [Download draw.io](docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio) |
| UHD 4K — 3840 × 2160 | [Download SVG](docs/templates/midra-layout/midra-layout-4k-2-layers.svg) | [Download draw.io](docs/templates/midra-layout/midra-layout-4k-2-layers.drawio) |
## PPTX reporter visual guide
**[Follow the illustrated PPTX reporter guide →](docs/user-guide.md)**

View File

@ -1,10 +1,26 @@
//! Manual native-editor round trip; all paths are explicit, no device access.
use midra_layout::{
Layout,
Geometry, Layout,
exchange::{self, Format, Options},
import::parse_values,
project::{Project, write_file},
project::{Project, Resolution, write_file},
};
fn template_project(resolution: [u32; 2]) -> Project {
let mut project = Project::from_layout(&Layout::default());
let scale = resolution[0] as f64 / 1920.0;
project.output_resolution = Resolution::from(resolution);
for layer in &mut project.layers {
layer.bounds = Geometry {
x: layer.bounds.x * scale,
y: layer.bounds.y * scale,
width: layer.bounds.width * scale,
height: layer.bounds.height * scale,
};
}
project
}
fn main() -> Result<(), String> {
let args: Vec<_> = std::env::args().skip(1).collect();
match args.as_slice() {
@ -54,9 +70,32 @@ fn main() -> Result<(), String> {
println!("Verified {} layer boxes: {path}", shapes.len());
}
}
[command, directory] if command == "templates" => {
let directory = std::path::Path::new(directory);
std::fs::create_dir_all(directory).map_err(|e| e.to_string())?;
for (label, resolution) in [("1080p", [1920, 1080]), ("4k", [3840, 2160])] {
let project = template_project(resolution);
let ids = project
.layers
.iter()
.map(|layer| layer.id)
.collect::<Vec<_>>();
for format in [Format::Svg, Format::Drawio] {
let contents = exchange::export(&project, &ids, format, Options::default())?;
write_file(
&directory.join(format!(
"midra-layout-{label}-2-layers.{}",
format.extension()
)),
contents.as_bytes(),
false,
)?;
}
}
}
_ => {
return Err(
"Usage: check_geometry_exchange generate DIRECTORY | verify FILE...".into(),
"Usage: check_geometry_exchange generate DIRECTORY | templates DIRECTORY | verify FILE...".into(),
);
}
}

View File

@ -3,7 +3,7 @@ use midra_layout::{
Geometry, Layout,
exchange::{self, Format, Options},
import::parse_values,
project::Project,
project::{Project, Resolution},
};
use std::io::Write;
@ -25,6 +25,63 @@ fn fixture() -> Project {
.unwrap();
Project::from_layout(&layout)
}
fn template(resolution: [u32; 2]) -> Project {
let mut project = Project::from_layout(&Layout::default());
let scale = resolution[0] as f64 / 1920.0;
project.output_resolution = Resolution::from(resolution);
for layer in &mut project.layers {
layer.bounds.x *= scale;
layer.bounds.y *= scale;
layer.bounds.width *= scale;
layer.bounds.height *= scale;
}
project
}
#[test]
fn readme_templates_match_the_exporter_and_contain_two_layers() {
for (resolution, svg, drawio) in [
(
[1920, 1080],
include_str!("../../../docs/templates/midra-layout/midra-layout-1080p-2-layers.svg"),
include_str!("../../../docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio"),
),
(
[3840, 2160],
include_str!("../../../docs/templates/midra-layout/midra-layout-4k-2-layers.svg"),
include_str!("../../../docs/templates/midra-layout/midra-layout-4k-2-layers.drawio"),
),
] {
let project = template(resolution);
let ids = project
.layers
.iter()
.map(|layer| layer.id)
.collect::<Vec<_>>();
for (format, documented) in [(Format::Svg, svg), (Format::Drawio, drawio)] {
assert_eq!(
exchange::export(&project, &ids, format, Options::default()).unwrap(),
documented
);
let imported = parse_values(documented).unwrap();
assert_eq!(imported.shapes.len(), 2);
assert!(imported.shapes.iter().all(|shape| !shape.background_only));
assert_eq!(
imported
.shapes
.iter()
.map(|shape| shape.geometry)
.collect::<Vec<_>>(),
project
.layers
.iter()
.map(|layer| layer.bounds)
.collect::<Vec<_>>()
);
}
}
}
#[test]
fn every_format_and_artwork_option_roundtrips_geometry_and_order() {
let project = fixture();

View File

@ -6,6 +6,15 @@ preserve layer **visible-box geometry**, not sources, crop settings, zoom, pivot
Midra links, locks, visibility, camera or selection. Pictures illustrate current
cropping; importing a picture does not reconstruct its crop or source settings.
Ready-to-open two-layer templates are published under
`docs/templates/midra-layout/` for Full HD (1920 × 1080) and UHD 4K
(3840 × 2160), in both SVG v2 and draw.io v1. The 4K geometry is an exact 2×
scale of the Full HD layout. Regenerate them with:
```sh
cargo run --locked -p midra-layout --example check_geometry_exchange -- templates docs/templates/midra-layout
```
## Scope, coordinates and artwork
Both formats offer Current layer (exactly one selected), Selected layers,

View File

@ -552,6 +552,9 @@ viewport preferences, and the embedded reference image. Apply pending edits
before saving. Opening asks before replacing current work and starts a fresh
undo history. Existing files require confirmation before replacement.
The root README links ready-to-open SVG and draw.io templates with two layers
for 1920 × 1080 and 3840 × 2160 output canvases.
**Project → Export → Export SVG / Export draw.io** offers **Current layer…**,
**Selected layers…**, **Specific layer…**, **All layers…** and **Visible layers
only…**. A current-layer export keeps its original screen position and full-screen

View File

@ -4,6 +4,8 @@
## Unreleased
- Add README-linked two-layer SVG and draw.io templates for Full HD and UHD 4K, generated by the application exporter and checked byte-for-byte in regression tests.
- Import SVG rendered by draw.io Desktop, including its SVG 1.1 DOCTYPE, nested cell wrappers, symbol/image layers and generated label fallbacks. A background-preserved native 31.7.0 round trip was checked; draw.io's cropped SVG exports necessarily retain their rebased coordinates.
- Add current-layer SVG and draw.io exports with optional embedded backgrounds and source-pattern placeholders; import native/compressed draw.io files. Round-trip tests cover scopes/artwork and whole-pixel geometry; draw.io Desktop 31.7.0 rendering and XML re-save were checked. Use JSON for full source/crop fidelity.

View File

@ -0,0 +1,4 @@
<mxfile host="Midra Layout" compressed="false"><diagram id="midra-layout" name="Layout"><mxGraphModel page="1" pageScale="1" pageWidth="1920" pageHeight="1080" grid="0" adaptiveColors="none" data-midra-layout-geometry="1"><root><mxCell id="0"/><mxCell id="1" parent="0"/>
<mxCell id="layer-2" value="Slides" data-midra-role="layer" vertex="1" parent="1" style="rounded=0;whiteSpace=wrap;html=0;strokeColor=none;fillColor=#173b50;fontColor=#ffffff;"><mxGeometry x="120" y="180" width="640" height="360" as="geometry"/></mxCell>
<mxCell id="layer-1" value="Presenter" data-midra-role="layer" vertex="1" parent="1" style="rounded=0;whiteSpace=wrap;html=0;strokeColor=none;fillColor=#173b50;fontColor=#ffffff;"><mxGeometry x="1160" y="180" width="640" height="360" as="geometry"/></mxCell>
</root></mxGraphModel></diagram></mxfile>

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-midra-layout-geometry="2" width="1920" height="1080" viewBox="0 0 1920 1080">
<title>Midra Layout geometry</title>
<rect id="layer-2" data-midra-role="layer" x="120" y="180" width="640" height="360" fill="#173b50"><title>Slides</title></rect>
<rect id="layer-1" data-midra-role="layer" x="1160" y="180" width="640" height="360" fill="#173b50"><title>Presenter</title></rect>
</svg>

After

Width:  |  Height:  |  Size: 470 B

View File

@ -0,0 +1,4 @@
<mxfile host="Midra Layout" compressed="false"><diagram id="midra-layout" name="Layout"><mxGraphModel page="1" pageScale="1" pageWidth="3840" pageHeight="2160" grid="0" adaptiveColors="none" data-midra-layout-geometry="1"><root><mxCell id="0"/><mxCell id="1" parent="0"/>
<mxCell id="layer-2" value="Slides" data-midra-role="layer" vertex="1" parent="1" style="rounded=0;whiteSpace=wrap;html=0;strokeColor=none;fillColor=#173b50;fontColor=#ffffff;"><mxGeometry x="240" y="360" width="1280" height="720" as="geometry"/></mxCell>
<mxCell id="layer-1" value="Presenter" data-midra-role="layer" vertex="1" parent="1" style="rounded=0;whiteSpace=wrap;html=0;strokeColor=none;fillColor=#173b50;fontColor=#ffffff;"><mxGeometry x="2320" y="360" width="1280" height="720" as="geometry"/></mxCell>
</root></mxGraphModel></diagram></mxfile>

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-midra-layout-geometry="2" width="3840" height="2160" viewBox="0 0 3840 2160">
<title>Midra Layout geometry</title>
<rect id="layer-2" data-midra-role="layer" x="240" y="360" width="1280" height="720" fill="#173b50"><title>Slides</title></rect>
<rect id="layer-1" data-midra-role="layer" x="2320" y="360" width="1280" height="720" fill="#173b50"><title>Presenter</title></rect>
</svg>

After

Width:  |  Height:  |  Size: 472 B