From c0e9067b7fccecf42264caeb7ebe9981be621ae9 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 13:09:05 +0700 Subject: [PATCH] Control bar and Properties draw the align buttons with Lucide's align glyphs, as the reference app did Only the Align panel drew its own dc-al glyphs; the bar and the Properties panel's Align row used Lucide's align-start-vertical and its siblings (with the panel's Align Centers glyph). --- crates/ui-egui/src/panels.rs | 9 +++++---- crates/ui-egui/src/panels/align.rs | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 9e459971c7..9609d3ac45 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -245,9 +245,10 @@ pub(crate) fn corner_radius_field(app: &mut VectorcraftApp, ui: &mut Ui, n: &Nod }); } -/// The icon the command catalog gives command `id`: the Align panel's align, distribute and Align -/// To buttons' and the Pathfinder panel's, so a bar or menu row of the command shows the panel's -/// glyph, and each tool's, which the tool rail and its flyouts show. `None` for every other command. +/// The icon the command catalog gives command `id`: the Align panel's distribute and Align To +/// buttons' (its align buttons' as the Control bar draws them, [`align::bar_glyph`]) and the +/// Pathfinder panel's, so a bar or menu row of the command shows the panel's glyph, and each +/// tool's, which the tool rail and its flyouts show. `None` for every other command. pub(crate) fn command_icon(id: &str) -> Option<&'static str> { use align::{AlignTo, Button}; if let Some(tool) = id.strip_prefix("tool:") { @@ -265,7 +266,7 @@ pub(crate) fn command_icon(id: &str) -> Option<&'static str> { } let in_table = |table: &[(&'static str, &str, &str, &str)], axis: &str, v: &str| table.iter().find(|r| r.2 == axis && r.3 == v).map(|r| r.0); match align::button(id)? { - Button::Align(axis, v) => in_table(&align::ALIGN, axis, v), + b @ Button::Align(..) => align::bar_glyph(b), Button::AlignCenters => Some("dc-al-center"), Button::Distribute(axis, v) => in_table(&align::DISTRIBUTE, axis, v), Button::Spacing("vertical") => Some("dc-dist-vspace"), diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index e243fc8f06..da6b9db182 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -99,6 +99,24 @@ pub const ALIGN: [(&str, &str, &str, &str); 6] = [ ("dc-al-bottom", "Vertical Align Bottom", "vertical", "bottom"), ]; +/// The glyphs of [`ALIGN`]'s buttons, in its order, in the Control bar and the Properties panel: the reference app drew +/// them there with Lucide's align glyphs, and only the Align panel with its own. +const BAR_ALIGN: [&str; 6] = [ + "align-start-vertical", + "align-center-vertical", + "align-end-vertical", + "align-start-horizontal", + "align-center-horizontal", + "align-end-horizontal", +]; + +/// The glyph of align button `b` in the Control bar and the Properties panel ([`BAR_ALIGN`]); `None` for the other +/// buttons, which draw the panel's glyph there too. +pub(crate) fn bar_glyph(b: Button) -> Option<&'static str> { + let Button::Align(axis, v) = b else { return None }; + ALIGN.iter().position(|r| r.2 == axis && r.3 == v).map(|i| BAR_ALIGN[i]) +} + pub const DISTRIBUTE: [(&str, &str, &str, &str); 6] = [ ("dc-dist-top", "Vertical Distribute Top", "vertical", "top"), ("dc-dist-vcenter", "Vertical Distribute Center", "vertical", "center"), @@ -288,7 +306,7 @@ fn bar_items(buttons: impl Iterator) -> BarItems { pub(crate) fn align_buttons(_app: &mut VectorcraftApp, ui: &mut Ui) { ui.horizontal(|ui| { for (icon, b) in align_icons() { - command_button(ui, icon, b); + command_button(ui, bar_glyph(b).unwrap_or(icon), b); } }); }