Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
autoheightspacer.c
Go to the documentation of this file.
1
// -----------------------------------------------------------
2
class
AutoHeightSpacer
:
ScriptedWidgetEventHandler
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
113
void
OnWidgetScriptInit
(
Widget
w)
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
};
AutoHeightSpacer
Definition
autoheightspacer.c:3
AutoHeightSpacer::m_root
Widget m_root
Definition
autoheightspacer.c:9
AutoHeightSpacer::Gap
reference int Gap
Definition
autoheightspacer.c:7
AutoHeightSpacer::OnChildRemove
override bool OnChildRemove(Widget w, Widget child)
Definition
autoheightspacer.c:121
AutoHeightSpacer::MinHeight
reference int MinHeight
Definition
autoheightspacer.c:5
AutoHeightSpacer::MaxHeight
reference int MaxHeight
Definition
autoheightspacer.c:6
AutoHeightSpacer::OnWidgetScriptInit
void OnWidgetScriptInit(Widget w)
Definition
autoheightspacer.c:113
AutoHeightSpacer::AlignChilds
reference bool AlignChilds
Definition
autoheightspacer.c:4
AutoHeightSpacer::Update
void Update()
Definition
autoheightspacer.c:11
AutoHeightSpacer::Top
reference float Top
Definition
autoheightspacer.c:8
Math
Definition
enmath.c:7
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition
enwidgets.c:657
Widget
Definition
enwidgets.c:190
Math::AbsInt
static proto int AbsInt(int i)
Returns absolute value.
WidgetFlags
WidgetFlags
Definition
enwidgets.c:58
x
Icon x
y
Icon y
Games
Dayz
scripts
3_game
gui
spacers
autoheightspacer.c
Generated by
1.17.0