11 [
Attribute(
"0 0 0 0.7", UIWidgets.ColorPicker,
"")]
12 protected ref Color m_ColorButtonDefault;
14 [
Attribute(
"1 1 1 0.25", UIWidgets.ColorPicker,
"")]
15 protected ref Color m_ColorButtonFocused;
17 [
Attribute(
"1 1 1 0.3", UIWidgets.ColorPicker,
"")]
18 protected ref Color m_ColorButtonPressed;
20 [
Attribute(
"0.8 0.8 0.8 0.1", UIWidgets.ColorPicker,
"")]
21 protected ref Color m_ColorButtonDisabled;
23 [
Attribute(
"false", UIWidgets.CheckBox,
"")]
24 protected bool m_bColorizeChildren;
26 [
Attribute(
"1 1 1 1", UIWidgets.ColorPicker,
"")]
27 protected ref Color m_ColorChildDefault;
29 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
30 protected ref Color m_ColorChildFocused;
32 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
33 protected ref Color m_ColorChildPressed;
35 [
Attribute(
"1 1 1 0.6", UIWidgets.ColorPicker,
"")]
36 protected ref Color m_ColorChildDisabled;
39 protected float m_fAnimationLength;
42 protected string m_sSoundClicked;
45 protected string m_sSoundFocused;
48 protected Widget m_wChild;
49 protected bool m_bIsFocused =
false;
52 override void HandlerAttached(Widget w)
54 m_wChild = w.GetChildren();
55 m_fAnimationLength = 1 / m_fAnimationLength;
59 w.SetColor(m_ColorButtonDisabled);
60 if (m_bColorizeChildren && m_wChild)
61 m_wChild.SetColor(m_ColorChildDisabled);
65 w.SetColor(m_ColorButtonDefault);
66 if (m_bColorizeChildren && m_wChild)
67 m_wChild.SetColor(m_ColorChildDefault);
72 override bool OnClick(Widget w,
int x,
int y,
int button)
79 void SetOnClickSound(
string newOnClickedSound)
81 m_sSoundClicked = newOnClickedSound;
85 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
87 AnimateWidget.Color(w, m_ColorButtonPressed, m_fAnimationLength);
88 if (m_bColorizeChildren && m_wChild)
89 AnimateWidget.Color(m_wChild, m_ColorChildPressed, m_fAnimationLength);
95 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
98 AnimateWidget.Color(w, m_ColorButtonFocused, m_fAnimationLength);
100 AnimateWidget.Color(w, m_ColorButtonDisabled, m_fAnimationLength);
102 if (m_bColorizeChildren && m_wChild)
105 AnimateWidget.Color(m_wChild, m_ColorChildFocused, m_fAnimationLength);
107 AnimateWidget.Color(m_wChild, m_ColorChildDisabled, m_fAnimationLength);
114 override bool OnFocus(Widget w,
int x,
int y)
120 AnimateWidget.Color(w, m_ColorButtonFocused, m_fAnimationLength);
122 AnimateWidget.Color(w, m_ColorButtonDisabled, m_fAnimationLength);
124 if (m_bColorizeChildren && m_wChild)
127 AnimateWidget.Color(m_wChild, m_ColorChildFocused, m_fAnimationLength);
129 AnimateWidget.Color(m_wChild, m_ColorChildDisabled, m_fAnimationLength);
136 override bool OnFocusLost(Widget w,
int x,
int y)
138 m_bIsFocused =
false;
141 AnimateWidget.Color(w, m_ColorButtonDefault, m_fAnimationLength);
143 AnimateWidget.Color(w, m_ColorButtonDisabled, m_fAnimationLength);
145 if (m_bColorizeChildren && m_wChild)
148 AnimateWidget.Color(m_wChild, m_ColorChildDefault, m_fAnimationLength);
150 AnimateWidget.Color(m_wChild, m_ColorChildDisabled, m_fAnimationLength);
157 override bool OnMouseEnter(Widget w,
int x,
int y)
159 if (w.GetFlags() & WidgetFlags.NOFOCUS)
162 GetGame().GetWorkspace().SetFocusedWidget(w);
168 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
170 if (w.GetFlags() & WidgetFlags.NOFOCUS)
171 OnFocusLost(w, x, y);
173 GetGame().GetWorkspace().SetFocusedWidget(enterW);