Skip to content

Commit

Permalink
update scrollbar styling
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Feb 12, 2024
1 parent a58b0d8 commit 441da66
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 64 deletions.
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 40 additions & 33 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ impl overlay::menu::StyleSheet for Theme {
background: p.middleground.into(),
border,
selected_text_color: p.text,
selected_background: Color {
a: 0.5,
..p.accent
}
.into(),
selected_background: Color { a: 0.5, ..p.accent }.into(),
}
}
}
Expand Down Expand Up @@ -468,7 +464,7 @@ pub enum Scrollable {
impl scrollable::StyleSheet for Theme {
type Style = Scrollable;

fn active(&self, style: &Self::Style) -> scrollable::Scrollbar {
fn active(&self, style: &Self::Style) -> scrollable::Appearance {
let p = self.inner();

let border = Border {
Expand All @@ -477,14 +473,18 @@ impl scrollable::StyleSheet for Theme {
radius: 3.0.into(),
};

let from_appearance = |c: Color, d: Color| scrollable::Scrollbar {
background: Some(Background::Color(c)),
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
..border
let from_appearance = |c: Color, d: Color| scrollable::Appearance {
gap: None,
scrollbar: scrollable::Scrollbar {
background: Some(Background::Color(c)),
scroller: scrollable::Scroller { color: d, border },
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
..border
},
},
scroller: scrollable::Scroller { color: d, border },
container: container::Appearance::default(),
};

let color = (p.middleground, p.foreground);
Expand All @@ -495,38 +495,45 @@ impl scrollable::StyleSheet for Theme {
}
}

fn hovered(&self, style: &Self::Style, is_mouse_over_scrollbar: bool) -> scrollable::Scrollbar {
fn hovered(
&self,
style: &Self::Style,
is_mouse_over_scrollbar: bool,
) -> scrollable::Appearance {
let p = self.inner();

scrollable::Scrollbar {
scroller: scrollable::Scroller {
color: if is_mouse_over_scrollbar {
Color { a: 0.5, ..p.accent }
} else {
self.active(style).scroller.color
},
border: Border {
scrollable::Appearance {
gap: None,
scrollbar: scrollable::Scrollbar {
scroller: scrollable::Scroller {
color: if is_mouse_over_scrollbar {
Color {
a: 0.75,
..p.accent
}
Color { a: 0.5, ..p.accent }
} else {
self.active(style).scroller.border.color
self.active(style).scrollbar.scroller.color
},
width: BORDER_WIDTH,
radius: 3.0.into(),
border: Border {
color: if is_mouse_over_scrollbar {
Color { a: 0.75, ..p.accent }
} else {
self.active(style).scrollbar.border.color
},
width: BORDER_WIDTH,
radius: 3.0.into(),
},
..self.active(style).scrollbar.scroller
},
..self.active(style).scrollbar
},
..self.active(style)
}
}

fn dragging(&self, style: &Self::Style) -> scrollable::Scrollbar {
fn dragging(&self, style: &Self::Style) -> scrollable::Appearance {
let hovered = self.hovered(style, true);

scrollable::Scrollbar {
scroller: scrollable::Scroller { ..hovered.scroller },
scrollable::Appearance {
scrollbar: scrollable::Scrollbar {
..hovered.scrollbar
},
..hovered
}
}
Expand Down

0 comments on commit 441da66

Please sign in to comment.