From 0857eb3bdee96fd8492796fb1f45535336d641b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 09:21:57 +0200 Subject: [PATCH 1/7] Improve contrast of built-in themes by leveraging Oklch --- core/src/color.rs | 10 +- core/src/theme/palette.rs | 172 +++++++++--------- core/src/widget/text.rs | 2 +- .../catppuccin_frappé-tiny-skia.sha256 | 2 +- .../catppuccin_latte-tiny-skia.sha256 | 2 +- .../catppuccin_macchiato-tiny-skia.sha256 | 2 +- .../catppuccin_mocha-tiny-skia.sha256 | 2 +- .../styling/snapshots/dark-tiny-skia.sha256 | 2 +- .../snapshots/dracula-tiny-skia.sha256 | 2 +- .../styling/snapshots/ferra-tiny-skia.sha256 | 2 +- .../snapshots/gruvbox_dark-tiny-skia.sha256 | 2 +- .../snapshots/gruvbox_light-tiny-skia.sha256 | 2 +- .../kanagawa_dragon-tiny-skia.sha256 | 2 +- .../snapshots/kanagawa_lotus-tiny-skia.sha256 | 2 +- .../snapshots/kanagawa_wave-tiny-skia.sha256 | 2 +- .../styling/snapshots/light-tiny-skia.sha256 | 2 +- .../snapshots/moonfly-tiny-skia.sha256 | 2 +- .../snapshots/nightfly-tiny-skia.sha256 | 2 +- .../styling/snapshots/nord-tiny-skia.sha256 | 2 +- .../snapshots/oxocarbon-tiny-skia.sha256 | 2 +- .../snapshots/solarized_dark-tiny-skia.sha256 | 2 +- .../solarized_light-tiny-skia.sha256 | 2 +- .../snapshots/tokyo_night-tiny-skia.sha256 | 2 +- .../tokyo_night_light-tiny-skia.sha256 | 2 +- .../tokyo_night_storm-tiny-skia.sha256 | 2 +- widget/src/button.rs | 4 +- widget/src/text_editor.rs | 3 +- widget/src/text_input.rs | 5 +- 28 files changed, 124 insertions(+), 116 deletions(-) diff --git a/core/src/color.rs b/core/src/color.rs index a280c795..65a47781 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -90,12 +90,12 @@ impl Color { } } - Self { - r: gamma_component(r), - g: gamma_component(g), - b: gamma_component(b), + Self::new( + gamma_component(r), + gamma_component(g), + gamma_component(b), a, - } + ) } /// Parses a [`Color`] from a hex string. diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index d9ac6402..96a48695 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -28,7 +28,7 @@ impl Palette { text: Color::BLACK, primary: color!(0x5865F2), success: color!(0x12664f), - warning: color!(0xffc14e), + warning: color!(0xb77e33), danger: color!(0xc3423f), }; @@ -453,9 +453,13 @@ pub struct Background { /// The weakest version of the base background color. pub weakest: Pair, /// A weaker version of the base background color. + pub weaker: Pair, + /// A weak version of the base background color. pub weak: Pair, - /// A stronger version of the base background color. + /// A strong version of the base background color. pub strong: Pair, + /// A stronger version of the base background color. + pub stronger: Pair, /// The strongest version of the base background color. pub strongest: Pair, } @@ -464,15 +468,19 @@ impl Background { /// Generates a set of [`Background`] colors from the base and text colors. pub fn new(base: Color, text: Color) -> Self { let weakest = deviate(base, 0.03); - let weak = muted(deviate(base, 0.1)); - let strong = muted(deviate(base, 0.2)); - let strongest = muted(deviate(base, 0.3)); + let weaker = deviate(base, 0.07); + let weak = deviate(base, 0.1); + let strong = deviate(base, 0.15); + let stronger = deviate(base, 0.175); + let strongest = deviate(base, 0.20); Self { base: Pair::new(base, text), weakest: Pair::new(weakest, text), + weaker: Pair::new(weaker, text), weak: Pair::new(weak, text), strong: Pair::new(strong, text), + stronger: Pair::new(stronger, text), strongest: Pair::new(strongest, text), } } @@ -517,9 +525,11 @@ pub struct Secondary { impl Secondary { /// Generates a set of [`Secondary`] colors from the base and text colors. pub fn generate(base: Color, text: Color) -> Self { - let base = mix(base, text, 0.2); - let weak = mix(base, text, 0.1); - let strong = mix(base, text, 0.3); + let bump = if is_dark(base) { 0.0 } else { 0.01 }; + + let weak = mix(deviate(base, 0.1 + bump), text, 0.4); + let base = mix(deviate(base, 0.3 + bump), text, 0.4); + let strong = mix(deviate(base, 0.5 + bump), text, 0.4); Self { base: Pair::new(base, text), @@ -604,53 +614,51 @@ impl Danger { } } -struct Hsl { - h: f32, - s: f32, +struct Oklch { l: f32, + c: f32, + h: f32, a: f32, } fn darken(color: Color, amount: f32) -> Color { - let mut hsl = to_hsl(color); + let mut oklch = to_oklch(color); - hsl.l = if hsl.l - amount < 0.0 { + // We try to bump the chroma a bit for more colorful palettes + oklch.c *= 1.0 + 2.0 * amount / oklch.l.max(0.05); + + oklch.l = if oklch.l - amount < 0.0 { 0.0 } else { - hsl.l - amount + oklch.l - amount }; - from_hsl(hsl) + from_oklch(oklch) } fn lighten(color: Color, amount: f32) -> Color { - let mut hsl = to_hsl(color); + let mut oklch = to_oklch(color); - hsl.l = if hsl.l + amount > 1.0 { + // We try to bump the chroma a bit for more colorful palettes + oklch.c *= 1.0 + 2.0 * amount / oklch.l.max(0.05); + + oklch.l = if oklch.l + amount > 1.0 { 1.0 } else { - hsl.l + amount + oklch.l + amount }; - from_hsl(hsl) + from_oklch(oklch) } fn deviate(color: Color, amount: f32) -> Color { if is_dark(color) { lighten(color, amount) } else { - darken(color, amount * 0.8) + darken(color, amount) } } -fn muted(color: Color) -> Color { - let mut hsl = to_hsl(color); - - hsl.s = hsl.s.min(0.5); - - from_hsl(hsl) -} - fn mix(a: Color, b: Color, factor: f32) -> Color { let b_amount = factor.clamp(0.0, 1.0); let a_amount = 1.0 - b_amount; @@ -680,6 +688,12 @@ fn readable(background: Color, text: Color) -> Color { return candidate; } + let candidate = improve(text, 0.2); + + if is_readable(background, candidate) { + return candidate; + } + let white_contrast = relative_contrast(background, Color::WHITE); let black_contrast = relative_contrast(background, Color::BLACK); @@ -691,11 +705,11 @@ fn readable(background: Color, text: Color) -> Color { } fn is_dark(color: Color) -> bool { - to_hsl(color).l < 0.6 + to_oklch(color).l < 0.6 } fn is_readable(a: Color, b: Color) -> bool { - relative_contrast(a, b) >= 7.0 + relative_contrast(a, b) >= 6.0 } // https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio @@ -711,65 +725,57 @@ fn relative_luminance(color: Color) -> f32 { 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2] } -// https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB -fn to_hsl(color: Color) -> Hsl { - let x_max = color.r.max(color.g).max(color.b); - let x_min = color.r.min(color.g).min(color.b); - let c = x_max - x_min; - let l = x_max.midpoint(x_min); +// https://en.wikipedia.org/wiki/Oklab_color_space#Conversions_between_color_spaces +fn to_oklch(color: Color) -> Oklch { + let [r, g, b, alpha] = color.into_linear(); - let h = if c == 0.0 { - 0.0 - } else if x_max == color.r { - 60.0 * ((color.g - color.b) / c).rem_euclid(6.0) - } else if x_max == color.g { - 60.0 * (((color.b - color.r) / c) + 2.0) - } else { - // x_max == color.b - 60.0 * (((color.r - color.g) / c) + 4.0) - }; + // linear RGB → LMS + let l = 0.41222146 * r + 0.53633255 * g + 0.051445995 * b; + let m = 0.2119035 * r + 0.6806995 * g + 0.10739696 * b; + let s = 0.08830246 * r + 0.28171885 * g + 0.6299787 * b; - let s = if l == 0.0 || l == 1.0 { - 0.0 - } else { - (x_max - l) / l.min(1.0 - l) - }; + // Nonlinear transform (cube root) + let l_ = l.cbrt(); + let m_ = m.cbrt(); + let s_ = s.cbrt(); - Hsl { - h, - s, - l, - a: color.a, - } + // LMS → Oklab + let l = 0.21045426 * l_ + 0.7936178 * m_ - 0.004072047 * s_; + let a = 1.9779985 * l_ - 2.4285922 * m_ + 0.4505937 * s_; + let b = 0.025904037 * l_ + 0.78277177 * m_ - 0.80867577 * s_; + + // Oklab → Oklch + let c = (a * a + b * b).sqrt(); + let h = b.atan2(a); // radians + + Oklch { l, c, h, a: alpha } } -// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB -fn from_hsl(hsl: Hsl) -> Color { - let c = (1.0 - (2.0 * hsl.l - 1.0).abs()) * hsl.s; - let h = hsl.h / 60.0; - let x = c * (1.0 - (h.rem_euclid(2.0) - 1.0).abs()); +// https://en.wikipedia.org/wiki/Oklab_color_space#Conversions_between_color_spaces +fn from_oklch(oklch: Oklch) -> Color { + let Oklch { l, c, h, a: alpha } = oklch; - let (r1, g1, b1) = if h < 1.0 { - (c, x, 0.0) - } else if h < 2.0 { - (x, c, 0.0) - } else if h < 3.0 { - (0.0, c, x) - } else if h < 4.0 { - (0.0, x, c) - } else if h < 5.0 { - (x, 0.0, c) - } else { - // h < 6.0 - (c, 0.0, x) - }; + let a = c * h.cos(); + let b = c * h.sin(); - let m = hsl.l - (c / 2.0); + // Oklab → LMS (nonlinear) + let l_ = l + 0.39633778 * a + 0.21580376 * b; + let m_ = l - 0.105561346 * a - 0.06385417 * b; + let s_ = l - 0.08948418 * a - 1.2914855 * b; - Color { - r: r1 + m, - g: g1 + m, - b: b1 + m, - a: hsl.a, - } + // Cubing back + let l = l_ * l_ * l_; + let m = m_ * m_ * m_; + let s = s_ * s_ * s_; + + let r = 4.0767417 * l - 3.3077116 * m + 0.23096994 * s; + let g = -1.268438 * l + 2.6097574 * m - 0.34131938 * s; + let b = -0.0041960863 * l - 0.7034186 * m + 1.7076147 * s; + + Color::from_linear_rgba( + r.clamp(0.0, 1.0), + g.clamp(0.0, 1.0), + b.clamp(0.0, 1.0), + alpha, + ) } diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 972ab731..24966211 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -441,7 +441,7 @@ pub fn primary(theme: &Theme) -> Style { /// Text conveying some secondary information, like a footnote. pub fn secondary(theme: &Theme) -> Style { Style { - color: Some(theme.extended_palette().secondary.strong.color), + color: Some(theme.extended_palette().secondary.base.color), } } diff --git a/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 index 188d6c67..adb46a04 100644 --- a/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 @@ -1 +1 @@ -e440e5e00db4fff0a79251aaf493c4af86241196a746d9147a895d14f01b1283 \ No newline at end of file +a496cc09220283466d5eb3635f6b63d011ec1dc765726b81213a823825836e4a \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 index b72ceb65..4f164ab7 100644 --- a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 @@ -1 +1 @@ -d81cf7c3974fc5b49251e8287c536fd3477c18e7afd3e9e42619364db7787fcc \ No newline at end of file +661e3f5313b98c65fd0ce9615d9a42201f2b1bafe0285b4a9c5c5af403782452 \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 index 2cca5768..73859c52 100644 --- a/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 @@ -1 +1 @@ -ad4fbda3cc3d60209320dd713b7be6b0a5e6b55650689d70ac563a0a81f2eefc \ No newline at end of file +a530ad9b59628d95e9aaa187af2681b26e7219786b5a114848f41690ed25ef21 \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 index 4dd06594..75e14cfd 100644 --- a/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 @@ -1 +1 @@ -3863252d1f15750d7f5375bd23e8363c6a70d77ac9aac853e3515f7ff5170bce \ No newline at end of file +f959b1b8ca2d7f87110e0decf63bf04bb685a8958de6879e008edb40415a84e8 \ No newline at end of file diff --git a/examples/styling/snapshots/dark-tiny-skia.sha256 b/examples/styling/snapshots/dark-tiny-skia.sha256 index e8ae6200..59ea0058 100644 --- a/examples/styling/snapshots/dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/dark-tiny-skia.sha256 @@ -1 +1 @@ -c0bc58fcbde8e7ac4447ba4a454c5c2cb2c6d570e873897887c626b2dc07329b \ No newline at end of file +043d53e59e66ed06105abac613ed49c6beaf57f5009e605107cb77307807790b \ No newline at end of file diff --git a/examples/styling/snapshots/dracula-tiny-skia.sha256 b/examples/styling/snapshots/dracula-tiny-skia.sha256 index 4b48c1d2..3569448c 100644 --- a/examples/styling/snapshots/dracula-tiny-skia.sha256 +++ b/examples/styling/snapshots/dracula-tiny-skia.sha256 @@ -1 +1 @@ -1f17779b3291c133399f1eba9f7e517889108d60dbaa8d5b6cd024ad67ef1c8c \ No newline at end of file +f7894c6738710e8054b41c2d958eb50182d9655d8651d1fd2371a9ed05f28ddc \ No newline at end of file diff --git a/examples/styling/snapshots/ferra-tiny-skia.sha256 b/examples/styling/snapshots/ferra-tiny-skia.sha256 index 6ea26878..5caad7ab 100644 --- a/examples/styling/snapshots/ferra-tiny-skia.sha256 +++ b/examples/styling/snapshots/ferra-tiny-skia.sha256 @@ -1 +1 @@ -51d7bfc1af8ba7503b9800ae7eaaa660047d9b16b0bdc1e8a3850df1d9901652 \ No newline at end of file +e0ec3911121e303bdfe3956c72af423ec21a17a958768116ee452adcace02e15 \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 index 173efa4e..9c798964 100644 --- a/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 @@ -1 +1 @@ -5423fa06a1dc73f9cce42447f3134768114e8321c8f2367da1e04db4d4673f52 \ No newline at end of file +81e4f065fc985a2c5fc9d15fea941667e914dbc6fe7a5262dac5390955e34f67 \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 index b1b97fa5..d49549ed 100644 --- a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 @@ -1 +1 @@ -b7ea69b9ce1f73694cccb8b0bc9acab35fc4dcedd01795e3897215c416550fc2 \ No newline at end of file +9d91bfb3504ebf59881ca1554fa63f7293c2750f7ff15a91ff8e86ccf65a0f6f \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 index 3c6e8060..b02de3c1 100644 --- a/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 @@ -1 +1 @@ -fa43206adec5dce05c4181ec5d9c71d15067dd3b1d7f5b3267c452cf1de2ca95 \ No newline at end of file +491041848f77c6e9b70b7e677d0809bff5ceae783326f6dbdd10bdcd45eb56e2 \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 index 84c64e60..32759d28 100644 --- a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 @@ -1 +1 @@ -5d7445700ff415428ae43d32ef30b279c38ddc6ffd0e3619ea28044b1d8c709b \ No newline at end of file +8209ef9862c56280f711a477843f6d9ab2d1b201ba257f553c9ad2caf0c78731 \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 index b27cd469..2f1b3050 100644 --- a/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 @@ -1 +1 @@ -52d424e4dfa3ae9b1195e95f17eb655675e4507ec8fb4e36372612fd57a5d86d \ No newline at end of file +304163accbfcd947b5231beaeb4d8194aab02409df9e334862fe5eb79a835116 \ No newline at end of file diff --git a/examples/styling/snapshots/light-tiny-skia.sha256 b/examples/styling/snapshots/light-tiny-skia.sha256 index 2c30b309..5e68c473 100644 --- a/examples/styling/snapshots/light-tiny-skia.sha256 +++ b/examples/styling/snapshots/light-tiny-skia.sha256 @@ -1 +1 @@ -a0c84b36979f6a6f780af80689425b92a1b68743c39f8e519efcb11b46b9de42 \ No newline at end of file +dd82fb5d72db1a33c52bbd27836dbed0c51af5a8bc726c4d73865af779701aba \ No newline at end of file diff --git a/examples/styling/snapshots/moonfly-tiny-skia.sha256 b/examples/styling/snapshots/moonfly-tiny-skia.sha256 index 377e0509..21d299eb 100644 --- a/examples/styling/snapshots/moonfly-tiny-skia.sha256 +++ b/examples/styling/snapshots/moonfly-tiny-skia.sha256 @@ -1 +1 @@ -21820cf793f0a3af6fd339132b32cc77cbca52f1ca32f7ae334f74849a046ba8 \ No newline at end of file +bc88452bb81a702a8c29c9dde933bf0bdb1723af1c910cb44e56180dc64270b5 \ No newline at end of file diff --git a/examples/styling/snapshots/nightfly-tiny-skia.sha256 b/examples/styling/snapshots/nightfly-tiny-skia.sha256 index a4a22ca2..90c3b78a 100644 --- a/examples/styling/snapshots/nightfly-tiny-skia.sha256 +++ b/examples/styling/snapshots/nightfly-tiny-skia.sha256 @@ -1 +1 @@ -1ba92e64ddcc5f5fc6f841d5fde961382099e7698a253ac93670b900287ee55c \ No newline at end of file +140ca7cf98bec0d955678b5160e0ccb43d85a829eed62c54f09d5e0b1a401e6f \ No newline at end of file diff --git a/examples/styling/snapshots/nord-tiny-skia.sha256 b/examples/styling/snapshots/nord-tiny-skia.sha256 index d1f4cf12..aa36b9a7 100644 --- a/examples/styling/snapshots/nord-tiny-skia.sha256 +++ b/examples/styling/snapshots/nord-tiny-skia.sha256 @@ -1 +1 @@ -f6559f58f9acae81d929ee1aa5f8db33fca9d4ff49d21acf1e627d891ed77565 \ No newline at end of file +e8b2b050896d2b2cfd1c31b2c8773f74b2c23b94b3d94e8f16b8fb6604e8b2f2 \ No newline at end of file diff --git a/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 b/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 index 5cb7f75e..096bad4c 100644 --- a/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 +++ b/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 @@ -1 +1 @@ -d3d34b3b02b11156cb9a545d60cba078e78e4124c8f3ae61be66908a42799166 \ No newline at end of file +d40514ab3f75e4aa08d8d21e197e5fa486dd0689a4e81027ae335e9abd2ea311 \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 b/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 index 367d8198..93ec5161 100644 --- a/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 @@ -1 +1 @@ -3c983866c4feaa10ed34206c1a4c98933e87ba6239849bd7e1b7876f6c9596e7 \ No newline at end of file +3ea703ef5d769c6184777bee6caa71e49adc381e1a47f3241f03250ab27b6988 \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 index bf7fb05b..4d5150b3 100644 --- a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 @@ -1 +1 @@ -dc6fc66e651d938a42f0a9c642a99e33865b87aefc3fdeafa1848f6a3fab20c3 \ No newline at end of file +73f01efd56087daa9372aed4b5e5d72d8f5713d75812978bf09a726684ea2b40 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 index 5685ce2f..99686307 100644 --- a/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 @@ -1 +1 @@ -7104099471f9c712f00cd2ac80e150e10f7d21604d7edc6b13181e74d42eb877 \ No newline at end of file +82a173e0c1b9c665fbf06de60acbb0523b7f9ab5af429d5ec29ce908f640d5ec \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 index 2efd8415..69c59503 100644 --- a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 @@ -1 +1 @@ -263b5eb190d7db2ab0a67dc8b73778d9130755b07a8295345c758e158fb52881 \ No newline at end of file +91d09c382a9d615a1ba68f74463c9a92baba705e35bb84173945d2fa5fd240d0 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 index c8a8d1ed..ed8f662b 100644 --- a/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 @@ -1 +1 @@ -6fd5700c7a63ba004957601e0d91b02e8d08b710cff81710d3b8cd1cb668faa6 \ No newline at end of file +dfc3317f39c204b8509c1b8f7e8e1d9b0911bfc1a7bd5fbde822a7a5c6c54e12 \ No newline at end of file diff --git a/widget/src/button.rs b/widget/src/button.rs index 37c07169..ac4a27cb 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -718,13 +718,13 @@ pub fn subtle(theme: &Theme, status: Status) -> Style { Status::Active => base, Status::Pressed => Style { background: Some(Background::Color( - palette.background.strongest.color, + palette.background.strong.color, )), ..base }, Status::Hovered => Style { background: Some(Background::Color( - palette.background.strong.color, + palette.background.weaker.color, )), ..base }, diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 4e1d594c..b8cee500 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -1423,7 +1423,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { color: palette.background.strong.color, }, icon: palette.background.weak.text, - placeholder: palette.background.strong.color, + placeholder: palette.secondary.base.color, value: palette.background.base.text, selection: palette.primary.weak.color, }; @@ -1447,6 +1447,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Disabled => Style { background: Background::Color(palette.background.weak.color), value: active.placeholder, + placeholder: palette.background.strongest.color, ..active }, } diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index ba15e916..3e849175 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -1817,10 +1817,10 @@ pub fn default(theme: &Theme, status: Status) -> Style { border: Border { radius: 2.0.into(), width: 1.0, - color: palette.background.strongest.color, + color: palette.background.strong.color, }, icon: palette.background.weak.text, - placeholder: palette.background.strongest.color, + placeholder: palette.secondary.base.color, value: palette.background.base.text, selection: palette.primary.weak.color, }; @@ -1844,6 +1844,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Disabled => Style { background: Background::Color(palette.background.weak.color), value: active.placeholder, + placeholder: palette.background.strongest.color, ..active }, } From 6e78bea2d2f99d497c4266932f472b6b7a118330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 10:06:38 +0200 Subject: [PATCH 2/7] Remove `bump` hack in `theme::palette` --- core/src/theme/palette.rs | 8 +++----- .../styling/snapshots/catppuccin_latte-tiny-skia.sha256 | 2 +- examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 | 2 +- .../styling/snapshots/kanagawa_lotus-tiny-skia.sha256 | 2 +- examples/styling/snapshots/light-tiny-skia.sha256 | 2 +- .../styling/snapshots/solarized_light-tiny-skia.sha256 | 2 +- .../styling/snapshots/tokyo_night_light-tiny-skia.sha256 | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 96a48695..dfd8acf0 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -525,11 +525,9 @@ pub struct Secondary { impl Secondary { /// Generates a set of [`Secondary`] colors from the base and text colors. pub fn generate(base: Color, text: Color) -> Self { - let bump = if is_dark(base) { 0.0 } else { 0.01 }; - - let weak = mix(deviate(base, 0.1 + bump), text, 0.4); - let base = mix(deviate(base, 0.3 + bump), text, 0.4); - let strong = mix(deviate(base, 0.5 + bump), text, 0.4); + let weak = mix(deviate(base, 0.1), text, 0.4); + let base = mix(deviate(base, 0.3), text, 0.4); + let strong = mix(deviate(base, 0.5), text, 0.4); Self { base: Pair::new(base, text), diff --git a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 index 4f164ab7..9fe9007a 100644 --- a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 @@ -1 +1 @@ -661e3f5313b98c65fd0ce9615d9a42201f2b1bafe0285b4a9c5c5af403782452 \ No newline at end of file +46f6341d1e3f63ddb4a6a9a11f0efee4dcb076861c351258a3d29095d67c170d \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 index d49549ed..8672a54b 100644 --- a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 @@ -1 +1 @@ -9d91bfb3504ebf59881ca1554fa63f7293c2750f7ff15a91ff8e86ccf65a0f6f \ No newline at end of file +3131fd97275095e2c562341e3b0b13dfbed45e2461595b692f20dae0e5941dba \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 index 32759d28..cc334448 100644 --- a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 @@ -1 +1 @@ -8209ef9862c56280f711a477843f6d9ab2d1b201ba257f553c9ad2caf0c78731 \ No newline at end of file +59a02d3278a9f321731c11c182edc897f87c2703af5f14a6e76dbea6e505fcc6 \ No newline at end of file diff --git a/examples/styling/snapshots/light-tiny-skia.sha256 b/examples/styling/snapshots/light-tiny-skia.sha256 index 5e68c473..0a1e8669 100644 --- a/examples/styling/snapshots/light-tiny-skia.sha256 +++ b/examples/styling/snapshots/light-tiny-skia.sha256 @@ -1 +1 @@ -dd82fb5d72db1a33c52bbd27836dbed0c51af5a8bc726c4d73865af779701aba \ No newline at end of file +b61b166bca3dce77002300e60ae778000ea00df5b5973f106ce58ce6d5e0b501 \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 index 4d5150b3..93cb2d82 100644 --- a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 @@ -1 +1 @@ -73f01efd56087daa9372aed4b5e5d72d8f5713d75812978bf09a726684ea2b40 \ No newline at end of file +ce493d0c75ecce3eedb82c459c6d3ac674a4f8ee0bdaf3a912ff8ef8e57e5b32 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 index 69c59503..bf0eea38 100644 --- a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 @@ -1 +1 @@ -91d09c382a9d615a1ba68f74463c9a92baba705e35bb84173945d2fa5fd240d0 \ No newline at end of file +40441bc94b7c524c5064ff155a0db28d896109c3cce4da6822efefd71b3a9a92 \ No newline at end of file From e14d3609ac1d2d64424cf294c07bfa8882c8d964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 10:07:10 +0200 Subject: [PATCH 3/7] Fix unnecessary parentheses in `winit::conversion` --- winit/src/conversion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index ab84afff..4b9fcc0d 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -289,7 +289,7 @@ pub fn window_event( Ime::Enabled => input_method::Event::Opened, Ime::Preedit(content, size) => input_method::Event::Preedit( content, - size.map(|(start, end)| (start..end)), + size.map(|(start, end)| start..end), ), Ime::Commit(content) => input_method::Event::Commit(content), Ime::Disabled => input_method::Event::Closed, From 4d4f565da71e923f74ea51240bfa4e48adf84887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 22:04:35 +0200 Subject: [PATCH 4/7] Try to make light themes a bit more colorful --- core/src/theme/palette.rs | 6 +++++- .../snapshots/catppuccin_latte-tiny-skia.sha256 | 2 +- .../snapshots/gruvbox_light-tiny-skia.sha256 | 2 +- .../snapshots/kanagawa_lotus-tiny-skia.sha256 | 2 +- .../snapshots/solarized_light-tiny-skia.sha256 | 2 +- .../snapshots/tokyo_night_light-tiny-skia.sha256 | 2 +- examples/styling/src/main.rs | 14 ++++++++------ widget/src/text_editor.rs | 3 --- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index dfd8acf0..24e15a9e 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -623,7 +623,10 @@ fn darken(color: Color, amount: f32) -> Color { let mut oklch = to_oklch(color); // We try to bump the chroma a bit for more colorful palettes - oklch.c *= 1.0 + 2.0 * amount / oklch.l.max(0.05); + if oklch.c > 0.0 { + // Formula empirically and cluelessly derived + oklch.c *= 1.0 + (0.3 / oklch.c).min(100.0) * amount; + } oklch.l = if oklch.l - amount < 0.0 { 0.0 @@ -638,6 +641,7 @@ fn lighten(color: Color, amount: f32) -> Color { let mut oklch = to_oklch(color); // We try to bump the chroma a bit for more colorful palettes + // Formula empirically and cluelessly derived oklch.c *= 1.0 + 2.0 * amount / oklch.l.max(0.05); oklch.l = if oklch.l + amount > 1.0 { diff --git a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 index 9fe9007a..6e3df4fc 100644 --- a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 @@ -1 +1 @@ -46f6341d1e3f63ddb4a6a9a11f0efee4dcb076861c351258a3d29095d67c170d \ No newline at end of file +045ee6f1580e728919431e5ae741b50277b96cb97089ad3bf2a0e2aefd9e0090 \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 index 8672a54b..76b632c1 100644 --- a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 @@ -1 +1 @@ -3131fd97275095e2c562341e3b0b13dfbed45e2461595b692f20dae0e5941dba \ No newline at end of file +09cb020de17de0695c3a383972af3562e49d87dcfc5bcf8f1459b19f8874834a \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 index cc334448..49bace10 100644 --- a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 @@ -1 +1 @@ -59a02d3278a9f321731c11c182edc897f87c2703af5f14a6e76dbea6e505fcc6 \ No newline at end of file +ddc366fdf1127014a47d18a8914b6e9967eada10fae48a03b10c9428c589c51f \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 index 93cb2d82..ce985f2c 100644 --- a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 @@ -1 +1 @@ -ce493d0c75ecce3eedb82c459c6d3ac674a4f8ee0bdaf3a912ff8ef8e57e5b32 \ No newline at end of file +9af0d10bb6b71fae760d9993e7ba6f9431002a376c6c064ac0e0738499f4e359 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 index bf0eea38..300f2eac 100644 --- a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 @@ -1 +1 @@ -40441bc94b7c524c5064ff155a0db28d896109c3cce4da6822efefd71b3a9a92 \ No newline at end of file +e2d049e13e1d88c9fd046803936c27e9a45809f133d8ea58d4731626594a87a3 \ No newline at end of file diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 934b9f5d..0ba4e20f 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -1,8 +1,8 @@ use iced::keyboard; use iced::widget::{ - button, center, checkbox, column, container, horizontal_rule, pick_list, - progress_bar, row, scrollable, slider, text, text_input, toggler, - vertical_rule, vertical_space, + button, center_x, center_y, checkbox, column, container, horizontal_rule, + pick_list, progress_bar, row, scrollable, slider, text, text_input, + toggler, vertical_rule, vertical_space, }; use iced::{Center, Element, Fill, Subscription, Theme}; @@ -94,7 +94,7 @@ impl Styling { let progress_bar = || progress_bar(0.0..=100.0, self.slider_value); - let scrollable = scrollable(column![ + let scroll_me = scrollable(column![ "Scroll me!", vertical_space().height(800), "You did it!" @@ -134,7 +134,7 @@ impl Styling { slider(), progress_bar(), row![ - scrollable, + scroll_me, row![vertical_rule(1), column![checkbox, toggler].spacing(20)] .spacing(20) ] @@ -147,7 +147,9 @@ impl Styling { .padding(20) .max_width(600); - center(content).into() + center_y(scrollable(center_x(content)).spacing(10)) + .padding(10) + .into() } fn subscription(&self) -> Subscription { diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index b8cee500..451072a8 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -1374,8 +1374,6 @@ pub struct Style { pub background: Background, /// The [`Border`] of the text input. pub border: Border, - /// The [`Color`] of the icon of the text input. - pub icon: Color, /// The [`Color`] of the placeholder of the text input. pub placeholder: Color, /// The [`Color`] of the value of the text input. @@ -1422,7 +1420,6 @@ pub fn default(theme: &Theme, status: Status) -> Style { width: 1.0, color: palette.background.strong.color, }, - icon: palette.background.weak.text, placeholder: palette.secondary.base.color, value: palette.background.base.text, selection: palette.primary.weak.color, From a8e2956f7483092b7b9d96aa5135604d1433a086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 22:05:51 +0200 Subject: [PATCH 5/7] Enable `crisp` feature by default :tada: --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e1f0c671..6fed9896 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ all-features = true maintenance = { status = "actively-developed" } [features] -default = ["wgpu", "tiny-skia", "web-colors", "auto-detect-theme", "thread-pool"] +default = ["wgpu", "tiny-skia", "crisp", "web-colors", "auto-detect-theme", "thread-pool"] # Enables the `wgpu` GPU-accelerated renderer backend wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"] # Enables the `tiny-skia` software renderer backend From 35df95e988de2df9cf6098c2ff6ed23fcc6de1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 5 Aug 2025 22:20:30 +0200 Subject: [PATCH 6/7] Fix broken intra-doc link in `graphics::text` --- graphics/src/text.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/src/text.rs b/graphics/src/text.rs index d2514c90..e00b3ac7 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -176,7 +176,7 @@ impl FontSystem { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub struct Version(u32); -/// A weak reference to a [`cosmic-text::Buffer`] that can be drawn. +/// A weak reference to a [`cosmic_text::Buffer`] that can be drawn. #[derive(Debug, Clone)] pub struct Raw { /// A weak reference to a [`cosmic_text::Buffer`]. From 468014a1841fb89602248c7d95ad50b3a550859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 6 Aug 2025 02:42:51 +0200 Subject: [PATCH 7/7] Fix minor styling inconsistencies in some widgets --- core/src/theme/palette.rs | 4 +-- .../catppuccin_frappé-tiny-skia.sha256 | 2 +- .../catppuccin_latte-tiny-skia.sha256 | 2 +- .../catppuccin_macchiato-tiny-skia.sha256 | 2 +- .../catppuccin_mocha-tiny-skia.sha256 | 2 +- .../styling/snapshots/dark-tiny-skia.sha256 | 2 +- .../snapshots/dracula-tiny-skia.sha256 | 2 +- .../styling/snapshots/ferra-tiny-skia.sha256 | 2 +- .../snapshots/gruvbox_dark-tiny-skia.sha256 | 2 +- .../snapshots/gruvbox_light-tiny-skia.sha256 | 2 +- .../kanagawa_dragon-tiny-skia.sha256 | 2 +- .../snapshots/kanagawa_lotus-tiny-skia.sha256 | 2 +- .../snapshots/kanagawa_wave-tiny-skia.sha256 | 2 +- .../styling/snapshots/light-tiny-skia.sha256 | 2 +- .../snapshots/moonfly-tiny-skia.sha256 | 2 +- .../snapshots/nightfly-tiny-skia.sha256 | 2 +- .../styling/snapshots/nord-tiny-skia.sha256 | 2 +- .../snapshots/oxocarbon-tiny-skia.sha256 | 2 +- .../snapshots/solarized_dark-tiny-skia.sha256 | 2 +- .../solarized_light-tiny-skia.sha256 | 2 +- .../snapshots/tokyo_night-tiny-skia.sha256 | 2 +- .../tokyo_night_light-tiny-skia.sha256 | 2 +- .../tokyo_night_storm-tiny-skia.sha256 | 2 +- widget/src/checkbox.rs | 29 ++++++++++++++----- widget/src/pick_list.rs | 2 +- widget/src/scrollable.rs | 2 +- widget/src/toggler.rs | 2 +- 27 files changed, 48 insertions(+), 35 deletions(-) diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 24e15a9e..08a80a26 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -623,9 +623,9 @@ fn darken(color: Color, amount: f32) -> Color { let mut oklch = to_oklch(color); // We try to bump the chroma a bit for more colorful palettes - if oklch.c > 0.0 { + if oklch.c > 0.0 && oklch.c < (1.0 - oklch.l) / 2.0 { // Formula empirically and cluelessly derived - oklch.c *= 1.0 + (0.3 / oklch.c).min(100.0) * amount; + oklch.c *= 1.0 + (0.2 / oklch.c).min(100.0) * amount; } oklch.l = if oklch.l - amount < 0.0 { diff --git a/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 index adb46a04..7be535ed 100644 --- a/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_frappé-tiny-skia.sha256 @@ -1 +1 @@ -a496cc09220283466d5eb3635f6b63d011ec1dc765726b81213a823825836e4a \ No newline at end of file +aeecd43f0921fe9f0ea3358cc3d55040e1b3117e43eb4490d621b0af71680899 \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 index 6e3df4fc..39882a5b 100644 --- a/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_latte-tiny-skia.sha256 @@ -1 +1 @@ -045ee6f1580e728919431e5ae741b50277b96cb97089ad3bf2a0e2aefd9e0090 \ No newline at end of file +121fd6018015dbc5e6c8f5c2db1197a7dc769a916fb29ef9f42622b4cf63a96c \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 index 73859c52..2197655b 100644 --- a/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_macchiato-tiny-skia.sha256 @@ -1 +1 @@ -a530ad9b59628d95e9aaa187af2681b26e7219786b5a114848f41690ed25ef21 \ No newline at end of file +56df225c9404745aae11734fcd13b062355a1d26198323711888c49b528bdfae \ No newline at end of file diff --git a/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 b/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 index 75e14cfd..542012dc 100644 --- a/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 +++ b/examples/styling/snapshots/catppuccin_mocha-tiny-skia.sha256 @@ -1 +1 @@ -f959b1b8ca2d7f87110e0decf63bf04bb685a8958de6879e008edb40415a84e8 \ No newline at end of file +a15a385aefc14ddd988536ee6eb81b7d6ececafbc7a7af4a5c282266c4f69d07 \ No newline at end of file diff --git a/examples/styling/snapshots/dark-tiny-skia.sha256 b/examples/styling/snapshots/dark-tiny-skia.sha256 index 59ea0058..5e28ca02 100644 --- a/examples/styling/snapshots/dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/dark-tiny-skia.sha256 @@ -1 +1 @@ -043d53e59e66ed06105abac613ed49c6beaf57f5009e605107cb77307807790b \ No newline at end of file +95630596cd95dbe070c20d3eec0bb131f5b0b05e1afa8c07a38cedd4775cfff8 \ No newline at end of file diff --git a/examples/styling/snapshots/dracula-tiny-skia.sha256 b/examples/styling/snapshots/dracula-tiny-skia.sha256 index 3569448c..44ebe62e 100644 --- a/examples/styling/snapshots/dracula-tiny-skia.sha256 +++ b/examples/styling/snapshots/dracula-tiny-skia.sha256 @@ -1 +1 @@ -f7894c6738710e8054b41c2d958eb50182d9655d8651d1fd2371a9ed05f28ddc \ No newline at end of file +fe0a3defebea5e0d728abec9f7395cced9d5fe46d1e64523afe649774fb7dc3e \ No newline at end of file diff --git a/examples/styling/snapshots/ferra-tiny-skia.sha256 b/examples/styling/snapshots/ferra-tiny-skia.sha256 index 5caad7ab..657e0dd8 100644 --- a/examples/styling/snapshots/ferra-tiny-skia.sha256 +++ b/examples/styling/snapshots/ferra-tiny-skia.sha256 @@ -1 +1 @@ -e0ec3911121e303bdfe3956c72af423ec21a17a958768116ee452adcace02e15 \ No newline at end of file +840c1eff30f6dc63cf3e7f19e2cd0acd31b0b3eb2bf0773000aef5b9a46d9df6 \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 index 9c798964..1da1b8c7 100644 --- a/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256 @@ -1 +1 @@ -81e4f065fc985a2c5fc9d15fea941667e914dbc6fe7a5262dac5390955e34f67 \ No newline at end of file +7d4c6ae83e8436b1d4e850c82f19e97a911b4ce389a4ba75f8ea722ffc51329a \ No newline at end of file diff --git a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 index 76b632c1..98e9dbfd 100644 --- a/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/gruvbox_light-tiny-skia.sha256 @@ -1 +1 @@ -09cb020de17de0695c3a383972af3562e49d87dcfc5bcf8f1459b19f8874834a \ No newline at end of file +36ab94c5f69c09ef60feb4524e0a593d2670e345d71139b783796496bdcbceb0 \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 index b02de3c1..cf6fbeac 100644 --- a/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_dragon-tiny-skia.sha256 @@ -1 +1 @@ -491041848f77c6e9b70b7e677d0809bff5ceae783326f6dbdd10bdcd45eb56e2 \ No newline at end of file +262314758d1facbc16b4949c92ba58dd95a10bdf1fe85fa7aa336dcdf536ab85 \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 index 49bace10..b0e8b1d5 100644 --- a/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_lotus-tiny-skia.sha256 @@ -1 +1 @@ -ddc366fdf1127014a47d18a8914b6e9967eada10fae48a03b10c9428c589c51f \ No newline at end of file +fbafd69c60962465f4e0759fc72b3f5bb13895e85821273fff4b51ad1994e7ba \ No newline at end of file diff --git a/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 b/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 index 2f1b3050..9a502d0f 100644 --- a/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 +++ b/examples/styling/snapshots/kanagawa_wave-tiny-skia.sha256 @@ -1 +1 @@ -304163accbfcd947b5231beaeb4d8194aab02409df9e334862fe5eb79a835116 \ No newline at end of file +6a237b0387d6621c835521d560b1e56b2c63ca1ebca8256742b0afea3c71725c \ No newline at end of file diff --git a/examples/styling/snapshots/light-tiny-skia.sha256 b/examples/styling/snapshots/light-tiny-skia.sha256 index 0a1e8669..cd41d1b8 100644 --- a/examples/styling/snapshots/light-tiny-skia.sha256 +++ b/examples/styling/snapshots/light-tiny-skia.sha256 @@ -1 +1 @@ -b61b166bca3dce77002300e60ae778000ea00df5b5973f106ce58ce6d5e0b501 \ No newline at end of file +a1832dfc240eac78bafcdfdbe36fc66b35f984cf67d71adb265fc4f30d383e2b \ No newline at end of file diff --git a/examples/styling/snapshots/moonfly-tiny-skia.sha256 b/examples/styling/snapshots/moonfly-tiny-skia.sha256 index 21d299eb..f3c9d57d 100644 --- a/examples/styling/snapshots/moonfly-tiny-skia.sha256 +++ b/examples/styling/snapshots/moonfly-tiny-skia.sha256 @@ -1 +1 @@ -bc88452bb81a702a8c29c9dde933bf0bdb1723af1c910cb44e56180dc64270b5 \ No newline at end of file +82e617ffb6f5805014377e0b9094b91827de14fa919855d4c6443267291ca677 \ No newline at end of file diff --git a/examples/styling/snapshots/nightfly-tiny-skia.sha256 b/examples/styling/snapshots/nightfly-tiny-skia.sha256 index 90c3b78a..3745dd49 100644 --- a/examples/styling/snapshots/nightfly-tiny-skia.sha256 +++ b/examples/styling/snapshots/nightfly-tiny-skia.sha256 @@ -1 +1 @@ -140ca7cf98bec0d955678b5160e0ccb43d85a829eed62c54f09d5e0b1a401e6f \ No newline at end of file +3cae3ed606e1927ef9aaba7e498a54b62ea70d114f0011a048192a2743accbef \ No newline at end of file diff --git a/examples/styling/snapshots/nord-tiny-skia.sha256 b/examples/styling/snapshots/nord-tiny-skia.sha256 index aa36b9a7..52e996e5 100644 --- a/examples/styling/snapshots/nord-tiny-skia.sha256 +++ b/examples/styling/snapshots/nord-tiny-skia.sha256 @@ -1 +1 @@ -e8b2b050896d2b2cfd1c31b2c8773f74b2c23b94b3d94e8f16b8fb6604e8b2f2 \ No newline at end of file +8daec0d941ecc2eb52135b63a91936786ef2af48d56fba2d192e00438230ae0b \ No newline at end of file diff --git a/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 b/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 index 096bad4c..356e9b0b 100644 --- a/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 +++ b/examples/styling/snapshots/oxocarbon-tiny-skia.sha256 @@ -1 +1 @@ -d40514ab3f75e4aa08d8d21e197e5fa486dd0689a4e81027ae335e9abd2ea311 \ No newline at end of file +d0bd8d738130d56857e618efbd9e11b515aa0655e2edf8dc2326b8dabf54c490 \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 b/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 index 93ec5161..f8475616 100644 --- a/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_dark-tiny-skia.sha256 @@ -1 +1 @@ -3ea703ef5d769c6184777bee6caa71e49adc381e1a47f3241f03250ab27b6988 \ No newline at end of file +d1c06a7016554e03308c0a642ea0edf17e397b639aa9194c2314b0e32d8165ff \ No newline at end of file diff --git a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 index ce985f2c..213ee947 100644 --- a/examples/styling/snapshots/solarized_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/solarized_light-tiny-skia.sha256 @@ -1 +1 @@ -9af0d10bb6b71fae760d9993e7ba6f9431002a376c6c064ac0e0738499f4e359 \ No newline at end of file +c8596fa0d72e96e144de58953e7a8ef7c37b88625070642747769af1104a0050 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 index 99686307..4700021e 100644 --- a/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night-tiny-skia.sha256 @@ -1 +1 @@ -82a173e0c1b9c665fbf06de60acbb0523b7f9ab5af429d5ec29ce908f640d5ec \ No newline at end of file +c831821798f5fe38609a7fe854a3785942ae04750ed23936f32b33139126e195 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 index 300f2eac..a26fd224 100644 --- a/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_light-tiny-skia.sha256 @@ -1 +1 @@ -e2d049e13e1d88c9fd046803936c27e9a45809f133d8ea58d4731626594a87a3 \ No newline at end of file +26c9d551330f5dbe6680f1c9e8cdf3b6810c26c9de3b22a9a948eae16d5fa3d9 \ No newline at end of file diff --git a/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 b/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 index ed8f662b..27013156 100644 --- a/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 +++ b/examples/styling/snapshots/tokyo_night_storm-tiny-skia.sha256 @@ -1 +1 @@ -dfc3317f39c204b8509c1b8f7e8e1d9b0911bfc1a7bd5fbde822a7a5c6c54e12 \ No newline at end of file +5660044597f3ca9e10f5f704cfd4723e7c68f1d211c999063134aa8576227757 \ No newline at end of file diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 8fce8b1d..91c87ac0 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -556,20 +556,23 @@ pub fn primary(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.base, + palette.primary.base.text, palette.primary.base, is_checked, ), Status::Hovered { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.weak, + palette.primary.base.text, palette.primary.strong, is_checked, ), Status::Disabled { is_checked } => styled( palette.background.weak.color, palette.background.weak, + palette.primary.base.text, palette.background.strong, is_checked, ), @@ -582,20 +585,23 @@ pub fn secondary(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.base, + palette.background.base.text, palette.background.strong, is_checked, ), Status::Hovered { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.weak, + palette.background.base.text, palette.background.strong, is_checked, ), Status::Disabled { is_checked } => styled( palette.background.weak.color, palette.background.weak, + palette.background.base.text, palette.background.weak, is_checked, ), @@ -610,18 +616,21 @@ pub fn success(theme: &Theme, status: Status) -> Style { Status::Active { is_checked } => styled( palette.background.weak.color, palette.background.base, + palette.success.base.text, palette.success.base, is_checked, ), Status::Hovered { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.weak, + palette.success.base.text, palette.success.strong, is_checked, ), Status::Disabled { is_checked } => styled( palette.background.weak.color, palette.background.weak, + palette.success.base.text, palette.success.weak, is_checked, ), @@ -634,20 +643,23 @@ pub fn danger(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.base, + palette.danger.base.text, palette.danger.base, is_checked, ), Status::Hovered { is_checked } => styled( - palette.background.strongest.color, + palette.background.strong.color, palette.background.weak, + palette.danger.base.text, palette.danger.strong, is_checked, ), Status::Disabled { is_checked } => styled( palette.background.weak.color, palette.background.weak, + palette.danger.base.text, palette.danger.weak, is_checked, ), @@ -657,6 +669,7 @@ pub fn danger(theme: &Theme, status: Status) -> Style { fn styled( border_color: Color, base: palette::Pair, + icon_color: Color, accent: palette::Pair, is_checked: bool, ) -> Style { @@ -668,7 +681,7 @@ fn styled( Style { background: Background::Color(background.color), - icon_color: background.text, + icon_color, border: Border { radius: 2.0.into(), width: 1.0, diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index 517ff35d..4076d7f7 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -899,7 +899,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { let active = Style { text_color: palette.background.weak.text, background: palette.background.weak.color.into(), - placeholder_color: palette.background.strong.color, + placeholder_color: palette.secondary.base.color, handle_color: palette.background.weak.text, border: Border { radius: 2.0.into(), diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 01c4ef7c..61e78d50 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -2069,7 +2069,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { background: Some(palette.background.weak.color.into()), border: border::rounded(2), scroller: Scroller { - color: palette.background.strong.color, + color: palette.background.strongest.color, border: border::rounded(2), }, }; diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index 7f6e6795..41e4bd64 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -556,7 +556,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { if is_toggled { palette.primary.base.color } else { - palette.background.strongest.color + palette.background.strong.color } } Status::Disabled => palette.background.weak.color,