diff options
Diffstat (limited to 'widget')
| -rw-r--r-- | widget/src/button.rs | 24 | ||||
| -rw-r--r-- | widget/src/checkbox.rs | 4 | ||||
| -rw-r--r-- | widget/src/container.rs | 6 | ||||
| -rw-r--r-- | widget/src/overlay/menu.rs | 12 | ||||
| -rw-r--r-- | widget/src/pane_grid.rs | 9 | ||||
| -rw-r--r-- | widget/src/pick_list.rs | 4 | ||||
| -rw-r--r-- | widget/src/progress_bar.rs | 6 | ||||
| -rw-r--r-- | widget/src/radio.rs | 13 | ||||
| -rw-r--r-- | widget/src/rule.rs | 6 | ||||
| -rw-r--r-- | widget/src/scrollable.rs | 16 | ||||
| -rw-r--r-- | widget/src/slider.rs | 16 | ||||
| -rw-r--r-- | widget/src/text_editor.rs | 4 | ||||
| -rw-r--r-- | widget/src/text_input.rs | 4 | ||||
| -rw-r--r-- | widget/src/toggler.rs | 24 | ||||
| -rw-r--r-- | widget/src/vertical_slider.rs | 15 | 
15 files changed, 67 insertions, 96 deletions
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,  | 
