Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_ScrollBarComponent.c
Go to the documentation of this file.
1
3
4
//------------------------------------------------------------------------------------------------
5
class
SCR_ScrollBarComponent
:
SCR_WLibComponentBase
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
12
protected
Widget
m_wBackground
;
13
protected
Widget
m_wHandler
;
14
protected
Widget
m_wFillerTop
;
15
protected
Widget
m_wFillerBottom
;
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
30
protected
ref
SCR_ScrollBarHandleComponent
m_Handle
;
31
32
ref
ScriptInvoker
m_OnScroll
=
new
ScriptInvoker
;
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
54
m_Handle
=
SCR_ScrollBarHandleComponent
.Cast(
m_wHandler
.FindHandler(
SCR_ScrollBarHandleComponent
));
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
88
SetupPosition
(
m_fHandlerAmount
, scrollY);
89
90
// Invoke scroll move
91
m_OnScroll
.Invoke(
m_fHandlerPositon
);
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
116
SetupScrollbarProperties
();
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
137
if
(!
m_wFillerTop
|| !
m_wFillerBottom
)
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
//------------------------------------------------------------------------------------------------
199
void
MoveHandlerPos
(
float
pos) {
SetupPosition
(
m_fHandlerAmount
, pos); }
200
201
//-------------------------------------
202
// Get & Set
203
//-------------------------------------
204
205
//------------------------------------------------------------------------------------------------
206
float
GetHandlerPosition
() {
return
m_fHandlerPositon
; }
207
};
Math
Definition
Math.c:13
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_ScrollBarComponent
Definition
SCR_ScrollBarComponent.c:6
SCR_ScrollBarComponent::WIDGET_FILLER_TOP
string WIDGET_FILLER_TOP
Definition
SCR_ScrollBarComponent.c:9
SCR_ScrollBarComponent::mouseX
int mouseX
Definition
SCR_ScrollBarComponent.c:18
SCR_ScrollBarComponent::SetupPosition
void SetupPosition(float fillAmount, float pos)
Setup fill of top and boom fillers by handler fill amount and current scroll position.
Definition
SCR_ScrollBarComponent.c:134
SCR_ScrollBarComponent::m_OnScroll
ref ScriptInvoker m_OnScroll
Definition
SCR_ScrollBarComponent.c:32
SCR_ScrollBarComponent::m_fHandlerAmount
float m_fHandlerAmount
Definition
SCR_ScrollBarComponent.c:27
SCR_ScrollBarComponent::m_wHandler
Widget m_wHandler
Definition
SCR_ScrollBarComponent.c:13
SCR_ScrollBarComponent::m_wFillerTop
Widget m_wFillerTop
Definition
SCR_ScrollBarComponent.c:14
SCR_ScrollBarComponent::m_wFillerBottom
Widget m_wFillerBottom
Definition
SCR_ScrollBarComponent.c:15
SCR_ScrollBarComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_ScrollBarComponent.c:39
SCR_ScrollBarComponent::m_Handle
ref SCR_ScrollBarHandleComponent m_Handle
Definition
SCR_ScrollBarComponent.c:30
SCR_ScrollBarComponent::mouseY
int mouseY
Definition
SCR_ScrollBarComponent.c:18
SCR_ScrollBarComponent::SetupHandlerFill
void SetupHandlerFill(float fillAmount)
Set amount of handler fill in percent.
Definition
SCR_ScrollBarComponent.c:110
SCR_ScrollBarComponent::WIDGET_HANDLER
string WIDGET_HANDLER
Definition
SCR_ScrollBarComponent.c:8
SCR_ScrollBarComponent::m_IsClicked
bool m_IsClicked
Definition
SCR_ScrollBarComponent.c:17
SCR_ScrollBarComponent::GetHandlerPosition
float GetHandlerPosition()
Definition
SCR_ScrollBarComponent.c:206
SCR_ScrollBarComponent::m_fRootPosY
float m_fRootPosY
Definition
SCR_ScrollBarComponent.c:23
SCR_ScrollBarComponent::WIDGET_BACKGROUND
string WIDGET_BACKGROUND
Definition
SCR_ScrollBarComponent.c:7
SCR_ScrollBarComponent::DragHandler
void DragHandler()
Definition
SCR_ScrollBarComponent.c:64
SCR_ScrollBarComponent::m_wBackground
Widget m_wBackground
Definition
SCR_ScrollBarComponent.c:12
SCR_ScrollBarComponent::WIDGET_FILLER_BOTTOM
string WIDGET_FILLER_BOTTOM
Definition
SCR_ScrollBarComponent.c:10
SCR_ScrollBarComponent::m_fHandlerPositon
float m_fHandlerPositon
Definition
SCR_ScrollBarComponent.c:28
SCR_ScrollBarComponent::SetupScrollbarProperties
void SetupScrollbarProperties()
Setup base position and size properties.
Definition
SCR_ScrollBarComponent.c:96
SCR_ScrollBarComponent::m_fRootSizeY
float m_fRootSizeY
Definition
SCR_ScrollBarComponent.c:24
SCR_ScrollBarComponent::MoveHandlerPos
void MoveHandlerPos(float pos)
Definition
SCR_ScrollBarComponent.c:199
SCR_ScrollBarHandleComponent
Definition
SCR_ScrollBarHandleComponent.c:4
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition
SCR_WLibComponentBase.c:9
VerticalLayoutSlot
Definition
VerticalLayoutSlot.c:13
Widget
Definition
Widget.c:13
WidgetManager
Definition
WidgetManager.c:16
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Components
WidgetLibrary
SCR_ScrollBar
SCR_ScrollBarComponent.c
Generated by
1.17.0