From 6ac3f3a6c48e2ac8a2d7af2eb0cebe578c005242 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:25:12 -0800 Subject: [PATCH] Layers: a horizontal and a vertical ruler guide's rows show a glyph of their own, a line across or down from a ruler, as production's rows drew a line across or down --- ASSETS.md | 2 ++ assets/icons/dc-guide-horizontal.svg | 1 + assets/icons/dc-guide-vertical.svg | 1 + crates/ui-egui/src/icon_data.rs | 2 ++ crates/ui-egui/src/panels/layers/model.rs | 9 ++++++++- crates/ui-egui/src/panels/layers/tests.rs | 24 +++++++++++++++++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 assets/icons/dc-guide-horizontal.svg create mode 100644 assets/icons/dc-guide-vertical.svg diff --git a/ASSETS.md b/ASSETS.md index a21d7a9692..95d1048c61 100644 --- a/ASSETS.md +++ b/ASSETS.md @@ -207,6 +207,8 @@ Generated-in-code art is original and has no file to list. This covers the defau | `assets/icons/dc-graphic-styles.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-grid-view.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-group-select.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | +| `assets/icons/dc-guide-horizontal.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a ruler down the left with a line across) | MIT OR Apache-2.0 | | +| `assets/icons/dc-guide-vertical.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a ruler along the top with a line down) | MIT OR Apache-2.0 | | | `assets/icons/dc-help.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a question mark in a circle) | MIT OR Apache-2.0 | | | `assets/icons/dc-join-bevel.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-join-miter.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | diff --git a/assets/icons/dc-guide-horizontal.svg b/assets/icons/dc-guide-horizontal.svg new file mode 100644 index 0000000000..941eba1f1d --- /dev/null +++ b/assets/icons/dc-guide-horizontal.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/dc-guide-vertical.svg b/assets/icons/dc-guide-vertical.svg new file mode 100644 index 0000000000..3383fd4c22 --- /dev/null +++ b/assets/icons/dc-guide-vertical.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/src/icon_data.rs b/crates/ui-egui/src/icon_data.rs index 8c8962dd50..8d9929e481 100644 --- a/crates/ui-egui/src/icon_data.rs +++ b/crates/ui-egui/src/icon_data.rs @@ -119,6 +119,8 @@ pub static ICONS: &[(&str, &[u8])] = &[ ("dc-graphic-styles", include_bytes!("../../../assets/icons/dc-graphic-styles.svg")), ("dc-grid-view", include_bytes!("../../../assets/icons/dc-grid-view.svg")), ("dc-group-select", include_bytes!("../../../assets/icons/dc-group-select.svg")), + ("dc-guide-horizontal", include_bytes!("../../../assets/icons/dc-guide-horizontal.svg")), + ("dc-guide-vertical", include_bytes!("../../../assets/icons/dc-guide-vertical.svg")), ("dc-help", include_bytes!("../../../assets/icons/dc-help.svg")), ("dc-join", include_bytes!("../../../assets/icons/dc-join.svg")), ("dc-join-bevel", include_bytes!("../../../assets/icons/dc-join-bevel.svg")), diff --git a/crates/ui-egui/src/panels/layers/model.rs b/crates/ui-egui/src/panels/layers/model.rs index 46d24e0806..7ec3597938 100644 --- a/crates/ui-egui/src/panels/layers/model.rs +++ b/crates/ui-egui/src/panels/layers/model.rs @@ -4,6 +4,7 @@ use std::collections::{HashMap, HashSet}; use std::hash::{Hash as _, Hasher as _}; use std::ops::Deref; +use craft::behavior::IconId; use craft::keymap::Mods; pub(super) use craft::layers::ui::filter::{FilterObject, FilterState}; use craft::layers::ui::filter::{LayerFilter, SmartSource}; @@ -36,6 +37,12 @@ pub(crate) fn shown_name(app: &VectorcraftApp, n: &Node, lang: crate::i18n::Lang listed_name(n, by_xml_id(app), lang) } +/// The glyph of a horizontal ruler guide's row: a line across from a ruler. +const HORIZONTAL_GUIDE_ICON: &str = "dc-guide-horizontal"; + +/// The glyph of a vertical ruler guide's row: a line down from a ruler. +const VERTICAL_GUIDE_ICON: &str = "dc-guide-vertical"; + /// Whether Identify Objects By is XML ID. fn by_xml_id(app: &VectorcraftApp) -> bool { app.session.prefs.identify_objects_by == "xmlId" @@ -411,7 +418,7 @@ impl LayerRows { info.dimmed = !self.shown(layer) || !info.visible; info.color = Some(self.color(layer)); } - // PLAN: dp.L12's horizontal and vertical guide marks need app icons the icon set lacks; the row keeps the kind's ruler glyph. + info.icon = Some(IconId::new(if vertical { VERTICAL_GUIDE_ICON } else { HORIZONTAL_GUIDE_ICON })); info.renamable = false; info.thumbnail = false; info diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 2ac1b0af3f..1cd5128585 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -343,6 +343,30 @@ fn rows_list_by_depth_and_ruler_guide_nodes_get_no_object_row() { assert_eq!(ids, [second, first, rect]); } +/// A horizontal and a vertical ruler guide's rows each show a glyph of their own, in place of the +/// guide kind's ruler, and both glyphs are in the app's icon set. +#[test] +fn horizontal_and_vertical_guide_rows_show_their_own_drawn_glyphs() { + use craft::ui::primitives::{has_icon, register_app_icons}; + + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + app.session.execute("guide.add", &json!({"vertical": false, "pos": 40})).unwrap(); + app.session.execute("guide.add", &json!({"vertical": true, "pos": 60})).unwrap(); + let st = app.session.active().unwrap(); + let rows = LayerRows::new(&app, st); + let icon_of = |vertical: bool| { + let i = st.doc.ruler_guides().iter().position(|g| g.vertical == vertical).unwrap(); + rows.info(&RowId::Guide(i)).icon.unwrap_or_else(|| panic!("the vertical: {vertical} guide row has no glyph of its own")) + }; + let (across, down) = (icon_of(false), icon_of(true)); + assert_ne!(across, down, "the two kinds of guide rows look alike"); + register_app_icons(&crate::icons::APP_ICONS); + for icon in [&across, &down] { + assert!(has_icon(icon), "{icon:?} is in no icon set, so the row draws nothing"); + } +} + /// The undo steps of the active document. pub(super) fn undo_len(app: &VectorcraftApp) -> usize { app.session.active().unwrap().history.undo.len()