Introduce Border struct analogous to Shadow
This commit is contained in:
parent
4d502012b3
commit
25f182f933
44 changed files with 382 additions and 424 deletions
|
|
@ -1,5 +1,5 @@
|
|||
//! Change the apperance of a button.
|
||||
use iced_core::{Background, BorderRadius, Color, Vector};
|
||||
use iced_core::{Background, Border, Color, Vector};
|
||||
|
||||
/// The appearance of a button.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -8,12 +8,8 @@ pub struct Appearance {
|
|||
pub shadow_offset: Vector,
|
||||
/// The [`Background`] of the button.
|
||||
pub background: Option<Background>,
|
||||
/// The border radius of the button.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the button.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the button.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the butoon.
|
||||
pub border: Border,
|
||||
/// The text [`Color`] of the button.
|
||||
pub text_color: Color,
|
||||
}
|
||||
|
|
@ -23,9 +19,7 @@ impl std::default::Default for Appearance {
|
|||
Self {
|
||||
shadow_offset: Vector::default(),
|
||||
background: None,
|
||||
border_radius: 0.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::default(),
|
||||
text_color: Color::BLACK,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Change the appearance of a checkbox.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use iced_core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a checkbox.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -8,12 +8,8 @@ pub struct Appearance {
|
|||
pub background: Background,
|
||||
/// The icon [`Color`] of the checkbox.
|
||||
pub icon_color: Color,
|
||||
/// The border radius of the checkbox.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the checkbox.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the checkbox.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of hte checkbox.
|
||||
pub border: Border,
|
||||
/// The text [`Color`] of the checkbox.
|
||||
pub text_color: Option<Color>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
//! Change the appearance of a container.
|
||||
use crate::core::{Background, BorderRadius, Color, Pixels};
|
||||
use crate::core::{Background, Border, Color, Pixels};
|
||||
|
||||
/// The appearance of a container.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct Appearance {
|
||||
/// The text [`Color`] of the container.
|
||||
pub text_color: Option<Color>,
|
||||
/// The [`Background`] of the container.
|
||||
pub background: Option<Background>,
|
||||
/// The border radius of the container.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the container.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the container.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the container.
|
||||
pub border: Border,
|
||||
}
|
||||
|
||||
impl Appearance {
|
||||
|
|
@ -25,8 +21,11 @@ impl Appearance {
|
|||
width: impl Into<Pixels>,
|
||||
) -> Self {
|
||||
Self {
|
||||
border_color: color.into(),
|
||||
border_width: width.into().0,
|
||||
border: Border {
|
||||
color: color.into(),
|
||||
width: width.into().0,
|
||||
..Border::default()
|
||||
},
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
|
@ -40,18 +39,6 @@ impl Appearance {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::default::Default for Appearance {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
text_color: None,
|
||||
background: None,
|
||||
border_radius: 0.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of rules that dictate the [`Appearance`] of a container.
|
||||
pub trait StyleSheet {
|
||||
/// The supported style of the [`StyleSheet`].
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Change the appearance of menus.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use iced_core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a menu.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -8,12 +8,8 @@ pub struct Appearance {
|
|||
pub text_color: Color,
|
||||
/// The [`Background`] of the menu.
|
||||
pub background: Background,
|
||||
/// The border width of the menu.
|
||||
pub border_width: f32,
|
||||
/// The border radius of the menu.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border [`Color`] of the menu.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the menu.
|
||||
pub border: Border,
|
||||
/// The text [`Color`] of a selected option in the menu.
|
||||
pub selected_text_color: Color,
|
||||
/// The background [`Color`] of a selected option in the menu.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
//! Change the appearance of a pane grid.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use iced_core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of the hovered region of a pane grid.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Appearance {
|
||||
/// The [`Background`] of the hovered pane region.
|
||||
/// The [`Background`] of the pane region.
|
||||
pub background: Background,
|
||||
/// The border width of the hovered pane region.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the hovered pane region.
|
||||
pub border_color: Color,
|
||||
/// The border radius of the hovered pane region.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The [`Border`] of the pane region.
|
||||
pub border: Border,
|
||||
}
|
||||
|
||||
/// A line.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Change the appearance of a pick list.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use iced_core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a pick list.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -12,12 +12,8 @@ pub struct Appearance {
|
|||
pub handle_color: Color,
|
||||
/// The [`Background`] of the pick list.
|
||||
pub background: Background,
|
||||
/// The border radius of the pick list.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the pick list.
|
||||
pub border_width: f32,
|
||||
/// The border color of the pick list.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the pick list.
|
||||
pub border: Border,
|
||||
}
|
||||
|
||||
/// A set of rules that dictate the style of a container.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Change the appearance of a progress bar.
|
||||
use iced_core::{Background, BorderRadius};
|
||||
use crate::core::border;
|
||||
use crate::core::Background;
|
||||
|
||||
/// The appearance of a progress bar.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -9,7 +10,7 @@ pub struct Appearance {
|
|||
/// The [`Background`] of the bar of the progress bar.
|
||||
pub bar: Background,
|
||||
/// The border radius of the progress bar.
|
||||
pub border_radius: BorderRadius,
|
||||
pub border_radius: border::Radius,
|
||||
}
|
||||
|
||||
/// A set of rules that dictate the style of a progress bar.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Change the appearance of a rule.
|
||||
use iced_core::{BorderRadius, Color};
|
||||
use crate::core::border;
|
||||
use crate::core::Color;
|
||||
|
||||
/// The appearance of a rule.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -9,7 +10,7 @@ pub struct Appearance {
|
|||
/// The width (thickness) of the rule line.
|
||||
pub width: u16,
|
||||
/// The radius of the line corners.
|
||||
pub radius: BorderRadius,
|
||||
pub radius: border::Radius,
|
||||
/// The [`FillMode`] of the rule.
|
||||
pub fill_mode: FillMode,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
//! Change the appearance of a scrollable.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use crate::core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a scrollable.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Scrollbar {
|
||||
/// The [`Background`] of a scrollable.
|
||||
pub background: Option<Background>,
|
||||
/// The border radius of a scrollable.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of a scrollable.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of a scrollable.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of a scrollable.
|
||||
pub border: Border,
|
||||
/// The appearance of the [`Scroller`] of a scrollable.
|
||||
pub scroller: Scroller,
|
||||
}
|
||||
|
|
@ -21,12 +17,8 @@ pub struct Scrollbar {
|
|||
pub struct Scroller {
|
||||
/// The [`Color`] of the scroller.
|
||||
pub color: Color,
|
||||
/// The border radius of the scroller.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the scroller.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the scroller.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the scroller.
|
||||
pub border: Border,
|
||||
}
|
||||
|
||||
/// A set of rules that dictate the style of a scrollable.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Change the apperance of a slider.
|
||||
use iced_core::{BorderRadius, Color};
|
||||
use crate::core::border;
|
||||
use crate::core::Color;
|
||||
|
||||
/// The appearance of a slider.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -18,7 +19,7 @@ pub struct Rail {
|
|||
/// The width of the stroke of a slider rail.
|
||||
pub width: f32,
|
||||
/// The border radius of the corners of the rail.
|
||||
pub border_radius: BorderRadius,
|
||||
pub border_radius: border::Radius,
|
||||
}
|
||||
|
||||
/// The appearance of the handle of a slider.
|
||||
|
|
@ -47,7 +48,7 @@ pub enum HandleShape {
|
|||
/// The width of the rectangle.
|
||||
width: u16,
|
||||
/// The border radius of the corners of the rectangle.
|
||||
border_radius: BorderRadius,
|
||||
border_radius: border::Radius,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
//! Change the appearance of a text editor.
|
||||
use crate::core::{Background, BorderRadius, Color};
|
||||
use crate::core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a text input.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Appearance {
|
||||
/// The [`Background`] of the text input.
|
||||
/// The [`Background`] of the text editor.
|
||||
pub background: Background,
|
||||
/// The border radius of the text input.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the text input.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the text input.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the text editor.
|
||||
pub border: Border,
|
||||
}
|
||||
|
||||
/// A set of rules that dictate the style of a text input.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
//! Change the appearance of a text input.
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
use iced_core::{Background, Border, Color};
|
||||
|
||||
/// The appearance of a text input.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Appearance {
|
||||
/// The [`Background`] of the text input.
|
||||
pub background: Background,
|
||||
/// The border radius of the text input.
|
||||
pub border_radius: BorderRadius,
|
||||
/// The border width of the text input.
|
||||
pub border_width: f32,
|
||||
/// The border [`Color`] of the text input.
|
||||
pub border_color: Color,
|
||||
/// The [`Border`] of the text input.
|
||||
pub border: Border,
|
||||
/// The icon [`Color`] of the text input.
|
||||
pub icon_color: Color,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use crate::text_editor;
|
|||
use crate::text_input;
|
||||
use crate::toggler;
|
||||
|
||||
use iced_core::{Background, Color, Vector};
|
||||
use crate::core::{Background, Border, Color, Vector};
|
||||
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -199,7 +199,7 @@ impl button::StyleSheet for Theme {
|
|||
let palette = self.extended_palette();
|
||||
|
||||
let appearance = button::Appearance {
|
||||
border_radius: 2.0.into(),
|
||||
border: Border::with_radius(2),
|
||||
..button::Appearance::default()
|
||||
};
|
||||
|
||||
|
|
@ -388,9 +388,11 @@ fn checkbox_appearance(
|
|||
base.color
|
||||
}),
|
||||
icon_color,
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: accent.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: accent.color,
|
||||
},
|
||||
text_color: None,
|
||||
}
|
||||
}
|
||||
|
|
@ -431,9 +433,7 @@ impl container::StyleSheet for Theme {
|
|||
container::Appearance {
|
||||
text_color: None,
|
||||
background: Some(palette.background.weak.color.into()),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::with_radius(2),
|
||||
}
|
||||
}
|
||||
Container::Custom(custom) => custom.appearance(self),
|
||||
|
|
@ -555,9 +555,11 @@ impl menu::StyleSheet for Theme {
|
|||
menu::Appearance {
|
||||
text_color: palette.background.weak.text,
|
||||
background: palette.background.weak.color.into(),
|
||||
border_width: 1.0,
|
||||
border_radius: 0.0.into(),
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
selected_text_color: palette.primary.strong.text,
|
||||
selected_background: palette.primary.strong.color.into(),
|
||||
}
|
||||
|
|
@ -602,9 +604,11 @@ impl pick_list::StyleSheet for Theme {
|
|||
background: palette.background.weak.color.into(),
|
||||
placeholder_color: palette.background.strong.color,
|
||||
handle_color: palette.background.weak.text,
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
}
|
||||
}
|
||||
PickList::Custom(custom, _) => custom.active(self),
|
||||
|
|
@ -621,9 +625,11 @@ impl pick_list::StyleSheet for Theme {
|
|||
background: palette.background.weak.color.into(),
|
||||
placeholder_color: palette.background.strong.color,
|
||||
handle_color: palette.background.weak.text,
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.primary.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.primary.strong.color,
|
||||
},
|
||||
}
|
||||
}
|
||||
PickList::Custom(custom, _) => custom.hovered(self),
|
||||
|
|
@ -776,9 +782,11 @@ impl pane_grid::StyleSheet for Theme {
|
|||
a: 0.5,
|
||||
..palette.primary.base.color
|
||||
}),
|
||||
border_width: 2.0,
|
||||
border_color: palette.primary.strong.color,
|
||||
border_radius: 0.0.into(),
|
||||
border: Border {
|
||||
width: 2.0,
|
||||
color: palette.primary.strong.color,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
PaneGrid::Custom(custom) => custom.hovered_region(self),
|
||||
|
|
@ -986,14 +994,10 @@ impl scrollable::StyleSheet for Theme {
|
|||
|
||||
scrollable::Scrollbar {
|
||||
background: Some(palette.background.weak.color.into()),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::with_radius(2),
|
||||
scroller: scrollable::Scroller {
|
||||
color: palette.background.strong.color,
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::with_radius(2),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1013,14 +1017,10 @@ impl scrollable::StyleSheet for Theme {
|
|||
|
||||
scrollable::Scrollbar {
|
||||
background: Some(palette.background.weak.color.into()),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::with_radius(2),
|
||||
scroller: scrollable::Scroller {
|
||||
color: palette.primary.strong.color,
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border::with_radius(2),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1120,9 +1120,11 @@ impl text_input::StyleSheet for Theme {
|
|||
|
||||
text_input::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
icon_color: palette.background.weak.text,
|
||||
}
|
||||
}
|
||||
|
|
@ -1136,9 +1138,11 @@ impl text_input::StyleSheet for Theme {
|
|||
|
||||
text_input::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.base.text,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.base.text,
|
||||
},
|
||||
icon_color: palette.background.weak.text,
|
||||
}
|
||||
}
|
||||
|
|
@ -1152,9 +1156,11 @@ impl text_input::StyleSheet for Theme {
|
|||
|
||||
text_input::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.primary.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.primary.strong.color,
|
||||
},
|
||||
icon_color: palette.background.weak.text,
|
||||
}
|
||||
}
|
||||
|
|
@ -1198,9 +1204,11 @@ impl text_input::StyleSheet for Theme {
|
|||
|
||||
text_input::Appearance {
|
||||
background: palette.background.weak.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
icon_color: palette.background.strong.color,
|
||||
}
|
||||
}
|
||||
|
|
@ -1236,9 +1244,11 @@ impl text_editor::StyleSheet for Theme {
|
|||
|
||||
text_editor::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1251,9 +1261,11 @@ impl text_editor::StyleSheet for Theme {
|
|||
|
||||
text_editor::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.base.text,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.base.text,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1266,9 +1278,11 @@ impl text_editor::StyleSheet for Theme {
|
|||
|
||||
text_editor::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.primary.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.primary.strong.color,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1311,9 +1325,11 @@ impl text_editor::StyleSheet for Theme {
|
|||
|
||||
text_editor::Appearance {
|
||||
background: palette.background.weak.color.into(),
|
||||
border_radius: 2.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.strong.color,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue