Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScrollBarComponent.c
Go to the documentation of this file.
1
3
4//------------------------------------------------------------------------------------------------
6{
7 protected string WIDGET_BACKGROUND = "Background";
8 protected string WIDGET_HANDLER = "Handler";
9 protected string WIDGET_FILLER_TOP = "FillerTop";
10 protected string WIDGET_FILLER_BOTTOM = "FillerBottom";
11
13 protected Widget m_wHandler;
16
17 protected bool m_IsClicked = false;
18 protected int mouseX, mouseY = 0;
19
20 //protected float m_fHeight = 20;
21
22 // Scroll root properties
23 protected float m_fRootPosY;
24 protected float m_fRootSizeY;
25
26 // Normalized size and position
27 protected float m_fHandlerAmount = 1;
28 protected float m_fHandlerPositon = 0;
29
31
33
34 //-------------------------------------
35 // ScriptedWidgetComponent override
36 //-------------------------------------
37
38 //------------------------------------------------------------------------------------------------
39 override void HandlerAttached(Widget w)
40 {
41 super.HandlerAttached(w);
42
43 // Widgets
44 m_wBackground = w.FindAnyWidget(WIDGET_BACKGROUND);
45 m_wFillerTop = w.FindAnyWidget(WIDGET_FILLER_TOP);
46 m_wFillerBottom = w.FindAnyWidget(WIDGET_FILLER_BOTTOM);
47
48 // Get handler widget
49 m_wHandler = w.FindAnyWidget(WIDGET_HANDLER);
50 if (!m_wHandler)
51 return;
52
53 // Access handler component
55 if(m_Handle)
56 m_Handle.m_OnDrag.Insert(DragHandler);
57 }
58
59 //-------------------------------------
60 // Protected
61 //-------------------------------------
62
63 //------------------------------------------------------------------------------------------------
64 protected void DragHandler()
65 {
66 // Handler hight
67 float handlerW, handlerH = 0;
68 m_Handle.GetRootWidget().GetScreenSize(handlerW, handlerH);
69
70 // Get vertical min a max
71 float top = handlerH/2;
72 float bottom = m_fRootSizeY - handlerH/2;
73
74 float clampHeight = bottom - top;
75
76 // mouse pos
77 int mousePosX, mousePosY;
78 WidgetManager.GetMousePos(mousePosX, mousePosY);
79
80 // mouse pos to root
81 mousePosY = mousePosY - m_fRootPosY - top - m_Handle.GetMouseOffsetY();
82
83 // Mouse perc
84 float scrollY = mousePosY / clampHeight;
85 scrollY = Math.Clamp(scrollY, 0, 1);
86
87 // Move widget position
89
90 // Invoke scroll move
92 }
93
94 //------------------------------------------------------------------------------------------------
96 protected void SetupScrollbarProperties()
97 {
98 float x;
99
100 m_wRoot.GetScreenPos(x, m_fRootPosY);
101 m_wRoot.GetScreenSize(x, m_fRootSizeY);
102 }
103
104 //-------------------------------------
105 // Public
106 //-------------------------------------
107
108 //------------------------------------------------------------------------------------------------
110 void SetupHandlerFill(float fillAmount)
111 {
112 // Limit
113 fillAmount = Math.Clamp(fillAmount, 0, 1.0);
114
115 // Setup base properties
117
118 // Handler check
119 if (!m_Handle)
120 return;
121
122 // Filling and size setup
123 m_fHandlerAmount = fillAmount;
124
125 VerticalLayoutSlot.SetFillWeight(m_Handle.GetRootWidget(), fillAmount);
126 m_Handle.SetSizeY(fillAmount * m_fRootSizeY);
127
128 // Setup filling of top and botton fillers
129 SetupPosition(fillAmount, m_fHandlerPositon);
130 }
131
132 //------------------------------------------------------------------------------------------------
134 void SetupPosition(float fillAmount, float pos)
135 {
136 // Filler widgets check
138 return;
139
140 // Limits
141 fillAmount = Math.Clamp(fillAmount, 0.0, 1.0);
142 pos = Math.Clamp(pos, 0.0, 1.0);
143
144 // Pass position value
145 m_fHandlerPositon = pos;
146
147 // Setup fillers
148 float fillersAmout = 1 - fillAmount;
149
150 float fillTop = fillersAmout * pos;
151 float fillBottom = fillersAmout * (1 - pos);
152
153 // Apply fillers amout
154 VerticalLayoutSlot.SetFillWeight(m_wFillerTop, fillTop);
155 VerticalLayoutSlot.SetFillWeight(m_wFillerBottom, fillBottom);
156
157 // Set handler position
158 float x,y;
159 m_Handle.GetRootWidget().GetScreenPos(x, y);
160 m_Handle.SetPositionY(y);
161 }
162
163 //------------------------------------------------------------------------------------------------
164 // TODO:@wernerjak - Replace this with functions above
165 /*void SetSize(float view, float count)
166 {
167 if (!m_wHandler)
168 return;
169
170 m_fHandlerAmount = view / count;
171 VerticalLayoutSlot.SetFillWeight(m_wHandler, m_fHandlerAmount);
172 }
173
174 //------------------------------------------------------------------------------------------------
175 // TODO:@wernerjak - Replace this with functions above
176 void SetPosition(float pos, float view, float count)
177 {
178 int iPositions = count - view;
179
180 //m_fHandlerPositon = (view / count) * (iPos / (count - view - 1));
181 m_fHandlerPositon = pos / iPositions;
182
183 float fill = 1 - m_fHandlerAmount;
184 float fillTop = fill * m_fHandlerPositon;
185 float fillBottom = fill * (1 - m_fHandlerPositon);
186
187 if (m_wFillerTop)
188 VerticalLayoutSlot.SetFillWeight(m_wFillerTop, fillTop);
189 if (m_wFillerBottom)
190 VerticalLayoutSlot.SetFillWeight(m_wFillerBottom, fillBottom);
191
192 /*if(m_Handle)
193 {
194 m_Handle.SetPosition((int)pos);
195 }*/
196 //}
197
198 //------------------------------------------------------------------------------------------------
200
201 //-------------------------------------
202 // Get & Set
203 //-------------------------------------
204
205 //------------------------------------------------------------------------------------------------
207};
Definition Math.c:13
void SetupPosition(float fillAmount, float pos)
Setup fill of top and boom fillers by handler fill amount and current scroll position.
override void HandlerAttached(Widget w)
ref SCR_ScrollBarHandleComponent m_Handle
void SetupHandlerFill(float fillAmount)
Set amount of handler fill in percent.
void SetupScrollbarProperties()
Setup base position and size properties.
Base class for all final Reforger interactive elements.
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134