DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AutoHeightSpacer.c
См. документацию.
1// -----------------------------------------------------------
3{
4 reference bool AlignChilds;
5 reference int MinHeight;
6 reference int MaxHeight;
7 reference int Gap;
8 reference float Top;
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;
33 rowRight = rowWidth;
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;
55 rowRight = rowWidth;
56 rowHeight = 0;
57 }
58
59 // increase row height if necessary
60 if (height > rowHeight) rowHeight = height;
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 {
80 height = top;
81 }
82 else
83 {
84 m_root.GetScreenPos(x, y);
85 height = top - y;
86 }
87 }
88
89 m_root.GetSize(width, heightOld);
90
91 if (MaxHeight > 0 && height > MaxHeight)
92 {
93 height = MaxHeight;
94 }
95
96 if (MinHeight > height)
97 {
98 height = MinHeight;
99 }
100
101 if (Math.AbsInt(heightOld - height) > 1)
102 {
103 m_root.SetSize(width, height);
104 }
105 else if (AlignChilds)
106 {
107 m_root.Update();
108 }
109
110 return;
111 }
112
114 {
115 m_root = w;
116 m_root.SetHandler(this);
117 m_root.SetFlags(WidgetFlags.VEXACTPOS);
118 Update();
119 }
120
121 override bool OnChildRemove( Widget w, Widget child) {
122 if (w == m_root)
123 {
124 Update();
125 }
126
127 return false;
128 }
129};
Icon x
Icon y
void OnWidgetScriptInit(Widget w)
Определения AutoHeightSpacer.c:113
Widget m_root
Определения AutoHeightSpacer.c:9
reference float Top
Определения AutoHeightSpacer.c:8
reference int Gap
Определения AutoHeightSpacer.c:7
override bool OnChildRemove(Widget w, Widget child)
Определения AutoHeightSpacer.c:121
reference int MaxHeight
Определения AutoHeightSpacer.c:6
reference bool AlignChilds
Определения AutoHeightSpacer.c:4
reference int MinHeight
Определения AutoHeightSpacer.c:5
void Update()
Определения AutoHeightSpacer.c:11
Определения EnMath.c:7
map: item x vector(index, width, height)
Определения EnWidgets.c:651
Определения EnWidgets.c:190
static proto int AbsInt(int i)
Returns absolute value.
WidgetFlags
Определения EnWidgets.c:58