From 952c40734660d3b8c10c47cff53528eced4a85ea Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 13 Nov 2026 14:36:27 +0100 Subject: [PATCH] Move output format selection into the icon toolbar --- crates/midra-layout/src/gui.rs | 46 +++++++++++++++++++++++++--------- docs/midra-layout.md | 2 +- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/crates/midra-layout/src/gui.rs b/crates/midra-layout/src/gui.rs index 6df14e4..7a36dd2 100644 --- a/crates/midra-layout/src/gui.rs +++ b/crates/midra-layout/src/gui.rs @@ -1125,25 +1125,32 @@ impl Editor { let ink = Ink::new(ui, r); let output = self.layout.formats().output; let [sw, sh] = output.map(|v| v as f32); - ink.button(24.0, 20.0, 185.0, "Output format…", false); - if click(ui, &ink, [24.0, 20.0, 185.0, 34.0], "output-format") { + ink.card(24.0, 65.0, 36.0, 36.0, FIELD, LINE); + if toolbar_icon( + ui, + Rect::from_min_size(ink.point(26.0, 67.0), Vec2::splat(32.0)), + "Output format", + ToolbarIcon::Output, + ) + .clicked() + { self.output_draft = Some(OutputDraft::new(output)); } ink.text( - 224.0, + 24.0, 30.0, &format!("{} × {} px", output[0], output[1]), 12.0, MUTED, ); // A single compact strip: view tools, then history tools. - ink.card(24.0, 65.0, 150.0, 36.0, FIELD, LINE); - ink.line([99.0, 73.0], [99.0, 93.0], LINE); + ink.card(72.0, 65.0, 150.0, 36.0, FIELD, LINE); + ink.line([147.0, 73.0], [147.0, 93.0], LINE); for (x, text, icon) in [ - (28.0, "Fit screen", ToolbarIcon::Screen), - (62.0, "Fit selected", ToolbarIcon::Selection), - (104.0, "Undo", ToolbarIcon::Undo), - (138.0, "Redo", ToolbarIcon::Redo), + (76.0, "Fit screen", ToolbarIcon::Screen), + (110.0, "Fit selected", ToolbarIcon::Selection), + (152.0, "Undo", ToolbarIcon::Undo), + (186.0, "Redo", ToolbarIcon::Redo), ] { let rect = Rect::from_min_size(ink.point(x, 67.0), Vec2::splat(32.0)); if toolbar_icon(ui, rect, text, icon).clicked() { @@ -1175,7 +1182,7 @@ impl Editor { ui.scope_builder( egui::UiBuilder::new() .max_rect(Rect::from_min_size( - ink.point(184.0, 66.0), + ink.point(232.0, 66.0), Vec2::new(36.0, 34.0), )) .layout(egui::Layout::left_to_right(egui::Align::Center)), @@ -1213,7 +1220,7 @@ impl Editor { ui.scope_builder( egui::UiBuilder::new() .max_rect(Rect::from_min_size( - ink.point(232.0, 66.0), + ink.point(280.0, 66.0), Vec2::new(154.0, 34.0), )) .layout(egui::Layout::left_to_right(egui::Align::Center)), @@ -1872,6 +1879,7 @@ fn alignment_icon( #[derive(Clone, Copy)] enum ToolbarIcon { + Output, Screen, Selection, Undo, @@ -1898,6 +1906,19 @@ fn toolbar_icon(ui: &mut egui::Ui, rect: Rect, label: &str, icon: ToolbarIcon) - let c = rect.center(); let point = |x, y| c + Vec2::new(x, y); match icon { + ToolbarIcon::Output => { + painter.rect_stroke( + Rect::from_center_size(c, Vec2::new(22.0, 18.0)), + 2.0, + stroke, + StrokeKind::Inside, + ); + for (y, knob) in [(-4.0, -3.0), (4.0, 3.0)] { + painter.line_segment([point(-7.0, y), point(7.0, y)], stroke); + painter.circle_filled(point(knob, y), 2.5, FIELD); + painter.circle_stroke(point(knob, y), 2.5, stroke); + } + } ToolbarIcon::Screen => { painter.rect_stroke( Rect::from_center_size(point(0.0, -2.0), Vec2::new(20.0, 14.0)), @@ -1960,6 +1981,7 @@ fn toolbar_icon(ui: &mut egui::Ui, rect: Rect, label: &str, icon: ToolbarIcon) - } } response.on_hover_text(match icon { + ToolbarIcon::Output => "Output format — screen ratio and resolution", ToolbarIcon::Screen => "Fit screen — show the entire output", ToolbarIcon::Selection => "Fit selected — frame the selected layers", ToolbarIcon::Undo => "Undo (Ctrl/Cmd+Z)", @@ -2955,7 +2977,7 @@ mod tests { } fn open_alignment_test_menu(app: &mut Editor, ctx: &egui::Context) -> egui::FullOutput { frame(app, ctx, vec![]); - let pos = Pos2::new(200.0, 127.0); + let pos = Pos2::new(248.0, 127.0); frame( app, ctx, diff --git a/docs/midra-layout.md b/docs/midra-layout.md index d46ea34..550509c 100644 --- a/docs/midra-layout.md +++ b/docs/midra-layout.md @@ -276,7 +276,7 @@ one Undo restores the complete resize. Locked or hidden layers cannot be resized ## Formats and content framing -Open **Output format…** for HD (1280 × 720), Full HD (1920 × 1080), UHD 4K +Open the **Output format** icon (screen with sliders), first in the toolbar, for HD (1280 × 720), Full HD (1920 × 1080), UHD 4K (3840 × 2160), aspect presets or a custom whole-pixel resolution. Output/native sizes support 1–16384 pixels per side as an implementation limit, not a promise of hardware support. Layer positions/sizes remain unchanged; screen-corner