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);