Add resize snapping, pixel guides and complete local export scopes

This commit is contained in:
Dandaedre 2026-11-13 17:45:03 +01:00
parent ec371e00d2
commit 932b707680
12 changed files with 446 additions and 26 deletions

View File

@ -11,6 +11,8 @@ mod menu_ui;
mod preferences_ui;
#[path = "project_ui.rs"]
mod project_ui;
#[path = "viewport_guides.rs"]
mod viewport_guides;
use format_ui::{FormatDraft, OutputDraft, PropertyTab};
use midra_layout::import::{DetectedShape, ImportDocument, parse_svg, parse_values};
use midra_layout::{AlignTarget, Alignment, Corner, Geometry, Layout, ResizeHandle, ResizeMode};
@ -60,6 +62,7 @@ struct Marquee {
}
struct Paste {
targets: Vec<usize>,
target_ids: Vec<usize>,
text: String,
shapes: Vec<DetectedShape>,
mapping: Vec<Option<usize>>,
@ -159,7 +162,14 @@ impl Paste {
self.targets.len()
));
}
if layout.selected_indices() != self.targets {
if layout.selected_indices() != self.targets
|| self
.targets
.iter()
.map(|i| layout.layer_info(*i).id)
.collect::<Vec<_>>()
!= self.target_ids
{
return Err(
"Selection changed. Close this review and import again for the current selection."
.into(),
@ -432,6 +442,10 @@ impl Editor {
return;
}
let mut p = Paste {
target_ids: targets
.iter()
.map(|i| self.layout.layer_info(*i).id)
.collect(),
targets,
text,
shapes: Vec::new(),
@ -2131,6 +2145,7 @@ impl Editor {
);
}
}
viewport_guides::paint(&screen.painter, area, origin, scale, output);
if let Some(rect) = self.crop_bounds(origin, scale) {
let p = &screen.painter;
p.rect_stroke(
@ -2667,6 +2682,53 @@ mod tests {
}
}
#[test]
fn paste_review_rejects_replaced_layer_with_same_list_index() {
let mut app = Editor::default();
app.open_paste(include_str!("../tests/fixtures/drawio-rectangle.txt").into());
app.layout.remove_selected().unwrap();
app.layout.add_layer().unwrap();
assert_eq!(app.layout.selected_indices(), vec![1]);
assert!(
app.paste
.as_ref()
.unwrap()
.values(&app.layout)
.unwrap_err()
.contains("Selection changed")
);
}
#[test]
#[ignore = "manual viewport timing; run with --release --ignored --nocapture"]
fn viewport_capacity_timing() {
let ctx = egui::Context::default();
let mut app = Editor::default();
for _ in 2..256 {
app.layout.add_layer().unwrap();
}
let before = app.layout.layers().clone();
let mut timings = Vec::new();
for n in 0..120 {
let now = std::time::Instant::now();
frame(
&mut app,
&ctx,
vec![egui::Event::PointerMoved(Pos2::new(
200.0 + (n % 20) as f32,
300.0,
))],
);
if n >= 20 {
timings.push(now.elapsed().as_secs_f64() * 1000.0);
}
}
timings.sort_by(f64::total_cmp);
println!(
"256 layers, 1440×940 headless egui: p50 {:.2} ms, p95 {:.2} ms; excludes GPU presentation",
timings[50], timings[95]
);
assert_eq!(*app.layout.layers(), before);
}
#[test]
fn double_click_enters_crop_mode_without_changing_geometry() {
for target in [Some(0), Some(1), None] {
let mut app = Editor::default();

View File

@ -391,15 +391,14 @@ impl Layout {
}
fn restore(&mut self, s: Snapshot) {
self.gesture_error = None;
// Keep current protection/selection for surviving IDs; restore deleted IDs' flags.
// Selection remains independent of history for surviving IDs.
let mut selected = s.selected;
let mut locked = s.locked;
let mut visible = s.visible;
let locked = s.locked;
let visible = s.visible;
for (i, info) in s.info.iter().enumerate() {
if let Some(j) = self.info.iter().position(|old| old.id == info.id) {
selected[i] = self.selected[j];
locked[i] = self.locked[j];
visible[i] = self.visible[j];
selected[i] &= visible[i] && !locked[i];
}
}
self.selected = selected;
@ -684,24 +683,28 @@ impl Layout {
fn selectable(&self, index: usize) -> bool {
self.visible(index) && !self.locked(index)
}
/// Editor protection flags do not change geometry or its undo history.
/// Protection flags are local, undoable edits; cancel any active gesture first.
pub fn set_locked(&mut self, index: usize, locked: bool) {
self.cancel_drag();
let before = self.snapshot();
if let Some(value) = self.locked.get_mut(index) {
*value = locked;
if locked {
self.selected[index] = false;
}
}
self.remember(before);
}
pub fn set_visible(&mut self, index: usize, visible: bool) {
self.cancel_drag();
let before = self.snapshot();
if let Some(value) = self.visible.get_mut(index) {
*value = visible;
if !visible {
self.selected[index] = false;
}
}
self.remember(before);
}
/// A single selected layer, or None for zero/multiple selections.
pub fn selected(&self) -> Option<usize> {

View File

@ -62,13 +62,13 @@ impl Editor {
ui.checkbox(&mut self.keep_aspect_ratio, "Keep aspect ratio when resizing");
ui.label("Applies to layer handles and numeric width/height edits. Crop zoom always keeps the source proportions.");
ui.separator();
ui.checkbox(&mut self.snapping.enabled, "Snap while moving layers");
ui.checkbox(&mut self.snapping.enabled, "Snap movement & resizing");
ui.add_enabled_ui(self.snapping.enabled, |ui| {
ui.checkbox(&mut self.snapping.pixels, "Pixel edges");
ui.checkbox(&mut self.snapping.screen_edges, "Screen edges");
ui.checkbox(&mut self.snapping.layer_edges, "Other visible layer edges");
});
ui.weak("Hold Alt to bypass snapping. Numeric entry remains exact. Resize and crop handles do not proximity-snap.");
ui.weak("Hold Alt to bypass snapping. Numeric entry remains exact. Resize handles also snap; crop-content handles do not.");
ui.separator();
ui.label("Arrow keys: move 1 pixel · Shift-arrow: move 10 pixels");
ui.label("Shift-click: add/remove a layer from selection");
@ -166,7 +166,7 @@ mod tests {
click_label(&mut app, &ctx, "Show toolbar icon names");
click_label(&mut app, &ctx, "Editing");
click_label(&mut app, &ctx, "Keep aspect ratio when resizing");
click_label(&mut app, &ctx, "Snap while moving layers");
click_label(&mut app, &ctx, "Snap movement & resizing");
let (_, saved) = settings::Store::at(path);
assert!(saved.snapping.enabled);
assert!(saved.show_toolbar_icon_names);

View File

@ -117,6 +117,38 @@ impl Editor {
ui.small("Saves applied values and the reference image.");
ui.separator();
ui.menu_button("Export SVG", |ui| {
ui.menu_button("Specific layer…", |ui| {
egui::ScrollArea::vertical()
.max_height(320.0)
.show(ui, |ui| {
for i in 0..self.layout.layers().len() {
let title = format!(
"{}{}",
self.layout.layer_label(i),
if self.layout.visible(i) {
""
} else {
" (hidden)"
}
);
if ui.button(title).clicked() {
ui.close_menu();
match self.project().to_svg_ids(&[self.layout.layer_info(i).id]) {
Ok(svg) => {
if let Some(path) = rfd::FileDialog::new()
.add_filter("SVG geometry", &["svg"])
.set_file_name("layer.svg")
.save_file()
{
self.queue_write(path, svg);
}
}
Err(e) => self.files.message = Some(e),
}
}
}
});
});
if ui
.add_enabled(
!self.layout.selected_indices().is_empty(),

View File

@ -1,5 +1,5 @@
//! Proximity snapping for moving one layer or a selection as a rigid group.
use crate::{Geometry, Layout};
use crate::{Geometry, Layout, ResizeHandle};
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
@ -22,13 +22,16 @@ impl Default for Snapping {
impl Layout {
/// Recompute from the gesture's original snapshot, never from a previous snapped frame.
/// `tolerance` is in screen pixels; the UI converts its fixed logical hit distance.
/// Resizing and content gestures retain their existing anchor/crop semantics.
/// Layer resize handles preserve anchors/ratios; content crop gestures do not snap.
pub fn drag_to_snapped(
&mut self,
point: [f64; 2],
options: Snapping,
tolerance: f64,
) -> [Option<f64>; 2] {
if self.resize.is_some() && options.enabled && tolerance.is_finite() && tolerance >= 0.0 {
return self.resize_to_snapped(point, options, tolerance);
}
let mut guides = [None; 2];
let Some((selected, before, start)) = self.drag.clone() else {
self.drag_to(point);
@ -101,4 +104,81 @@ impl Layout {
}
guides
}
fn resize_to_snapped(
&mut self,
point: [f64; 2],
options: Snapping,
tolerance: f64,
) -> [Option<f64>; 2] {
let r = self.resize.clone().expect("resize gesture");
self.drag_to(point);
if self.gesture_error.is_some() || point.iter().any(|v| !v.is_finite()) {
return [None; 2];
}
let base = self.snapshot();
let handle_point = |geometry| {
ResizeHandle::positions(geometry)
.into_iter()
.find(|(handle, _)| *handle == r.handle)
.unwrap()
.1
};
let current = handle_point(self.layers[r.index]);
let mut candidates = Vec::new();
for (axis, _) in current.iter().enumerate() {
if (axis == 0 && matches!(r.handle, ResizeHandle::Top | ResizeHandle::Bottom))
|| (axis == 1 && matches!(r.handle, ResizeHandle::Left | ResizeHandle::Right))
{
continue;
}
let mut targets = Vec::new();
if options.screen_edges {
targets.extend([0.0, self.formats.output[axis] as f64]);
}
if options.layer_edges {
for (i, g) in r.before.layers.iter().enumerate() {
if !r.targets[i] && self.visible(i) {
targets.extend(if axis == 0 {
[g.x, g.x + g.width]
} else {
[g.y, g.y + g.height]
});
}
}
}
if let Some(target) = targets
.into_iter()
.filter(|t| (*t - current[axis]).abs() <= tolerance)
.min_by(|a, b| {
(a - current[axis])
.abs()
.total_cmp(&(b - current[axis]).abs())
})
{
candidates.push((0, (target - current[axis]).abs(), axis, target));
}
if options.pixels {
let target = current[axis].round();
candidates.push((1, (target - current[axis]).abs(), axis, target));
}
}
candidates.sort_by(|a, b| a.0.cmp(&b.0).then(a.1.total_cmp(&b.1)));
for (priority, _, axis, target) in candidates {
let mut adjusted = point;
adjusted[axis] += target - current[axis];
self.drag_to(adjusted);
// Ratio/minimum-size constraints can prevent the requested snap. Never show a false guide.
if self.gesture_error.is_none()
&& (handle_point(self.layers[r.index])[axis] - target).abs() < 1e-6
{
let mut guides = [None; 2];
if priority == 0 {
guides[axis] = Some(target);
}
return guides;
}
self.restore(base.clone());
}
[None; 2]
}
}

View File

@ -0,0 +1,118 @@
use super::*;
fn ticks(min: f32, max: f32, origin: f32, scale: f32, extent: u32, step: u32) -> Vec<(f32, u32)> {
if !scale.is_finite() || scale <= 0.0 || step == 0 {
return Vec::new();
}
let first = (((min - origin) / scale).max(0.0) / step as f32).ceil() as u32;
let last = (((max - origin) / scale).min(extent as f32) / step as f32)
.floor()
.max(0.0) as u32;
if first > last || last - first > 4096 {
return Vec::new();
}
(first..=last)
.filter_map(|n| {
let value = n * step;
let p = origin + value as f32 * scale;
(value <= extent && p >= min && p <= max).then_some((p, value))
})
.collect()
}
/// High-zoom measurement guides. Drawing cost depends on visible pixels, not canvas size.
pub(super) fn paint(
painter: &egui::Painter,
area: Rect,
origin: Pos2,
scale: f32,
output: [u32; 2],
) {
if scale < 2.0 {
return;
}
let palette = theme::palette(painter.ctx());
let canvas = Rect::from_min_size(
origin,
Vec2::new(output[0] as f32, output[1] as f32) * scale,
);
let clipped = painter.with_clip_rect(area.intersect(canvas));
if scale >= 8.0 {
for (x, _) in ticks(area.left(), area.right(), origin.x, scale, output[0], 1) {
clipped.line_segment(
[Pos2::new(x, area.top()), Pos2::new(x, area.bottom())],
Stroke::new(0.5_f32, palette.grid.gamma_multiply(0.5)),
);
}
for (y, _) in ticks(area.top(), area.bottom(), origin.y, scale, output[1], 1) {
clipped.line_segment(
[Pos2::new(area.left(), y), Pos2::new(area.right(), y)],
Stroke::new(0.5_f32, palette.grid.gamma_multiply(0.5)),
);
}
}
let step = [1, 2, 5, 10, 20, 50, 100]
.into_iter()
.find(|step| *step as f32 * scale >= 48.0)
.unwrap_or(100);
let ruler = painter.with_clip_rect(area);
for (x, n) in ticks(
area.left() + 28.0,
area.right() - 10.0,
origin.x,
scale,
output[0],
step,
) {
ruler.line_segment(
[Pos2::new(x, area.top()), Pos2::new(x, area.top() + 4.0)],
Stroke::new(1.0_f32, palette.muted),
);
ruler.text(
Pos2::new(x, area.top() + 5.0),
Align2::CENTER_TOP,
n.to_string(),
FontId::proportional(10.0),
palette.muted,
);
}
for (y, n) in ticks(
area.top() + 24.0,
area.bottom() - 10.0,
origin.y,
scale,
output[1],
step,
) {
ruler.line_segment(
[
Pos2::new(area.left() + 35.0, y),
Pos2::new(area.left() + 39.0, y),
],
Stroke::new(1.0_f32, palette.muted),
);
ruler.text(
Pos2::new(area.left() + 3.0, y),
Align2::LEFT_CENTER,
n.to_string(),
FontId::proportional(9.0),
palette.muted,
);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn guides_follow_pixel_coordinates_and_stay_bounded_when_panned() {
assert_eq!(
ticks(0.0, 100.0, -20.0, 10.0, 1920, 1),
(2..=12)
.map(|n| (-20.0 + n as f32 * 10.0, n))
.collect::<Vec<_>>()
);
assert!(ticks(0.0, 100.0, 1000.0, 10.0, 1920, 1).is_empty());
assert!(ticks(0.0, 100.0, -200000.0, 10.0, 1920, 1).is_empty());
assert!(ticks(0.0, 1000.0, -10000.0, 256.0, 16384, 1).len() < 6);
assert!(ticks(0.0, 100.0, 0.0, 0.0, 1920, 1).is_empty());
}
}

View File

@ -114,3 +114,19 @@ fn documented_v3_example_matches_default() {
Project::from_layout(&Layout::default())
);
}
#[test]
fn visibility_and_lock_changes_are_local_undoable_edits() {
let mut layout = Layout::default();
let before = layout.layers().clone();
layout.set_visible(1, false);
assert!(!layout.visible(1));
layout.undo();
assert!(layout.visible(1));
layout.redo();
assert!(!layout.visible(1));
layout.set_locked(0, true);
assert!(layout.locked(0));
layout.undo();
assert!(!layout.locked(0));
assert_eq!(*layout.layers(), before);
}

View File

@ -97,3 +97,68 @@ fn pixel_snap_can_be_disabled_and_numeric_entry_bypasses_it() {
assert_eq!(layout.layers()[1], g);
}
}
#[test]
fn resize_snaps_to_screen_keeps_anchor_and_undo() {
use midra_layout::ResizeHandle;
let mut layout = Layout::default();
layout.select(Some(0));
let before = layout.layers().clone();
let g = before[0];
layout.start_handle_resize(
0,
ResizeHandle::Right,
[g.x + g.width, g.y + g.height / 2.0],
true,
);
let guides = layout.drag_to_snapped(
[1918.0, g.y + g.height / 2.0],
Snapping {
enabled: true,
pixels: false,
screen_edges: true,
layer_edges: false,
},
6.0,
);
let next = layout.layers()[0];
assert_eq!(guides, [Some(1920.0), None]);
assert_eq!(next.x, g.x);
assert_eq!(next.x + next.width, 1920.0);
assert!((next.width / next.height - g.width / g.height).abs() < 1e-9);
layout.finish_drag();
layout.undo();
assert_eq!(*layout.layers(), before);
}
#[test]
fn resize_can_bypass_snapping_and_cancel() {
use midra_layout::ResizeHandle;
let mut layout = Layout::default();
layout.select(Some(0));
let g = layout.layers()[0];
layout.start_handle_resize(0, ResizeHandle::Top, [g.x + g.width / 2.0, g.y], false);
let options = Snapping {
enabled: true,
pixels: false,
screen_edges: true,
layer_edges: false,
};
assert_eq!(
layout.drag_to_snapped([g.x + g.width / 2.0, 2.0], options, 6.0),
[None, Some(0.0)]
);
assert_eq!(
layout.layers()[0].y + layout.layers()[0].height,
g.y + g.height
);
layout.drag_to_snapped(
[g.x + g.width / 2.0, 2.0],
Snapping {
enabled: false,
..options
},
6.0,
);
assert_eq!(layout.layers()[0].y, 2.0);
layout.cancel_drag();
assert_eq!(layout.layers()[0], g);
}

View File

@ -98,5 +98,7 @@ and save immediately; closing the window requires no Apply step. Restore default
preferences resets all values, including theme history and snapping, without
changing layer geometry or pending position/size text fields. Snapping uses a
fixed six-logical-pixel proximity radius converted by viewport scale. It affects
layer movement only; numeric entry, nudges, resize and crop gestures bypass it.
layer movement and resize handles; numeric entry, nudges and crop-content gestures
bypass it. Resize snapping preserves anchors and proportions and shows guides only
when the resulting edge actually reaches its target.
Alt temporarily disables it without changing the saved option.

View File

@ -121,8 +121,9 @@ leaves the existing file intact.
Add/remove/rename and folder edits are undoable. Device mappings are not implied
by editor IDs. Selection stores stable layer IDs, not zero-based indices. At
least one layer must remain. Visibility and locks remain local protection flags.
SVG export supports all, visible-only or selected layers (including a single
least one layer must remain. Visibility and locks remain local protection flags and are undoable.
SVG export supports all, visible-only, explicit specific-layer (including hidden)
or selected layers (including a single
layer); rectangles retain stable IDs and document stacking order. Names/folders
are not added to the geometry SVG format.

View File

@ -30,7 +30,7 @@ Remaining work, in priority order:
hardware mapping controls remain follow-ups.
2. Reference native-size/offset mapping, outline-only display, adaptive filtering
and background picture import are implemented. Embedded-image project loading
remains synchronous. Pixel-grid/ruler refinement and resize snapping remain.
remains synchronous. High-zoom pixel grids/rulers and resize snapping are implemented.
3. Additional clipboard adapters after obtaining real application/version samples.
4. Local device mappings, specific-layer export, destination review, and two
independently tested sizing/crop strategies. Hardware values remain provisional.
@ -295,7 +295,7 @@ This backlog entry does not authorize future live-device testing or writes.
the verified device adapter. Identify any required position correction and
include it explicitly in the proposed change. Do not alter source routing,
transitions or trigger a Take as an implicit side effect.
- [ ] Keep offline mode as the default. Selecting a device or editing, dragging,
- [x] Keep offline mode as the default. Selecting a device or editing, dragging,
pasting, undoing or redoing locally must never automatically send commands.
- [ ] Present a concrete before/after preview with the device identity, firmware,
screen, layer, Program/Preview target and every setting to be changed. Require
@ -315,12 +315,13 @@ explicit authorization at that time. No API calls are part of this planning task
### 11. Later stretch goal: layer management and export scope
Status: per-layer visibility and locking are implemented for the two current layers;
the remaining management features are requested for later. This is local document organization; it can be
Status: stable-ID collections, add/remove/rename, visibility/locking with undo,
folder labels/filtering and all/visible/selected/specific SVG scopes are implemented.
Hardware mapping and nested/reorderable folder trees remain. This local organization can be
implemented independently of step 10 and does not authorize device connectivity.
Folders are an optional follow-up, not a prerequisite for adding/hiding layers.
- [ ] Replace the fixed two-layer document with a collection using stable local
- [x] Replace the fixed two-layer document with a collection using stable local
IDs. Add an **Add layer** button and editable names. New local layers start
visible and unmapped; adding a planning layer does not create a hardware layer.
- [x] Add per-layer **Show / Hide** controls in the layer list. Hidden layers
@ -330,7 +331,8 @@ Folders are an optional follow-up, not a prerequisite for adding/hiding layers.
- [ ] Add an **Options → Layer mapping** section that maps each local layer to
an explicit device/profile, screen and Midra layer ID. Keep local names and list
order independent of hardware identity; reordering or hiding must not remap.
- [ ] Add an export-scope choice: **Specific layer…** or **Visible layers only**.
- [ ] Hardware export destination review remains; SVG scopes are implemented.
Add an export-scope choice: **Specific layer…** or **Visible layers only**.
The specific-layer picker uses local names and shows the mapped destination;
allow intentionally exporting a hidden layer through this explicit selection.
Visible means enabled in the layer list, not currently inside the viewport,
@ -345,7 +347,8 @@ Folders are an optional follow-up, not a prerequisite for adding/hiding layers.
- [ ] Keep export scope distinct from transport: exporting/copying a configuration
does not send it. Future device writes still use step 10's separate reviewed,
explicit send action, including an explicit Program/Preview target.
- [ ] Make layer creation and visibility changes undoable. When session save/load
- [ ] Creation/visibility undo and project persistence are implemented; device
mappings are pending. When session save/load
is added, preserve stable IDs, names, geometry, visibility and mappings. Extend
selection, paste targeting and undo so they no longer depend on array indices.
- [ ] Optional: add named folders with expand/collapse and drag-to-organize.
@ -520,3 +523,18 @@ provisional calculation reports are implemented. Resize/source edits preserve
normalized content centers, with explicit review of any required adjustment.
Document history includes source, output and layer crops atomically. Firmware
container verification, crop quantization and hardware integration remain deferred.
## Current external/verification gates
- Preview geometry writes remain disabled: physical UP/DOWN bank writes race with
a TAKE from another controller. A verified logical Preview or atomic guarded API
is needed before offering sends that satisfy “never modify Program”.
- Source/input and advanced crop conversion, both sizing strategies and hardware
range/rounding tests remain unverified. Container import must not be called full
source/crop synchronization.
- Native clipboard adapters beyond text/SVG/draw.io need actual application/version
samples; no undocumented Illustrator/Inkscape clipboard compatibility is claimed.
- Operator-platform acceptance (Windows/macOS, DPI, GPU presentation) and release
packaging remain separate from the Linux native UI and headless timing checks.
- Embedded-reference project loading is still synchronous. Folder labels/filtering
are implemented; nested folder trees and drag reordering remain optional work.

View File

@ -501,13 +501,13 @@ presented as implemented until their mapping and transport are available.
### Movement snapping
Enable **Preferences → Editing → Snap while moving layers** and choose pixel,
Enable **Preferences → Editing → Snap movement & resizing** and choose pixel,
screen-edge and/or other-visible-layer-edge targets. Nearby edges show a guide;
the proximity radius stays six logical pixels at any zoom. A selection moves as
a rigid group. Hidden layers are ignored; visible locked layers can be targets.
Hold **Alt** to bypass snapping. Turning snapping on/off alone never moves layers.
Exact numeric entry and nudges bypass proximity snapping; resize and crop handles
retain their existing behavior. One drag remains one undo step, with Escape to cancel.
Exact numeric entry and nudges bypass proximity snapping; resize handles snap while preserving their anchors/ratios, and crop-content
handles retain their existing behavior. One drag remains one undo step, with Escape to cancel.
## Hardware connectivity check
@ -522,7 +522,7 @@ are pending; this adapter exposes no write endpoints.
Use **Layers → Manage layers & folders…** or **Manage…** above the inspector list.
Add layers, select one or more to remove, and apply names/folder labels. These
changes support Undo/Redo; at least one layer must remain. Folder filtering helps
manage the list without changing stacking order. Lock/Show remain local flags.
manage the list without changing stacking order. Lock/Show remain local, undoable flags.
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.
@ -546,3 +546,26 @@ reference until successful completion. Canceling/removing discards late results;
failed replacements keep the current image. Decoder work is serialized to bound
peak memory. Minification uses linear filtering, magnification nearest-neighbor.
Embedded reference decoding during project load remains synchronous.
Resize snapping now uses the same preference and Alt bypass as movement snapping.
It preserves opposite anchors, aspect ratio and group-resize proportions. Guides
appear only when the resulting handle reaches the target; crop-content gestures
remain unsnapped. At 2 logical pixels per screen pixel, adaptive coordinate rulers
appear; at 8, a pixel grid appears. Guide drawing is limited to the visible region.
SVG export also offers **Specific layer…**, listing every local layer, including
hidden/locked layers. Choosing one explicitly exports its geometry without
changing visibility or selection. No device mapping or send is implied.
## Viewport capacity check
Run the explicit headless timing check with:
```sh
cargo test --locked --release -p midra-layout --bin midra-layout viewport_capacity_timing -- --ignored --nocapture
```
On the development Linux host (2026-11-13), 256 visible layers at 1440×940
measured p50 **0.73 ms**, p95 **0.78 ms** across 100 frames after 20 warm-up frames.
This measures egui CPU frame construction, not GPU presentation, image decoding,
OS/DPI behavior or performance on an operator laptop. It is not a release gate.