DayZ 1.24
Loading...
Searching...
No Matches
AutoHeightSpacer.c
Go to the documentation of this file.
1// -----------------------------------------------------------
3{
9 protected Widget m_root;
10
11 void Update()
12 {
13 float x = 0;
14 float y = 0;
15 float width = 0;
16 float height = 0;
17 float heightOld = 0;
18 float top = Top;
19 float rowRight;
20 float rowHeight;
21 float rowWidth;
22 Widget child = m_root.GetChildren();
23
24 //PrintString(m_root.GetName() + ": AutoHeightSpacer::Update()");
25
26 if (!AlignChilds) top = -100000;
27
28 if (child != NULL)
29 {
30 // first row init
31 m_root.GetScreenSize(rowWidth, height);
32 rowHeight = 0;
34
35 while (child)
36 {
37 if (child.IsVisible() == false || child.GetName() == "SelectedContainer" || child.GetName() == "Icon")
38 {
39 // skip invisible widgets
40 child = child.GetSibling();
41 continue;
42 }
43
44 child.GetScreenSize(width, height);
45
46 if (AlignChilds)
47 {
48 child.SetFlags(WidgetFlags.EXACTPOS, false);
49
50 // no space left in this row, move to next one
51 if (rowRight < width)
52 {
53 top += rowHeight;
54 if (rowHeight > 0) top += Gap;
56 rowHeight = 0;
57 }
58
59 // increase row height if necessary
61
62 child.SetPos(rowWidth - rowRight, top, false);
63 rowRight -= width + Gap;
64 }
65 else
66 {
67 child.GetScreenPos(x, y);
68 y += height;
69 if (top < y) top = y;
70 }
71
72 child = child.GetSibling();
73 }
74
75 // add last row height;
76 top += rowHeight;
77
78 if (AlignChilds)
79 height = top;
80 else
81 {
82 m_root.GetScreenPos(x, y);
83 height = top - y;
84 }
85 }
86
87 m_root.GetSize(width, heightOld);
88
89 if (MaxHeight > 0 && height > MaxHeight)
91
92 if (MinHeight > height)
94
95 if (Math.AbsInt(heightOld - height) > 1)
96 m_root.SetSize(width, height);
97 else if (AlignChilds)
98 m_root.Update();
99
100 return;
101 }
102
104 {
105 m_root = w;
106 m_root.SetHandler(this);
107 m_root.SetFlags(WidgetFlags.VEXACTPOS);
108 Update();
109 }
110
112 {
113 if (w == m_root)
114 Update();
115
116 return false;
117 }
118};
Icon x
Icon y
void OnWidgetScriptInit(Widget w)
reference float Top
reference int Gap
override bool OnChildRemove(Widget w, Widget child)
reference int MaxHeight
reference bool AlignChilds
reference int MinHeight
Definition EnMath.c:7
map: item x vector(index, width, height)
Definition EnWidgets.c:651
static proto int AbsInt(int i)
Returns absolute value.
WidgetFlags
Definition EnWidgets.c:58