theme, ui-contract: overlay.cursor colors a painted pointer's marks and a tool's icon; VectorCraft's themes pin it white

overlay.cursor follows overlay.stroke unless a theme pins it, so pointers in other themes keep the color they had. VectorCraft Modern and Modern Medium pin it to #ffffff in both variants, so their tool pointers no longer show in the #ffa492 overlay tint, and their hand, magnifier, rotate and badge marks match the icons. The shared pointer art no longer borrows overlay.handle_fill for tool icons.

overlay.cursor joins overlay.stroke in the halo contrast rule, so a pin that misses the minimum is reported, and a user's accent keeps a theme's pinned cursor color. Trials; dumps gain the token.
This commit is contained in:
dotCooCoo committed 2026-11-25 20:32:11 -08:00
1 parent fea3af7ca8
commit a830ff539b
95 files changed
+193 -37

No files matched your search

+24
View File
@@ -228,3 +228,27 @@ fn the_grip_ink_lies_a_little_apart_from_the_panel_and_a_theme_can_pin_it() {
let r = resolve(&pinned, standard(Mode::Dark), None);
assert_eq!(r.tokens.color.line.grip, hex("#5a6b7c"), "a theme's pinned line.grip is used");
}
/// A painted pointer's colour is `overlay.stroke` in a theme that does not pin `overlay.cursor`, in every appearance;
/// a theme that pins it gets its pin with `overlay.stroke` unchanged, and a pin that misses the halo minimum is
/// reported.
#[test]
fn the_cursor_colour_follows_the_overlay_stroke_and_a_theme_can_pin_it() {
for def in [grey_blue(), violet()] {
for a in appearances() {
let c = &resolve(&def, a, None).tokens.color;
assert_eq!(c.overlay.cursor, c.overlay.stroke, "{} {a:?}: overlay.cursor follows overlay.stroke", def.name);
}
}
let reported = |r: &Resolved| r.warnings.iter().any(|w| w.fg == T::OverlayCursor && w.bg == T::OverlayHalo);
let unpinned = resolve(&grey_blue(), app(Mode::Dark, Contrast::Standard), None).tokens.color.overlay.stroke;
let mut pinned = grey_blue();
pinned.pins.dark = Pins::from_iter([(T::OverlayCursor, Rgba::WHITE)]);
let r = resolve(&pinned, app(Mode::Dark, Contrast::Standard), None);
assert_eq!(r.tokens.color.overlay.cursor, Rgba::WHITE, "a theme's pinned overlay.cursor is used");
assert_eq!(r.tokens.color.overlay.stroke, unpinned, "the pin leaves overlay.stroke as it was");
assert!(!reported(&r), "white reads on the halo: {:?}", r.warnings);
pinned.pins.dark = Pins::from_iter([(T::OverlayCursor, hex("#404040"))]);
let r = resolve(&pinned, app(Mode::Dark, Contrast::Standard), None);
assert!(reported(&r), "a dark grey on the dark halo is reported: {:?}", r.warnings);
}
+16
View File
@@ -53,3 +53,19 @@ fn an_accent_over_a_theme_takes_its_fill_and_fails_no_pair_the_theme_passes() {
}
}
}
/// A user's accent leaves a theme's pinned pointer colour as it is, and an unpinned one follows `overlay.stroke` to the
/// new accent.
#[test]
fn an_accent_over_a_theme_keeps_its_pinned_cursor_colour() {
let appearance =
Appearance { mode: Mode::Dark, contrast: Contrast::Standard, size: Size::default(), text_size: TextSize::default(), reduced_motion: false };
let seed = Rgba::rgb(0x12, 0x80, 0x30);
let vectorcraft = builtins().iter().find(|t| t.id.as_str() == "craft.vectorcraft-modern").unwrap();
let pinned = resolve(&vectorcraft.with_accent(seed), appearance, None).tokens;
assert_eq!(pinned.color(ColorToken::OverlayCursor), Rgba::WHITE, "the theme's pin stays");
let pro = builtins().iter().find(|t| t.id.as_str() == "craft.pro").unwrap();
let (before, after) = (resolve(pro, appearance, None).tokens, resolve(&pro.with_accent(seed), appearance, None).tokens);
assert_eq!(after.color(ColorToken::OverlayCursor), after.color(ColorToken::OverlayStroke), "an unpinned cursor follows the stroke");
assert_ne!(after.color(ColorToken::OverlayCursor), before.color(ColorToken::OverlayCursor), "and with it the new accent");
}
+4 -2
View File
@@ -71,7 +71,8 @@ impl ThemeDef {
/// colours (the tokens the accent ramp gives, and the ones derived from them) and the text of every contrast pair
/// drawn on an accent colour drop their pins and references in every layer, the high-contrast and per-app ones
/// included, so they derive from the seed and the contrast pass fits them as it fits an unpinned theme. A token
/// the theme refers to an accent colour keeps its reference, and so follows the seed.
/// the theme refers to an accent colour keeps its reference, and so follows the seed. A pinned `overlay.cursor`
/// keeps its pin, although its default follows the accent through `overlay.stroke`.
#[must_use]
pub fn with_accent(&self, seed: Rgba) -> ThemeDef {
let mut theme = self.clone();
@@ -97,7 +98,8 @@ impl ThemeDef {
/// and the text of each contrast pair drawn on an accent colour, counting the tokens a layer refers to one.
fn accent_derived(&self, mode: Mode) -> BTreeSet<ColorToken> {
use crate::values::{Bg, RULES, follows_accent};
let own: BTreeSet<ColorToken> = ColorToken::ALL.iter().copied().filter(|&token| follows_accent(token, mode)).collect();
let own: BTreeSet<ColorToken> =
ColorToken::ALL.iter().copied().filter(|&token| token != ColorToken::OverlayCursor && follows_accent(token, mode)).collect();
let layers = [&self.pins, &self.high_contrast].into_iter().chain(self.apps.values().flat_map(|app| [&app.pins, &app.high_contrast]));
let refs: Vec<(ColorToken, ColorToken)> = layers.flat_map(|layer| layer.get(mode).refs.iter().map(|(&token, &to)| (token, to))).collect();
let mut shown = own.clone();
+7 -1
View File
@@ -212,8 +212,11 @@ pub struct StateColors {
/// Canvas overlays: selection paths, handles, guides.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct OverlayColors {
/// Marks drawn over `halo` (the rotate cursor); handle outlines follow it.
/// Marks drawn over `halo`; handle outlines follow it.
pub stroke: Rgba,
/// A painted pointer's marks over `halo`, a tool's icon included (the circle and crosshair keep their own ink);
/// follows `stroke` unless pinned.
pub cursor: Rgba,
/// Bare lines on the canvas: a transform box, path outlines, a pen draft, warp boundaries.
/// The accent itself, with no halo and no contrast pair, as guides are.
pub line: Rgba,
@@ -363,6 +366,7 @@ impl ColorTokens {
},
overlay: OverlayColors {
stroke: c,
cursor: c,
line: c,
halo: c,
handle_fill: c,
@@ -583,6 +587,8 @@ color_tokens! {
StateStripe = "state.stripe" => state.stripe;
/// `overlay.stroke`
OverlayStroke = "overlay.stroke" => overlay.stroke;
/// `overlay.cursor`
OverlayCursor = "overlay.cursor" => overlay.cursor;
/// `overlay.line`
OverlayLine = "overlay.line" => overlay.line;
/// `overlay.halo`
+2 -1
View File
@@ -300,6 +300,7 @@ pub(super) fn source(token: ColorToken, mode: Mode) -> ColorSource {
T::StateMatchCurrent => Faded(T::StatusWarnSolid, 0x6e),
T::StateStripe => Faded(T::StateHover, 0x40),
T::OverlayStroke => Accent(9),
T::OverlayCursor => Same(T::OverlayStroke),
T::OverlayLine => Same(T::AccentSolid),
T::OverlayHalo => Fixed(Rgba::BLACK.with_alpha(alpha(0.6))),
T::OverlayHandleFill => Fixed(Rgba::WHITE),
@@ -457,7 +458,7 @@ pub(super) const RULES: &[PairRule] = &[
TEXT_MIN.1,
)
},
rule(&[T::OverlayStroke], HALO_BGS, NON_TEXT_MIN.0, NON_TEXT_MIN.1),
rule(&[T::OverlayStroke, T::OverlayCursor], HALO_BGS, NON_TEXT_MIN.0, NON_TEXT_MIN.1),
// A selected anchor is a handle filled with its outline colour: the outline on the fill is the
// only mark of the selection. Standard keeps the accent PhotoCraft outlines its handles in.
rule(&[T::OverlayHandleStroke], &[Token(T::OverlayHandleFill)], STATE_CUE_MIN.0, STATE_CUE_MIN.1),
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #48484c40
overlay.stroke = #d2e6ffff
overlay.cursor = #d2e6ffff
overlay.line = #6eaeffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #48484c40
overlay.stroke = #d2e6ffff
overlay.cursor = #d2e6ffff
overlay.line = #6eaeffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #48484c40
overlay.stroke = #8dbfffff
overlay.cursor = #8dbfffff
overlay.line = #3584e4ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #48484c40
overlay.stroke = #8dbfffff
overlay.cursor = #8dbfffff
overlay.line = #3584e4ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #766c005a
state.match_current = #f8e45c6e
state.stripe = #e2e2e540
overlay.stroke = #d2e6ffff
overlay.cursor = #d2e6ffff
overlay.line = #0058adff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #766c005a
state.match_current = #f8e45c6e
state.stripe = #e2e2e540
overlay.stroke = #d2e6ffff
overlay.cursor = #d2e6ffff
overlay.line = #0058adff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #e2e2e540
overlay.stroke = #8dbfffff
overlay.cursor = #8dbfffff
overlay.line = #3584e4ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f8e45c6e
state.stripe = #e2e2e540
overlay.stroke = #8dbfffff
overlay.cursor = #8dbfffff
overlay.line = #3584e4ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #59595940
overlay.stroke = #d3e6ffff
overlay.cursor = #d3e6ffff
overlay.line = #bbdaffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #59595940
overlay.stroke = #d3e6ffff
overlay.cursor = #d3e6ffff
overlay.line = #bbdaffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #62626240
overlay.stroke = #8fbeffff
overlay.cursor = #8fbeffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #62626240
overlay.stroke = #8fbeffff
overlay.cursor = #8fbeffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #d3e6ffff
overlay.cursor = #d3e6ffff
overlay.line = #0058abff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #d3e6ffff
overlay.cursor = #d3e6ffff
overlay.line = #0058abff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #8fbeffff
overlay.cursor = #8fbeffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #8fbeffff
overlay.cursor = #8fbeffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #32363b40
overlay.stroke = #c6e9ffff
overlay.cursor = #c6e9ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #32363b40
overlay.stroke = #c6e9ffff
overlay.cursor = #c6e9ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #32363b40
overlay.stroke = #61c6ffff
overlay.cursor = #61c6ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #32363b40
overlay.stroke = #61c6ffff
overlay.cursor = #61c6ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8075005a
state.match_current = #f478066e
state.stripe = #e2e6eb40
overlay.stroke = #c6e9ffff
overlay.cursor = #c6e9ffff
overlay.line = #005f89ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8075005a
state.match_current = #f478066e
state.stripe = #e2e6eb40
overlay.stroke = #c6e9ffff
overlay.cursor = #c6e9ffff
overlay.line = #005f89ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #e2e6eb40
overlay.stroke = #61c6ffff
overlay.cursor = #61c6ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f478066e
state.stripe = #e2e6eb40
overlay.stroke = #61c6ffff
overlay.cursor = #61c6ffff
overlay.line = #3aace8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #7154006e
state.stripe = #e2ded640
overlay.stroke = #d7e5ffff
overlay.cursor = #d7e5ffff
overlay.line = #0a246aff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #7154006e
state.stripe = #e2ded640
overlay.stroke = #d7e5ffff
overlay.cursor = #d7e5ffff
overlay.line = #0a246aff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #8060006e
state.stripe = #e2ded640
overlay.stroke = #ffffffff
overlay.cursor = #ffffffff
overlay.line = #0a246aff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #8060006e
state.stripe = #e2ded640
overlay.stroke = #ffffffff
overlay.cursor = #ffffffff
overlay.line = #0a246aff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #30303440
overlay.stroke = #d5e5ffff
overlay.cursor = #d5e5ffff
overlay.line = #5394feff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #30303440
overlay.stroke = #d5e5ffff
overlay.cursor = #d5e5ffff
overlay.line = #5394feff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #30303440
overlay.stroke = #94bdffff
overlay.cursor = #94bdffff
overlay.line = #4b8bf5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #30303440
overlay.stroke = #94bdffff
overlay.cursor = #94bdffff
overlay.line = #4b8bf5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #ffc14d6e
state.stripe = #f7f7f740
overlay.stroke = #d5e5ffff
overlay.cursor = #d5e5ffff
overlay.line = #014fcbff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #ffc14d6e
state.stripe = #f7f7f740
overlay.stroke = #d5e5ffff
overlay.cursor = #d5e5ffff
overlay.line = #014fcbff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #f7f7f740
overlay.stroke = #94bdffff
overlay.cursor = #94bdffff
overlay.line = #1b63e0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #ffc14d6e
state.stripe = #f7f7f740
overlay.stroke = #94bdffff
overlay.cursor = #94bdffff
overlay.line = #1b63e0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #42424240
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #60a9ffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #42424240
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #60a9ffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #42424240
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #42424240
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #42424240
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #685e005a
state.match_current = #e8b0466e
state.stripe = #c6c6c640
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #00498fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #685e005a
state.match_current = #e8b0466e
state.stripe = #c6c6c640
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #00498fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #c6c6c640
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #c6c6c640
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #0058abff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #d1e6ffff
overlay.cursor = #d1e6ffff
overlay.line = #0058abff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #e8b0466e
state.stripe = #e2e2e240
overlay.stroke = #8abfffff
overlay.cursor = #8abfffff
overlay.line = #378ef0ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0c8826e
state.stripe = #44445040
overlay.stroke = #dce3ffff
overlay.cursor = #dce3ffff
overlay.line = #97a8f7ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0c8826e
state.stripe = #44445040
overlay.stroke = #dce3ffff
overlay.cursor = #dce3ffff
overlay.line = #97a8f7ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0c8826e
state.stripe = #44445040
overlay.stroke = #a9b8ffff
overlay.cursor = #a9b8ffff
overlay.line = #8a9ae8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0c8826e
state.stripe = #44445040
overlay.stroke = #a9b8ffff
overlay.cursor = #a9b8ffff
overlay.line = #8a9ae8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8074005a
state.match_current = #8b47006e
state.stripe = #e4e2ea40
overlay.stroke = #dce3ffff
overlay.cursor = #dce3ffff
overlay.line = #4551a5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8074005a
state.match_current = #8b47006e
state.stripe = #e4e2ea40
overlay.stroke = #dce3ffff
overlay.cursor = #dce3ffff
overlay.line = #4551a5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #8c48006e
state.stripe = #e4e2ea40
overlay.stroke = #a7b9ffff
overlay.cursor = #a7b9ffff
overlay.line = #6e80d8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #8c48006e
state.stripe = #e4e2ea40
overlay.stroke = #a7b9ffff
overlay.cursor = #a7b9ffff
overlay.line = #6e80d8ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #bb8f116e
state.stripe = #0e4a5a40
overlay.stroke = #cde7ffff
overlay.cursor = #cde7ffff
overlay.line = #4dacf5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #bb8f116e
state.stripe = #0e4a5a40
overlay.stroke = #cde7ffff
overlay.cursor = #cde7ffff
overlay.line = #4dacf5ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #b589006e
state.stripe = #0e4a5a40
overlay.stroke = #79c2ffff
overlay.cursor = #79c2ffff
overlay.line = #268bd2ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #b589006e
state.stripe = #0e4a5a40
overlay.stroke = #79c2ffff
overlay.cursor = #79c2ffff
overlay.line = #268bd2ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #2c2c3040
overlay.stroke = #e2e2ffff
overlay.cursor = #e2e2ffff
overlay.line = #9385ffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #2c2c3040
overlay.stroke = #e2e2ffff
overlay.cursor = #e2e2ffff
overlay.line = #9385ffff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #2c2c3040
overlay.stroke = #b7b4ffff
overlay.cursor = #b7b4ffff
overlay.line = #8b7cf6ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #2c2c3040
overlay.stroke = #b7b4ffff
overlay.cursor = #b7b4ffff
overlay.line = #8b7cf6ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #7b70005a
state.match_current = #f0be5a6e
state.stripe = #e8e8ed40
overlay.stroke = #e2e2ffff
overlay.cursor = #e2e2ffff
overlay.line = #5740caff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #7b70005a
state.match_current = #f0be5a6e
state.stripe = #e8e8ed40
overlay.stroke = #e2e2ffff
overlay.cursor = #e2e2ffff
overlay.line = #5740caff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #e8e8ed40
overlay.stroke = #b7b4ffff
overlay.cursor = #b7b4ffff
overlay.line = #6c5ce7ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0be5a6e
state.stripe = #e8e8ed40
overlay.stroke = #b7b4ffff
overlay.cursor = #b7b4ffff
overlay.line = #6c5ce7ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #262b3540
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #f26b53ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #262b3540
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #f26b53ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #262b3540
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #f06a52ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #262b3540
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #f06a52ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #f0a3306e
state.stripe = #e3e7ed40
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #af1c00ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #8378005a
state.match_current = #f0a3306e
state.stripe = #e3e7ed40
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #af1c00ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #e3e7ed40
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #d9472fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #e3e7ed40
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #d9472fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #353c4940
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #fc755cff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #353c4940
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #fc755cff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #353c4940
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #f06a52ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #353c4940
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #f06a52ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #776c005a
state.match_current = #f0a3306e
state.stripe = #c5ccd640
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #af1b00ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #776c005a
state.match_current = #f0a3306e
state.stripe = #c5ccd640
overlay.stroke = #ffddd5ff
overlay.cursor = #ffffffff
overlay.line = #af1b00ff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #c5ccd640
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #d9472fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -74,6 +74,7 @@ state.match = #f0dc005a
state.match_current = #f0a3306e
state.stripe = #c5ccd640
overlay.stroke = #ffa492ff
overlay.cursor = #ffffffff
overlay.line = #d9472fff
overlay.halo = #00000099
overlay.handle_fill = #ffffffff
@@ -36,6 +36,7 @@
"line.divider": "#bcc3ce",
"line.grip": "#7d8594",
"line.outline": "#8a93a2",
"overlay.cursor": "#ffffff",
"seeds": {
"accent": "#d9472f",
"neutral": "#d3d8e0"
@@ -64,6 +65,7 @@
"line.divider": "#323946",
"line.grip": "#626b7a",
"line.outline": "#5a6476",
"overlay.cursor": "#ffffff",
"state.hover": "#353c49",
"state.pressed": "#633f3e",
"state.selected": "#573b3d",
@@ -36,6 +36,7 @@
"line.divider": "#dde1e8",
"line.grip": "#9aa1ad",
"line.outline": "#a4abb8",
"overlay.cursor": "#ffffff",
"seeds": {
"accent": "#d9472f",
"neutral": "#f3f5f8"
@@ -64,6 +65,7 @@
"line.divider": "#232832",
"line.grip": "#5a6271",
"line.outline": "#4a5363",
"overlay.cursor": "#ffffff",
"state.hover": "#262b35",
"state.pressed": "#593330",
"state.selected": "#4c2e2e",
@@ -32,9 +32,8 @@ pub(crate) fn pointer_art(env: &Env, cursor: &PaintedCursor, closed: bool, marks
let overlay = &env.tokens.color.overlay;
let pen = Pen {
art: RefCell::new(Art::default()),
fill: crate::style::rgba_color(overlay.stroke),
fill: crate::style::rgba_color(overlay.cursor),
halo: crate::style::rgba_color(overlay.halo),
icon: crate::style::rgba_color(overlay.handle_fill),
thin: env.tokens.stroke.thin,
rtl: env.direction.is_rtl(),
};
@@ -187,14 +186,12 @@ fn v(point: [f32; 2]) -> Vec2 {
Vec2::new(point[0], point[1])
}
/// What the pointers draw with: the art they add marks to, the mark colour, its halo, the colour of a tool's icon over
/// that halo, the hairline width, and whether the reading direction is right to left (marks that point along it
/// mirror).
/// What the pointers draw with: the art they add marks to, the mark colour, its halo, the hairline width, and whether
/// the reading direction is right to left (marks that point along it mirror).
pub(crate) struct Pen {
pub art: RefCell<Art>,
pub fill: Color32,
pub halo: Color32,
pub icon: Color32,
pub thin: f32,
pub rtl: bool,
}
@@ -345,7 +342,7 @@ pub(crate) fn zoom(pen: &Pen, out: bool) {
}
}
/// A tool's `icon` of `side` points with `hotspot` (a point of the icon's 24-unit box) on the pointer, in the icon
/// A tool's `icon` of `side` points with `hotspot` (a point of the icon's 24-unit box) on the pointer, in the mark
/// colour over a halo of the icon drawn a hairline off in every direction, and its badge at the icon's lower right. An
/// icon the catalog lacks leaves only the badge.
pub(crate) fn tool(pen: &Pen, icon: Option<SvgIcon>, hotspot: Vec2, badge: Option<CursorBadge>, side: f32) {
@@ -358,7 +355,7 @@ pub(crate) fn tool(pen: &Pen, icon: Option<SvgIcon>, hotspot: Vec2, badge: Optio
}
}
/// `icon` in `rect` in the icon colour, over copies of it a hairline off in each of eight directions in the halo.
/// `icon` in `rect` in the mark colour, over copies of it a hairline off in each of eight directions in the halo.
fn icon_on_halo(pen: &Pen, rect: Rect, icon: SvgIcon) {
for dx in [-1.0, 0.0, 1.0] {
for dy in [-1.0, 0.0, 1.0] {
@@ -367,7 +364,7 @@ fn icon_on_halo(pen: &Pen, rect: Rect, icon: SvgIcon) {
}
}
}
pen.push(Mark::Icon(rect, icon, pen.icon));
pen.push(Mark::Icon(rect, icon, pen.fill));
}
/// The I-beam centred on the pointer: its stem and two serifs, as rules so each lies on whole device pixels and the
@@ -499,14 +496,7 @@ fn minus(center: Vec2, half: f32) -> Line {
/// badges use, for interface icons that show the same mark. The hairline and the reading direction are those of the
/// component that paints the icon: `tokens` and `direction`.
pub(crate) fn paint_badge(painter: &egui::Painter, tokens: &UiTokens, direction: Direction, rect: Rect, badge: CursorBadge, ink: Color32) {
let pen = Pen {
art: RefCell::new(Art::default()),
fill: ink,
halo: Color32::TRANSPARENT,
icon: ink,
thin: tokens.stroke.thin,
rtl: direction.is_rtl(),
};
let pen = Pen { art: RefCell::new(Art::default()), fill: ink, halo: Color32::TRANSPARENT, thin: tokens.stroke.thin, rtl: direction.is_rtl() };
self::badge(&pen, Vec2::ZERO, badge);
pen.art.into_inner().paint(painter, rect.center());
}
+43 -15
View File
@@ -3,6 +3,7 @@
use craft_behavior::{CountMark, Cursor, CursorBadge, CursorIcon, CursorPriority, IconId, PaintedCursor, PointerGlyph};
use craft_host::target::{Backend, Caps, Os, Runtime, ShellInfo};
use craft_theme::{Appearance, ColorToken, Contrast, Mode, ModeChoice, Rgba, Size, TextSize, ThemeDef, format, resolve};
use craft_ui::runtime::cursor;
use craft_ui::runtime::env::{RootEnv, Scale};
use craft_ui::testing::pointer::moved;
@@ -245,22 +246,49 @@ fn a_badged_tool_pointer_keeps_its_tip_on_the_hotspot_and_the_badge_below_right(
}
}
/// A tool's icon on the pointer is a neutral light silhouette over its dark halo, whatever colour the theme gives the
/// canvas overlay marks: every pixel of the image is grey, with no tint from the overlay colour.
/// A library theme whose overlay marks take a blue tint from its accent, with `overlay.cursor` pinned to white in dark
/// mode when `pinned`.
fn tinted_theme(pinned: bool) -> Arc<ThemeDef> {
let pin = if pinned { r##", "dark": { "overlay.cursor": "#ffffff" }"## } else { "" };
let json = format!(
r##"{{
"schema": "craft-design-theme", "schema_version": 1,
"id": "trial.cursor-ink", "name": "Cursor ink",
"seeds": {{
"neutral": "#535353", "accent": "#78ADF6",
"status": {{ "good": "#85DC6A", "warn": "#E8B046", "bad": "#FF8080", "info": "#78ADF6" }}
}}{pin}
}}"##
);
Arc::new(format::parse(json.as_bytes()).expect("the trial's theme parses").theme)
}
/// A painted pointer is drawn in `overlay.cursor`: a theme that pins it gets a tool's icon and the pointer's own marks
/// in the pin, with no pixel in `overlay.stroke`, and a theme that does not gets them in `overlay.stroke`, which the
/// cursor colour follows.
#[trial]
fn a_tool_icon_on_the_pointer_takes_no_overlay_tint() {
let mut frames = frames(linux(), 1.0);
for cursor in [
PaintedCursor::tool(IconId::new("brush"), Vec2::new(4.0, 20.0), None),
PaintedCursor::pointer_tool(PointerGlyph::Crosshair, IconId::new("crop")),
] {
let image = painted(&mut frames, cursor.clone()).image.unwrap();
let tinted = image.rgba.chunks(4).filter(|p| p[3] > 0).find(|p| {
let (high, low) = (p[0].max(p[1]).max(p[2]), p[0].min(p[1]).min(p[2]));
high - low > 2
});
assert_eq!(tinted, None, "{cursor:?}: a tinted pixel");
assert!(image.rgba.chunks(4).any(|p| p[3] == 255 && p[0] > 200), "{cursor:?}: the icon is drawn light");
fn a_painted_pointer_is_drawn_in_the_cursor_colour() {
let appearance =
Appearance { mode: Mode::Dark, contrast: Contrast::Standard, size: Size::default(), text_size: TextSize::default(), reduced_motion: false };
for pinned in [false, true] {
let def = tinted_theme(pinned);
let tokens = resolve(&def, appearance, None).tokens;
let (ink, stroke) = (tokens.color(ColorToken::OverlayCursor), tokens.color(ColorToken::OverlayStroke));
assert_eq!(ink == stroke, !pinned, "pinned {pinned}: the cursor colour follows overlay.stroke unless pinned");
let mut frames = frames(linux(), 1.0);
frames.root(RootEnv::new().library_theme(def).mode(ModeChoice::Dark));
for cursor in [
PaintedCursor::tool(IconId::new("brush"), Vec2::new(4.0, 20.0), None),
PaintedCursor::pointer_tool(PointerGlyph::Arrow, IconId::new("lasso")),
PaintedCursor::Hand,
] {
let image = painted(&mut frames, cursor.clone()).image.unwrap();
let drawn_in = |colour: Rgba| image.rgba.chunks(4).any(|p| p[3] == 255 && (0..3).all(|i| p[i].abs_diff(colour.0[i]) <= 2));
assert!(drawn_in(ink), "pinned {pinned}, {cursor:?}: drawn in overlay.cursor");
if pinned {
assert!(!drawn_in(stroke), "{cursor:?}: no pixel in overlay.stroke");
}
}
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ High contrast meets every minimum below: it moves pinned values that miss one. S
| `accent.text` on `surface.panel`, `surface.raised` and `surface.sunken`; `accent.on_soft` on `accent.soft` | 4.5 | 7 |
| Status text (`status.good.fg` ...) on `surface.panel`, `surface.raised` and its own `status.*.bg` | 4.5 | 7 |
| `text.on_accent` on `accent.solid`, `accent.hover` and `accent.pressed`; `text.on_strong` on `accent.strong`, `accent.strong_hover` and `accent.strong_pressed`; `text.on_status` on the status solids and their hover and pressed steps | 4.5 | 7 |
| `line.focus` on the surfaces; `accent.solid` on the control surfaces (panel, raised, sunken: checked and selected marks); `line.mark` (slider marks and ticks, the badge ring) on the control surfaces, `state.hover` and `state.pressed`; `overlay.stroke` on `overlay.halo` over black and over white | 3 | 4.5 |
| `line.focus` on the surfaces; `accent.solid` on the control surfaces (panel, raised, sunken: checked and selected marks); `line.mark` (slider marks and ticks, the badge ring) on the control surfaces, `state.hover` and `state.pressed`; `overlay.stroke` and `overlay.cursor` on `overlay.halo` over black and over white | 3 | 4.5 |
| State cues: `accent.border` (the outline of a selected or on control) on the control surfaces; `overlay.handle_stroke` on `overlay.handle_fill` (a selected anchor against a hollow one); the data channel colours (`data.red` ... `data.yellow`) on `surface.sunken` (a curve editor's plot) | 0 (listed, never warned) | 4.5 |
| The thumb of a canvas scroll bar (`text.faint`, `text.muted`) on its track (`surface.chrome`) | 0 (listed, never warned) | 3 |