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
73
74
75
76
77
78
79
80
81
82
83
84
85
use super::{AxisInfo, RulesSetter, RulesSolver, SizeRules};
use crate::geom::Rect;
use kas::AlignHints;
pub struct SingleSolver {
axis: AxisInfo,
rules: SizeRules,
}
impl SingleSolver {
pub fn new(axis: AxisInfo, _dim: (), _storage: &mut ()) -> Self {
SingleSolver {
axis,
rules: SizeRules::EMPTY,
}
}
}
impl RulesSolver for SingleSolver {
type Storage = ();
type ChildInfo = ();
fn for_child<CR: FnOnce(AxisInfo) -> SizeRules>(
&mut self,
_storage: &mut Self::Storage,
_child_info: Self::ChildInfo,
child_rules: CR,
) {
self.rules = child_rules(self.axis);
}
fn finish(self, _storage: &mut Self::Storage) -> SizeRules {
self.rules
}
}
pub struct SingleSetter {
rect: Rect,
}
impl SingleSetter {
pub fn new(rect: Rect, _dim: (), _align: AlignHints, _storage: &mut ()) -> Self {
SingleSetter { rect }
}
}
impl RulesSetter for SingleSetter {
type Storage = ();
type ChildInfo = ();
fn child_rect(&mut self, _: &mut Self::Storage, _: Self::ChildInfo) -> Rect {
self.rect
}
fn maximal_rect_of(&mut self, _: &mut Self::Storage, _: Self::ChildInfo) -> Rect {
self.rect
}
}