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
use super::position::*;
///
/// Represents the bounds of a particular control
///
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct Bounds {
pub x1: Position,
pub y1: Position,
pub x2: Position,
pub y2: Position
}
impl Bounds {
///
/// Creates a bounding box that fills a container
///
pub fn fill_all() -> Bounds {
use Position::*;
Bounds { x1: Start, y1: Start, x2: End, y2: End }
}
///
/// Bounding box that fills the container vertically and follows the previous control horizontally
///
pub fn next_horiz(width: f32) -> Bounds {
use Position::*;
Bounds { x1: After, y1: Start, x2: Offset(width), y2: End }
}
///
/// Bounding box that fills the container horizontally and follows the previous control horizontally
///
pub fn next_vert(height: f32) -> Bounds {
use Position::*;
Bounds { x1: Start, y1: After, x2: End, y2: Offset(height) }
}
///
/// Bounding box that fills the remaining horizontal space
///
pub fn fill_horiz() -> Bounds {
use Position::*;
Bounds { x1: After, y1: Start, x2: End, y2: End }
}
///
/// Bounding box that stretchs to occupy the remaining horizontal space
///
pub fn stretch_horiz(ratio: f32) -> Bounds {
use Position::*;
Bounds { x1: After, y1: Start, x2: Stretch(ratio), y2: End }
}
///
/// Bounding box that fills the remaining vertical space
///
pub fn fill_vert() -> Bounds {
use Position::*;
Bounds { x1: Start, y1: After, x2: End, y2: End }
}
}