iced_core/renderer/
null.rs1use 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 const SCROLL_UP_ICON: char = '0';
49 const SCROLL_DOWN_ICON: char = '0';
50 const SCROLL_LEFT_ICON: char = '0';
51 const SCROLL_RIGHT_ICON: char = '0';
52 const ICED_LOGO: char = '0';
53
54 fn default_font(&self) -> Self::Font {
55 Font::default()
56 }
57
58 fn default_size(&self) -> Pixels {
59 Pixels(16.0)
60 }
61
62 fn fill_paragraph(
63 &mut self,
64 _paragraph: &Self::Paragraph,
65 _position: Point,
66 _color: Color,
67 _clip_bounds: Rectangle,
68 ) {
69 }
70
71 fn fill_editor(
72 &mut self,
73 _editor: &Self::Editor,
74 _position: Point,
75 _color: Color,
76 _clip_bounds: Rectangle,
77 ) {
78 }
79
80 fn fill_text(
81 &mut self,
82 _paragraph: Text,
83 _position: Point,
84 _color: Color,
85 _clip_bounds: Rectangle,
86 ) {
87 }
88}
89
90impl text::Paragraph for () {
91 type Font = Font;
92
93 fn with_text(_text: Text<&str>) -> Self {}
94
95 fn with_spans<Link>(
96 _text: Text<&[text::Span<'_, Link, Self::Font>], Self::Font>,
97 ) -> Self {
98 }
99
100 fn resize(&mut self, _new_bounds: Size) {}
101
102 fn compare(&self, _text: Text<()>) -> text::Difference {
103 text::Difference::None
104 }
105
106 fn size(&self) -> Pixels {
107 Pixels(16.0)
108 }
109
110 fn font(&self) -> Font {
111 Font::DEFAULT
112 }
113
114 fn line_height(&self) -> text::LineHeight {
115 text::LineHeight::default()
116 }
117
118 fn align_x(&self) -> text::Alignment {
119 text::Alignment::Default
120 }
121
122 fn align_y(&self) -> alignment::Vertical {
123 alignment::Vertical::Top
124 }
125
126 fn wrapping(&self) -> text::Wrapping {
127 text::Wrapping::default()
128 }
129
130 fn shaping(&self) -> text::Shaping {
131 text::Shaping::default()
132 }
133
134 fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point> {
135 None
136 }
137
138 fn bounds(&self) -> Size {
139 Size::ZERO
140 }
141
142 fn min_bounds(&self) -> Size {
143 Size::ZERO
144 }
145
146 fn hit_test(&self, _point: Point) -> Option<text::Hit> {
147 None
148 }
149
150 fn hit_span(&self, _point: Point) -> Option<usize> {
151 None
152 }
153
154 fn span_bounds(&self, _index: usize) -> Vec<Rectangle> {
155 vec![]
156 }
157}
158
159impl text::Editor for () {
160 type Font = Font;
161
162 fn with_text(_text: &str) -> Self {}
163
164 fn is_empty(&self) -> bool {
165 true
166 }
167
168 fn cursor(&self) -> text::editor::Cursor {
169 text::editor::Cursor {
170 position: text::editor::Position { line: 0, column: 0 },
171 selection: None,
172 }
173 }
174
175 fn selection(&self) -> text::editor::Selection {
176 text::editor::Selection::Caret(Point::ORIGIN)
177 }
178
179 fn copy(&self) -> Option<String> {
180 None
181 }
182
183 fn line(&self, _index: usize) -> Option<text::editor::Line<'_>> {
184 None
185 }
186
187 fn line_count(&self) -> usize {
188 0
189 }
190
191 fn perform(&mut self, _action: text::editor::Action) {}
192
193 fn move_to(&mut self, _cursor: text::editor::Cursor) {}
194
195 fn bounds(&self) -> Size {
196 Size::ZERO
197 }
198
199 fn min_bounds(&self) -> Size {
200 Size::ZERO
201 }
202
203 fn update(
204 &mut self,
205 _new_bounds: Size,
206 _new_font: Self::Font,
207 _new_size: Pixels,
208 _new_line_height: text::LineHeight,
209 _new_wrapping: text::Wrapping,
210 _new_highlighter: &mut impl text::Highlighter,
211 ) {
212 }
213
214 fn highlight<H: text::Highlighter>(
215 &mut self,
216 _font: Self::Font,
217 _highlighter: &mut H,
218 _format_highlight: impl Fn(
219 &H::Highlight,
220 ) -> text::highlighter::Format<Self::Font>,
221 ) {
222 }
223}
224
225impl image::Renderer for () {
226 type Handle = image::Handle;
227
228 fn load_image(
229 &self,
230 handle: &Self::Handle,
231 ) -> Result<image::Allocation, image::Error> {
232 #[allow(unsafe_code)]
233 Ok(unsafe { image::allocate(handle, Size::new(100, 100)) })
234 }
235
236 fn measure_image(&self, _handle: &Self::Handle) -> Option<Size<u32>> {
237 Some(Size::new(100, 100))
238 }
239
240 fn draw_image(
241 &mut self,
242 _image: Image,
243 _bounds: Rectangle,
244 _clip_bounds: Rectangle,
245 ) {
246 }
247}
248
249impl svg::Renderer for () {
250 fn measure_svg(&self, _handle: &svg::Handle) -> Size<u32> {
251 Size::default()
252 }
253
254 fn draw_svg(
255 &mut self,
256 _svg: svg::Svg,
257 _bounds: Rectangle,
258 _clip_bounds: Rectangle,
259 ) {
260 }
261}