Merge pull request #487 from Kaiden42/background
Implement `From<Color>` for `Option<Background>`
This commit is contained in:
commit
56273c5a3c
|
@ -13,3 +13,9 @@ impl From<Color> for Background {
|
||||||
Background::Color(color)
|
Background::Color(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Color> for Option<Background> {
|
||||||
|
fn from(color: Color) -> Self {
|
||||||
|
Some(Background::from(color))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -241,16 +241,14 @@ mod style {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod light {
|
mod light {
|
||||||
use iced::{button, Background, Color, Vector};
|
use iced::{button, Color, Vector};
|
||||||
|
|
||||||
pub struct Button;
|
pub struct Button;
|
||||||
|
|
||||||
impl button::StyleSheet for Button {
|
impl button::StyleSheet for Button {
|
||||||
fn active(&self) -> button::Style {
|
fn active(&self) -> button::Style {
|
||||||
button::Style {
|
button::Style {
|
||||||
background: Some(Background::Color(Color::from_rgb(
|
background: Color::from_rgb(0.11, 0.42, 0.87).into(),
|
||||||
0.11, 0.42, 0.87,
|
|
||||||
))),
|
|
||||||
border_radius: 12,
|
border_radius: 12,
|
||||||
shadow_offset: Vector::new(1.0, 1.0),
|
shadow_offset: Vector::new(1.0, 1.0),
|
||||||
text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
|
text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
|
||||||
|
@ -271,7 +269,7 @@ mod style {
|
||||||
mod dark {
|
mod dark {
|
||||||
use iced::{
|
use iced::{
|
||||||
button, checkbox, container, progress_bar, radio, rule, scrollable,
|
button, checkbox, container, progress_bar, radio, rule, scrollable,
|
||||||
slider, text_input, Background, Color,
|
slider, text_input, Color,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SURFACE: Color = Color::from_rgb(
|
const SURFACE: Color = Color::from_rgb(
|
||||||
|
@ -303,10 +301,8 @@ mod style {
|
||||||
impl container::StyleSheet for Container {
|
impl container::StyleSheet for Container {
|
||||||
fn style(&self) -> container::Style {
|
fn style(&self) -> container::Style {
|
||||||
container::Style {
|
container::Style {
|
||||||
background: Some(Background::Color(Color::from_rgb8(
|
background: Color::from_rgb8(0x36, 0x39, 0x3F).into(),
|
||||||
0x36, 0x39, 0x3F,
|
text_color: Color::WHITE.into(),
|
||||||
))),
|
|
||||||
text_color: Some(Color::WHITE),
|
|
||||||
..container::Style::default()
|
..container::Style::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +313,7 @@ mod style {
|
||||||
impl radio::StyleSheet for Radio {
|
impl radio::StyleSheet for Radio {
|
||||||
fn active(&self) -> radio::Style {
|
fn active(&self) -> radio::Style {
|
||||||
radio::Style {
|
radio::Style {
|
||||||
background: Background::Color(SURFACE),
|
background: SURFACE.into(),
|
||||||
dot_color: ACTIVE,
|
dot_color: ACTIVE,
|
||||||
border_width: 1,
|
border_width: 1,
|
||||||
border_color: ACTIVE,
|
border_color: ACTIVE,
|
||||||
|
@ -326,7 +322,7 @@ mod style {
|
||||||
|
|
||||||
fn hovered(&self) -> radio::Style {
|
fn hovered(&self) -> radio::Style {
|
||||||
radio::Style {
|
radio::Style {
|
||||||
background: Background::Color(Color { a: 0.5, ..SURFACE }),
|
background: Color { a: 0.5, ..SURFACE }.into(),
|
||||||
..self.active()
|
..self.active()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +333,7 @@ mod style {
|
||||||
impl text_input::StyleSheet for TextInput {
|
impl text_input::StyleSheet for TextInput {
|
||||||
fn active(&self) -> text_input::Style {
|
fn active(&self) -> text_input::Style {
|
||||||
text_input::Style {
|
text_input::Style {
|
||||||
background: Background::Color(SURFACE),
|
background: SURFACE.into(),
|
||||||
border_radius: 2,
|
border_radius: 2,
|
||||||
border_width: 0,
|
border_width: 0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
|
@ -378,7 +374,7 @@ mod style {
|
||||||
impl button::StyleSheet for Button {
|
impl button::StyleSheet for Button {
|
||||||
fn active(&self) -> button::Style {
|
fn active(&self) -> button::Style {
|
||||||
button::Style {
|
button::Style {
|
||||||
background: Some(Background::Color(ACTIVE)),
|
background: ACTIVE.into(),
|
||||||
border_radius: 3,
|
border_radius: 3,
|
||||||
text_color: Color::WHITE,
|
text_color: Color::WHITE,
|
||||||
..button::Style::default()
|
..button::Style::default()
|
||||||
|
@ -387,7 +383,7 @@ mod style {
|
||||||
|
|
||||||
fn hovered(&self) -> button::Style {
|
fn hovered(&self) -> button::Style {
|
||||||
button::Style {
|
button::Style {
|
||||||
background: Some(Background::Color(HOVERED)),
|
background: HOVERED.into(),
|
||||||
text_color: Color::WHITE,
|
text_color: Color::WHITE,
|
||||||
..self.active()
|
..self.active()
|
||||||
}
|
}
|
||||||
|
@ -407,7 +403,7 @@ mod style {
|
||||||
impl scrollable::StyleSheet for Scrollable {
|
impl scrollable::StyleSheet for Scrollable {
|
||||||
fn active(&self) -> scrollable::Scrollbar {
|
fn active(&self) -> scrollable::Scrollbar {
|
||||||
scrollable::Scrollbar {
|
scrollable::Scrollbar {
|
||||||
background: Some(Background::Color(SURFACE)),
|
background: SURFACE.into(),
|
||||||
border_radius: 2,
|
border_radius: 2,
|
||||||
border_width: 0,
|
border_width: 0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
|
@ -424,10 +420,7 @@ mod style {
|
||||||
let active = self.active();
|
let active = self.active();
|
||||||
|
|
||||||
scrollable::Scrollbar {
|
scrollable::Scrollbar {
|
||||||
background: Some(Background::Color(Color {
|
background: Color { a: 0.5, ..SURFACE }.into(),
|
||||||
a: 0.5,
|
|
||||||
..SURFACE
|
|
||||||
})),
|
|
||||||
scroller: scrollable::Scroller {
|
scroller: scrollable::Scroller {
|
||||||
color: HOVERED,
|
color: HOVERED,
|
||||||
..active.scroller
|
..active.scroller
|
||||||
|
@ -494,8 +487,8 @@ mod style {
|
||||||
impl progress_bar::StyleSheet for ProgressBar {
|
impl progress_bar::StyleSheet for ProgressBar {
|
||||||
fn style(&self) -> progress_bar::Style {
|
fn style(&self) -> progress_bar::Style {
|
||||||
progress_bar::Style {
|
progress_bar::Style {
|
||||||
background: Background::Color(SURFACE),
|
background: SURFACE.into(),
|
||||||
bar: Background::Color(ACTIVE),
|
bar: ACTIVE.into(),
|
||||||
border_radius: 10,
|
border_radius: 10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,11 +499,8 @@ mod style {
|
||||||
impl checkbox::StyleSheet for Checkbox {
|
impl checkbox::StyleSheet for Checkbox {
|
||||||
fn active(&self, is_checked: bool) -> checkbox::Style {
|
fn active(&self, is_checked: bool) -> checkbox::Style {
|
||||||
checkbox::Style {
|
checkbox::Style {
|
||||||
background: Background::Color(if is_checked {
|
background: if is_checked { ACTIVE } else { SURFACE }
|
||||||
ACTIVE
|
.into(),
|
||||||
} else {
|
|
||||||
SURFACE
|
|
||||||
}),
|
|
||||||
checkmark_color: Color::WHITE,
|
checkmark_color: Color::WHITE,
|
||||||
border_radius: 2,
|
border_radius: 2,
|
||||||
border_width: 1,
|
border_width: 1,
|
||||||
|
@ -520,10 +510,11 @@ mod style {
|
||||||
|
|
||||||
fn hovered(&self, is_checked: bool) -> checkbox::Style {
|
fn hovered(&self, is_checked: bool) -> checkbox::Style {
|
||||||
checkbox::Style {
|
checkbox::Style {
|
||||||
background: Background::Color(Color {
|
background: Color {
|
||||||
a: 0.8,
|
a: 0.8,
|
||||||
..if is_checked { ACTIVE } else { SURFACE }
|
..if is_checked { ACTIVE } else { SURFACE }
|
||||||
}),
|
}
|
||||||
|
.into(),
|
||||||
..self.active(is_checked)
|
..self.active(is_checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue