summaryrefslogtreecommitdiffstats
path: root/examples/scrollable/src/style.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 03:26:48 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 03:26:48 +0200
commitde21a651c0616307bb6bfd36da1a06119e629b10 (patch)
treef565bfa3e75d57f6a4be1369d25dfd701b51c4ea /examples/scrollable/src/style.rs
parentce53d3933c860cd958636cce415ac97c04aee746 (diff)
downloadiced-de21a651c0616307bb6bfd36da1a06119e629b10.tar.gz
iced-de21a651c0616307bb6bfd36da1a06119e629b10.tar.bz2
iced-de21a651c0616307bb6bfd36da1a06119e629b10.zip
Implement theme styling for `Scrollable`
Diffstat (limited to 'examples/scrollable/src/style.rs')
-rw-r--r--examples/scrollable/src/style.rs79
1 files changed, 2 insertions, 77 deletions
diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs
index 64922ae4..c2c48470 100644
--- a/examples/scrollable/src/style.rs
+++ b/examples/scrollable/src/style.rs
@@ -1,4 +1,4 @@
-use iced::{container, scrollable};
+use iced::container;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Theme {
@@ -25,17 +25,8 @@ impl<'a> From<Theme> for Box<dyn container::StyleSheet + 'a> {
}
}
-impl<'a> From<Theme> for Box<dyn scrollable::StyleSheet + 'a> {
- fn from(theme: Theme) -> Self {
- match theme {
- Theme::Light => Default::default(),
- Theme::Dark => dark::Scrollable.into(),
- }
- }
-}
-
mod dark {
- use iced::{container, scrollable, Color};
+ use iced::{container, Color};
const BACKGROUND: Color = Color::from_rgb(
0x36 as f32 / 255.0,
@@ -43,24 +34,6 @@ mod dark {
0x3F as f32 / 255.0,
);
- const ACCENT: Color = Color::from_rgb(
- 0x6F as f32 / 255.0,
- 0xFF as f32 / 255.0,
- 0xE9 as f32 / 255.0,
- );
-
- const SCROLLBAR: Color = Color::from_rgb(
- 0x2E as f32 / 255.0,
- 0x33 as f32 / 255.0,
- 0x38 as f32 / 255.0,
- );
-
- const SCROLLER: Color = Color::from_rgb(
- 0x20 as f32 / 255.0,
- 0x22 as f32 / 255.0,
- 0x25 as f32 / 255.0,
- );
-
pub struct Container;
impl container::StyleSheet for Container {
@@ -76,52 +49,4 @@ mod dark {
}
}
}
-
- pub struct Scrollable;
-
- impl scrollable::StyleSheet for Scrollable {
- fn active(&self) -> scrollable::Scrollbar {
- scrollable::Scrollbar {
- background: Color {
- a: 0.8,
- ..SCROLLBAR
- }
- .into(),
- border_radius: 2.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- scroller: scrollable::Scroller {
- color: Color { a: 0.7, ..SCROLLER },
- border_radius: 2.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- },
- }
- }
-
- fn hovered(&self) -> scrollable::Scrollbar {
- let active = self.active();
-
- scrollable::Scrollbar {
- background: SCROLLBAR.into(),
- scroller: scrollable::Scroller {
- color: SCROLLER,
- ..active.scroller
- },
- ..active
- }
- }
-
- fn dragging(&self) -> scrollable::Scrollbar {
- let hovered = self.hovered();
-
- scrollable::Scrollbar {
- scroller: scrollable::Scroller {
- color: ACCENT,
- ..hovered.scroller
- },
- ..hovered
- }
- }
- }
}