From 031cdb1db04948cc6def1d0240001d7840be3425 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 17:59:10 -0800 Subject: [PATCH] Appearance: Fill and Stroke swatches no longer touch between rows Each Fill and Stroke row drew its swatch at the control height, the same height as the row, so the swatches of neighboring rows touched. The swatch is now a small control, so it sits inside its row with room above and below. --- crates/ui-egui/src/panels/appearance.rs | 6 ++++-- crates/ui-egui/src/panels/tests_panel_rows.rs | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/appearance.rs b/crates/ui-egui/src/panels/appearance.rs index 3d95d2c28d..ad1c544b5a 100644 --- a/crates/ui-egui/src/panels/appearance.rs +++ b/crates/ui-egui/src/panels/appearance.rs @@ -22,7 +22,7 @@ use std::sync::{Arc, OnceLock}; use craft::behavior::overlay::{Align, Side}; use craft::behavior::{ColumnKey, ColumnWidth, CopyKeys, DisplayOrder, EditEvent, IconId, ItemSource, Selection}; -use craft::theme::Srgba; +use craft::theme::{ControlSize, Srgba}; use craft::ui::buttons::{Button, ButtonOutput}; use craft::ui::choice::{Swatch, SwatchOutput}; use craft::ui::contract::overlay::{Anchor, Place}; @@ -876,7 +876,8 @@ fn item_row<'r>(cx: &'r RowCx<'_>, key: RowKey, i: usize) -> ListRow<'r> { } /// The well of a fill (`fill`) or stroke row, named for it: `paint` as its face, its colour (a solid paint's) as its -/// value. +/// value. The well is a small control, so it stands inside its control-high row and the wells of neighboring rows do +/// not touch. fn paint_swatch(fill: bool, paint: &Paint) -> Swatch { let color = paint.color().map_or(Srgba::BLACK, |c| { let [r, g, b] = c.to_rgb(); @@ -885,6 +886,7 @@ fn paint_swatch(fill: bool, paint: &Paint) -> Swatch { let row = if fill { tl!("Fill") } else { tl!("Stroke") }; Swatch::new(crate::i18n::fmt(tl!("{row} swatch"), &[("row", row)]), color) .face(paint_preview::rect_face(paint)) + .size(ControlSize::Sm) .tooltip(tl!("Click to choose a swatch, Shift-click to mix a colour")) } diff --git a/crates/ui-egui/src/panels/tests_panel_rows.rs b/crates/ui-egui/src/panels/tests_panel_rows.rs index 15554da438..cc2174e2ee 100644 --- a/crates/ui-egui/src/panels/tests_panel_rows.rs +++ b/crates/ui-egui/src/panels/tests_panel_rows.rs @@ -117,6 +117,14 @@ fn the_appearance_swatches_and_labels_line_up() { } } +#[test] +fn the_appearance_swatches_of_neighboring_rows_do_not_touch() { + let panel = Panel::new(app_with_rect(), appearance::show); + let (stroke, fill) = (panel.rect("Stroke swatch"), panel.rect("Fill swatch")); + let gap = (fill.top() - stroke.bottom()).max(stroke.top() - fill.bottom()); + assert!(gap >= 1.0, "the stroke swatch at {stroke:?} and the fill swatch at {fill:?} touch or overlap (gap {gap})"); +} + #[test] fn the_fill_swatch_lines_up_with_a_dashed_stroke_that_has_a_profile() { let mut panel = Panel::new(app_with_rect(), appearance::show);