diff --git a/ASSETS.md b/ASSETS.md
index 76a3d41962..5a08e4cec1 100644
--- a/ASSETS.md
+++ b/ASSETS.md
@@ -213,6 +213,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/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs
index a76527943f..edc9953497 100644
--- a/crates/ui-egui/src/dialogs/revolve.rs
+++ b/crates/ui-egui/src/dialogs/revolve.rs
@@ -727,7 +727,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();
@@ -773,7 +773,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 {
diff --git a/crates/ui-egui/src/icon_data.rs b/crates/ui-egui/src/icon_data.rs
index 16ce0cbc75..05054a53e6 100644
--- a/crates/ui-egui/src/icon_data.rs
+++ b/crates/ui-egui/src/icon_data.rs
@@ -121,6 +121,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 619fcd6559..57345e5040 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"
@@ -423,7 +430,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 172bf59860..8a210b6aa5 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()
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]