summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-20 12:25:07 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-20 12:25:07 +0100
commit370b2f6df799c948188d3949e34112258b2a8498 (patch)
tree925d98d94be0e82c34377a7e3f697eafc8d095a2
parentb7b457a575cdd103915994f640c50262ce30a7c5 (diff)
downloadiced-370b2f6df799c948188d3949e34112258b2a8498.tar.gz
iced-370b2f6df799c948188d3949e34112258b2a8498.tar.bz2
iced-370b2f6df799c948188d3949e34112258b2a8498.zip
Use `Default` implementation of `renderer::Quad`
-rw-r--r--core/src/element.rs3
-rw-r--r--examples/custom_widget/src/main.rs4
-rw-r--r--examples/loading_spinners/src/linear.rs17
-rw-r--r--examples/modal/src/main.rs4
-rw-r--r--tiny_skia/src/backend.rs25
-rw-r--r--widget/src/button.rs6
-rw-r--r--widget/src/checkbox.rs2
-rw-r--r--widget/src/container.rs2
-rw-r--r--widget/src/overlay/menu.rs8
-rw-r--r--widget/src/pane_grid.rs13
-rw-r--r--widget/src/pick_list.rs2
-rw-r--r--widget/src/progress_bar.rs10
-rw-r--r--widget/src/radio.rs9
-rw-r--r--widget/src/rule.rs8
-rw-r--r--widget/src/scrollable.rs4
-rw-r--r--widget/src/slider.rs14
-rw-r--r--widget/src/text_editor.rs15
-rw-r--r--widget/src/text_input.rs16
-rw-r--r--widget/src/toggler.rs4
-rw-r--r--widget/src/vertical_slider.rs13
20 files changed, 63 insertions, 116 deletions
diff --git a/core/src/element.rs b/core/src/element.rs
index a39919d3..e57ad777 100644
--- a/core/src/element.rs
+++ b/core/src/element.rs
@@ -539,8 +539,7 @@ where
bounds: layout.bounds(),
border_color: color,
border_width: 1.0,
- border_radius: 0.0.into(),
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Color::TRANSPARENT,
);
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index f5c34d6b..6578183d 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -63,9 +63,7 @@ mod circle {
renderer::Quad {
bounds: layout.bounds(),
border_radius: self.radius.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Color::BLACK,
);
diff --git a/examples/loading_spinners/src/linear.rs b/examples/loading_spinners/src/linear.rs
index 86469681..03aee9b1 100644
--- a/examples/loading_spinners/src/linear.rs
+++ b/examples/loading_spinners/src/linear.rs
@@ -225,10 +225,7 @@ where
width: bounds.width,
height: bounds.height,
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Background::Color(custom_style.track_color),
);
@@ -242,10 +239,7 @@ where
width: self.easing.y_at_x(*progress) * bounds.width,
height: bounds.height,
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Background::Color(custom_style.bar_color),
),
@@ -260,10 +254,7 @@ where
* bounds.width,
height: bounds.height,
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Background::Color(custom_style.bar_color),
),
@@ -291,7 +282,7 @@ pub struct Appearance {
pub bar_color: Color,
}
-impl std::default::Default for Appearance {
+impl Default for Appearance {
fn default() -> Self {
Self {
track_color: Color::TRANSPARENT,
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs
index 531a19b5..59287c06 100644
--- a/examples/modal/src/main.rs
+++ b/examples/modal/src/main.rs
@@ -475,9 +475,7 @@ mod modal {
renderer::Quad {
bounds: layout.bounds(),
border_radius: BorderRadius::default(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Color {
a: 0.80,
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index ae1abc84..5321d8c6 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -267,22 +267,23 @@ impl Backend {
})
.collect();
- if let Some(p) = tiny_skia::IntSize::from_wh(width, height)
- .and_then(|size| {
- tiny_skia::Pixmap::from_vec(
- bytemuck::cast_vec(colors),
- size,
- )
- })
- {
+ if let Some(pixmap) = tiny_skia::IntSize::from_wh(
+ width, height,
+ )
+ .and_then(|size| {
+ tiny_skia::Pixmap::from_vec(
+ bytemuck::cast_vec(colors),
+ size,
+ )
+ }) {
pixels.draw_pixmap(
x as i32,
y as i32,
- p.as_ref(),
- &Default::default(),
- Default::default(),
+ pixmap.as_ref(),
+ &tiny_skia::PixmapPaint::default(),
+ tiny_skia::Transform::default(),
None,
- )
+ );
}
}
diff --git a/widget/src/button.rs b/widget/src/button.rs
index 44628a6a..f9e59f23 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -402,9 +402,7 @@ where
..bounds
},
border_radius: styling.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
Background::Color([0.0, 0.0, 0.0, 0.5].into()),
);
@@ -416,7 +414,7 @@ where
border_radius: styling.border_radius,
border_width: styling.border_width,
border_color: styling.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
styling
.background
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index 5cc79b08..80397c13 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -287,7 +287,7 @@ where
border_radius: custom_style.border_radius,
border_width: custom_style.border_width,
border_color: custom_style.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
custom_style.background,
);
diff --git a/widget/src/container.rs b/widget/src/container.rs
index 519d4f15..b3d2f360 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -344,7 +344,7 @@ pub fn draw_background<Renderer>(
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
appearance
.background
diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs
index 03935e59..2086e993 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,
+ Clipboard, Length, Padding, Pixels, Point, Rectangle, Size, Vector,
};
use crate::core::{Element, Shell, Widget};
use crate::scrollable::{self, Scrollable};
@@ -309,7 +309,7 @@ where
border_color: appearance.border_color,
border_width: appearance.border_width,
border_radius: appearance.border_radius,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
appearance.background,
);
@@ -517,10 +517,8 @@ where
width: bounds.width - appearance.border_width * 2.0,
..bounds
},
- border_color: Color::TRANSPARENT,
- border_width: 0.0,
border_radius: appearance.border_radius,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
appearance.selected_background,
);
diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs
index fc30716d..38ae17f0 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
@@ -921,7 +921,7 @@ pub fn draw<Renderer, T>(
.border_radius,
border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.hovered_region(style).background,
);
@@ -951,7 +951,7 @@ pub fn draw<Renderer, T>(
border_radius: hovered_region_style.border_radius,
border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.hovered_region(style).background,
);
@@ -1012,10 +1012,7 @@ pub fn draw<Renderer, T>(
height: split_region.height,
},
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
highlight.color,
);
diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs
index 8931aa99..ef0c0eb3 100644
--- a/widget/src/pick_list.rs
+++ b/widget/src/pick_list.rs
@@ -656,7 +656,7 @@ pub fn draw<'a, T, Renderer>(
border_color: style.border_color,
border_width: style.border_width,
border_radius: style.border_radius,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.background,
);
diff --git a/widget/src/progress_bar.rs b/widget/src/progress_bar.rs
index 1e0f2a82..1d48ff73 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::{Element, Layout, Length, Rectangle, Size, Widget};
use std::ops::RangeInclusive;
@@ -131,9 +131,7 @@ where
renderer::Quad {
bounds: Rectangle { ..bounds },
border_radius: style.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.background,
);
@@ -146,9 +144,7 @@ where
..bounds
},
border_radius: style.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.bar,
);
diff --git a/widget/src/radio.rs b/widget/src/radio.rs
index 0a33825f..a782812e 100644
--- a/widget/src/radio.rs
+++ b/widget/src/radio.rs
@@ -9,8 +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,
- Widget,
+ Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, Size, Widget,
};
pub use iced_style::radio::{Appearance, StyleSheet};
@@ -315,7 +314,7 @@ where
border_radius: (size / 2.0).into(),
border_width: custom_style.border_width,
border_color: custom_style.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
custom_style.background,
);
@@ -330,9 +329,7 @@ where
height: bounds.height - dot_size,
},
border_radius: (dot_size / 2.0).into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
custom_style.dot_color,
);
diff --git a/widget/src/rule.rs b/widget/src/rule.rs
index 4a83e9d1..813b0e46 100644
--- a/widget/src/rule.rs
+++ b/widget/src/rule.rs
@@ -3,9 +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, Pixels, Rectangle, Size, Widget,
-};
+use crate::core::{Element, Layout, Length, Pixels, Rectangle, Size, Widget};
pub use crate::style::rule::{Appearance, FillMode, StyleSheet};
@@ -125,9 +123,7 @@ where
renderer::Quad {
bounds,
border_radius: style.radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.color,
);
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 82602a41..beaad704 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -912,7 +912,7 @@ pub fn draw<Renderer>(
border_radius: style.border_radius,
border_width: style.border_width,
border_color: style.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style
.background
@@ -933,7 +933,7 @@ pub fn draw<Renderer>(
border_radius: style.scroller.border_radius,
border_width: style.scroller.border_width,
border_color: style.scroller.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.scroller.color,
);
diff --git a/widget/src/slider.rs b/widget/src/slider.rs
index d89f50e0..d12e0ebe 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,
+ Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
+ Widget,
};
use std::ops::RangeInclusive;
@@ -399,9 +399,7 @@ pub fn draw<T, R>(
height: style.rail.width,
},
border_radius: style.rail.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.rail.colors.0,
);
@@ -415,9 +413,7 @@ pub fn draw<T, R>(
height: style.rail.width,
},
border_radius: style.rail.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.rail.colors.1,
);
@@ -433,7 +429,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius,
border_width: style.handle.border_width,
border_color: style.handle.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.handle.color,
);
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 3f3ccf72..01ab1262 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;
@@ -470,7 +469,7 @@ where
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
appearance.background,
);
@@ -509,10 +508,7 @@ where
)
.into(),
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.value_color(&self.style),
);
@@ -525,10 +521,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds: range,
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.selection_color(&self.style),
);
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index f8e6c7f8..7b15f58c 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;
@@ -1085,7 +1085,7 @@ pub fn draw<Renderer>(
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
appearance.background,
);
@@ -1132,10 +1132,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,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.value_color(style),
))
@@ -1174,10 +1171,7 @@ pub fn draw<Renderer>(
width,
height: text_bounds.height,
},
- border_radius: 0.0.into(),
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
theme.selection_color(style),
)),
diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs
index f7fb5d58..0bafffe1 100644
--- a/widget/src/toggler.rs
+++ b/widget/src/toggler.rs
@@ -317,7 +317,7 @@ where
border_color: style
.background_border
.unwrap_or(style.background),
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.background,
);
@@ -342,7 +342,7 @@ where
border_color: style
.foreground_border
.unwrap_or(style.foreground),
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.foreground,
);
diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs
index 4fdad861..7a461b08 100644
--- a/widget/src/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -13,8 +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,
- Widget,
+ Clipboard, Element, Length, Pixels, Point, Rectangle, Shell, Size, Widget,
};
/// An vertical bar and a handle that selects a single value from a range of
@@ -398,9 +397,7 @@ pub fn draw<T, R>(
height: offset + handle_width / 2.0,
},
border_radius: style.rail.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.rail.colors.1,
);
@@ -414,9 +411,7 @@ pub fn draw<T, R>(
height: bounds.height - offset - handle_width / 2.0,
},
border_radius: style.rail.border_radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.rail.colors.0,
);
@@ -432,7 +427,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius,
border_width: style.handle.border_width,
border_color: style.handle.border_color,
- shadow: Default::default(),
+ ..renderer::Quad::default()
},
style.handle.color,
);