summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 05:31:25 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 05:31:25 +0200
commit5a39dad506a1614fd0ccacb1f56e83acbaf4961a (patch)
treecefe62d150c0178b31f733a17e32a1ac49be609c /style
parent822a3cd04f9edeb887d85164b0b3e556c3fde6bb (diff)
downloadiced-5a39dad506a1614fd0ccacb1f56e83acbaf4961a.tar.gz
iced-5a39dad506a1614fd0ccacb1f56e83acbaf4961a.tar.bz2
iced-5a39dad506a1614fd0ccacb1f56e83acbaf4961a.zip
Tweak styling of `Slider` and improve contrast of `Background`
Diffstat (limited to 'style')
-rw-r--r--style/src/theme.rs10
-rw-r--r--style/src/theme/palette.rs24
2 files changed, 16 insertions, 18 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 1ddf97c3..cf939824 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -31,7 +31,7 @@ impl Theme {
impl Default for Theme {
fn default() -> Self {
- Self::Dark
+ Self::Light
}
}
@@ -145,10 +145,10 @@ impl slider::StyleSheet for Theme {
};
slider::Style {
- rail_colors: (palette.background.strong, palette.background.base),
+ rail_colors: (palette.primary.base, palette.background.base),
handle: slider::Handle {
color: palette.background.base,
- border_color: palette.border,
+ border_color: palette.primary.base,
..handle
},
}
@@ -160,7 +160,7 @@ impl slider::StyleSheet for Theme {
slider::Style {
handle: slider::Handle {
- color: palette.background.weak,
+ color: palette.primary.weak,
..active.handle
},
..active
@@ -173,7 +173,7 @@ impl slider::StyleSheet for Theme {
slider::Style {
handle: slider::Handle {
- color: palette.background.strong,
+ color: palette.primary.base,
..active.handle
},
..active
diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs
index 0394700b..acc147ed 100644
--- a/style/src/theme/palette.rs
+++ b/style/src/theme/palette.rs
@@ -63,7 +63,6 @@ pub struct Extended {
pub primary: Group,
pub success: Group,
pub danger: Group,
- pub border: Color,
}
lazy_static! {
@@ -91,7 +90,6 @@ impl Extended {
palette.background,
palette.text,
),
- border: mix(palette.background, palette.text, 0.7),
}
}
}
@@ -107,8 +105,8 @@ impl Background {
pub fn new(base: Color, text: Color) -> Self {
Self {
base,
- weak: muted(base, 0.1),
- strong: muted(base, 0.2),
+ weak: mix(base, text, 0.15),
+ strong: mix(base, text, 0.25),
text,
}
}
@@ -142,7 +140,7 @@ fn muted(color: Color, amount: f32) -> Color {
let mut hsl = to_hsl(color);
hsl.lightness = if is_dark(color) {
- let delta = amount * (1.0 - hsl.lightness).powi(7);
+ let delta = amount * (1.0 - hsl.lightness).powi(5);
hsl.lightness + delta
} else {
let delta = amount * hsl.lightness.powi(5);
@@ -164,14 +162,6 @@ fn darken(color: Color, amount: f32) -> Color {
from_hsl(hsl)
}
-fn mix(a: Color, b: Color, factor: f32) -> Color {
- let a_lin = Srgb::from(a).into_linear();
- let b_lin = Srgb::from(b).into_linear();
-
- let mixed = a_lin.mix(&b_lin, factor);
- Srgb::from_linear(mixed).into()
-}
-
fn lighten(color: Color, amount: f32) -> Color {
let mut hsl = to_hsl(color);
@@ -184,6 +174,14 @@ fn lighten(color: Color, amount: f32) -> Color {
from_hsl(hsl)
}
+fn mix(a: Color, b: Color, factor: f32) -> Color {
+ let a_lin = Srgb::from(a).into_linear();
+ let b_lin = Srgb::from(b).into_linear();
+
+ let mixed = a_lin.mix(&b_lin, factor);
+ Srgb::from_linear(mixed).into()
+}
+
fn readable(background: Color, text: Color) -> Color {
if is_readable(background, text) {
text