diff options
author | 2024-03-27 19:47:48 +0900 | |
---|---|---|
committer | 2024-03-27 19:47:48 +0900 | |
commit | 19afc66cadfc7ea230d4d749b0d7b0197e29cf93 (patch) | |
tree | d012dff84003f2d7d18a1e6bc4bdac62df73b322 /core/src/renderer | |
parent | 4334e63ba1dd88b367f3b7f2790b7869d11d12c0 (diff) | |
parent | 1df1cf82f4c9485533f2566c8490cfe188b4ae6a (diff) | |
download | iced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.tar.gz iced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.tar.bz2 iced-19afc66cadfc7ea230d4d749b0d7b0197e29cf93.zip |
Merge branch 'master' into viewer_content_fit
Diffstat (limited to 'core/src/renderer')
-rw-r--r-- | core/src/renderer/null.rs | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 83688ff7..c26ce1a5 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -1,5 +1,7 @@ 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, @@ -7,28 +9,14 @@ use crate::{ use std::borrow::Cow; -/// A renderer that does nothing. -/// -/// It can be useful if you are writing tests! -#[derive(Debug, Clone, Copy, Default)] -pub struct Null; +impl Renderer for () { + fn start_layer(&mut self) {} -impl Null { - /// Creates a new [`Null`] renderer. - pub fn new() -> Null { - Null - } -} + fn end_layer(&mut self, _bounds: Rectangle) {} -impl Renderer for Null { - fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {} + fn start_transformation(&mut self) {} - fn with_transformation( - &mut self, - _transformation: Transformation, - _f: impl FnOnce(&mut Self), - ) { - } + fn end_transformation(&mut self, _transformation: Transformation) {} fn clear(&mut self) {} @@ -40,7 +28,7 @@ impl Renderer for Null { } } -impl text::Renderer for Null { +impl text::Renderer for () { type Font = Font; type Paragraph = (); type Editor = (); @@ -174,3 +162,33 @@ 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, + ) { + } +} + +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, + ) { + } +} |