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] 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,