diff options
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/button.rs | 29 | ||||
-rw-r--r-- | widget/src/checkbox.rs | 5 | ||||
-rw-r--r-- | widget/src/container.rs | 10 | ||||
-rw-r--r-- | widget/src/overlay/menu.rs | 16 | ||||
-rw-r--r-- | widget/src/pane_grid.rs | 19 | ||||
-rw-r--r-- | widget/src/pick_list.rs | 5 | ||||
-rw-r--r-- | widget/src/progress_bar.rs | 12 | ||||
-rw-r--r-- | widget/src/radio.rs | 16 | ||||
-rw-r--r-- | widget/src/rule.rs | 7 | ||||
-rw-r--r-- | widget/src/scrollable.rs | 18 | ||||
-rw-r--r-- | widget/src/slider.rs | 23 | ||||
-rw-r--r-- | widget/src/text_editor.rs | 16 | ||||
-rw-r--r-- | widget/src/text_input.rs | 17 | ||||
-rw-r--r-- | widget/src/toggler.rs | 26 | ||||
-rw-r--r-- | widget/src/vertical_slider.rs | 21 |
15 files changed, 104 insertions, 136 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs index 0ebb8dcc..14626dd3 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,30 +391,15 @@ 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, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }, - Background::Color([0.0, 0.0, 0.0, 0.5].into()), - ); - } - + if styling.background.is_some() + || styling.border.width > 0.0 + || styling.shadow.color.a > 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, + shadow: styling.shadow, }, styling .background diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 0353b3ad..76268314 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -284,9 +284,8 @@ 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 cffb0458..f2d1aaba 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -337,13 +337,15 @@ 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 + || appearance.shadow.color.a > 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, + shadow: appearance.shadow, }, appearance .background diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs index f83eebea..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, Color, 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,8 @@ 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, ); @@ -512,13 +511,12 @@ 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_color: Color::TRANSPARENT, - border_width: 0.0, - 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 cf1f0455..3fda0e32 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -42,8 +42,8 @@ use crate::core::touch; use crate::core::widget; use crate::core::widget::tree::{self, Tree}; use crate::core::{ - Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell, - Size, Vector, Widget, + Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size, + Vector, Widget, }; /// A collection of panes distributed using either vertical or horizontal splits @@ -917,10 +917,8 @@ 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, ); @@ -947,9 +945,8 @@ 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, ); @@ -1010,9 +1007,7 @@ pub fn draw<Renderer, T>( height: split_region.height, }, }, - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..renderer::Quad::default() }, highlight.color, ); diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index 2e3aab6f..4d4e14d3 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -653,9 +653,8 @@ 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 15f1277b..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::{Color, Element, Layout, Length, Rectangle, Size, Widget}; +use crate::core::{Border, Element, Layout, Length, Rectangle, Size, Widget}; use std::ops::RangeInclusive; @@ -130,9 +130,8 @@ where renderer.fill_quad( renderer::Quad { bounds: Rectangle { ..bounds }, - border_radius: style.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.border_radius), + ..renderer::Quad::default() }, style.background, ); @@ -144,9 +143,8 @@ where width: active_progress_width, ..bounds }, - border_radius: style.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + 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 f91b20b1..ceb51ead 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -9,7 +9,7 @@ use crate::core::touch; use crate::core::widget; use crate::core::widget::tree::{self, Tree}; use crate::core::{ - Clipboard, Color, Element, Layout, Length, Pixels, Rectangle, Shell, Size, + Border, Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, Size, Widget, }; @@ -312,9 +312,12 @@ 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,9 +331,8 @@ where width: bounds.width - dot_size, height: bounds.height - dot_size, }, - border_radius: (dot_size / 2.0).into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + 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 cded9cb1..c958c44d 100644 --- a/widget/src/rule.rs +++ b/widget/src/rule.rs @@ -4,7 +4,7 @@ use crate::core::mouse; use crate::core::renderer; use crate::core::widget::Tree; use crate::core::{ - Color, Element, Layout, Length, Pixels, Rectangle, Size, Widget, + Border, Element, Layout, Length, Pixels, Rectangle, Size, Widget, }; pub use crate::style::rule::{Appearance, FillMode, StyleSheet}; @@ -124,9 +124,8 @@ where renderer.fill_quad( renderer::Quad { bounds, - border_radius: style.radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.radius), + ..renderer::Quad::default() }, style.color, ); diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 70db490a..b7b6c3d2 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -903,15 +903,14 @@ 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 .background @@ -923,15 +922,14 @@ 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 1bc94661..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, Color, 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,9 +398,8 @@ pub fn draw<T, R>( width: offset + handle_width / 2.0, height: style.rail.width, }, - border_radius: style.rail.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.rail.border_radius), + ..renderer::Quad::default() }, style.rail.colors.0, ); @@ -413,9 +412,8 @@ pub fn draw<T, R>( width: bounds.width - offset - handle_width / 2.0, height: style.rail.width, }, - border_radius: style.rail.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.rail.border_radius), + ..renderer::Quad::default() }, style.rail.colors.1, ); @@ -428,9 +426,12 @@ 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 09a0cac0..6b716238 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -10,8 +10,7 @@ use crate::core::text::highlighter::{self, Highlighter}; use crate::core::text::{self, LineHeight}; use crate::core::widget::{self, Widget}; use crate::core::{ - Clipboard, Color, Element, Length, Padding, Pixels, Rectangle, Shell, Size, - Vector, + Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector, }; use std::cell::RefCell; @@ -467,9 +466,8 @@ 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, ); @@ -508,9 +506,7 @@ where ) .into(), }, - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..renderer::Quad::default() }, theme.value_color(&self.style), ); @@ -523,9 +519,7 @@ where renderer.fill_quad( renderer::Quad { bounds: range, - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..renderer::Quad::default() }, theme.selection_color(&self.style), ); diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index c3dce8be..02715989 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -26,8 +26,8 @@ use crate::core::widget::operation::{self, Operation}; use crate::core::widget::tree::{self, Tree}; use crate::core::window; use crate::core::{ - Clipboard, Color, Element, Layout, Length, Padding, Pixels, Point, - Rectangle, Shell, Size, Vector, Widget, + Clipboard, Element, Layout, Length, Padding, Pixels, Point, Rectangle, + Shell, Size, Vector, Widget, }; use crate::runtime::Command; @@ -1082,9 +1082,8 @@ 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, ); @@ -1131,9 +1130,7 @@ pub fn draw<Renderer>( width: 1.0, height: text_bounds.height, }, - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..renderer::Quad::default() }, theme.value_color(style), )) @@ -1172,9 +1169,7 @@ pub fn draw<Renderer>( width, height: text_bounds.height, }, - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..renderer::Quad::default() }, theme.selection_color(style), )), diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index 941159ea..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,12 @@ 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, ); @@ -336,11 +337,12 @@ 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 a3029d76..52428c10 100644 --- a/widget/src/vertical_slider.rs +++ b/widget/src/vertical_slider.rs @@ -13,7 +13,7 @@ use crate::core::renderer; use crate::core::touch; use crate::core::widget::tree::{self, Tree}; use crate::core::{ - Clipboard, Color, Element, Length, Pixels, Point, Rectangle, Shell, Size, + Border, Clipboard, Element, Length, Pixels, Point, Rectangle, Shell, Size, Widget, }; @@ -397,9 +397,8 @@ pub fn draw<T, R>( width: style.rail.width, height: offset + handle_width / 2.0, }, - border_radius: style.rail.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.rail.border_radius), + ..renderer::Quad::default() }, style.rail.colors.1, ); @@ -412,9 +411,8 @@ pub fn draw<T, R>( width: style.rail.width, height: bounds.height - offset - handle_width / 2.0, }, - border_radius: style.rail.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, + border: Border::with_radius(style.rail.border_radius), + ..renderer::Quad::default() }, style.rail.colors.0, ); @@ -427,9 +425,12 @@ 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, ); |