Use Default implementation of renderer::Quad

This commit is contained in:
Héctor Ramón Jiménez 2024-01-20 12:25:07 +01:00
parent b7b457a575
commit 370b2f6df7
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
20 changed files with 63 additions and 116 deletions

View file

@ -539,8 +539,7 @@ where
bounds: layout.bounds(), bounds: layout.bounds(),
border_color: color, border_color: color,
border_width: 1.0, border_width: 1.0,
border_radius: 0.0.into(), ..renderer::Quad::default()
shadow: Default::default(),
}, },
Color::TRANSPARENT, Color::TRANSPARENT,
); );

View file

@ -63,9 +63,7 @@ mod circle {
renderer::Quad { renderer::Quad {
bounds: layout.bounds(), bounds: layout.bounds(),
border_radius: self.radius.into(), border_radius: self.radius.into(),
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Color::BLACK, Color::BLACK,
); );

View file

@ -225,10 +225,7 @@ where
width: bounds.width, width: bounds.width,
height: bounds.height, height: bounds.height,
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Background::Color(custom_style.track_color), Background::Color(custom_style.track_color),
); );
@ -242,10 +239,7 @@ where
width: self.easing.y_at_x(*progress) * bounds.width, width: self.easing.y_at_x(*progress) * bounds.width,
height: bounds.height, height: bounds.height,
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Background::Color(custom_style.bar_color), Background::Color(custom_style.bar_color),
), ),
@ -260,10 +254,7 @@ where
* bounds.width, * bounds.width,
height: bounds.height, height: bounds.height,
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Background::Color(custom_style.bar_color), Background::Color(custom_style.bar_color),
), ),
@ -291,7 +282,7 @@ pub struct Appearance {
pub bar_color: Color, pub bar_color: Color,
} }
impl std::default::Default for Appearance { impl Default for Appearance {
fn default() -> Self { fn default() -> Self {
Self { Self {
track_color: Color::TRANSPARENT, track_color: Color::TRANSPARENT,

View file

@ -475,9 +475,7 @@ mod modal {
renderer::Quad { renderer::Quad {
bounds: layout.bounds(), bounds: layout.bounds(),
border_radius: BorderRadius::default(), border_radius: BorderRadius::default(),
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Color { Color {
a: 0.80, a: 0.80,

View file

@ -267,22 +267,23 @@ impl Backend {
}) })
.collect(); .collect();
if let Some(p) = tiny_skia::IntSize::from_wh(width, height) if let Some(pixmap) = tiny_skia::IntSize::from_wh(
.and_then(|size| { width, height,
tiny_skia::Pixmap::from_vec( )
bytemuck::cast_vec(colors), .and_then(|size| {
size, tiny_skia::Pixmap::from_vec(
) bytemuck::cast_vec(colors),
}) size,
{ )
}) {
pixels.draw_pixmap( pixels.draw_pixmap(
x as i32, x as i32,
y as i32, y as i32,
p.as_ref(), pixmap.as_ref(),
&Default::default(), &tiny_skia::PixmapPaint::default(),
Default::default(), tiny_skia::Transform::default(),
None, None,
) );
} }
} }

View file

@ -402,9 +402,7 @@ where
..bounds ..bounds
}, },
border_radius: styling.border_radius, border_radius: styling.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
Background::Color([0.0, 0.0, 0.0, 0.5].into()), Background::Color([0.0, 0.0, 0.0, 0.5].into()),
); );
@ -416,7 +414,7 @@ where
border_radius: styling.border_radius, border_radius: styling.border_radius,
border_width: styling.border_width, border_width: styling.border_width,
border_color: styling.border_color, border_color: styling.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
styling styling
.background .background

View file

@ -287,7 +287,7 @@ where
border_radius: custom_style.border_radius, border_radius: custom_style.border_radius,
border_width: custom_style.border_width, border_width: custom_style.border_width,
border_color: custom_style.border_color, border_color: custom_style.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
custom_style.background, custom_style.background,
); );

View file

@ -344,7 +344,7 @@ pub fn draw_background<Renderer>(
border_radius: appearance.border_radius, border_radius: appearance.border_radius,
border_width: appearance.border_width, border_width: appearance.border_width,
border_color: appearance.border_color, border_color: appearance.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
appearance appearance
.background .background

View file

@ -10,7 +10,7 @@ use crate::core::text::{self, Text};
use crate::core::touch; use crate::core::touch;
use crate::core::widget::Tree; use crate::core::widget::Tree;
use crate::core::{ 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::core::{Element, Shell, Widget};
use crate::scrollable::{self, Scrollable}; use crate::scrollable::{self, Scrollable};
@ -309,7 +309,7 @@ where
border_color: appearance.border_color, border_color: appearance.border_color,
border_width: appearance.border_width, border_width: appearance.border_width,
border_radius: appearance.border_radius, border_radius: appearance.border_radius,
shadow: Default::default(), ..renderer::Quad::default()
}, },
appearance.background, appearance.background,
); );
@ -517,10 +517,8 @@ where
width: bounds.width - appearance.border_width * 2.0, width: bounds.width - appearance.border_width * 2.0,
..bounds ..bounds
}, },
border_color: Color::TRANSPARENT,
border_width: 0.0,
border_radius: appearance.border_radius, border_radius: appearance.border_radius,
shadow: Default::default(), ..renderer::Quad::default()
}, },
appearance.selected_background, appearance.selected_background,
); );

