DayZ 1.24
Loading...
Searching...
No Matches
SizeToChild.c
Go to the documentation of this file.
2{
8
9 protected Widget m_Root;
10 protected Widget m_Child;
11
12 protected static bool m_IgnoredBool;
13
15 {
16 m_Root = w;
17
18 m_Child = m_Root.FindAnyWidget(m_ChildName);
19 if (m_Child)
20 ResizeParentToChild();
21 }
22
24 {
25 return ResizeParentToChild(m_IgnoredBool, -1, true);
26 }
27
28 bool ResizeParentToChild(out bool changed_size, int limit = -1, bool immedUpdate = true)
29 {
30 float x, y, o_x, o_y, new_x, new_y;
31 if (m_Child)
32 {
33 m_Child.Update();
34 m_Child.GetScreenSize(x, y);
35 m_Root.GetScreenSize(new_x, new_y);
36 m_Root.GetSize(o_x, o_y);
37
38 bool changed = false;
39 bool hit_limit = false;
40
41 if (m_ResizeHorizontal && (x > new_x + 0.01 || x < new_x - 0.01))
42 {
43 new_x = x + m_HorizontalOffset;
44 changed = true;
45 }
46 else
47 new_x = o_x;
48
49 if (m_ResizeVertical && (y > new_y + 0.01 || y < new_y - 0.01))
50 {
51 new_y = y + m_VerticalOffset;
52 changed = true;
53 }
54 else
55 new_y = o_y;
56
57 if (limit > 0 && new_y > limit)
58 {
59 new_y = limit;
60 hit_limit = true;
61 }
62
63 if (changed)
64 m_Root.SetSize(new_x, new_y, immedUpdate);
65
67 return hit_limit;
68 }
69 else
70 {
71 m_Child = m_Root.FindAnyWidget(m_ChildName);
72 if (!m_Child)
73 Print("Error in size to child, " + m_Root.GetName() + " has no child named " + m_ChildName);
74 }
75
76 return false;
77 }
78}
79
81{
84
85 protected Widget m_Root;
86 protected Widget m_Parent;
87
89 {
90 m_Root = w;
91
93 m_Root.ClearFlags(WidgetFlags.HEXACTSIZE);
95 m_Root.ClearFlags(WidgetFlags.VEXACTSIZE);
96
97 m_Parent = m_Root.GetParent();
98
99 Refresh();
100 }
101
102 void Refresh()
103 {
104 float x, y, o_x, o_y, new_x, new_y;
105 m_Parent.Update();
106 m_Parent.GetScreenSize(x, y);
107 m_Root.GetScreenSize(new_x, new_y);
108 m_Root.GetSize(o_x, o_y);
109
110 bool changed = false;
111
112 if (m_ResizeHorizontal && x != new_x)
113 {
114 new_x = x;
115 changed = true;
116 }
117 else
118 new_x = o_x;
119
120 if (m_ResizeVertical && y != new_y)
121 {
122 new_y = y;
123 changed = true;
124 }
125 else
126 new_y = o_y;
127
128 if (changed)
129 m_Root.SetSize(new_x, new_y);
130 }
131}
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
Widget m_Parent
Definition SizeToChild.c:86
class SizeToChild extends ScriptedWidgetEventHandler m_ResizeHorizontal
void Refresh()
void OnWidgetScriptInit(Widget w)
Definition SizeToChild.c:88
reference bool m_ResizeVertical
Definition SizeToChild.c:83
map: item x vector(index, width, height)
Definition EnWidgets.c:651
reference bool m_ResizeHorizontal
Definition SizeToChild.c:6
void OnWidgetScriptInit(Widget w)
Definition SizeToChild.c:14
reference float m_VerticalOffset
Definition SizeToChild.c:5
bool ResizeParentToChild(out bool changed_size, int limit=-1, bool immedUpdate=true)
Definition SizeToChild.c:28
reference float m_HorizontalOffset
Definition SizeToChild.c:4
reference string m_ChildName
Definition SizeToChild.c:3
reference bool m_ResizeVertical
Definition SizeToChild.c:7
proto void Print(void var)
Prints content of variable to console/log.
WidgetFlags
Definition EnWidgets.c:58