Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SimpleButtonComponent.c
Go to the documentation of this file.
1// Simple button provides 4 states in which it can be:
2// Default, focused, pressed and disabled.
3// Hovering over the button will focus it instantly.
4// Use it in places where you don't need onHover functionality.
5
6// TODO:
7// Need events OnDisable and onEnable to recolorize widgets
8
10{
11 [Attribute("0 0 0 0.7", UIWidgets.ColorPicker, "")]
13
14 [Attribute("1 1 1 0.25", UIWidgets.ColorPicker, "")]
16
17 [Attribute("1 1 1 0.3", UIWidgets.ColorPicker, "")]
19
20 [Attribute("0.8 0.8 0.8 0.1", UIWidgets.ColorPicker, "")]
22
23 [Attribute("false", UIWidgets.CheckBox, "")]
24 protected bool m_bColorizeChildren;
25
26 [Attribute("1 1 1 1", UIWidgets.ColorPicker, "")]
28
29 [Attribute("0 0 0 1", UIWidgets.ColorPicker, "")]
31
32 [Attribute("0 0 0 1", UIWidgets.ColorPicker, "")]
34
35 [Attribute("1 1 1 0.6", UIWidgets.ColorPicker, "")]
37
38 [Attribute("0.2", UIWidgets.EditBox, "")]
39 protected float m_fAnimationLength;
40
41 [Attribute(SCR_SoundEvent.CLICK, UIWidgets.EditBox, "")]
42 protected string m_sSoundClicked;
43
44 [Attribute(SCR_SoundEvent.FOCUS, UIWidgets.EditBox, "")]
45 protected string m_sSoundFocused;
46
47
48 protected Widget m_wChild;
49 protected bool m_bIsFocused = false;
50
51 //------------------------------------------------------------------------------------------------
52 override void HandlerAttached(Widget w)
53 {
54 m_wChild = w.GetChildren();
56
57 if (!w.IsEnabled())
58 {
59 w.SetColor(m_ColorButtonDisabled);
62 }
63 else
64 {
65 w.SetColor(m_ColorButtonDefault);
68 }
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override bool OnClick(Widget w, int x, int y, int button)
73 {
75 return false;
76 }
77
78 //------------------------------------------------------------------------------------------------
79 void SetOnClickSound(string newOnClickedSound)
80 {
81 m_sSoundClicked = newOnClickedSound;
82 }
83
84 //------------------------------------------------------------------------------------------------
93
94 //------------------------------------------------------------------------------------------------
95 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
96 {
97 if (w.IsEnabled())
99 else
101
103 {
104 if (w.IsEnabled())
106 else
108 }
109
110 return false;
111 }
112
113 //------------------------------------------------------------------------------------------------
114 override bool OnFocus(Widget w, int x, int y)
115 {
116 m_bIsFocused = true;
118
119 if (w.IsEnabled())
121 else
123
125 {
126 if (w.IsEnabled())
128 else
130 }
131
132 return false;
133 }
134
135 //------------------------------------------------------------------------------------------------
136 override bool OnFocusLost(Widget w, int x, int y)
137 {
138 m_bIsFocused = false;
139
140 if (w.IsEnabled())
142 else
144
146 {
147 if (w.IsEnabled())
149 else
151 }
152
153 return false;
154 }
155
156 //------------------------------------------------------------------------------------------------
157 override bool OnMouseEnter(Widget w, int x, int y)
158 {
159 if (w.GetFlags() & WidgetFlags.NOFOCUS)
160 OnFocus(w, x, y);
161 else
162 GetGame().GetWorkspace().SetFocusedWidget(w);
163
164 return false;
165 }
166
167 //------------------------------------------------------------------------------------------------
168 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
169 {
170 if (w.GetFlags() & WidgetFlags.NOFOCUS)
171 OnFocusLost(w, x, y);
172 else
173 GetGame().GetWorkspace().SetFocusedWidget(enterW);
174
175 return false;
176 }
177};
ArmaReforgerScripted GetGame()
Definition game.c:1398
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition Color.c:13
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnFocus(Widget w, int x, int y)
void SetOnClickSound(string newOnClickedSound)
override void HandlerAttached(Widget w)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool OnMouseEnter(Widget w, int x, int y)
SCR_FieldOfViewSettings Attribute
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14