Implemented From<Color for Background
This commit is contained in:
parent
ed045b45ba
commit
33ad332ce9
6 changed files with 26 additions and 20 deletions
|
|
@ -7,3 +7,9 @@ pub enum Background {
|
||||||
Color(Color),
|
Color(Color),
|
||||||
// TODO: Add gradient and image variants
|
// TODO: Add gradient and image variants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Color> for Background {
|
||||||
|
fn from(color: Color) -> Self {
|
||||||
|
Background::Color(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,13 @@ impl Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a [`Color`] from its RGB components.
|
||||||
|
///
|
||||||
|
/// [`Color`]: struct.Color.html
|
||||||
|
pub fn from_rgb(r: f32, g: f32, b: f32) -> Color {
|
||||||
|
Color { r, g, b, a: 1.0 }
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts the [`Color`] into its linear values.
|
/// Converts the [`Color`] into its linear values.
|
||||||
///
|
///
|
||||||
/// [`Color`]: struct.Color.html
|
/// [`Color`]: struct.Color.html
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use iced::{
|
use iced::{
|
||||||
button, image, Align, Application, Background, Button, Color, Column,
|
button, image, Align, Application, Button, Color, Column,
|
||||||
Command, Container, Element, Image, Length, Row, Settings, Text,
|
Command, Container, Element, Image, Length, Row, Settings, Text,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ impl From<reqwest::Error> for Error {
|
||||||
|
|
||||||
fn button<'a>(state: &'a mut button::State, text: &str) -> Button<'a, Message> {
|
fn button<'a>(state: &'a mut button::State, text: &str) -> Button<'a, Message> {
|
||||||
Button::new(state, Text::new(text).color(Color::WHITE))
|
Button::new(state, Text::new(text).color(Color::WHITE))
|
||||||
.background(Background::Color([0.11, 0.42, 0.87].into()))
|
.background(Color::from_rgb(0.11, 0.42, 0.87).into())
|
||||||
.border_radius(10)
|
.border_radius(10)
|
||||||
.padding(10)
|
.padding(10)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use iced::{
|
use iced::{
|
||||||
button, scrollable, text_input, Align, Application, Background, Button,
|
button, scrollable, text_input, Align, Application, Button,
|
||||||
Checkbox, Color, Column, Command, Container, Element, Font,
|
Checkbox, Color, Column, Command, Container, Element, Font,
|
||||||
HorizontalAlignment, Length, Row, Scrollable, Settings, Text, TextInput,
|
HorizontalAlignment, Length, Row, Scrollable, Settings, Text, TextInput,
|
||||||
};
|
};
|
||||||
|
|
@ -332,7 +332,7 @@ impl Task {
|
||||||
.on_press(TaskMessage::Delete)
|
.on_press(TaskMessage::Delete)
|
||||||
.padding(10)
|
.padding(10)
|
||||||
.border_radius(5)
|
.border_radius(5)
|
||||||
.background(Background::Color([0.8, 0.2, 0.2].into())),
|
.background(Color::from_rgb(0.8, 0.2, 0.2).into()),
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +361,7 @@ impl Controls {
|
||||||
let label = Text::new(label).size(16).width(Length::Shrink);
|
let label = Text::new(label).size(16).width(Length::Shrink);
|
||||||
let button = if filter == current_filter {
|
let button = if filter == current_filter {
|
||||||
Button::new(state, label.color(Color::WHITE))
|
Button::new(state, label.color(Color::WHITE))
|
||||||
.background(Background::Color([0.2, 0.2, 0.7].into()))
|
.background(Color::from_rgb(0.2, 0.2, 0.7).into())
|
||||||
} else {
|
} else {
|
||||||
Button::new(state, label)
|
Button::new(state, label)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use iced::{
|
use iced::{
|
||||||
button, scrollable, slider, text_input, Background, Button, Checkbox,
|
button, scrollable, slider, text_input, Button, Checkbox,
|
||||||
Color, Column, Container, Element, HorizontalAlignment, Image, Length,
|
Color, Column, Container, Element, HorizontalAlignment, Image, Length,
|
||||||
Radio, Row, Sandbox, Scrollable, Settings, Slider, Text, TextInput,
|
Radio, Row, Sandbox, Scrollable, Settings, Slider, Text, TextInput,
|
||||||
};
|
};
|
||||||
|
|
@ -684,24 +684,17 @@ fn primary_button<'a, Message>(
|
||||||
state: &'a mut button::State,
|
state: &'a mut button::State,
|
||||||
label: &str,
|
label: &str,
|
||||||
) -> Button<'a, Message> {
|
) -> Button<'a, Message> {
|
||||||
button(state, label).background(Background::Color(Color {
|
button(state, label)
|
||||||
r: 0.11,
|
.background(Color::from_rgb(0.11, 0.42, 0.87).into())
|
||||||
g: 0.42,
|
|
||||||
b: 0.87,
|
|
||||||
a: 1.0,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn secondary_button<'a, Message>(
|
fn secondary_button<'a, Message>(
|
||||||
state: &'a mut button::State,
|
state: &'a mut button::State,
|
||||||
label: &str,
|
label: &str,
|
||||||
) -> Button<'a, Message> {
|
) -> Button<'a, Message> {
|
||||||
button(state, label).background(Background::Color(Color {
|
button(state, label)
|
||||||
r: 0.4,
|
.background(Color::from_rgb(0.4, 0.4, 0.4).into())
|
||||||
g: 0.4,
|
|
||||||
b: 0.4,
|
|
||||||
a: 1.0,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl slider::Renderer for Renderer {
|
||||||
width: bounds.width,
|
width: bounds.width,
|
||||||
height: 2.0,
|
height: 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color([0.6, 0.6, 0.6].into()),
|
background: Color::from_rgb(0.6, 0.6, 0.6).into(),
|
||||||
border_radius: 0,
|
border_radius: 0,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
@ -57,7 +57,7 @@ impl slider::Renderer for Renderer {
|
||||||
width: HANDLE_WIDTH + 2.0,
|
width: HANDLE_WIDTH + 2.0,
|
||||||
height: HANDLE_HEIGHT + 2.0,
|
height: HANDLE_HEIGHT + 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color([0.6, 0.6, 0.6].into()),
|
background: Color::from_rgb(0.6, 0.6, 0.6).into(),
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue