3 [
Attribute(
"", UIWidgets.EditBox,
"Name of the widget to colorize. Leave empty for colorize root widget")]
6 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
7 ref Color m_ColorDefault;
10 bool m_bSetHoverColor;
12 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
13 ref Color m_ColorHover;
16 bool m_bSetFocusColor;
18 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
19 ref Color m_ColorFocus;
22 bool m_bSetClickColor;
24 [
Attribute(
"0 0 0 1", UIWidgets.ColorPicker,
"")]
25 ref Color m_ColorClick;
28 bool m_bAnimateWidgets;
31 protected float m_fAnimationLength;
33 private Widget m_Widget;
34 private float m_wAnimationSpeed;
37 override void HandlerAttached(Widget w)
39 if (m_sWidgetName !=
string.Empty)
40 m_Widget = w.FindAnyWidget(m_sWidgetName);
44 if (m_fAnimationLength > 0)
45 m_wAnimationSpeed = 1 / m_fAnimationLength;
47 m_wAnimationSpeed = 1000;
50 m_Widget.SetColor(m_ColorDefault);
54 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
56 if (!m_bSetClickColor)
59 Colorize(m_ColorClick);
64 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
66 if (!m_bSetClickColor)
69 if (w ==
GetGame().GetWorkspace().GetFocusedWidget())
70 Colorize(m_ColorFocus);
72 Colorize(m_ColorHover);
77 override bool OnFocus(Widget w,
int x,
int y)
79 if (!m_bSetFocusColor)
82 Colorize(m_ColorFocus);
87 override bool OnFocusLost(Widget w,
int x,
int y)
89 if (!m_bSetFocusColor)
92 if (w == WidgetManager.GetWidgetUnderCursor())
93 Colorize(m_ColorHover);
95 Colorize(m_ColorDefault);
100 override bool OnMouseEnter(Widget w,
int x,
int y)
102 if (!m_bSetHoverColor)
105 if (w !=
GetGame().GetWorkspace().GetFocusedWidget())
106 Colorize(m_ColorHover);
112 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
114 if (!m_bSetHoverColor)
117 if (w !=
GetGame().GetWorkspace().GetFocusedWidget())
118 Colorize(m_ColorDefault);
123 void Colorize(Color color)
128 if (m_bAnimateWidgets)
129 AnimateWidget.Color(m_Widget, color, m_wAnimationSpeed);
131 m_Widget.SetColor(color);