mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 19:51:26 -05:00
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).
This commit is contained in:
@@ -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"),
|
||||
|
||||
@@ -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<Item = Button>) -> 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user