iced_core/renderer/
null.rs

1use crate::alignment;
2use crate::image::{self, Image};
3use crate::renderer::{self, Renderer};
4use crate::svg;
5use crate::text::{self, Text};
6use crate::{
7    Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation,
8};
9
10impl Renderer for () {
11    fn start_layer(&mut self, _bounds: Rectangle) {}
12
13    fn end_layer(&mut self) {}
14
15    fn start_transformation(&mut self, _transformation: Transformation) {}
16
17    fn end_transformation(&mut self) {}
18
19    fn reset(&mut self, _new_bounds: Rectangle) {}
20
21    fn fill_quad(
22        &mut self,
23        _quad: renderer::Quad,
24        _background: impl Into<Background>,
25    ) {
26    }
27
28    fn allocate_image(
29        &mut self,
30        handle: &image::Handle,
31        callback: impl FnOnce(Result<image::Allocation, image::Error>)
32        + Send
33        + 'static,
34    ) {
35        #[allow(unsafe_code)]
36        callback(Ok(unsafe { image::allocate(handle, Size::new(100, 100)) }));
37    }
38}
39
40impl text::Renderer for () {
41    type Font = Font;
42    type Paragraph = ();
43    type Editor = ();
44
45    const ICON_FONT: Font = Font::DEFAULT;
46    const CHECKMARK_ICON: char = '0';
47    const ARROW_DOWN_ICON: char = '0';
48
49    fn default_font(&self) -> Self::Font {
50        Font::default()
51    }
52
53    fn default_size(&self) -> Pixels {
54        Pixels(16.0)
55    }
56
57    fn fill_paragraph(
58        &mut self,
59        _paragraph: &Self::Paragraph,
60        _position: Point,
61        _color: Color,
62        _clip_bounds: Rectangle,
63    ) {
64    }
65
66    fn fill_editor(
67        &mut self,
68        _editor: &Self::Editor,
69        _position: Point,
70        _color: Color,
71        _clip_bounds: Rectangle,
72    ) {
73    }
74
75    fn fill_text(
76        &mut self,
77        _paragraph: Text,
78        _position: Point,
79        _color: Color,
80        _clip_bounds: Rectangle,
81    ) {
82    }
83}
84
85impl text::Paragraph for () {
86    type Font = Font;
87
88    fn with_text(_text: Text<&str>) -> Self {}
89
90    fn with_spans<Link>(
91        _text: Text<&[text::Span<'_, Link, Self::Font>], Self::Font>,
92    ) -> Self {
93    }
94
95    fn resize(&mut self, _new_bounds: Size) {}
96
97    fn compare(&self, _text: Text<()>) -> text::Difference {
98        text::Difference::None
99    }
100
101    fn size(&self) -> Pixels {
102        Pixels(16.0)
103    }
104
105    fn font(&self) -> Font {
106        Font::DEFAULT
107    }
108
109    fn line_height(&self) -> text::LineHeight {
110        text::LineHeight::default()
111    }
112
113    fn align_x(&self) -> text::Alignment {
114        text::Alignment::Default
115    }
116
117    fn align_y(&self) -> alignment::Vertical {
118        alignment::Vertical::Top
119    }
120
121    fn wrapping(&self) -> text::Wrapping {
122        text::Wrapping::default()
123    }
124
125    fn shaping(&self) -> text::Shaping {
126        text::Shaping::default()
127    }
128
129    fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point> {
130        None
131    }
132
133    fn bounds(&self) -> Size {
134        Size::ZERO
135    }
136
137    fn min_bounds(&self) -> Size {
138        Size::ZERO
139    }
140
141    fn hit_test(&self, _point: Point) -> Option<text::Hit> {
142        None
143    }
144
145    fn hit_span(&self, _point: Point) -> Option<usize> {
146        None
147    }
148
149    fn span_bounds(&self, _index: usize) -> Vec<Rectangle> {
150        vec![]
151    }
152}
153
154impl text::Editor for () {
155    type Font = Font;
156
157    fn with_text(_text: &str) -> Self {}
158
159    fn is_empty(&self) -> bool {
160        true
161    }
162
163    fn cursor(&self) -> text::editor::Cursor {
164        text::editor::Cursor::Caret(Point::ORIGIN)
165    }
166
167    fn cursor_position(&self) -> (usize, usize) {
168        (0, 0)
169    }
170
171    fn selection(&self) -> Option<String> {
172        None
173    }
174
175    fn line(&self, _index: usize) -> Option<text::editor::Line<'_>> {
176        None
177    }
178
179    fn line_count(&self) -> usize {
180        0
181    }
182
183    fn perform(&mut self, _action: text::editor::Action) {}
184
185    fn bounds(&self) -> Size {
186        Size::ZERO
187    }
188
189    fn min_bounds(&self) -> Size {
190        Size::ZERO
191    }
192
193    fn update(
194        &mut self,
195        _new_bounds: Size,
196        _new_font: Self::Font,
197        _new_size: Pixels,
198        _new_line_height: text::LineHeight,
199        _new_wrapping: text::Wrapping,
200        _new_highlighter: &mut impl text::Highlighter,
201    ) {
202    }
203
204    fn highlight<H: text::Highlighter>(
205        &mut self,
206        _font: Self::Font,
207        _highlighter: &mut H,
208        _format_highlight: impl Fn(
209            &H::Highlight,
210        ) -> text::highlighter::Format<Self::Font>,
211    ) {
212    }
213}
214
215impl image::Renderer for () {
216    type Handle = image::Handle;
217
218    fn load_image(
219        &self,
220        handle: &Self::Handle,
221    ) -> Result<image::Allocation, image::Error> {
222        #[allow(unsafe_code)]
223        Ok(unsafe { image::allocate(handle, Size::new(100, 100)) })
224    }
225
226    fn measure_image(&self, _handle: &Self::Handle) -> Option<Size<u32>> {
227        Some(Size::new(100, 100))
228    }
229
230    fn draw_image(
231        &mut self,
232        _image: Image,
233        _bounds: Rectangle,
234        _clip_bounds: Rectangle,
235    ) {
236    }
237}
238
239impl svg::Renderer for () {
240    fn measure_svg(&self, _handle: &svg::Handle) -> Size<u32> {
241        Size::default()
242    }
243
244    fn draw_svg(
245        &mut self,
246        _svg: svg::Svg,
247        _bounds: Rectangle,
248        _clip_bounds: Rectangle,
249    ) {
250    }
251}