Source file layout_input.ml
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
86
87
type t = {
run_mode : Run_mode.t;
sizing_mode : Sizing_mode.t;
axis : Requested_axis.t;
known_dimensions : float option Geometry.size;
parent_size : float option Geometry.size;
available_space : Available_space.t Geometry.size;
vertical_margins_are_collapsible : bool Geometry.line;
}
let make ~run_mode ~sizing_mode ~axis ~known_dimensions ~parent_size
~available_space ~vertical_margins_are_collapsible =
{
run_mode;
sizing_mode;
axis;
known_dimensions;
parent_size;
available_space;
vertical_margins_are_collapsible;
}
let run_mode t = t.run_mode
let sizing_mode t = t.sizing_mode
let axis t = t.axis
let known_dimensions t = t.known_dimensions
let parent_size t = t.parent_size
let available_space t = t.available_space
let vertical_margins_are_collapsible t = t.vertical_margins_are_collapsible
let hidden =
{
run_mode = Run_mode.Perform_hidden_layout;
sizing_mode = Sizing_mode.Inherent_size;
axis = Requested_axis.Both;
known_dimensions = Geometry.(Size.none);
parent_size = Geometry.(Size.none);
available_space =
{
width = Available_space.Max_content;
height = Available_space.Max_content;
};
vertical_margins_are_collapsible = { start = false; end_ = false };
}
let to_string t =
Printf.sprintf "LayoutInput { run_mode: %s; sizing_mode: %s; axis: %s; ... }"
(Run_mode.to_string t.run_mode)
(Sizing_mode.to_string t.sizing_mode)
(Requested_axis.to_string t.axis)
let compare a b =
let cmp = Run_mode.compare a.run_mode b.run_mode in
if cmp <> 0 then cmp
else
let cmp = Sizing_mode.compare a.sizing_mode b.sizing_mode in
if cmp <> 0 then cmp
else
let cmp = Requested_axis.compare a.axis b.axis in
if cmp <> 0 then cmp
else
let cmp =
Geometry.Size.compare
(Option.compare Float.compare)
a.known_dimensions b.known_dimensions
in
if cmp <> 0 then cmp
else
let cmp =
Geometry.Size.compare
(Option.compare Float.compare)
a.parent_size b.parent_size
in
if cmp <> 0 then cmp
else
let cmp =
Geometry.Size.compare Available_space.compare a.available_space
b.available_space
in
if cmp <> 0 then cmp
else
Geometry.Line.compare Bool.compare
a.vertical_margins_are_collapsible
b.vertical_margins_are_collapsible
let equal a b = compare a b = 0
let pp fmt t = Format.pp_print_string fmt (to_string t)