-
Notifications
You must be signed in to change notification settings - Fork 5
/
HOW_GUIS_WORK
62 lines (42 loc) · 2.52 KB
/
HOW_GUIS_WORK
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
HOW GUIs WORK hbox.layout({
maxWidth: screenWidth,
maxHeight: screenHeight
})
Hbox.layout(constraints)
mywidth = 0
myheight = 0
non_stretched_total_width = 0
non_stretched = filter(...children)
for child in non_stretched:
child.layout({
maxHeight: constraints.maxHeight
})
cwidth, cheight = child.size
mywidth += cwidth
myheight = max(myheight, cheight)
non_stretched_total_width += cwidth
remaining = constraints.maxWidth - non_stretched_total_width
stretched = filter(...children)
width_per_stretched = remaining / len(stretched)
for child in stretched:
child.layout({
minWidth: width_per_stretched,
maxWidth: width_per_stretched,
maxHeight: constraints.maxHeight
})
mywidth += cwidth
myheight = max(myheight, cheight)
self.size = (mywidth, myheight)
1. Layout
2. Rendering
* HBox
* text field(stretched="x")
* button
Flutter Algorithm:
layout(constraints) has to decide what an element's size is.
type Constraints {
minWidth?: number,
maxWidth?: number,
minHeight?: number,
maxHeight?: number
}