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
use crate::{api::prelude::*, proc_macros::*};
/// The `PopupState` handles the open and close behavior of the `Popup` widget.
#[derive(AsAny, Default)]
pub struct PopupState {
//actions: Vec<PopupAction>,
}
impl PopupState {}
impl State for PopupState {}
widget!(
/// The `Popup` is used to presents content bound to target entity.
///
/// The `target` is specified either via its widget id (`Entitiy`)
/// or using a point coordinate (`Point`). The placmement of the
/// popup widget itself is controlled via its `placement`
/// property. An optional attribute (float), defines the
/// margin between the target and the popup widget.
///
/// [`placement`]: ../orbtk_core/render_object/enum.Placement.html
///
/// **style:** `popup``
Popup<PopupState> : KeyDownHandler, MouseHandler {
/// Sets or shares the background property.
background: Brush,
/// Sets or shares the border brush property.
border_brush: Brush,
/// Sets or shares the border radius property.
border_radius: f64,
/// Sets or shares the border thickness property.
border_width: Thickness,
/// Sets or shares the popup open state.
open: bool,
/// Sets or shares the padding property.
padding: Thickness,
/// Sets or shares the placement property relative to the
/// target position. Valid placement variants are defined via
/// the `Placement` enumeration.
placement: Placement,
/// Sets or shares the offset property that assignes a margin
/// between popup and target entity.
offset: f64,
///
/// Defined ether as an entity (Entity), or as a point
/// coordinate (Point).
target: PopupTarget
}
);
impl Template for Popup {
fn template(self, _id: Entity, _: &mut BuildContext) -> Self {
self.name("Popup").style("popup").open(false)
}
fn render_object(&self) -> Box<dyn RenderObject> {
Box::new(PopupRenderObject::new())
}
fn layout(&self) -> Box<dyn Layout> {
PopupLayout::new().into()
}
}