Skip to content

Commit

Permalink
Theme for iced scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Jun 7, 2024
1 parent 0506cc0 commit 7a4ea59
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion neothesia/src/scene/menu_scene/iced_menu/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Page for SettingsPage {
.width(Length::Fill)
.align_items(Alignment::Center);

let column = iced_widget::scrollable(body);
let column = iced_widget::scrollable(body).style(theme::scrollable());

Layout::new()
.body(column)
Expand Down
39 changes: 39 additions & 0 deletions neothesia/src/scene/menu_scene/iced_menu/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,42 @@ impl iced_style::toggler::StyleSheet for TogglerStyle {
}
}
}

pub fn scrollable() -> iced_style::theme::Scrollable {
iced_style::theme::Scrollable::Custom(Box::new(ScrollableStyle))
}

struct ScrollableStyle;

impl iced_style::scrollable::StyleSheet for ScrollableStyle {
type Style = iced_style::Theme;

fn active(&self, style: &Self::Style) -> iced_style::scrollable::Appearance {
self.hovered(style, true)
}

fn hovered(
&self,
_style: &Self::Style,
is_mouse_over_scrollbar: bool,
) -> iced_style::scrollable::Appearance {
iced_style::scrollable::Appearance {
container: iced_style::container::Appearance::default(),
scrollbar: iced_style::scrollable::Scrollbar {
background: Some(iced_core::Background::Color(Color::from_rgba8(
37, 35, 42, 1.0,
))),
border: Border::with_radius(10.0),
scroller: iced_style::scrollable::Scroller {
color: if is_mouse_over_scrollbar {
Color::from_rgba8(87, 81, 101, 1.0)
} else {
Color::from_rgba8(74, 68, 88, 1.0)
},
border: Border::with_radius(10.0),
},
},
gap: None,
}
}
}

0 comments on commit 7a4ea59

Please sign in to comment.