summaryrefslogtreecommitdiffstats
path: root/style/src/scrollable.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-12 19:24:09 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-12 19:24:09 +0100
commit0eaaeaa517a00765045de155bb1de01c2d8f553f (patch)
treebf6d2d909bb9d2b1c9aae623775573d6e7df8c8c /style/src/scrollable.rs
parent0f920e0435932c0b6927c771424b2ba495ddb46e (diff)
downloadiced-0eaaeaa517a00765045de155bb1de01c2d8f553f.tar.gz
iced-0eaaeaa517a00765045de155bb1de01c2d8f553f.tar.bz2
iced-0eaaeaa517a00765045de155bb1de01c2d8f553f.zip
Simplify `scrollable` styling API
Diffstat (limited to 'style/src/scrollable.rs')
-rw-r--r--style/src/scrollable.rs55
1 files changed, 18 insertions, 37 deletions
diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs
index 3daa8886..d2348510 100644
--- a/style/src/scrollable.rs
+++ b/style/src/scrollable.rs
@@ -1,6 +1,18 @@
//! Change the appearance of a scrollable.
+use crate::container;
use crate::core::{Background, Border, Color};
+/// The appearance of a scrolable.
+#[derive(Debug, Clone, Copy)]
+pub struct Appearance {
+ /// The [`container::Appearance`] of a scrollable.
+ pub container: container::Appearance,
+ /// The [`Scrollbar`] appearance.
+ pub scrollbar: Scrollbar,
+ /// The [`Background`] of the gap between a horizontal and vertical scrollbar.
+ pub gap: Option<Background>,
+}
+
/// The appearance of the scrollbar of a scrollable.
#[derive(Debug, Clone, Copy)]
pub struct Scrollbar {
@@ -21,54 +33,23 @@ pub struct Scroller {
pub border: Border,
}
-/// The appearance of a scrolable.
-#[derive(Debug, Clone, Copy)]
-pub struct Appearance {
- /// The [`Background`] of a scrollable.
- pub background: Option<Background>,
- /// The [`Background`] of the gap between a horizontal and vertical scrollbar.
- pub gap: Option<Background>,
-}
-
/// A set of rules that dictate the style of a scrollable.
pub trait StyleSheet {
/// The supported style of the [`StyleSheet`].
type Style: Default;
- /// Produces the style of the scrollable container.
- fn appearance(&self, style: &Self::Style) -> Appearance;
-
- /// Produces the style of an active scrollbar.
- fn active(&self, style: &Self::Style) -> Scrollbar;
+ /// Produces the [`Appearance`] of an active scrollable.
+ fn active(&self, style: &Self::Style) -> Appearance;
- /// Produces the style of a scrollbar when the scrollable is being hovered.
+ /// Produces the [`Appearance`] of a scrollable when it is being hovered.
fn hovered(
&self,
style: &Self::Style,
is_mouse_over_scrollbar: bool,
- ) -> Scrollbar;
+ ) -> Appearance;
- /// Produces the style of a scrollbar that is being dragged.
- fn dragging(&self, style: &Self::Style) -> Scrollbar {
+ /// Produces the [`Appearance`] of a scrollable when it is being dragged.
+ fn dragging(&self, style: &Self::Style) -> Appearance {
self.hovered(style, true)
}
-
- /// Produces the style of an active horizontal scrollbar.
- fn active_horizontal(&self, style: &Self::Style) -> Scrollbar {
- self.active(style)
- }
-
- /// Produces the style of a horizontal scrollbar when the scrollable is being hovered.
- fn hovered_horizontal(
- &self,
- style: &Self::Style,
- is_mouse_over_scrollbar: bool,
- ) -> Scrollbar {
- self.hovered(style, is_mouse_over_scrollbar)
- }
-
- /// Produces the style of a horizontal scrollbar that is being dragged.
- fn dragging_horizontal(&self, style: &Self::Style) -> Scrollbar {
- self.hovered_horizontal(style, true)
- }
}