View file

@ -42,8 +42,8 @@ use crate::core::touch;
use crate::core::widget; use crate::core::widget;
use crate::core::widget::tree::{self, Tree}; use crate::core::widget::tree::{self, Tree};
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
Size, Vector, Widget, Vector, Widget,
}; };
/// A collection of panes distributed using either vertical or horizontal splits /// A collection of panes distributed using either vertical or horizontal splits
@ -921,7 +921,7 @@ pub fn draw<Renderer, T>(
.border_radius, .border_radius,
border_width: hovered_region_style.border_width, border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color, border_color: hovered_region_style.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
theme.hovered_region(style).background, theme.hovered_region(style).background,
); );
@ -951,7 +951,7 @@ pub fn draw<Renderer, T>(
border_radius: hovered_region_style.border_radius, border_radius: hovered_region_style.border_radius,
border_width: hovered_region_style.border_width, border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color, border_color: hovered_region_style.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
theme.hovered_region(style).background, theme.hovered_region(style).background,
); );
@ -1012,10 +1012,7 @@ pub fn draw<Renderer, T>(
height: split_region.height, height: split_region.height,
}, },
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
highlight.color, highlight.color,
); );

View file

@ -656,7 +656,7 @@ pub fn draw<'a, T, Renderer>(
border_color: style.border_color, border_color: style.border_color,
border_width: style.border_width, border_width: style.border_width,
border_radius: style.border_radius, border_radius: style.border_radius,
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.background, style.background,
); );

View file

@ -3,7 +3,7 @@ use crate::core::layout;
use crate::core::mouse; use crate::core::mouse;
use crate::core::renderer; use crate::core::renderer;
use crate::core::widget::Tree; 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; use std::ops::RangeInclusive;
@ -131,9 +131,7 @@ where
renderer::Quad { renderer::Quad {
bounds: Rectangle { ..bounds }, bounds: Rectangle { ..bounds },
border_radius: style.border_radius, border_radius: style.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.background, style.background,
); );
@ -146,9 +144,7 @@ where
..bounds ..bounds
}, },
border_radius: style.border_radius, border_radius: style.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.bar, style.bar,
); );

View file

@ -9,8 +9,7 @@ use crate::core::touch;
use crate::core::widget; use crate::core::widget;
use crate::core::widget::tree::{self, Tree}; use crate::core::widget::tree::{self, Tree};
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Layout, Length, Pixels, Rectangle, Shell, Size, Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, Size, Widget,
Widget,
}; };
pub use iced_style::radio::{Appearance, StyleSheet}; pub use iced_style::radio::{Appearance, StyleSheet};
@ -315,7 +314,7 @@ where
border_radius: (size / 2.0).into(), border_radius: (size / 2.0).into(),
border_width: custom_style.border_width, border_width: custom_style.border_width,
border_color: custom_style.border_color, border_color: custom_style.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
custom_style.background, custom_style.background,
); );
@ -330,9 +329,7 @@ where
height: bounds.height - dot_size, height: bounds.height - dot_size,
}, },
border_radius: (dot_size / 2.0).into(), border_radius: (dot_size / 2.0).into(),
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
custom_style.dot_color, custom_style.dot_color,
); );

View file

@ -3,9 +3,7 @@ use crate::core::layout;
use crate::core::mouse; use crate::core::mouse;
use crate::core::renderer; use crate::core::renderer;
use crate::core::widget::Tree; use crate::core::widget::Tree;
use crate::core::{ use crate::core::{Element, Layout, Length, Pixels, Rectangle, Size, Widget};
Color, Element, Layout, Length, Pixels, Rectangle, Size, Widget,
};
pub use crate::style::rule::{Appearance, FillMode, StyleSheet}; pub use crate::style::rule::{Appearance, FillMode, StyleSheet};
@ -125,9 +123,7 @@ where
renderer::Quad { renderer::Quad {
bounds, bounds,
border_radius: style.radius, border_radius: style.radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.color, style.color,
); );

View file

@ -912,7 +912,7 @@ pub fn draw<Renderer>(
border_radius: style.border_radius, border_radius: style.border_radius,
border_width: style.border_width, border_width: style.border_width,
border_color: style.border_color, border_color: style.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
style style
.background .background
@ -933,7 +933,7 @@ pub fn draw<Renderer>(
border_radius: style.scroller.border_radius, border_radius: style.scroller.border_radius,
border_width: style.scroller.border_width, border_width: style.scroller.border_width,
border_color: style.scroller.border_color, border_color: style.scroller.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.scroller.color, style.scroller.color,
); );

View file

