Skip to content

Commit

Permalink
Merge pull request #1869 from casperstorm/extend-border-radius
Browse files Browse the repository at this point in the history
Extended border radius on relevant widgets
  • Loading branch information
hecrj authored May 23, 2023
2 parents 8300d86 + 25804d9 commit 6c6930b
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 108 deletions.
22 changes: 22 additions & 0 deletions core/src/border_radius.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// 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 BorderRadius([f32; 4]);

impl From<f32> for BorderRadius {
fn from(w: f32) -> Self {
Self([w; 4])
}
}

impl From<[f32; 4]> for BorderRadius {
fn from(radi: [f32; 4]) -> Self {
Self(radi)
}
}

impl From<BorderRadius> for [f32; 4] {
fn from(radi: BorderRadius) -> Self {
radi.0
}
}
2 changes: 2 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub mod window;

mod angle;
mod background;
mod border_radius;
mod color;
mod content_fit;
mod element;
Expand All @@ -60,6 +61,7 @@ mod vector;
pub use alignment::Alignment;
pub use angle::{Degrees, Radians};
pub use background::Background;
pub use border_radius::BorderRadius;
pub use clipboard::Clipboard;
pub use color::Color;
pub use content_fit::ContentFit;
Expand Down
25 changes: 1 addition & 24 deletions core/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod null;
pub use null::Null;

use crate::layout;
use crate::{Background, Color, Element, Rectangle, Vector};
use crate::{Background, BorderRadius, Color, Element, Rectangle, Vector};

