iced_core/renderer/
null.rs1use crate::alignment;
2use crate::image::{self, Image};
3use crate::renderer::{self, Renderer};
4use crate::svg;
5use crate::text::highlighter;
6use crate::text::{self, Text};
7use crate::{Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation};
8
9impl Renderer for () {
10 fn start_layer(&mut self, _bounds: Rectangle) {}
11
12 fn end_layer(&mut self) {}
13
14 fn start_transformation(&mut self, _transformation: Transformation) {}
15
16 fn end_transformation(&mut self) {}
17
18 fn fill_quad(&mut self, _quad: renderer::Quad, _background: impl Into<Background>) {}
19
20 fn allocate_image(
21 &self,
22 handle: &image::Handle,
23 callback: impl FnOnce(Result<image::Allocation, image::Error>) + Send + 'static,
24 ) {
25 #[allow(unsafe_code)]
26 callback(Ok(unsafe { image::allocate(handle, Size::new(100, 100)) }));
27 }
28
29 fn hint(&mut self, _scale: renderer::Scale) {}
30
31 fn scale(&self) -> Option<renderer::Scale> {
32 None
33 }
34
35 fn reset(&mut self, _new_bounds: Rectangle) {}
36
37 fn settings(&self) -> renderer::Settings {
38 renderer::Settings::default()
39 }
40}
41
42impl text::Renderer for () {
43 type Paragraph = ();
44 type Editor = ();
45
46 const ICON_FONT: Font = Font::DEFAULT;
47 const CHECKMARK_ICON: char = '0';
48 const ARROW_DOWN_ICON: char = '0';
49 const SCROLL_UP_ICON: char = '0';
50 const SCROLL_DOWN_ICON: char = '0';
51 const SCROLL_LEFT_ICON: char = '0';
52 const SCROLL_RIGHT_ICON: char = '0';
53 const ICED_LOGO: char = '0';
54
55 fn fill_paragraph(
56 &mut self,
57 _paragraph: &Self::Paragraph,
58 _position: Point,
59 _color: Color,
60 _clip_bounds: Rectangle,
61 ) {
62 }
63
64 fn fill_editor(
65 &mut self,
66 _editor: &Self::Editor,
67 _position: Point,
68 _color: Color,
69 _clip_bounds: Rectangle,
70 ) {
71 }
72
73 fn fill_text(
74 &mut self,
75 _paragraph: Text,
76 _position: Point,
77 _color: Color,
78 _clip_bounds: Rectangle,
79 ) {
80 }
81}
82
83impl text::Paragraph for () {
84 fn with_text(_text: Text<&str>) -> Self {}
85
86 fn with_spans<Link>(_text: Text<&[text::Span<'_, Link>]>) -> Self {}
87
88 fn resize(&mut self, _new_bounds: Size) {}
89
90 fn compare(&self, _text: Text<()>) -> text::Difference {
91 text::Difference::None
92 }
93
94 fn hint_factor(&self) -> Option<f32> {
95 None
96 }
97
98 fn size(&self) -> Pixels {
99 Pixels(16.0)
100 }
101
102 fn font(&self) -> Font {
103 Font::DEFAULT
104 }
105
106 fn line_height(&self) -> text::LineHeight {
107 text::LineHeight::default()
108 }
109
110 fn align_x(&self) -> text::Alignment {
111 text::Alignment::Default
112 }
113
114 fn align_y(&self) -> alignment::Vertical {
115 alignment::Vertical::Top
116 }
117
118 fn wrapping(&self) -> text::Wrapping {
119 text::Wrapping::default()
120 }
121
122 fn ellipsis(&self) -> text::Ellipsis {
123 text::Ellipsis::default()
124 }
125
126 fn shaping(&self) -> text::Shaping {
127 text::Shaping::default()
128 }
129
130 fn bounds(&self) -> Size {
131 Size::ZERO
132 }
133
134 fn min_bounds(&self) -> Size {
135 Size::ZERO
136 }
137
138 fn hit_test(&self, _point: Point) -> Option<text::Hit> {
139 None
140 }
141
142 fn hit_span(&self, _point: Point) -> Option<usize> {
143 None
144 }
145
146 fn span_bounds(&self, _index: usize) -> Vec<Rectangle> {
147 vec![]
148 }
149
150 fn select(&mut self, _start: Point, _end: Point, _target: text::Target) {}
151 fn select_all(&mut self) {}
152 fn deselect(&mut self) {}
153
154 fn selection(&self) -> &[Rectangle] {
155 &[]
156 }
157
158 fn copy(&mut self) -> Option<String> {
159 None
160 }
161}
162
163impl text::Editor for () {
164 fn with_text(_text: &str) -> Self {}
165
166 fn is_empty(&self) -> bool {
167 true
168 }
169
170 fn cursor(&self) -> text::editor::Cursor {
171 text::editor::Cursor {
172 position: text::Position { line: 0, index: 0 },
173 selection: None,
174 }
175 }
176
177 fn selection(&self) -> Option<text::editor::Selection> {
178 None
179 }
180
181 fn copy(&self) -> Option<String> {
182 None
183 }
184
185 fn line(&self, _index: usize) -> Option<text::editor::Line<'_>> {
186 None
187 }
188
189 fn line_count(&self) -> usize {
190 0
191 }
192
193 fn perform(&mut self, _action: text::editor::Action) {}
194
195 fn move_to(&mut self, _cursor: text::editor::Cursor) {}
196
197 fn bounds(&self) -> Size {
198 Size::ZERO
199 }
200
201 fn hint_factor(&self) -> Option<f32> {
202 None
203 }
204
205 fn min_bounds(&self) -> Size {
206 Size::ZERO
207 }
208
209 fn update(
210 &mut self,
211 _new_bounds: Size,
212 _new_font: Font,
213 _new_size: Pixels,
214 _new_line_height: text::LineHeight,
215 _new_wrapping: text::Wrapping,
216 _new_alignment: text::Alignment,
217 _new_hint_factor: Option<f32>,
218 _new_parser: &mut impl text::Parser,
219 ) {
220 }
221
222 fn overwrite(&mut self, _new_text: &str) {}
223
224 fn highlight<P: text::Parser>(
225 &mut self,
226 _font: Font,
227 _parser: &mut P,
228 _highlighter: impl Fn(P::Output) -> highlighter::Style,
229 ) {
230 }
231
232 fn text_size(&self) -> Pixels {
233 Pixels(0.0)
234 }
235
236 fn line_height(&self) -> text::LineHeight {
237 text::LineHeight::default()
238 }
239
240 fn font(&self) -> Font {
241 Font::default()
242 }
243}
244
245impl image::Renderer for () {
246 type Handle = image::Handle;
247
248 fn load_image(&self, handle: &Self::Handle) -> Result<image::Allocation, image::Error> {
249 #[allow(unsafe_code)]
250 Ok(unsafe { image::allocate(handle, Size::new(100, 100)) })
251 }
252
253 fn measure_image(&self, _handle: &Self::Handle) -> Option<Size<u32>> {
254 Some(Size::new(100, 100))
255 }
256
257 fn draw_image(&mut self, _image: Image, _bounds: Rectangle, _clip_bounds: Rectangle) {}
258}
259
260impl svg::Renderer for () {
261 fn measure_svg(&self, _handle: &svg::Handle) -> Size<u32> {
262 Size::default()
263 }
264
265 fn draw_svg(&mut self, _svg: svg::Svg, _bounds: Rectangle, _clip_bounds: Rectangle) {}
266}
267
268impl renderer::Headless for () {
269 async fn new(_settings: renderer::Settings, _backend: Option<&str>) -> Option<Self>
270 where
271 Self: Sized,
272 {
273 Some(())
274 }
275
276 fn name(&self) -> String {
277 "null renderer".to_owned()
278 }
279
280 fn screenshot(
281 &mut self,
282 _size: Size<u32>,
283 _scale_factor: f32,
284 _background_color: Color,
285 ) -> Vec<u8> {
286 Vec::new()
287 }
288}