1use crate::{
2 geometry::vector::Vector2F, AfterLayoutContext, Element, Event, EventContext, LayoutContext,
3 PaintContext, SizeConstraint,
4};
5
6pub struct Svg {
7 path: String,
8}
9
10impl Svg {
11 pub fn new(path: String) -> Self {
12 Self { path }
13 }
14}
15
16impl Element for Svg {
17 type LayoutState = ();
18 type PaintState = ();
19
20 fn layout(
21 &mut self,
22 _: SizeConstraint,
23 _: &mut LayoutContext,
24 ) -> (Vector2F, Self::LayoutState) {
25 // let size;
26 // match ctx.asset_cache.svg(&self.path) {
27 // Ok(tree) => {
28 // size = if constraint.max.x().is_infinite() && constraint.max.y().is_infinite() {
29 // let rect = usvg_rect_to_euclid_rect(&tree.svg_node().view_box.rect);
30 // rect.size()
31 // } else {
32 // let max_size = constraint.max;
33 // let svg_size = usvg_rect_to_euclid_rect(&tree.svg_node().view_box.rect).size();
34
35 // if max_size.x().is_infinite()
36 // || max_size.x() / max_size.y() > svg_size.x() / svg_size.y()
37 // {
38 // vec2f(svg_size.x() * max_size.y() / svg_size.y(), max_size.y())
39 // } else {
40 // vec2f(max_size.x(), svg_size.y() * max_size.x() / svg_size.x())
41 // }
42 // };
43 // self.tree = Some(tree);
44 // }
45 // Err(error) => {
46 // log::error!("{}", error);
47 // size = constraint.min;
48 // }
49 // };
50
51 // size
52
53 todo!()
54 }
55
56 fn after_layout(&mut self, _: Vector2F, _: &mut Self::LayoutState, _: &mut AfterLayoutContext) {
57 }
58
59 fn paint(
60 &mut self,
61 _: pathfinder_geometry::rect::RectF,
62 _: &mut Self::LayoutState,
63 _: &mut PaintContext,
64 ) -> Self::PaintState {
65 }
66
67 fn dispatch_event(
68 &mut self,
69 _: &Event,
70 _: pathfinder_geometry::rect::RectF,
71 _: &mut Self::LayoutState,
72 _: &mut Self::PaintState,
73 _: &mut EventContext,
74 ) -> bool {
75 false
76 }
77}