Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added scrollable style focused to be displayed when mouse is over the scrollable area #1669

Merged
merged 8 commits into from
Mar 27, 2023
4 changes: 4 additions & 0 deletions native/src/widget/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ pub fn draw<Renderer>(
theme.dragging(style)
} else if mouse_over_y_scrollbar {
theme.hovered(style)
} else if mouse_over_scrollable {
theme.focused(style)
} else {
theme.active(style)
};
Expand All @@ -869,6 +871,8 @@ pub fn draw<Renderer>(
theme.dragging_horizontal(style)
} else if mouse_over_x_scrollbar {
theme.hovered_horizontal(style)
} else if mouse_over_scrollable {
theme.focused_horizontal(style)
} else {
theme.active_horizontal(style)
};
Expand Down
10 changes: 10 additions & 0 deletions style/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ pub trait StyleSheet {
self.hovered(style)
}

/// Produces the style of a scrollbar when mouse is over the scrollable area.
fn focused(&self, style: &Self::Style) -> Scrollbar {
self.active(style)
}

/// Produces the style of an active horizontal scrollbar.
fn active_horizontal(&self, style: &Self::Style) -> Scrollbar {
self.active(style)
Expand All @@ -59,4 +64,9 @@ pub trait StyleSheet {
fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar {
self.hovered_horizontal(style)
}

/// Produces the style of a horizontal scrollbar when mouse is over the scrollable area.
fn focused_horizontal(&self, style: &Self::Style) -> Scrollbar {
self.active_horizontal(style)
}
}
17 changes: 17 additions & 0 deletions style/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,13 @@ impl scrollable::StyleSheet for Theme {
}
}

fn focused(&self, style: &Self::Style) -> scrollable::Scrollbar {
match style {
Scrollable::Default => self.active(style),
Scrollable::Custom(custom) => custom.focused(self),
}
}

fn active_horizontal(&self, style: &Self::Style) -> scrollable::Scrollbar {
match style {
Scrollable::Default => self.active(style),
Expand All @@ -958,6 +965,16 @@ impl scrollable::StyleSheet for Theme {
Scrollable::Custom(custom) => custom.dragging_horizontal(self),
}
}

fn focused_horizontal(
&self,
style: &Self::Style,
) -> scrollable::Scrollbar {
match style {
Scrollable::Default => self.active_horizontal(style),
Scrollable::Custom(custom) => custom.focused_horizontal(self),
}
}
}

/// The style of text.
Expand Down