summaryrefslogtreecommitdiffstats
path: root/examples/styling
diff options
context:
space:
mode:
authorLibravatar Kaiden42 <gitlab@tinysn.com>2020-08-19 01:30:46 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-08-25 10:42:53 +0200
commitf0257949856a9a7edf747684925f85d2ce811198 (patch)
tree82a4d93f2a467078c0b4e16932551a5ef5a02d13 /examples/styling
parent1b980bc6e823b7e049f5bb86d039e3b7db5ce353 (diff)
downloadiced-f0257949856a9a7edf747684925f85d2ce811198.tar.gz
iced-f0257949856a9a7edf747684925f85d2ce811198.tar.bz2
iced-f0257949856a9a7edf747684925f85d2ce811198.zip
Update styling example
Also run `cargo fmt`
Diffstat (limited to 'examples/styling')
-rw-r--r--examples/styling/src/main.rs47
1 files changed, 19 insertions, 28 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index 0c2cfc57..dcbc2744 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -241,16 +241,14 @@ mod style {
}
mod light {
- use iced::{button, Background, Color, Vector};
+ use iced::{button, Color, Vector};
pub struct Button;
impl button::StyleSheet for Button {
fn active(&self) -> button::Style {
button::Style {
- background: Some(Background::Color(Color::from_rgb(
- 0.11, 0.42, 0.87,
- ))),
+ background: Color::from_rgb(0.11, 0.42, 0.87).into(),
border_radius: 12,
shadow_offset: Vector::new(1.0, 1.0),
text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
@@ -271,7 +269,7 @@ mod style {
mod dark {
use iced::{
button, checkbox, container, progress_bar, radio, rule, scrollable,
- slider, text_input, Background, Color,
+ slider, text_input, Color,
};
const SURFACE: Color = Color::from_rgb(
@@ -303,10 +301,8 @@ mod style {
impl container::StyleSheet for Container {
fn style(&self) -> container::Style {
container::Style {
- background: Some(Background::Color(Color::from_rgb8(
- 0x36, 0x39, 0x3F,
- ))),
- text_color: Some(Color::WHITE),
+ background: Color::from_rgb8(0x36, 0x39, 0x3F).into(),
+ text_color: Color::WHITE.into(),
..container::Style::default()
}
}
@@ -317,7 +313,7 @@ mod style {
impl radio::StyleSheet for Radio {
fn active(&self) -> radio::Style {
radio::Style {
- background: Background::Color(SURFACE),
+ background: SURFACE.into(),
dot_color: ACTIVE,
border_width: 1,
border_color: ACTIVE,
@@ -326,7 +322,7 @@ mod style {
fn hovered(&self) -> radio::Style {
radio::Style {
- background: Background::Color(Color { a: 0.5, ..SURFACE }),
+ background: Color { a: 0.5, ..SURFACE }.into(),
..self.active()
}
}
@@ -337,7 +333,7 @@ mod style {
impl text_input::StyleSheet for TextInput {
fn active(&self) -> text_input::Style {
text_input::Style {
- background: Background::Color(SURFACE),
+ background: SURFACE.into(),
border_radius: 2,
border_width: 0,
border_color: Color::TRANSPARENT,
@@ -378,7 +374,7 @@ mod style {
impl button::StyleSheet for Button {
fn active(&self) -> button::Style {
button::Style {
- background: Some(Background::Color(ACTIVE)),
+ background: ACTIVE.into(),
border_radius: 3,
text_color: Color::WHITE,
..button::Style::default()
@@ -387,7 +383,7 @@ mod style {
fn hovered(&self) -> button::Style {
button::Style {
- background: Some(Background::Color(HOVERED)),
+ background: HOVERED.into(),
text_color: Color::WHITE,
..self.active()
}
@@ -407,7 +403,7 @@ mod style {
impl scrollable::StyleSheet for Scrollable {
fn active(&self) -> scrollable::Scrollbar {
scrollable::Scrollbar {
- background: Some(Background::Color(SURFACE)),
+ background: SURFACE.into(),
border_radius: 2,
border_width: 0,
border_color: Color::TRANSPARENT,
@@ -424,10 +420,7 @@ mod style {
let active = self.active();
scrollable::Scrollbar {
- background: Some(Background::Color(Color {
- a: 0.5,
- ..SURFACE
- })),
+ background: Color { a: 0.5, ..SURFACE }.into(),
scroller: scrollable::Scroller {
color: HOVERED,
..active.scroller
@@ -494,8 +487,8 @@ mod style {
impl progress_bar::StyleSheet for ProgressBar {
fn style(&self) -> progress_bar::Style {
progress_bar::Style {
- background: Background::Color(SURFACE),
- bar: Background::Color(ACTIVE),
+ background: SURFACE.into(),
+ bar: ACTIVE.into(),
border_radius: 10,
}
}
@@ -506,11 +499,8 @@ mod style {
impl checkbox::StyleSheet for Checkbox {
fn active(&self, is_checked: bool) -> checkbox::Style {
checkbox::Style {
- background: Background::Color(if is_checked {
- ACTIVE
- } else {
- SURFACE
- }),
+ background: if is_checked { ACTIVE } else { SURFACE }
+ .into(),
checkmark_color: Color::WHITE,
border_radius: 2,
border_width: 1,
@@ -520,10 +510,11 @@ mod style {
fn hovered(&self, is_checked: bool) -> checkbox::Style {
checkbox::Style {
- background: Background::Color(Color {
+ background: Color {
a: 0.8,
..if is_checked { ACTIVE } else { SURFACE }
- }),
+ }
+ .into(),
..self.active(is_checked)
}
}