aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPolesznyák Márk <contact@pml68.dev>2025-11-28 12:19:51 +0100
committerPolesznyák Márk <contact@pml68.dev>2025-11-30 01:58:04 +0100
commit9eb4a16495921ef65e3fb27277e64e8e9b7b2fd1 (patch)
treec7700a1ab1246c49911a09b3cbbd43b6416d21a1
parentfeat!: combine `Primary`, `Secondary`, `Tertiary` and `Error` (diff)
downloadiced_material-9eb4a16495921ef65e3fb27277e64e8e9b7b2fd1.tar.gz
chore: update as necessary for upstream iced changes
-rw-r--r--examples/styling.rs7
-rw-r--r--src/menu.rs3
-rw-r--r--src/scrollable.rs78
-rw-r--r--src/toggler.rs25
4 files changed, 82 insertions, 31 deletions
diff --git a/examples/styling.rs b/examples/styling.rs
index 4ed643e..37a613d 100644
--- a/examples/styling.rs
+++ b/examples/styling.rs
@@ -118,7 +118,8 @@ impl Styling {
.width(Fill)
.into()
},
- checkbox("Use system theme", self.system_theme)
+ checkbox(self.system_theme)
+ .label("Use system theme")
.on_toggle(Message::SystemTheme)
]
.spacing(10)
@@ -153,10 +154,12 @@ impl Styling {
column!["Scroll me!", space::vertical().height(800), "You did it!"]
.padding(10),
)
+ .auto_scroll(true)
.width(Fill)
.height(100);
- let checkbox = checkbox("Check me!", self.checkbox_value)
+ let checkbox = checkbox(self.checkbox_value)
+ .label("Check me!")
.on_toggle(Message::CheckboxToggled);
let toggler = toggler(self.toggler_value)
diff --git a/src/menu.rs b/src/menu.rs
index 4741ecd..226955f 100644
--- a/src/menu.rs
+++ b/src/menu.rs
@@ -1,4 +1,4 @@
-use iced_widget::core::{Background, border};
+use iced_widget::core::{Background, Shadow, border};
use iced_widget::overlay::menu::{Catalog, Style, StyleFn};
use super::Theme;
@@ -29,5 +29,6 @@ pub fn default(theme: &Theme) -> Style {
HOVERED_LAYER_OPACITY,
)),
selected_text_color: colors.text,
+ shadow: Shadow::default(),
}
}
diff --git a/src/scrollable.rs b/src/scrollable.rs
index f7bed54..0277ea8 100644
--- a/src/scrollable.rs
+++ b/src/scrollable.rs
@@ -1,6 +1,6 @@
-use iced_widget::core::{Background, Border, border};
+use iced_widget::core::{Background, Border, Shadow, border};
use iced_widget::scrollable::{
- Catalog, Rail, Scroller, Status, Style, StyleFn,
+ AutoScroll, Catalog, Rail, Scroller, Status, Style, StyleFn,
};
use super::Theme;
@@ -26,7 +26,7 @@ impl Catalog for Theme {
pub fn default(theme: &Theme, status: Status) -> Style {
let surface = theme.colors().surface;
- let active = Rail {
+ let active_rail = Rail {
background: None,
scroller: Scroller {
color: surface.text,
@@ -35,20 +35,35 @@ pub fn default(theme: &Theme, status: Status) -> Style {
border: Border::default(),
};
- let disabled = Rail {
+ let disabled_rail = Rail {
background: Some(Background::Color(disabled_container(surface.text))),
scroller: Scroller {
color: disabled_text(surface.text),
border: border::rounded(400),
},
- ..active
+ ..active_rail
+ };
+
+ let active_auto_scroll = AutoScroll {
+ background: surface.color.into(),
+ border: border::rounded(500).width(1).color(surface.text),
+ icon: surface.text,
+ shadow: Shadow::default(),
+ };
+
+ let disabled_auto_scroll = AutoScroll {
+ background: disabled_container(surface.text).into(),
+ border: border::rounded(400),
+ icon: disabled_text(surface.text),
+ shadow: Shadow::default(),
};
let style = Style {
container: surface_container(theme),
- vertical_rail: active,
- horizontal_rail: active,
+ vertical_rail: active_rail,
+ horizontal_rail: active_rail,
gap: None,
+ auto_scroll: active_auto_scroll,
};
match status {
@@ -57,14 +72,21 @@ pub fn default(theme: &Theme, status: Status) -> Style {
is_vertical_scrollbar_disabled,
} => Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
+ } else {
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
} else {
- active
+ active_auto_scroll
},
..style
},
@@ -83,23 +105,30 @@ pub fn default(theme: &Theme, status: Status) -> Style {
),
border: border::rounded(400),
},
- ..active
+ ..active_rail
};
Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_horizontal_scrollbar_hovered {
hovered_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_vertical_scrollbar_hovered {
hovered_rail
} else {
- active
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
+ } else {
+ active_auto_scroll
},
..style
}
@@ -119,23 +148,30 @@ pub fn default(theme: &Theme, status: Status) -> Style {
),
border: border::rounded(400),
},
- ..active
+ ..active_rail
};
Style {
horizontal_rail: if is_horizontal_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_horizontal_scrollbar_dragged {
dragged_rail
} else {
- active
+ active_rail
},
vertical_rail: if is_vertical_scrollbar_disabled {
- disabled
+ disabled_rail
} else if is_vertical_scrollbar_dragged {
dragged_rail
} else {
- active
+ active_rail
+ },
+ auto_scroll: if is_vertical_scrollbar_disabled
+ && is_horizontal_scrollbar_disabled
+ {
+ disabled_auto_scroll
+ } else {
+ active_auto_scroll
},
..style
}
diff --git a/src/toggler.rs b/src/toggler.rs
index 61e11a7..25730a2 100644
--- a/src/toggler.rs
+++ b/src/toggler.rs
@@ -29,7 +29,7 @@ pub fn styled(
background_border_width: if border.is_some() { 2.0 } else { 0.0 },
background_border_color: border.unwrap_or(Color::TRANSPARENT),
foreground,
- foreground_border_width: 0.0,
+ foreground_border_width: 2.0,
foreground_border_color: Color::TRANSPARENT,
text_color: Some(text_color),
}
@@ -68,11 +68,22 @@ pub fn default(theme: &Theme, status: Status) -> Style {
)
}
}
- Status::Disabled => styled(
- disabled_container(surface.container.highest),
- disabled_text(surface.text),
- surface.text,
- Some(disabled_text(surface.text)),
- ),
+ Status::Disabled { is_toggled } => {
+ if is_toggled {
+ styled(
+ disabled_container(surface.text),
+ disabled_text(surface.color),
+ surface.text,
+ None,
+ )
+ } else {
+ styled(
+ disabled_container(surface.container.highest),
+ disabled_text(surface.text),
+ surface.text,
+ Some(disabled_text(surface.text)),
+ )
+ }
+ }
}
}