summaryrefslogtreecommitdiffstats
path: root/core/src/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
commitd8ba6b0673a33724a177f3a1ba59705527280142 (patch)
tree89482c8d1e3a03e00b3a8151abbb81e30ae5898c /core/src/renderer
parent72ed8bcc8def9956e25f3720a3095fc96bb2eef0 (diff)
parent468794d918eb06c1dbebb33c32b10017ad335f05 (diff)
downloadiced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.gz
iced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.bz2
iced-d8ba6b0673a33724a177f3a1ba59705527280142.zip
Merge branch 'master' into feat/text-macro
Diffstat (limited to 'core/src/renderer')
-rw-r--r--core/src/renderer/null.rs75
1 files changed, 47 insertions, 28 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs
index 83688ff7..e8709dbc 100644
--- a/core/src/renderer/null.rs
+++ b/core/src/renderer/null.rs
@@ -1,34 +1,21 @@
use crate::alignment;
+use crate::image;
use crate::renderer::{self, Renderer};
+use crate::svg;
use crate::text::{self, Text};
use crate::{
- Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation,
+ Background, Color, Font, Pixels, Point, Radians, Rectangle, Size,
+ Transformation,
};
-use std::borrow::Cow;
+impl Renderer for () {
+ fn start_layer(&mut self, _bounds: Rectangle) {}
-/// A renderer that does nothing.
-///
-/// It can be useful if you are writing tests!
-#[derive(Debug, Clone, Copy, Default)]
-pub struct Null;
+ fn end_layer(&mut self) {}
-impl Null {
- /// Creates a new [`Null`] renderer.
- pub fn new() -> Null {
- Null
- }
-}
-
-impl Renderer for Null {
- fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {}
+ fn start_transformation(&mut self, _transformation: Transformation) {}
- fn with_transformation(
- &mut self,
- _transformation: Transformation,
- _f: impl FnOnce(&mut Self),
- ) {
- }
+ fn end_transformation(&mut self) {}
fn clear(&mut self) {}
@@ -40,7 +27,7 @@ impl Renderer for Null {
}
}
-impl text::Renderer for Null {
+impl text::Renderer for () {
type Font = Font;
type Paragraph = ();
type Editor = ();
@@ -57,8 +44,6 @@ impl text::Renderer for Null {
Pixels(16.0)
}
- fn load_font(&mut self, _font: Cow<'static, [u8]>) {}
-
fn fill_paragraph(
&mut self,
_paragraph: &Self::Paragraph,
@@ -79,7 +64,7 @@ impl text::Renderer for Null {
fn fill_text(
&mut self,
- _paragraph: Text<'_, Self::Font>,
+ _paragraph: Text,
_position: Point,
_color: Color,
_clip_bounds: Rectangle,
@@ -90,11 +75,11 @@ impl text::Renderer for Null {
impl text::Paragraph for () {
type Font = Font;
- fn with_text(_text: Text<'_, Self::Font>) -> Self {}
+ fn with_text(_text: Text<&str>) -> Self {}
fn resize(&mut self, _new_bounds: Size) {}
- fn compare(&self, _text: Text<'_, Self::Font>) -> text::Difference {
+ fn compare(&self, _text: Text<&str>) -> text::Difference {
text::Difference::None
}
@@ -174,3 +159,37 @@ impl text::Editor for () {
) {
}
}
+
+impl image::Renderer for () {
+ type Handle = ();
+
+ fn measure_image(&self, _handle: &Self::Handle) -> Size<u32> {
+ Size::default()
+ }
+
+ fn draw_image(
+ &mut self,
+ _handle: Self::Handle,
+ _filter_method: image::FilterMethod,
+ _bounds: Rectangle,
+ _rotation: Radians,
+ _opacity: f32,
+ ) {
+ }
+}
+
+impl svg::Renderer for () {
+ fn measure_svg(&self, _handle: &svg::Handle) -> Size<u32> {
+ Size::default()
+ }
+
+ fn draw_svg(
+ &mut self,
+ _handle: svg::Handle,
+ _color: Option<Color>,
+ _bounds: Rectangle,
+ _rotation: Radians,
+ _opacity: f32,
+ ) {
+ }
+}