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(),
border_color: color,
border_width: 1.0,
border_radius: 0.0.into(),
shadow: Default::default(),
..renderer::Quad::default()
},
Color::TRANSPARENT,
);

View file

@ -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,
);

View file

@ -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,

View file

@ -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,

View file

@ -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,
)
);
}
}

View file

@ -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

View file

@ -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,
);

View file

@ -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

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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,
);

View file

@ -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),
);

View file

@ -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),
)),

View file

@ -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,
);

View file

@ -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,
);