@ -8,8 +8,8 @@ use crate::core::renderer;
use crate::core::touch; use crate::core::touch;
use crate::core::widget::tree::{self, Tree}; use crate::core::widget::tree::{self, Tree};
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
Size, Widget, Widget,
}; };
use std::ops::RangeInclusive; use std::ops::RangeInclusive;
@ -399,9 +399,7 @@ pub fn draw<T, R>(
height: style.rail.width, height: style.rail.width,
}, },
border_radius: style.rail.border_radius, border_radius: style.rail.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.rail.colors.0, style.rail.colors.0,
); );
@ -415,9 +413,7 @@ pub fn draw<T, R>(
height: style.rail.width, height: style.rail.width,
}, },
border_radius: style.rail.border_radius, border_radius: style.rail.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.rail.colors.1, style.rail.colors.1,
); );
@ -433,7 +429,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius, border_radius: handle_border_radius,
border_width: style.handle.border_width, border_width: style.handle.border_width,
border_color: style.handle.border_color, border_color: style.handle.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.handle.color, style.handle.color,
); );

View file

@ -10,8 +10,7 @@ use crate::core::text::highlighter::{self, Highlighter};
use crate::core::text::{self, LineHeight}; use crate::core::text::{self, LineHeight};
use crate::core::widget::{self, Widget}; use crate::core::widget::{self, Widget};
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector,
Vector,
}; };
use std::cell::RefCell; use std::cell::RefCell;
@ -470,7 +469,7 @@ where
border_radius: appearance.border_radius, border_radius: appearance.border_radius,
border_width: appearance.border_width, border_width: appearance.border_width,
border_color: appearance.border_color, border_color: appearance.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
appearance.background, appearance.background,
); );
@ -509,10 +508,7 @@ where
) )
.into(), .into(),
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
theme.value_color(&self.style), theme.value_color(&self.style),
); );
@ -525,10 +521,7 @@ where
renderer.fill_quad( renderer.fill_quad(
renderer::Quad { renderer::Quad {
bounds: range, bounds: range,
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
theme.selection_color(&self.style), theme.selection_color(&self.style),
); );

View file

@ -26,8 +26,8 @@ use crate::core::widget::operation::{self, Operation};
use crate::core::widget::tree::{self, Tree}; use crate::core::widget::tree::{self, Tree};
use crate::core::window; use crate::core::window;
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Layout, Length, Padding, Pixels, Point, Clipboard, Element, Layout, Length, Padding, Pixels, Point, Rectangle,
Rectangle, Shell, Size, Vector, Widget, Shell, Size, Vector, Widget,
}; };
use crate::runtime::Command; use crate::runtime::Command;
@ -1085,7 +1085,7 @@ pub fn draw<Renderer>(
border_radius: appearance.border_radius, border_radius: appearance.border_radius,
border_width: appearance.border_width, border_width: appearance.border_width,
border_color: appearance.border_color, border_color: appearance.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
appearance.background, appearance.background,
); );
@ -1132,10 +1132,7 @@ pub fn draw<Renderer>(
width: 1.0, width: 1.0,
height: text_bounds.height, height: text_bounds.height,
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
theme.value_color(style), theme.value_color(style),
)) ))
@ -1174,10 +1171,7 @@ pub fn draw<Renderer>(
width, width,
height: text_bounds.height, height: text_bounds.height,
}, },
border_radius: 0.0.into(), ..renderer::Quad::default()
border_width: 0.0,
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
theme.selection_color(style), theme.selection_color(style),
)), )),

View file

@ -317,7 +317,7 @@ where
border_color: style border_color: style
.background_border .background_border
.unwrap_or(style.background), .unwrap_or(style.background),
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.background, style.background,
); );
@ -342,7 +342,7 @@ where
border_color: style border_color: style
.foreground_border .foreground_border
.unwrap_or(style.foreground), .unwrap_or(style.foreground),
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.foreground, style.foreground,
); );

View file

@ -13,8 +13,7 @@ use crate::core::renderer;
use crate::core::touch; use crate::core::touch;
use crate::core::widget::tree::{self, Tree}; use crate::core::widget::tree::{self, Tree};
use crate::core::{ use crate::core::{
Clipboard, Color, Element, Length, Pixels, Point, Rectangle, Shell, Size, Clipboard, Element, Length, Pixels, Point, Rectangle, Shell, Size, Widget,
Widget,
}; };
/// An vertical bar and a handle that selects a single value from a range of /// 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, height: offset + handle_width / 2.0,
}, },
border_radius: style.rail.border_radius, border_radius: style.rail.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.rail.colors.1, style.rail.colors.1,
); );
@ -414,9 +411,7 @@ pub fn draw<T, R>(
height: bounds.height - offset - handle_width / 2.0, height: bounds.height - offset - handle_width / 2.0,
}, },
border_radius: style.rail.border_radius, border_radius: style.rail.border_radius,
border_width: 0.0, ..renderer::Quad::default()
border_color: Color::TRANSPARENT,
shadow: Default::default(),
}, },
style.rail.colors.0, style.rail.colors.0,
); );
@ -432,7 +427,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius, border_radius: handle_border_radius,
border_width: style.handle.border_width, border_width: style.handle.border_width,
border_color: style.handle.border_color, border_color: style.handle.border_color,
shadow: Default::default(), ..renderer::Quad::default()
}, },
style.handle.color, style.handle.color,
); );