/// A component that can be used by widgets to draw themselves on a screen.
pub trait Renderer: Sized {
Expand Down Expand Up @@ -60,29 +60,6 @@ pub struct Quad {
pub border_color: Color,
}

/// 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 BorderRadius([f32; 4]);

impl From<f32> for BorderRadius {
fn from(w: f32) -> Self {
Self([w; 4])
}
}

impl From<[f32; 4]> for BorderRadius {
fn from(radi: [f32; 4]) -> Self {
Self(radi)
}
}

impl From<BorderRadius> for [f32; 4] {
fn from(radi: BorderRadius) -> Self {
radi.0
}
}

/// The styling attributes of a [`Renderer`].
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Style {
Expand Down
2 changes: 1 addition & 1 deletion examples/modal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod modal {
renderer.fill_quad(
renderer::Quad {
bounds: layout.bounds(),
border_radius: renderer::BorderRadius::from(0.0),
border_radius: Default::default(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
Expand Down
6 changes: 3 additions & 3 deletions examples/scrollable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ impl scrollable::StyleSheet for ScrollbarCustomStyle {
background: style
.active(&theme::Scrollable::default())
.background,
border_radius: 0.0,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Default::default(),
scroller: Scroller {
color: Color::from_rgb8(250, 85, 134),
border_radius: 0.0,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Default::default(),
},
Expand All @@ -371,6 +371,6 @@ fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Appearance {
progress_bar::Appearance {
background: theme.extended_palette().background.strong.color.into(),
bar: Color::from_rgb8(250, 85, 134).into(),
border_radius: 0.0,
border_radius: 0.0.into(),
}
}
6 changes: 3 additions & 3 deletions style/src/button.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the apperance of a button.
use iced_core::{Background, Color, Vector};
use iced_core::{Background, BorderRadius, Color, Vector};

/// The appearance of a button.
#[derive(Debug, Clone, Copy)]
Expand All @@ -9,7 +9,7 @@ pub struct Appearance {
/// The [`Background`] of the button.
pub background: Option<Background>,
/// The border radius of the button.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border width of the button.
pub border_width: f32,
/// The border [`Color`] of the button.
Expand All @@ -23,7 +23,7 @@ impl std::default::Default for Appearance {
Self {
shadow_offset: Vector::default(),
background: None,
border_radius: 0.0,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
text_color: Color::BLACK,
Expand Down
4 changes: 2 additions & 2 deletions style/src/checkbox.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a checkbox.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, Color};

/// The appearance of a checkbox.
#[derive(Debug, Clone, Copy)]
Expand All @@ -9,7 +9,7 @@ pub struct Appearance {
/// The icon [`Color`] of the checkbox.
pub icon_color: Color,
/// The border radius of the checkbox.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border width of the checkbox.
pub border_width: f32,
/// The border [`Color`] of the checkbox.
Expand Down
6 changes: 3 additions & 3 deletions style/src/container.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a container.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, Color};

/// The appearance of a container.
#[derive(Debug, Clone, Copy)]
Expand All @@ -9,7 +9,7 @@ pub struct Appearance {
/// The [`Background`] of the container.
pub background: Option<Background>,
/// The border radius of the container.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border width of the container.
pub border_width: f32,
/// The border [`Color`] of the container.
Expand All @@ -21,7 +21,7 @@ impl std::default::Default for Appearance {
Self {
text_color: None,
background: None,
border_radius: 0.0,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
Expand Down
4 changes: 2 additions & 2 deletions style/src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of menus.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, Color};

/// The appearance of a menu.
#[derive(Debug, Clone, Copy)]
Expand All @@ -11,7 +11,7 @@ pub struct Appearance {
/// The border width of the menu.
pub border_width: f32,
/// The border radius of the menu.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border [`Color`] of the menu.
pub border_color: Color,
/// The text [`Color`] of a selected option in the menu.
Expand Down
4 changes: 2 additions & 2 deletions style/src/pane_grid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a pane grid.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, Color};

/// The appearance of the hovered region of a pane grid.
#[derive(Debug, Clone, Copy)]
Expand All @@ -11,7 +11,7 @@ pub struct Appearance {
/// The border [`Color`] of the hovered pane region.
pub border_color: Color,
/// The border radius of the hovered pane region.
pub border_radius: f32,
pub border_radius: BorderRadius,
}

/// A line.
Expand Down
4 changes: 2 additions & 2 deletions style/src/pick_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a pick list.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, Color};

/// The appearance of a pick list.
#[derive(Debug, Clone, Copy)]
Expand All @@ -13,7 +13,7 @@ pub struct Appearance {
/// The [`Background`] of the pick list.
pub background: Background,
/// The border radius of the pick list.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border width of the pick list.
pub border_width: f32,
/// The border color of the pick list.
Expand Down
4 changes: 2 additions & 2 deletions style/src/progress_bar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a progress bar.
use iced_core::Background;
use iced_core::{Background, BorderRadius};

/// The appearance of a progress bar.
#[derive(Debug, Clone, Copy)]
Expand All @@ -9,7 +9,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: f32,
pub border_radius: BorderRadius,
}

/// A set of rules that dictate the style of a progress bar.
Expand Down
4 changes: 2 additions & 2 deletions style/src/rule.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the appearance of a rule.
use iced_core::Color;
use iced_core::{BorderRadius, Color};

/// The appearance of a rule.
#[derive(Debug, Clone, Copy)]
Expand All @@ -9,7 +9,7 @@ pub struct Appearance {
/// The width (thickness) of the rule line.
pub width: u16,
/// The radius of the line corners.
pub radius: f32,
pub radius: BorderRadius,
/// The [`FillMode`] of the rule.
pub fill_mode: FillMode,
}
Expand Down
6 changes: 3 additions & 3 deletions style/src/scrollable.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Change the appearance of a scrollable.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, 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: f32,
pub border_radius: BorderRadius,
/// The border width of a scrollable.
pub border_width: f32,
/// The border [`Color`] of a scrollable.
Expand All @@ -22,7 +22,7 @@ pub struct Scroller {
/// The [`Color`] of the scroller.
pub color: Color,
/// The border radius of the scroller.
pub border_radius: f32,
pub border_radius: BorderRadius,
/// The border width of the scroller.
pub border_width: f32,
/// The border [`Color`] of the scroller.
Expand Down
4 changes: 2 additions & 2 deletions style/src/slider.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Change the apperance of a slider.
use iced_core::Color;
use iced_core::{BorderRadius, Color};

/// The appearance of a slider.
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -45,7 +45,7 @@ pub enum HandleShape {
/// The width of the rectangle.
width: u16,
/// The border radius of the corners of the rectangle.
border_radius: f32,
border_radius: BorderRadius,
},
}

Expand Down
4 changes: 2 additions & 2 deletions style/src/text_input.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Change the appearance of a text input.
use iced_core::{Background, Color};
use iced_core::{Background, BorderRadius, 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: f32,
pub border_radius: BorderRadius,
/// The border width of the text input.
pub border_width: f32,
/// The border [`Color`] of the text input.
Expand Down
Loading

0 comments on commit 6c6930b

Please sign in to comment.