Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScrollBarHandleComponent.c
Go to the documentation of this file.
1
2//------------------------------------------------------------------------------------------------
4{
5 protected bool m_bIsDragged = false;
6 protected bool m_bIsHovered = false;
7
8 // Stable
9 protected float m_fSizeY;
10
11 protected float m_fPositionY;
12 protected float m_fMouseOffsetY;
13
14 protected ref Color COLOR_HANDLER_DEFAULT = UIColors.CONTRAST_COLOR;
15 protected ref Color COLOR_HANDLER_HOVERED = Color.White;
16
18
19 //-------------------------------------
20 // Override
21 //-------------------------------------
22
23 //------------------------------------------------------------------------------------------------
24 override void HandlerAttached(Widget w)
25 {
26 super.HandlerAttached(w);
27
28 // Handler root setup
29 m_wRoot = w;
31 }
32
33 //------------------------------------------------------------------------------------------------
34 override bool OnMouseEnter(Widget w, int x, int y)
35 {
36 super.OnMouseEnter(w, x, y);
37
38 m_bIsHovered = true;
40
41 return false;
42 }
43
44 //------------------------------------------------------------------------------------------------
45 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
46 {
47 super.OnMouseLeave(w, enterW, x, y);
48
49 m_bIsHovered = true;
50
51 if (m_bIsDragged)
52 return false;
53
55 return false;
56 }
57
58 //------------------------------------------------------------------------------------------------
59 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
60 {
61 // Accept only LMB as valid click
62 if (button != 0)
63 return false;
64
65 m_bIsDragged = true;
66
67 // Mouse offset
68 int mouseX, mouseY;
69 WidgetManager.GetMousePos(mouseX, mouseY);
71
73
75 return false;
76 }
77
78 //------------------------------------------------------------------------------------------------
79 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
80 {
81 // Accept only LMB as valid click
82 if (button != 0)
83 return false;
84
85 m_bIsDragged = false;
86
87 if (!m_bIsHovered)
89
91 return false;
92 }
93
94 //-------------------------------------
95 // Protected
96 //-------------------------------------
97
98 //------------------------------------------------------------------------------------------------
100 protected void DragHandler()
101 {
102 if(!m_bIsDragged)
103 return;
104
105 // Invoke move
106 m_OnDrag.Invoke();
107
108 // Call drag
109 GetGame().GetCallqueue().CallLater(DragHandler, 0);
110 }
111
112 //-------------------------------------
113 // Get & Set
114 //-------------------------------------
115
116 //------------------------------------------------------------------------------------------------
117 void SetSizeY(float size) { m_fSizeY = size; }
118
119 //------------------------------------------------------------------------------------------------
120 float GetSizeY() { return m_fSizeY; }
121
122 //------------------------------------------------------------------------------------------------
123 void SetPositionY(float pos) { m_fPositionY = pos; }
124
125 //------------------------------------------------------------------------------------------------
126 float GetPositionY() { return m_fPositionY; }
127
128 //------------------------------------------------------------------------------------------------
130};
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
Definition Color.c:13
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
void DragHandler()
Move with handler if handler is clicked.
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Base class for all final Reforger interactive elements.
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134