1use crate::{
2 AfterLayoutContext, AppContext, Element, Event, EventContext, LayoutContext, MutableAppContext,
3 PaintContext, SizeConstraint,
4};
5use pathfinder_geometry::vector::Vector2F;
6
7pub struct Empty {
8 size: Option<Vector2F>,
9 origin: Option<Vector2F>,
10}
11
12impl Empty {
13 pub fn new() -> Self {
14 Self {
15 size: None,
16 origin: None,
17 }
18 }
19}
20
21impl Element for Empty {
22 fn layout(
23 &mut self,
24 constraint: SizeConstraint,
25 _: &mut LayoutContext,
26 _: &AppContext,
27 ) -> Vector2F {
28 self.size = Some(constraint.min);
29 constraint.max
30 }
31
32 fn after_layout(&mut self, _: &mut AfterLayoutContext, _: &mut MutableAppContext) {}
33
34 fn paint(&mut self, origin: Vector2F, _: &mut PaintContext, _: &AppContext) {
35 self.origin = Some(origin);
36 }
37
38 fn dispatch_event(&self, _: &Event, _: &mut EventContext, _: &AppContext) -> bool {
39 false
40 }
41
42 fn size(&self) -> Option<Vector2F> {
43 self.size
44 }
45}