8 protected ResourceName m_sImageResource;
10 [
Attribute(defvalue:
"",
desc:
"When the texture is an image set, define the quad name here")]
11 private string m_sImageName;
13 [
Attribute(defvalue:
"4", UIWidgets.EditBox,
"How ,uch of spaceis between image and text - work if both are visible")]
14 protected float m_fContentPadding;
17 protected string WIDGET_CONTET_HLAYOUT =
"hLayoutContent";
18 protected string WIDGET_IMAGE =
"ImageContent";
20 ref ScriptInvoker m_OnChanged =
new ScriptInvoker();
21 protected bool m_bIsSelected =
false;
22 protected bool m_bIsTriggered =
true;
25 protected Widget m_wHLayoutContent;
26 protected ImageWidget m_wImageContent;
28 protected ref Color COLOR_CHECKED_TRUE =
UIColors.CONTRAST_COLOR;
29 protected ref Color COLOR_CHECKED_FALSE =
UIColors.WHITE_DEFAULT;
32 override void HandlerAttached(Widget w)
34 super.HandlerAttached(w);
37 m_wHLayoutContent =
m_wRoot.FindAnyWidget(WIDGET_CONTET_HLAYOUT);
38 m_wImageContent = ImageWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_IMAGE));
41 SetImage(m_sImageResource, m_sImageName);
56 if (m_wImageContent.IsVisible() &&
m_wContent.IsVisible())
58 HorizontalLayoutSlot.SetPadding(
m_wContent, m_fContentPadding, 0, 0, 0);
63 void SetImage(ResourceName sResource,
string sImageName)
68 m_wImageContent.SetVisible(!sResource.IsEmpty());
70 if(sResource.IsEmpty())
73 if (sResource.EndsWith(
"imageset"))
74 m_wImageContent.LoadImageFromSet(0, sResource, sImageName);
76 m_wImageContent.LoadImageTexture(0, sResource);
80 override bool OnClick(Widget w,
int x,
int y,
int button)
82 super.OnClick(w, x, y, button);
86 SetSelected(!m_bIsSelected);
91 override bool OnMouseEnter(Widget w,
int x,
int y)
93 if (m_bMouseOverToFocus)
94 GetGame().GetWorkspace().SetFocusedWidget(w);
98 if (
GetGame().GetWorkspace().GetFocusedWidget() != w)
99 ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
105 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
107 if (
GetGame().GetWorkspace().GetFocusedWidget() != w)
108 ColorizeWidgets(COLOR_BACKGROUND_DEFAULT, COLOR_CONTENT_DEFAULT);
114 override bool OnFocus(Widget w,
int x,
int y)
117 ColorizeWidgets(COLOR_BACKGROUND_FOCUSED, COLOR_CONTENT_FOCUSED);
118 ColorizeCheckWidget();
123 override bool OnFocusLost(Widget w,
int x,
int y)
126 if (WidgetManager.GetWidgetUnderCursor() == w)
127 ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
129 ColorizeWidgets(COLOR_BACKGROUND_DEFAULT, COLOR_CONTENT_DEFAULT);
131 ColorizeCheckWidget();
137 override protected void OnMenuSelect()
142 super.OnMenuSelect();
143 ColorizeCheckWidget();
147 override protected void ColorizeWidgets(Color colorBackground, Color colorContent,
float speed = -1)
150 speed = m_fAnimationRate;
157 protected void ColorizeCheckWidget()
160 AnimateWidget.Color(
m_wOverlay, COLOR_CHECKED_TRUE, m_fAnimationRate);
162 AnimateWidget.Color(
m_wOverlay, COLOR_CHECKED_FALSE, m_fAnimationRate);
169 return m_bIsSelected;
173 void SetSelected(
bool selected,
bool notify =
true)
175 if (m_bIsSelected == selected)
178 m_bIsSelected = selected;
180 ColorizeCheckWidget();