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
95
96
97
98
99
100
101
102
103
104
105
use gpui::*;
fn main() {
env_logger::init();
let app = Application::new();
app.run(move |cx| {
let window_options = WindowOptions {
window_bounds: Some(WindowBounds::Windowed(Bounds {
origin: point(px(100.), px(100.)),
size: size(px(600.), px(400.)),
})),
titlebar: Some(TitlebarOptions {
title: Some("SVG Path Test".into()),
appears_transparent: false,
..Default::default()
}),
..Default::default()
};
cx.open_window(window_options, |window, cx| {
cx.new(|cx| SvgPathTest::new(window, cx))
}).unwrap();
});
}
struct SvgPathTest {}
impl SvgPathTest {
fn new(_window: &mut Window, _cx: &mut Context<Self>) -> Self {
Self {}
}
}
impl Render for SvgPathTest {
fn render(&mut self, _: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.bg(rgb(0xFFFFFF))
.flex()
.flex_col()
.items_center()
.justify_center()
.gap_8()
.child(
div()
.text_xl()
.font_weight(FontWeight::BOLD)
.child("SVG Path Loading Test")
)
.child(
div()
.flex()
.flex_col()
.gap_4()
.child(
div()
.flex()
.items_center()
.gap_4()
.child("Method 1: svg().path() with relative path:")
.child(
svg()
.path("icons/arrow-down.svg")
.size(px(48.))
.text_color(rgb(0x000000))
)
)
.child(
div()
.flex()
.items_center()
.gap_4()
.child("Method 2: svg().path() with absolute path:")
.child(
svg()
.path(concat!(env!("CARGO_MANIFEST_DIR"), "/icons/arrow-down.svg"))
.size(px(48.))
.text_color(rgb(0x000000))
)
)
.child(
div()
.flex()
.items_center()
.gap_4()
.child("Method 3: svg().path() with crate root:")
.child(
svg()
.path("crate://fluix/icons/arrow-down.svg")
.size(px(48.))
.text_color(rgb(0x000000))
)
)
)
.child(
div()
.text_sm()
.text_color(rgb(0x666666))
.child("If you see icons above, one of these methods works!")
)
}
}