1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
use crate::{Font, Point, Size};
use iced_graphics::backend;
use iced_graphics::text;
use std::borrow::Cow;
pub enum Backend {
Wgpu(iced_wgpu::Backend),
}
impl iced_graphics::Backend for Backend {}
impl backend::Text for Backend {
const ICON_FONT: Font = Font::Name("Iced-Icons");
const CHECKMARK_ICON: char = '\u{f00c}';
const ARROW_DOWN_ICON: char = '\u{e800}';
fn default_font(&self) -> Font {
match self {
Self::Wgpu(backend) => backend.default_font(),
}
}
fn default_size(&self) -> f32 {
match self {
Self::Wgpu(backend) => backend.default_size(),
}
}
fn measure(
&self,
contents: &str,
size: f32,
font: Font,
bounds: Size,
) -> (f32, f32) {
match self {
Self::Wgpu(backend) => {
backend.measure(contents, size, font, bounds)
}
}
}
fn hit_test(
&self,
contents: &str,
size: f32,
font: Font,
bounds: Size,
position: Point,
nearest_only: bool,
) -> Option<text::Hit> {
match self {
Self::Wgpu(backend) => backend.hit_test(
contents,
size,
font,
bounds,
position,
nearest_only,
),
}
}
fn load_font(&mut self, font: Cow<'static, [u8]>) {
match self {
Self::Wgpu(backend) => {
backend.load_font(font);
}
}
}
}
#[cfg(feature = "image")]
impl backend::Image for Backend {
fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
match self {
Self::Wgpu(backend) => backend.dimensions(handle),
}
}
}
#[cfg(feature = "svg")]
impl backend::Svg for Backend {
fn viewport_dimensions(
&self,
handle: &iced_native::svg::Handle,
) -> Size<u32> {
match self {
Self::Wgpu(backend) => backend.viewport_dimensions(handle),
}
}
}
|