summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-02-28 10:34:39 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-28 10:34:39 +0100
commitaf9fb367f361a564aa2a9fc11333816566eb5d55 (patch)
tree5febf78005da8ecbe8419088d9a8359878deb144
parentd03786792995d9dcb1939a7d2c6c8150014c8b85 (diff)
parent49d900d54bd6ba14fd202887083a6420d9fa6c37 (diff)
downloadiced-af9fb367f361a564aa2a9fc11333816566eb5d55.tar.gz
iced-af9fb367f361a564aa2a9fc11333816566eb5d55.tar.bz2
iced-af9fb367f361a564aa2a9fc11333816566eb5d55.zip
Merge pull request #2303 from GyulyVGC/master
[Minor Fix] Scrollbar style when cursor is over scrollable area
-rw-r--r--widget/src/scrollable.rs32
1 files changed, 17 insertions, 15 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index c4873648..f736d92e 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -907,7 +907,15 @@ pub fn draw<Theme, Renderer>(
theme.active(style)
};
- let idle_scrollbar = theme.active(style).scrollbar;
+ let scrollbar_style = |is_dragging: bool, mouse_over_scrollbar: bool| {
+ if is_dragging {
+ theme.dragging(style).scrollbar
+ } else if cursor_over_scrollable.is_some() {
+ theme.hovered(style, mouse_over_scrollbar).scrollbar
+ } else {
+ theme.active(style).scrollbar
+ }
+ };
container::draw_background(
renderer,
@@ -984,13 +992,10 @@ pub fn draw<Theme, Renderer>(
if let Some(scrollbar) = scrollbars.y {
draw_scrollbar(
renderer,
- if mouse_over_y_scrollbar
- || state.y_scroller_grabbed_at.is_some()
- {
- appearance.scrollbar
- } else {
- idle_scrollbar
- },
+ scrollbar_style(
+ state.y_scroller_grabbed_at.is_some(),
+ mouse_over_y_scrollbar,
+ ),
&scrollbar,
);
}
@@ -998,13 +1003,10 @@ pub fn draw<Theme, Renderer>(
if let Some(scrollbar) = scrollbars.x {
draw_scrollbar(
renderer,
- if mouse_over_x_scrollbar
- || state.x_scroller_grabbed_at.is_some()
- {
- appearance.scrollbar
- } else {
- idle_scrollbar
- },
+ scrollbar_style(
+ state.x_scroller_grabbed_at.is_some(),
+ mouse_over_x_scrollbar,
+ ),
&scrollbar,
);
}