From a1886f6957a5735471034add3a7470442fa82f88 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 19:32:35 -0800 Subject: [PATCH 1/3] 3D: the light list is a framework Stack, and the light sphere measures as tall as it shows The light sphere's height follows its width, but it measured with the width of a band picture, which is its least width when a column measures it with no room. In a Stack the measuring run then found the light list shorter than it showed (by 64 pt in the 3D panel test), and "Light behind the object", the last row, lay outside the Stack and took no clicks. The sphere now measures with MeasureCx::picture_size, so the column measures it again at the width it shows at. The light list moves from ui.vertical into form::stacked: each run edits a copy of the values, and the copy from the run that is not a measuring run replaces them. --- crates/ui-egui/src/dialogs/revolve.rs | 3 +-- crates/ui-egui/src/dialogs/revolve_lights.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index a61190970e..a20c8c720b 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -721,7 +721,7 @@ pub(crate) fn light_editor(_data: &Data, place: Place, classic: bool) -> Param { fields.remove("__lightPick"); set_light_value(fields, "lightColor", json!(hex)); } - ui.vertical(|ui| { + super::form::stacked(ui, fields, |ui, fields| { let mut list = explicit_lights(fields).unwrap_or_else(|| vec![light_record(fields)]); let mut index = light_index(fields, list.len()); let titles: Vec = (1..=list.len()).map(|i| format!("{} {i}", c3("Light"))).collect(); @@ -767,7 +767,6 @@ pub(crate) fn light_editor(_data: &Data, place: Place, classic: bool) -> Param { store_selected(fields, &selected); } }) - .response }) .companions(LIGHT_KEYS.iter().map(|(_, k)| *k).chain(["__light", "__lightPick"])) .on_set(set_light_field) diff --git a/crates/ui-egui/src/dialogs/revolve_lights.rs b/crates/ui-egui/src/dialogs/revolve_lights.rs index 992ccf44ae..342f032808 100644 --- a/crates/ui-egui/src/dialogs/revolve_lights.rs +++ b/crates/ui-egui/src/dialogs/revolve_lights.rs @@ -272,8 +272,8 @@ impl Component for LightSphere<'_> { /// The row's width and the height of the sphere that fits it, with its suns. fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { - let width = cx.picture_width((24.0 + SUN + 8.0) * 2.0, f32::INFINITY); - Vec2::new(width, (radius_in(width) + SUN + 6.0) * 2.0) + // The height follows the width: a column that measures the sphere with no room measures it again at its width. + cx.picture_size((24.0 + SUN + 8.0) * 2.0, f32::INFINITY, |width| (radius_in(width) + SUN + 6.0) * 2.0) } fn sense(&self) -> Sense { From 1693a4f71bfbb08ea0a95e5975d704df9c23d73f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:14:03 -0800 Subject: [PATCH 2/3] Transparency: the mask row renders its thumbnails at the size.thumb.lg token in place of a fixed 48 pt The object and mask thumbnails sit in a large thumbnail row, whose cells take their side from size.thumb.lg, but the pictures were requested at a fixed 48 points. Every built-in size set gives 48 today, so the two only part when the app's sizes change size.thumb.lg; the pictures were then rendered smaller or larger than the cells that show them. The request now reads the token, and a test checks that the picture covers its cell at both densities and with the token changed. --- crates/ui-egui/src/panels/transparency.rs | 53 ++++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/panels/transparency.rs b/crates/ui-egui/src/panels/transparency.rs index 1fafa33563..3f6e38014b 100644 --- a/crates/ui-egui/src/panels/transparency.rs +++ b/crates/ui-egui/src/panels/transparency.rs @@ -24,7 +24,7 @@ use craft::ui::primitives::{ }; use craft::ui::primitives::{Revision, ThumbPaint}; use craft::ui::runtime::commands::{CommandRef, CommandState, CommandStates}; -use craft::ui::runtime::env::UnitKind; +use craft::ui::runtime::env::{Env, UnitKind}; use craft::ui::style::DataColor; use craft::ui::text::NumberField; use egui::{Color32, Ui}; @@ -37,10 +37,6 @@ use crate::VectorcraftApp; use crate::edits::{EditPath, apply_edits}; use crate::fields::blend_entries; -/// The side of the mask row's thumbnails, in points. -// PLAN: should come from the `size.thumb.lg` token; the row's `ThumbSize::Large` gives the rect, this only sizes the render. -const THUMB_POINTS: f32 = 48.0; - /// The command ids of the menu's own rows. const THUMBNAILS: &str = "ui.transparency.thumbnails"; const OPTIONS: &str = "ui.transparency.options"; @@ -156,6 +152,12 @@ fn mask_click(m: &OpacityMask, id: NodeId, mods: craft::keymap::Mods, editing: b } } +/// The render request of the mask row's thumbnails: the side `ThumbSize::Large` gives the row's cells +/// (`size.thumb.lg`), in pixels of the screen `ui` shows on. +fn mask_thumb_request(ui: &Ui) -> ThumbRequest { + ThumbRequest::for_cell(Env::of(ui).tokens.size.thumb.lg, ui.ctx().pixels_per_point()) +} + /// The one-row list of the object's and the mask's thumbnails with the mask's link; the events it reported. fn mask_row( app: &VectorcraftApp, @@ -168,7 +170,7 @@ fn mask_row( let Some(st) = app.session.active() else { return vec![] }; let source = MaskThumbs { doc: &st.doc, revision: st.revision }; let store = Thumbnails::::in_context(ui.ctx(), "vc-mask-thumbs", ThumbnailOptions::new()); - let request = ThumbRequest::for_cell(THUMB_POINTS, ui.ctx().pixels_per_point()); + let request = mask_thumb_request(ui); let state_of = |ui: &Ui, node: NodeId, bg, own_mask| { store.state(ui.ctx(), &source, &MaskKey { uid: st.uid, node, bg, own_mask }, &request, Priority::VISIBLE) }; @@ -572,6 +574,45 @@ mod tests { assert_eq!(page(&app), [true, true]); } + /// The mask row's pictures are rendered at the size of the cells a large thumbnail row draws them in, at + /// either density and when the app's sizes change `size.thumb.lg`: at least as many pixels as the cell + /// covers, and less than one request step (16 pixels) more. + #[test] + fn mask_thumbnails_render_at_the_size_of_their_cells() { + use craft::theme::{AppSizes, Size}; + use craft::ui::runtime::env::RootEnv; + use craft::ui::testing::Fixture; + use std::cell::Cell; + use std::rc::Rc; + let ppp = 2.0; + let changed = AppSizes::parse(br#"{"all": {"size.thumb.lg": 72}}"#).expect("a size override"); + for density in [Size::Compact, Size::Comfortable] { + for sizes in [crate::theme::app_sizes(), Arc::new(changed.clone())] { + let (cell, side) = (Rc::new(Cell::new(None)), Rc::new(Cell::new(None))); + let (cell_seen, side_seen) = (Rc::clone(&cell), Rc::clone(&side)); + let mut fixture = Fixture::new(move |ui| { + side_seen.set(Some(mask_thumb_request(ui).side)); + let cell_seen = Rc::clone(&cell_seen); + let keys = [()]; + List::<()>::new("Thumbnails").select(SelectMode::None).natural_height(true).show_items(ui, &keyed(&keys, |_| ()), &mut |_, _| { + let cell_seen = Rc::clone(&cell_seen); + ListRow::new("Row").thumbnails_only().thumb(ThumbSize::Large, move |_: &ContentPainterCx, rect: egui::Rect| { + cell_seen.set(Some(rect)); + }) + }); + }); + let mut root = RootEnv::new().density(density); + root.sizes = sizes; + fixture.root(root).pixels_per_point(ppp); + fixture.frame(vec![]); + fixture.frame(vec![]); + let cell = cell.get().expect("the row draws its thumbnail"); + let (side, covered) = (side.get().expect("the request") as f32, cell.width().max(cell.height()) * ppp); + assert!(side >= covered && side < covered + 16.0, "{density:?}: a {side} px picture for a {covered} px cell"); + } + } + } + /// The panel's state holds the target as the document holds it, a new one after an edit and /// after Undo; the object thumbnail of a masked object draws as the object without its mask. #[test] From 6ac3f3a6c48e2ac8a2d7af2eb0cebe578c005242 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:25:12 -0800 Subject: [PATCH 3/3] 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()