mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
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.
This commit is contained in:
1 parent
ac031311a2
commit
031cdb1db0
2 files changed
+12
-2
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user