summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/border.rs54
-rw-r--r--core/src/element.rs10
-rw-r--r--core/src/lib.rs6
-rw-r--r--core/src/renderer.rs22
-rw-r--r--core/src/shadow.rs11
-rw-r--r--examples/custom_quad/src/main.rs14
-rw-r--r--examples/custom_widget/src/main.rs4
-rw-r--r--examples/modal/src/main.rs6
-rw-r--r--examples/pane_grid/src/main.rs16
-rw-r--r--examples/scrollable/src/main.rs16
-rw-r--r--graphics/src/damage.rs6
-rw-r--r--graphics/src/primitive.rs12
-rw-r--r--graphics/src/renderer.rs4
-rw-r--r--src/lib.rs7
-rw-r--r--style/src/button.rs14
-rw-r--r--style/src/checkbox.rs10
-rw-r--r--style/src/container.rs31
-rw-r--r--style/src/menu.rs10
-rw-r--r--style/src/pane_grid.rs12
-rw-r--r--style/src/pick_list.rs10
-rw-r--r--style/src/progress_bar.rs5
-rw-r--r--style/src/rule.rs5
-rw-r--r--style/src/scrollable.rs18
-rw-r--r--style/src/slider.rs7
-rw-r--r--style/src/text_editor.rs12
-rw-r--r--style/src/text_input.rs10
-rw-r--r--style/src/theme.rs128
-rw-r--r--tiny_skia/src/backend.rs167
-rw-r--r--wgpu/src/layer.rs20
-rw-r--r--widget/src/button.rs24
-rw-r--r--widget/src/checkbox.rs4
-rw-r--r--widget/src/container.rs6
-rw-r--r--widget/src/overlay/menu.rs12
-rw-r--r--widget/src/pane_grid.rs9
-rw-r--r--widget/src/pick_list.rs4
-rw-r--r--widget/src/progress_bar.rs6
-rw-r--r--widget/src/radio.rs13
-rw-r--r--widget/src/rule.rs6
-rw-r--r--widget/src/scrollable.rs16
-rw-r--r--widget/src/slider.rs16
-rw-r--r--widget/src/text_editor.rs4
-rw-r--r--widget/src/text_input.rs4
-rw-r--r--widget/src/toggler.rs24
-rw-r--r--widget/src/vertical_slider.rs15
44 files changed, 384 insertions, 426 deletions
diff --git a/core/src/border.rs b/core/src/border.rs
new file mode 100644
index 00000000..21823341
--- /dev/null
+++ b/core/src/border.rs
@@ -0,0 +1,54 @@
+//! Draw lines around containers.
+use crate::Color;
+
+/// A border.
+#[derive(Debug, Clone, Copy, PartialEq, Default)]
+pub struct Border {
+ /// The color of the border.
+ pub color: Color,
+
+ /// The width of the border.
+ pub width: f32,
+
+ /// The radius of the border.
+ pub radius: Radius,
+}
+
+impl Border {
+ /// Creates a new default [`Border`] with the given [`Radius`].
+ pub fn with_radius(radius: impl Into<Radius>) -> Self {
+ Self {
+ radius: radius.into(),
+ ..Self::default()
+ }
+ }
+}
+
+/// The border radii for the corners of a graphics primitive in the order:
+/// top-left, top-right, bottom-right, bottom-left.
+#[derive(Debug, Clone, Copy, PartialEq, Default)]
+pub struct Radius([f32; 4]);
+
+impl From<f32> for Radius {
+ fn from(w: f32) -> Self {
+ Self([w; 4])
+ }
+}
+
+impl From<u8> for Radius {
+ fn from(w: u8) -> Self {
+ Self([f32::from(w); 4])
+ }
+}
+
+impl From<[f32; 4]> for Radius {
+ fn from(radi: [f32; 4]) -> Self {
+ Self(radi)
+ }
+}
+
+impl From<Radius> for [f32; 4] {
+ fn from(radi: Radius) -> Self {
+ radi.0
+ }
+}
diff --git a/core/src/element.rs b/core/src/element.rs
index e57ad777..4d4bfa36 100644
--- a/core/src/element.rs
+++ b/core/src/element.rs
@@ -6,7 +6,8 @@ use crate::renderer;
use crate::widget;
use crate::widget::tree::{self, Tree};
use crate::{
- Clipboard, Color, Layout, Length, Rectangle, Shell, Size, Vector, Widget,
+ Border, Clipboard, Color, Layout, Length, Rectangle, Shell, Size, Vector,
+ Widget,
};
use std::any::Any;
@@ -537,8 +538,11 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: layout.bounds(),
- border_color: color,
- border_width: 1.0,
+ border: Border {
+ color,
+ width: 1.0,
+ ..Border::default()
+ },
..renderer::Quad::default()
},
Color::TRANSPARENT,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index b326d0f3..bbc973f0 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -17,6 +17,7 @@
rustdoc::broken_intra_doc_links
)]
pub mod alignment;
+pub mod border;
pub mod clipboard;
pub mod event;
pub mod font;
@@ -27,7 +28,6 @@ pub mod layout;
pub mod mouse;
pub mod overlay;
pub mod renderer;
-pub mod shadow;
pub mod svg;
pub mod text;
pub mod time;
@@ -37,7 +37,6 @@ pub mod window;
mod angle;
mod background;
-mod border_radius;
mod color;
mod content_fit;
mod element;
@@ -47,6 +46,7 @@ mod padding;
mod pixels;
mod point;
mod rectangle;
+mod shadow;
mod shell;
mod size;
mod vector;
@@ -54,7 +54,7 @@ mod vector;
pub use alignment::Alignment;
pub use angle::{Degrees, Radians};
pub use background::Background;
-pub use border_radius::BorderRadius;
+pub use border::Border;
pub use clipboard::Clipboard;
pub use color::Color;
pub use content_fit::ContentFit;
diff --git a/core/src/renderer.rs b/core/src/renderer.rs
index 1ca62559..a2a66aa8 100644
--- a/core/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -5,7 +5,7 @@ mod null;
#[cfg(debug_assertions)]
pub use null::Null;
-use crate::{Background, BorderRadius, Color, Rectangle, Shadow, Size, Vector};
+use crate::{Background, Border, Color, Rectangle, Shadow, Size, Vector};
/// A component that can be used by widgets to draw themselves on a screen.
pub trait Renderer: Sized {
@@ -37,27 +37,19 @@ pub struct Quad {
/// The bounds of the [`Quad`].
pub bounds: Rectangle,
- /// The border radius of the [`Quad`].
- pub border_radius: BorderRadius,
+ /// The [`Border`] of the [`Quad`].
+ pub border: Border,
- /// The border width of the [`Quad`].
- pub border_width: f32,
-
- /// The border color of the [`Quad`].
- pub border_color: Color,
-
- /// The shadow of the [`Quad`].
- pub shadow: Option<Shadow>,
+ /// The [`Shadow`] of the [`Quad`].
+ pub shadow: Shadow,
}
impl Default for Quad {
fn default() -> Self {
Self {
bounds: Rectangle::with_size(Size::ZERO),
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: None,
+ border: Border::default(),
+ shadow: Shadow::default(),
}
}
}
diff --git a/core/src/shadow.rs b/core/src/shadow.rs
index de8ce1c3..803101ed 100644
--- a/core/src/shadow.rs
+++ b/core/src/shadow.rs
@@ -1,15 +1,14 @@
-//! Shadow
use crate::{Color, Vector};
-/// A shadow
-#[derive(Debug, Clone, Copy, PartialEq)]
+/// A shadow.
+#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct Shadow {
- /// The color of the shadow
+ /// The color of the shadow.
pub color: Color,
- /// The offset of the shadow
+ /// The offset of the shadow.
pub offset: Vector,
- /// The blur radius of the shadow
+ /// The blur radius of the shadow.
pub blur_radius: f32,
}
diff --git a/examples/custom_quad/src/main.rs b/examples/custom_quad/src/main.rs
index e3f110bb..14f62caa 100644
--- a/examples/custom_quad/src/main.rs
+++ b/examples/custom_quad/src/main.rs
@@ -3,8 +3,8 @@ mod quad {
use iced::advanced::layout::{self, Layout};
use iced::advanced::renderer;
use iced::advanced::widget::{self, Widget};
- use iced::{mouse, Shadow};
- use iced::{Color, Element, Length, Rectangle, Size};
+ use iced::mouse;
+ use iced::{Border, Color, Element, Length, Rectangle, Shadow, Size};
pub struct CustomQuad {
size: f32,
@@ -62,10 +62,12 @@ mod quad {
renderer.fill_quad(
renderer::Quad {
bounds: layout.bounds(),
- border_radius: self.radius.into(),
- border_width: self.border_width,
- border_color: Color::from_rgb(1.0, 0.0, 0.0),
- shadow: Some(self.shadow),
+ border: Border {
+ radius: self.radius.into(),
+ width: self.border_width,
+ color: Color::from_rgb(1.0, 0.0, 0.0),
+ },
+ shadow: self.shadow,
},
Color::BLACK,
);
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index 6578183d..d5ecebaf 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -13,7 +13,7 @@ mod circle {
use iced::advanced::renderer;
use iced::advanced::widget::{self, Widget};
use iced::mouse;
- use iced::{Color, Element, Length, Rectangle, Size};
+ use iced::{Border, Color, Element, Length, Rectangle, Size};
pub struct Circle {
radius: f32,
@@ -62,7 +62,7 @@ mod circle {
renderer.fill_quad(
renderer::Quad {
bounds: layout.bounds(),
- border_radius: self.radius.into(),
+ border: Border::with_radius(self.radius),
..renderer::Quad::default()
},
Color::BLACK,
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs
index 59287c06..c9d5df29 100644
--- a/examples/modal/src/main.rs
+++ b/examples/modal/src/main.rs
@@ -231,10 +231,7 @@ mod modal {
use iced::alignment::Alignment;
use iced::event;
use iced::mouse;
- use iced::{
- BorderRadius, Color, Element, Event, Length, Point, Rectangle, Size,
- Vector,
- };
+ use iced::{Color, Element, Event, Length, Point, Rectangle, Size, Vector};
/// A widget that centers a modal element over some base element
pub struct Modal<'a, Message, Renderer> {
@@ -474,7 +471,6 @@ mod modal {
renderer.fill_quad(
renderer::Quad {
bounds: layout.bounds(),
- border_radius: BorderRadius::default(),
..renderer::Quad::default()
},
Color {
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index d5e5bcbe..742dc344 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -348,7 +348,7 @@ fn view_controls<'a>(
mod style {
use iced::widget::container;
- use iced::Theme;
+ use iced::{Border, Theme};
pub fn title_bar_active(theme: &Theme) -> container::Appearance {
let palette = theme.extended_palette();
@@ -375,8 +375,11 @@ mod style {
container::Appearance {
background: Some(palette.background.weak.color.into()),
- border_width: 2.0,
- border_color: palette.background.strong.color,
+ border: Border {
+ width: 2.0,
+ color: palette.background.strong.color,
+ ..Border::default()
+ },
..Default::default()
}
}
@@ -386,8 +389,11 @@ mod style {
container::Appearance {
background: Some(palette.background.weak.color.into()),
- border_width: 2.0,
- border_color: palette.primary.strong.color,
+ border: Border {
+ width: 2.0,
+ color: palette.primary.strong.color,
+ ..Border::default()
+ },
..Default::default()
}
}
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index 4b57a5a4..ff691917 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -1,10 +1,14 @@
+use iced::executor;
+use iced::theme;
use iced::widget::scrollable::{Properties, Scrollbar, Scroller};
use iced::widget::{
button, column, container, horizontal_space, progress_bar, radio, row,
scrollable, slider, text, vertical_space,
};
-use iced::{executor, theme, Alignment, Color};
-use iced::{Application, Command, Element, Length, Settings, Theme};
+use iced::{
+ Alignment, Application, Border, Color, Command, Element, Length, Settings,
+ Theme,
+};
use once_cell::sync::Lazy;
@@ -373,14 +377,10 @@ impl scrollable::StyleSheet for ScrollbarCustomStyle {
background: style
.active(&theme::Scrollable::default())
.background,
- border_radius: 2.0.into(),
- border_width: 0.0,
- border_color: Color::default(),
+ border: Border::with_radius(2),
scroller: Scroller {
color: Color::from_rgb8(250, 85, 134),
- border_radius: 2.0.into(),
- border_width: 0.0,
- border_color: Color::default(),
+ border: Border::with_radius(2),
},
}
} else {
diff --git a/graphics/src/damage.rs b/graphics/src/damage.rs
index cced0c97..ba9192ef 100644
--- a/graphics/src/damage.rs
+++ b/graphics/src/damage.rs
@@ -78,11 +78,7 @@ impl<T: Damage> Damage for Primitive<T> {
// damage bounds (?)
raw.clip_bounds.expand(1.5)
}
- Self::Quad {
- bounds,
- shadow: Some(shadow),
- ..
- } => {
+ Self::Quad { bounds, shadow, .. } if shadow.color.a > 0.0 => {
let bounds_with_shadow = Rectangle {
x: bounds.x + shadow.offset.x.min(0.0) - shadow.blur_radius,
y: bounds.y + shadow.offset.y.min(0.0) - shadow.blur_radius,
diff --git a/graphics/src/primitive.rs b/graphics/src/primitive.rs
index a428c31a..aed59e1a 100644
--- a/graphics/src/primitive.rs
+++ b/graphics/src/primitive.rs
@@ -4,7 +4,7 @@ use crate::core::image;
use crate::core::svg;
use crate::core::text;
use crate::core::{
- Background, Color, Font, Pixels, Point, Rectangle, Shadow, Vector,
+ Background, Border, Color, Font, Pixels, Point, Rectangle, Shadow, Vector,
};
use crate::text::editor;
use crate::text::paragraph;
@@ -67,14 +67,10 @@ pub enum Primitive<T> {
bounds: Rectangle,
/// The background of the quad
background: Background,
- /// The border radii of the quad
- border_radius: [f32; 4],
- /// The border width of the quad
- border_width: f32,
- /// The border color of the quad
- border_color: Color,
+ /// The [`Border`] of the quad
+ border: Border,
/// The [`Shadow`] of the quad
- shadow: Option<Shadow>,
+ shadow: Shadow,
},
/// An image primitive
Image {
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 6f312331..3ba41c3f 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -124,9 +124,7 @@ impl<B: Backend, T> iced_core::Renderer for Renderer<B, T> {
self.primitives.push(Primitive::Quad {
bounds: quad.bounds,
background: background.into(),
- border_radius: quad.border_radius.into(),
- border_width: quad.border_width,
- border_color: quad.border_color,
+ border: quad.border,
shadow: quad.shadow,
});
}
diff --git a/src/lib.rs b/src/lib.rs
index 02bb227a..eb1bd3bd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -188,11 +188,12 @@ pub mod multi_window;
pub use style::theme;
pub use crate::core::alignment;
+pub use crate::core::border;
+pub use crate::core::color;
pub use crate::core::gradient;
pub use crate::core::{
- color, Alignment, Background, BorderRadius, Color, ContentFit, Degrees,
- Gradient, Length, Padding, Pixels, Point, Radians, Rectangle, Shadow, Size,
- Vector,
+ Alignment, Background, Border, Color, ContentFit, Degrees, Gradient,
+ Length, Padding, Pixels, Point, Radians, Rectangle, Shadow, Size, Vector,
};
pub mod clipboard {
diff --git a/style/src/button.rs b/style/src/button.rs
index e49ad94a..d8732263 100644
--- a/style/src/button.rs
+++ b/style/src/button.rs
@@ -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,
}
}
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index cf52c05d..d96ea4ad 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -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>,
}
diff --git a/style/src/container.rs b/style/src/container.rs
index 490a9dab..a490c187 100644
--- a/style/src/container.rs
+++ b/style/src/container.rs
@@ -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`].
diff --git a/style/src/menu.rs b/style/src/menu.rs
index dbf19dae..be60a3f8 100644
--- a/style/src/menu.rs
+++ b/style/src/menu.rs
@@ -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.
diff --git a/style/src/pane_grid.rs b/style/src/pane_grid.rs
index dfdc9186..35570584 100644
--- a/style/src/pane_grid.rs
+++ b/style/src/pane_grid.rs
@@ -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.
diff --git a/style/src/pick_list.rs b/style/src/pick_list.rs
index 961c1e93..8f008f4a 100644
--- a/style/src/pick_list.rs
+++ b/style/src/pick_list.rs
@@ -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.
diff --git a/style/src/progress_bar.rs b/style/src/progress_bar.rs
index c05a6ee4..b62512d8 100644
--- a/style/src/progress_bar.rs
+++ b/style/src/progress_bar.rs
@@ -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.
diff --git a/style/src/rule.rs b/style/src/rule.rs
index efbe7444..12980da7 100644
--- a/style/src/rule.rs
+++ b/style/src/rule.rs
@@ -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,
}
diff --git a/style/src/scrollable.rs b/style/src/scrollable.rs
index 952c11e1..6f37305f 100644
--- a/style/src/scrollable.rs
+++ b/style/src/scrollable.rs
@@ -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.
diff --git a/style/src/slider.rs b/style/src/slider.rs
index f0068558..bf1c7329 100644
--- a/style/src/slider.rs
+++ b/style/src/slider.rs
@@ -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,
},
}
diff --git a/style/src/text_editor.rs b/style/src/text_editor.rs
index f6bae7e6..87f481e3 100644
--- a/style/src/text_editor.rs
+++ b/style/src/text_editor.rs
@@ -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.
diff --git a/style/src/text_input.rs b/style/src/text_input.rs
index 90251b5c..8ba9957f 100644
--- a/style/src/text_input.rs
+++ b/style/src/text_input.rs
@@ -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,
}
diff --git a/style/src/theme.rs b/style/src/theme.rs
index f78587e5..d90efb0a 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -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,
+ },
}
}
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index bad6221f..ea4a3ec6 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -152,9 +152,7 @@ impl Backend {
Primitive::Quad {
bounds,
background,
- border_radius,
- border_width,
- border_color,
+ border,
shadow,
} => {
let physical_bounds = (*bounds + translation) * scale_factor;
@@ -173,11 +171,12 @@ impl Backend {
.post_scale(scale_factor, scale_factor);
// Make sure the border radius is not larger than the bounds
- let border_width = border_width
+ let border_width = border
+ .width
.min(bounds.width / 2.0)
.min(bounds.height / 2.0);
- let mut fill_border_radius = *border_radius;
+ let mut fill_border_radius = <[f32; 4]>::from(border.radius);
for radius in &mut fill_border_radius {
*radius = (*radius)
.min(bounds.width / 2.0)
@@ -185,92 +184,78 @@ impl Backend {
}
let path = rounded_rectangle(*bounds, fill_border_radius);
- if let Some(shadow) = shadow {
- if shadow.color.a > 0.0 {
- let shadow_bounds = (Rectangle {
- x: bounds.x + shadow.offset.x - shadow.blur_radius,
- y: bounds.y + shadow.offset.y - shadow.blur_radius,
- width: bounds.width + shadow.blur_radius * 2.0,
- height: bounds.height + shadow.blur_radius * 2.0,
- } + translation)
- * scale_factor;
-
- let radii = fill_border_radius
- .into_iter()
- .map(|radius| radius * scale_factor)
- .collect::<Vec<_>>();
- let (x, y, width, height) = (
- shadow_bounds.x as u32,
- shadow_bounds.y as u32,
- shadow_bounds.width as u32,
- shadow_bounds.height as u32,
- );
- let half_width = physical_bounds.width / 2.0;
- let half_height = physical_bounds.height / 2.0;
-
- let colors = (y..y + height)
- .flat_map(|y| {
- (x..x + width)
- .map(move |x| (x as f32, y as f32))
- })
- .filter_map(|(x, y)| {
- Size::from_wh(half_width, half_height).map(
- |size| {
- let shadow_distance = rounded_box_sdf(
- Vector::new(
- x - physical_bounds
- .position()
- .x
- - (shadow.offset.x
- * scale_factor)
- - half_width,
- y - physical_bounds
- .position()
- .y
- - (shadow.offset.y
- * scale_factor)
- - half_height,
- ),
- size,
- &radii,
- );
- let shadow_alpha = 1.0
- - smoothstep(
- -shadow.blur_radius
- * scale_factor,
- shadow.blur_radius
- * scale_factor,
- shadow_distance,
- );
-
- let mut color =
- into_color(shadow.color);
- color.apply_opacity(shadow_alpha);
-
- color.to_color_u8().premultiply()
- },
- )
+ if shadow.color.a > 0.0 {
+ let shadow_bounds = (Rectangle {
+ x: bounds.x + shadow.offset.x - shadow.blur_radius,
+ y: bounds.y + shadow.offset.y - shadow.blur_radius,
+ width: bounds.width + shadow.blur_radius * 2.0,
+ height: bounds.height + shadow.blur_radius * 2.0,
+ } + translation)
+ * scale_factor;
+
+ let radii = fill_border_radius
+ .into_iter()
+ .map(|radius| radius * scale_factor)
+ .collect::<Vec<_>>();
+ let (x, y, width, height) = (
+ shadow_bounds.x as u32,
+ shadow_bounds.y as u32,
+ shadow_bounds.width as u32,
+ shadow_bounds.height as u32,
+ );
+ let half_width = physical_bounds.width / 2.0;
+ let half_height = physical_bounds.height / 2.0;
+
+ let colors = (y..y + height)
+ .flat_map(|y| {
+ (x..x + width).map(move |x| (x as f32, y as f32))
+ })
+ .filter_map(|(x, y)| {
+ Size::from_wh(half_width, half_height).map(|size| {
+ let shadow_distance = rounded_box_sdf(
+ Vector::new(
+ x - physical_bounds.position().x
+ - (shadow.offset.x * scale_factor)
+ - half_width,
+ y - physical_bounds.position().y
+ - (shadow.offset.y * scale_factor)
+ - half_height,
+ ),
+ size,
+ &radii,
+ );
+ let shadow_alpha = 1.0
+ - smoothstep(
+ -shadow.blur_radius * scale_factor,
+ shadow.blur_radius * scale_factor,
+ shadow_distance,
+ );
+
+ let mut color = into_color(shadow.color);
+ color.apply_opacity(shadow_alpha);
+
+ color.to_color_u8().premultiply()
})
- .collect();
+ })
+ .collect();
- if let Some(pixmap) = tiny_skia::IntSize::from_wh(
- width, height,
+ if let Some(pixmap) = tiny_skia::IntSize::from_wh(
+ width, height,
+ )
+ .and_then(|size| {
+ tiny_skia::Pixmap::from_vec(
+ bytemuck::cast_vec(colors),
+ size,
)
- .and_then(|size| {
- tiny_skia::Pixmap::from_vec(
- bytemuck::cast_vec(colors),
- size,
- )
- }) {
- pixels.draw_pixmap(
- x as i32,
- y as i32,
- pixmap.as_ref(),
- &tiny_skia::PixmapPaint::default(),
- tiny_skia::Transform::default(),
- None,
- );
- }
+ }) {
+ pixels.draw_pixmap(
+ x as i32,
+ y as i32,
+ pixmap.as_ref(),
+ &tiny_skia::PixmapPaint::default(),
+ tiny_skia::Transform::default(),
+ None,
+ );
}
}
@@ -344,7 +329,7 @@ impl Backend {
};
// Make sure the border radius is correct
- let mut border_radius = *border_radius;
+ let mut border_radius = <[f32; 4]>::from(border.radius);
let mut is_simple_border = true;
for radius in &mut border_radius {
@@ -370,7 +355,7 @@ impl Backend {
&border_path,
&tiny_skia::Paint {
shader: tiny_skia::Shader::SolidColor(
- into_color(*border_color),
+ into_color(border.color),
),
anti_alias: true,
..tiny_skia::Paint::default()
@@ -426,7 +411,7 @@ impl Backend {
&border_radius_path,
&tiny_skia::Paint {
shader: tiny_skia::Shader::SolidColor(
- into_color(*border_color),
+ into_color(border.color),
),
anti_alias: true,
..tiny_skia::Paint::default()
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index cb91878d..e213c95f 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -12,9 +12,7 @@ pub use text::Text;
use crate::core;
use crate::core::alignment;
-use crate::core::{
- Color, Font, Pixels, Point, Rectangle, Shadow, Size, Vector,
-};
+use crate::core::{Color, Font, Pixels, Point, Rectangle, Size, Vector};
use crate::graphics;
use crate::graphics::color;
use crate::graphics::Viewport;
@@ -197,28 +195,20 @@ impl<'a> Layer<'a> {
Primitive::Quad {
bounds,
background,
- border_radius,
- border_width,
- border_color,
+ border,
shadow,
} => {
let layer = &mut layers[current_layer];
- let shadow = shadow.unwrap_or_else(|| Shadow {
- color: Color::TRANSPARENT,
- offset: Vector::ZERO,
- blur_radius: 0.0,
- });
-
let quad = Quad {
position: [
bounds.x + translation.x,
bounds.y + translation.y,
],
size: [bounds.width, bounds.height],
- border_color: color::pack(*border_color),
- border_radius: *border_radius,
- border_width: *border_width,
+ border_color: color::pack(border.color),
+ border_radius: border.radius.into(),
+ border_width: border.width,
shadow_color: shadow.color.into_linear(),
shadow_offset: shadow.offset.into(),
shadow_blur_radius: shadow.blur_radius,
diff --git a/widget/src/button.rs b/widget/src/button.rs
index f9e59f23..f052ebab 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -11,7 +11,7 @@ use crate::core::widget::tree::{self, Tree};
use crate::core::widget::Operation;
use crate::core::{
Background, Clipboard, Color, Element, Layout, Length, Padding, Rectangle,
- Shell, Size, Vector, Widget,
+ Shell, Size, Widget,
};
pub use iced_style::button::{Appearance, StyleSheet};
@@ -391,29 +391,11 @@ where
style_sheet.active(style)
};
- if styling.background.is_some() || styling.border_width > 0.0 {
- if styling.shadow_offset != Vector::default() {
- // TODO: Implement proper shadow support
- renderer.fill_quad(
- renderer::Quad {
- bounds: Rectangle {
- x: bounds.x + styling.shadow_offset.x,
- y: bounds.y + styling.shadow_offset.y,
- ..bounds
- },
- border_radius: styling.border_radius,
- ..renderer::Quad::default()
- },
- Background::Color([0.0, 0.0, 0.0, 0.5].into()),
- );
- }
-
+ if styling.background.is_some() || styling.border.width > 0.0 {
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: styling.border_radius,
- border_width: styling.border_width,
- border_color: styling.border_color,
+ border: styling.border,
..renderer::Quad::default()
},
styling
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index 80397c13..76268314 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -284,9 +284,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: custom_style.border_radius,
- border_width: custom_style.border_width,
- border_color: custom_style.border_color,
+ border: custom_style.border,
..renderer::Quad::default()
},
custom_style.background,
diff --git a/widget/src/container.rs b/widget/src/container.rs
index b3d2f360..b87f1d9f 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -337,13 +337,11 @@ pub fn draw_background<Renderer>(
) where
Renderer: crate::core::Renderer,
{
- if appearance.background.is_some() || appearance.border_width > 0.0 {
+ if appearance.background.is_some() || appearance.border.width > 0.0 {
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: appearance.border_radius,
- border_width: appearance.border_width,
- border_color: appearance.border_color,
+ border: appearance.border,
..renderer::Quad::default()
},
appearance
diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs
index 2086e993..678bb7b5 100644
--- a/widget/src/overlay/menu.rs
+++ b/widget/src/overlay/menu.rs
@@ -10,7 +10,7 @@ use crate::core::text::{self, Text};
use crate::core::touch;
use crate::core::widget::Tree;
use crate::core::{
- Clipboard, Length, Padding, Pixels, Point, Rectangle, Size, Vector,
+ Border, Clipboard, Length, Padding, Pixels, Point, Rectangle, Size, Vector,
};
use crate::core::{Element, Shell, Widget};
use crate::scrollable::{self, Scrollable};
@@ -306,9 +306,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border_color: appearance.border_color,
- border_width: appearance.border_width,
- border_radius: appearance.border_radius,
+ border: appearance.border,
..renderer::Quad::default()
},
appearance.background,
@@ -513,11 +511,11 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: Rectangle {
- x: bounds.x + appearance.border_width,
- width: bounds.width - appearance.border_width * 2.0,
+ x: bounds.x + appearance.border.width,
+ width: bounds.width - appearance.border.width * 2.0,
..bounds
},
- border_radius: appearance.border_radius,
+ border: Border::with_radius(appearance.border.radius),
..renderer::Quad::default()
},
appearance.selected_background,
diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs
index 38ae17f0..3fda0e32 100644
--- a/widget/src/pane_grid.rs
+++ b/widget/src/pane_grid.rs
@@ -917,10 +917,7 @@ pub fn draw<Renderer, T>(
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: hovered_region_style
- .border_radius,
- border_width: hovered_region_style.border_width,
- border_color: hovered_region_style.border_color,
+ border: hovered_region_style.border,
..renderer::Quad::default()
},
theme.hovered_region(style).background,
@@ -948,9 +945,7 @@ pub fn draw<Renderer, T>(
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: hovered_region_style.border_radius,
- border_width: hovered_region_style.border_width,
- border_color: hovered_region_style.border_color,
+ border: hovered_region_style.border,
..renderer::Quad::default()
},
theme.hovered_region(style).background,
diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs
index ef0c0eb3..4d4e14d3 100644
--- a/widget/src/pick_list.rs
+++ b/widget/src/pick_list.rs
@@ -653,9 +653,7 @@ pub fn draw<'a, T, Renderer>(
renderer.fill_quad(
renderer::Quad {
bounds,
- border_color: style.border_color,
- border_width: style.border_width,
- border_radius: style.border_radius,
+ border: style.border,
..renderer::Quad::default()
},
style.background,
diff --git a/widget/src/progress_bar.rs b/widget/src/progress_bar.rs
index 1d48ff73..eb15644e 100644
--- a/widget/src/progress_bar.rs
+++ b/widget/src/progress_bar.rs
@@ -3,7 +3,7 @@ use crate::core::layout;
use crate::core::mouse;
use crate::core::renderer;
use crate::core::widget::Tree;
-use crate::core::{Element, Layout, Length, Rectangle, Size, Widget};
+use crate::core::{Border, Element, Layout, Length, Rectangle, Size, Widget};
use std::ops::RangeInclusive;
@@ -130,7 +130,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: Rectangle { ..bounds },
- border_radius: style.border_radius,
+ border: Border::with_radius(style.border_radius),
..renderer::Quad::default()
},
style.background,
@@ -143,7 +143,7 @@ where
width: active_progress_width,
..bounds
},
- border_radius: style.border_radius,
+ border: Border::with_radius(style.border_radius),
..renderer::Quad::default()
},
style.bar,
diff --git a/widget/src/radio.rs b/widget/src/radio.rs
index a782812e..ceb51ead 100644
--- a/widget/src/radio.rs
+++ b/widget/src/radio.rs
@@ -9,7 +9,8 @@ use crate::core::touch;
use crate::core::widget;
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, Size, Widget,
+ Border, Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, Size,
+ Widget,
};
pub use iced_style::radio::{Appearance, StyleSheet};
@@ -311,9 +312,11 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: (size / 2.0).into(),
- border_width: custom_style.border_width,
- border_color: custom_style.border_color,
+ border: Border {
+ radius: (size / 2.0).into(),
+ width: custom_style.border_width,
+ color: custom_style.border_color,
+ },
..renderer::Quad::default()
},
custom_style.background,
@@ -328,7 +331,7 @@ where
width: bounds.width - dot_size,
height: bounds.height - dot_size,
},
- border_radius: (dot_size / 2.0).into(),
+ border: Border::with_radius(dot_size / 2.0),
..renderer::Quad::default()
},
custom_style.dot_color,
diff --git a/widget/src/rule.rs b/widget/src/rule.rs
index 813b0e46..c958c44d 100644
--- a/widget/src/rule.rs
+++ b/widget/src/rule.rs
@@ -3,7 +3,9 @@ use crate::core::layout;
use crate::core::mouse;
use crate::core::renderer;
use crate::core::widget::Tree;
-use crate::core::{Element, Layout, Length, Pixels, Rectangle, Size, Widget};
+use crate::core::{
+ Border, Element, Layout, Length, Pixels, Rectangle, Size, Widget,
+};
pub use crate::style::rule::{Appearance, FillMode, StyleSheet};
@@ -122,7 +124,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: style.radius,
+ border: Border::with_radius(style.radius),
..renderer::Quad::default()
},
style.color,
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index beaad704..b7b6c3d2 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -903,15 +903,13 @@ pub fn draw<Renderer>(
if scrollbar.bounds.width > 0.0
&& scrollbar.bounds.height > 0.0
&& (style.background.is_some()
- || (style.border_color != Color::TRANSPARENT
- && style.border_width > 0.0))
+ || (style.border.color != Color::TRANSPARENT
+ && style.border.width > 0.0))
{
renderer.fill_quad(
renderer::Quad {
bounds: scrollbar.bounds,
- border_radius: style.border_radius,
- border_width: style.border_width,
- border_color: style.border_color,
+ border: style.border,
..renderer::Quad::default()
},
style
@@ -924,15 +922,13 @@ pub fn draw<Renderer>(
if scrollbar.scroller.bounds.width > 0.0
&& scrollbar.scroller.bounds.height > 0.0
&& (style.scroller.color != Color::TRANSPARENT
- || (style.scroller.border_color != Color::TRANSPARENT
- && style.scroller.border_width > 0.0))
+ || (style.scroller.border.color != Color::TRANSPARENT
+ && style.scroller.border.width > 0.0))
{
renderer.fill_quad(
renderer::Quad {
bounds: scrollbar.scroller.bounds,
- border_radius: style.scroller.border_radius,
- border_width: style.scroller.border_width,
- border_color: style.scroller.border_color,
+ border: style.scroller.border,
..renderer::Quad::default()
},
style.scroller.color,
diff --git a/widget/src/slider.rs b/widget/src/slider.rs
index d12e0ebe..79b0a7d8 100644
--- a/widget/src/slider.rs
+++ b/widget/src/slider.rs
@@ -8,8 +8,8 @@ use crate::core::renderer;
use crate::core::touch;
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
- Widget,
+ Border, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle,
+ Shell, Size, Widget,
};
use std::ops::RangeInclusive;
@@ -398,7 +398,7 @@ pub fn draw<T, R>(
width: offset + handle_width / 2.0,
height: style.rail.width,
},
- border_radius: style.rail.border_radius,
+ border: Border::with_radius(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.0,
@@ -412,7 +412,7 @@ pub fn draw<T, R>(
width: bounds.width - offset - handle_width / 2.0,
height: style.rail.width,
},
- border_radius: style.rail.border_radius,
+ border: Border::with_radius(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.1,
@@ -426,9 +426,11 @@ pub fn draw<T, R>(
width: handle_width,
height: handle_height,
},
- border_radius: handle_border_radius,
- border_width: style.handle.border_width,
- border_color: style.handle.border_color,
+ border: Border {
+ radius: handle_border_radius,
+ width: style.handle.border_width,
+ color: style.handle.border_color,
+ },
..renderer::Quad::default()
},
style.handle.color,
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 01ab1262..6b716238 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -466,9 +466,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: appearance.border_radius,
- border_width: appearance.border_width,
- border_color: appearance.border_color,
+ border: appearance.border,
..renderer::Quad::default()
},
appearance.background,
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index 7b15f58c..02715989 100644
--- a/widget/src/text_input.rs
+++ b/widget/src/text_input.rs
@@ -1082,9 +1082,7 @@ pub fn draw<Renderer>(
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: appearance.border_radius,
- border_width: appearance.border_width,
- border_color: appearance.border_color,
+ border: appearance.border,
..renderer::Quad::default()
},
appearance.background,
diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs
index 0bafffe1..58cd38ab 100644
--- a/widget/src/toggler.rs
+++ b/widget/src/toggler.rs
@@ -9,8 +9,8 @@ use crate::core::touch;
use crate::core::widget;
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Clipboard, Element, Event, Layout, Length, Pixels, Rectangle, Shell, Size,
- Widget,
+ Border, Clipboard, Element, Event, Layout, Length, Pixels, Rectangle,
+ Shell, Size, Widget,
};
pub use crate::style::toggler::{Appearance, StyleSheet};
@@ -312,11 +312,11 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: toggler_background_bounds,
- border_radius: border_radius.into(),
- border_width: 1.0,
- border_color: style
- .background_border
- .unwrap_or(style.background),
+ border: Border {
+ radius: border_radius.into(),
+ width: 1.0,
+ color: style.background_border.unwrap_or(style.background),
+ },
..renderer::Quad::default()
},
style.background,
@@ -337,11 +337,11 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: toggler_foreground_bounds,
- border_radius: border_radius.into(),
- border_width: 1.0,
- border_color: style
- .foreground_border
- .unwrap_or(style.foreground),
+ border: Border {
+ radius: border_radius.into(),
+ width: 1.0,
+ color: style.foreground_border.unwrap_or(style.foreground),
+ },
..renderer::Quad::default()
},
style.foreground,
diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs
index 7a461b08..52428c10 100644
--- a/widget/src/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -13,7 +13,8 @@ use crate::core::renderer;
use crate::core::touch;
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Clipboard, Element, Length, Pixels, Point, Rectangle, Shell, Size, Widget,
+ Border, Clipboard, Element, Length, Pixels, Point, Rectangle, Shell, Size,
+ Widget,
};
/// An vertical bar and a handle that selects a single value from a range of
@@ -396,7 +397,7 @@ pub fn draw<T, R>(
width: style.rail.width,
height: offset + handle_width / 2.0,
},
- border_radius: style.rail.border_radius,
+ border: Border::with_radius(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.1,
@@ -410,7 +411,7 @@ pub fn draw<T, R>(
width: style.rail.width,
height: bounds.height - offset - handle_width / 2.0,
},
- border_radius: style.rail.border_radius,
+ border: Border::with_radius(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.0,
@@ -424,9 +425,11 @@ pub fn draw<T, R>(
width: handle_height,
height: handle_width,
},
- border_radius: handle_border_radius,
- border_width: style.handle.border_width,
- border_color: style.handle.border_color,
+ border: Border {
+ radius: handle_border_radius,
+ width: style.handle.border_width,
+ color: style.handle.border_color,
+ },
..renderer::Quad::default()
},
style.handle.color,