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
use super::*;
use super::super::property::*;
use modifier::*;
///
/// The direction in which the popup should be shown
///
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum PopupDirection {
/// Popup appears directly over the top of the parent control
OnTop,
/// Popup appears to the left of the parent control
Left,
/// Popup appears to the right of the parent control
Right,
/// Popup appears above the parent control
Above,
/// Popup appears below the parent control
Below,
/// Popup appears centered in the window
WindowCentered,
/// Popup appears at the top of the window
WindowTop,
}
///
/// Attributes associated with controlling a popup
///
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum Popup {
/// Whether or not this popup is open (popups are closed by default)
IsOpen(Property),
/// The direction in which this popup should appear relative to its parent control
Direction(PopupDirection),
/// The size in pixels of this popup
Size(u32, u32),
/// The offset in pixels for the popup along the direction it's opening in
Offset(u32)
}
impl Modifier<Control> for Popup {
fn modify(self, control: &mut Control) {
control.add_attribute(ControlAttribute::PopupAttr(self))
}
}
impl Modifier<Control> for PopupDirection {
fn modify(self, control: &mut Control) {
control.add_attribute(ControlAttribute::PopupAttr(Popup::Direction(self)))
}
}
impl<'a> Modifier<Control> for &'a Popup {
fn modify(self, control: &mut Control) {
control.add_attribute(ControlAttribute::PopupAttr(self.clone()))
}
}