From defc55a73ec41548045ef74c9908d4d87be5f79e Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 15 Nov 2026 11:29:05 +0100 Subject: [PATCH] Use compact icons for layer header actions --- crates/midra-layout/src/gui.rs | 73 +++++++++++++++++++++++----- crates/midra-layout/src/layers_ui.rs | 10 ++-- docs/midra-layout/changelog.md | 2 + docs/midra-layout/guide/editing.md | 6 +-- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/crates/midra-layout/src/gui.rs b/crates/midra-layout/src/gui.rs index 20dd204..88d6359 100644 --- a/crates/midra-layout/src/gui.rs +++ b/crates/midra-layout/src/gui.rs @@ -1220,25 +1220,27 @@ impl Editor { let ink = Ink::new(ui, r); let w = r.width(); ink.text(0.0, 2.0, "LAYERS", 11.0, palette.muted); - if ui - .put( - Rect::from_min_size(ink.point(w - 85.0, -5.0), Vec2::new(85.0, 24.0)), - egui::Button::new("Manage…"), - ) - .clicked() + if toolbar_icon( + ui, + Rect::from_min_size(ink.point(w - 28.0, -5.0), Vec2::new(28.0, 24.0)), + "Manage layers and folders", + ToolbarIcon::ManageLayers, + ) + .clicked() { self.manage_layers(); } - if ui - .put( - Rect::from_min_size(ink.point(w - 195.0, -5.0), Vec2::new(105.0, 24.0)), - egui::Button::new("Add image…"), - ) - .clicked() + if toolbar_icon( + ui, + Rect::from_min_size(ink.point(w - 60.0, -5.0), Vec2::new(28.0, 24.0)), + "Add reference image", + ToolbarIcon::AddImage, + ) + .clicked() { self.import_reference_file(ui.ctx()); } - self.layer_tree_header(ui, &ink); + self.layer_tree_header(ui, &ink, w); let mut reorder = None; for (row_index, tree_row) in rows.into_iter().enumerate() { let y = 28.0 + row_index as f32 * 44.0; @@ -3717,6 +3719,9 @@ fn apply_button(ui: &mut egui::Ui, label: &str, pending: bool) -> egui::Response #[derive(Clone, Copy)] enum ToolbarIcon { + AddFolder, + AddImage, + ManageLayers, Select, Move, Pan, @@ -4008,6 +4013,45 @@ 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::AddFolder | ToolbarIcon::AddImage => { + if matches!(icon, ToolbarIcon::AddFolder) { + painter.add(egui::Shape::closed_line( + vec![ + point(-10.0, 7.0), + point(-10.0, -8.0), + point(-3.0, -8.0), + point(0.0, -5.0), + point(9.0, -5.0), + point(9.0, 7.0), + ], + stroke, + )); + } else { + painter.rect_stroke( + Rect::from_min_max(point(-10.0, -8.0), point(9.0, 7.0)), + 2.0, + stroke, + StrokeKind::Inside, + ); + painter.circle_filled(point(3.0, -3.0), 1.8, stroke.color); + painter.add(egui::Shape::line( + vec![point(-8.0, 4.0), point(-3.0, -1.0), point(2.0, 4.0)], + stroke, + )); + } + painter.circle_filled(point(7.0, 5.0), 5.5, palette.panel); + let accent = Stroke::new(1.6_f32, palette.cyan); + painter.line_segment([point(3.0, 5.0), point(11.0, 5.0)], accent); + painter.line_segment([point(7.0, 1.0), point(7.0, 9.0)], accent); + } + ToolbarIcon::ManageLayers => { + for (y, knob) in [(-6.0, -3.0), (0.0, 4.0), (6.0, -1.0)] { + painter.line_segment([point(-9.0, y), point(9.0, y)], stroke); + painter.circle_filled(point(knob, y), 2.5, palette.panel); + painter.circle_stroke(point(knob, y), 2.5, Stroke::new(1.6_f32, palette.cyan)); + } + } + ToolbarIcon::Select => { painter.add(egui::Shape::closed_line( vec![ @@ -4141,6 +4185,9 @@ fn toolbar_icon(ui: &mut egui::Ui, rect: Rect, label: &str, icon: ToolbarIcon) - } } response.on_hover_text(match icon { + ToolbarIcon::AddFolder => "Create a folder from the selected layers", + ToolbarIcon::AddImage => "Add reference image", + ToolbarIcon::ManageLayers => "Manage layers and folders", ToolbarIcon::Select => "Select (V) — select, move and resize layers; drag empty space to select. Grid and Pivot toggles still apply.", ToolbarIcon::Move => "Move (M) — drag anywhere to move the current selection without selecting, deselecting or resizing. In crop mode, moves content only.", ToolbarIcon::Pan => "Pan (H) — drag to move the view. Hold Space or middle-drag to pan temporarily from any tool.", diff --git a/crates/midra-layout/src/layers_ui.rs b/crates/midra-layout/src/layers_ui.rs index 1809215..8a6431d 100644 --- a/crates/midra-layout/src/layers_ui.rs +++ b/crates/midra-layout/src/layers_ui.rs @@ -421,16 +421,18 @@ impl Editor { rows } - pub(super) fn layer_tree_header(&mut self, ui: &mut egui::Ui, ink: &Ink) { + pub(super) fn layer_tree_header(&mut self, ui: &mut egui::Ui, ink: &Ink, width: f32) { let ids = self .layout .selected_indices() .iter() .map(|&i| self.layout.layer_info(i).id) .collect::>(); - let response = ui.put( - Rect::from_min_size(ink.point(65.0, -5.0), Vec2::new(100.0, 24.0)), - egui::Button::new("+ Folder…"), + let response = toolbar_icon( + ui, + Rect::from_min_size(ink.point(width - 92.0, -5.0), Vec2::new(28.0, 24.0)), + "Create folder", + ToolbarIcon::AddFolder, ); if response .on_hover_text("Create a folder from the selected layers.") diff --git a/docs/midra-layout/changelog.md b/docs/midra-layout/changelog.md index 4c8c625..f617554 100644 --- a/docs/midra-layout/changelog.md +++ b/docs/midra-layout/changelog.md @@ -4,6 +4,8 @@ ## Unreleased +- Replace the layer-header Folder, Add image and Manage text buttons with compact vector icons, grouped on the right, with tooltips and accessible action names. + ## v0.7.0 — 2026-11-14 - Split the Midra mdBook into Quick start and Advanced sections, with a first-layout walkthrough and nested workflow/contract chapters. Keep the existing detailed chapters and screenshot capture notes linked. diff --git a/docs/midra-layout/guide/editing.md b/docs/midra-layout/guide/editing.md index 19082df..b79d93c 100644 --- a/docs/midra-layout/guide/editing.md +++ b/docs/midra-layout/guide/editing.md @@ -10,7 +10,7 @@ unlocked layers. Shift-click adds/removes its contents from the selection. Double-click a folder or layer name to rename it. Folder eye and lock icons apply to every member; Undo restores each member's previous state, including mixed states. -Select layers and choose **+ Folder…** to group them. Drag a layer onto a folder +Select layers and choose the **Create folder** icon to group them. Drag a layer onto a folder name to move it inside, or onto **LAYERS** to return it to the root. Dropping on another layer also changes stacking order and adopts that layer's folder. Drag folder names above/below another folder to reorder all their layers as one @@ -20,7 +20,7 @@ menu also offers existing folders, the root, and a new folder. Folders are local, single-level groups stored with their layers. Empty folders are removed automatically; collapse state lasts for this session. The existing -**Manage…** window remains available for bulk name/folder editing. Grouping does +**Manage layers and folders** remains available for bulk name/folder editing. Grouping does not affect device links or source assignments. All document edits support Undo. ## Move and edit layers @@ -130,7 +130,7 @@ identifies every destination explicitly and applies the mapped selection togethe ## Layer management -Use **Layers → Manage layers & folders…** or **Manage…** above the inspector list. +Use **Layers → Manage layers & folders…** or the **Manage layers and folders** icon above the inspector list. Add layers, select one or more to remove, and edit names/folder labels. Names and folders commit on Enter or focus loss. 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, undoable flags.