Merge pull request #10026 from dotCooCoo/fix/appearance-well-spacing

Appearance: Fill and Stroke swatches no longer touch between rows
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 19:23:03 -08:00
commit 48a00802ab
2 files changed
+12 -2

No files matched your search

+4 -2
View File
@@ -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"))
}
@@ -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);