7 protected bool m_bUseLabel;
10 protected string m_sLabel;
13 protected bool m_bForceSize;
16 protected float m_fSizeWithLabel;
19 protected float m_fSizeWithoutLabel;
21 [
Attribute(
"{829BC1189A899017}UI/layouts/WidgetLibrary/WLibRefined/WLib_Label.layout", UIWidgets.EditBox,
"")]
22 protected ResourceName m_sLabelLayout;
24 [
Attribute(
"SizeLayout", UIWidgets.EditBox,
"Name of size layout if you want to find size that is not root child")]
25 protected string m_sSizeLayout;
27 protected Widget m_wBorder;
28 protected Widget m_wBackground;
29 protected Widget m_wLabelRoot;
31 ref ScriptInvoker m_OnChanged =
new ScriptInvoker();
42 override void HandlerAttached(Widget w)
44 super.HandlerAttached(w);
46 m_wBorder =
m_wRoot.FindAnyWidget(
"Border");
53 m_wBorder.SetOpacity(0);
62 override bool OnFocus(Widget w,
int x,
int y)
64 super.OnFocus(w, x, y);
66 AnimateWidget.Opacity(m_wBorder, 1, m_fAnimationRate);
68 AnimateWidget.Color(
m_wBackground, Color.FromInt(
UIColors.BACKGROUND_HOVERED.PackToInt()), m_fAnimationRate);
73 override bool OnFocusLost(Widget w,
int x,
int y)
75 super.OnFocusLost(w, x, y);
78 AnimateWidget.Opacity(m_wBorder, 0, m_fAnimationRate);
80 Widget mouseOver = WidgetManager.GetWidgetUnderCursor();
81 if (w != mouseOver && !IsChildWidget(w, mouseOver))
82 AnimateWidget.Color(
m_wBackground, Color.FromInt(
UIColors.BACKGROUND_DEFAULT.PackToInt()), m_fAnimationRate);
88 override bool OnMouseEnter(Widget w,
int x,
int y)
90 AnimateWidget.Color(
m_wBackground, Color.FromInt(
UIColors.BACKGROUND_HOVERED.PackToInt()), m_fAnimationRate);
91 return super.OnMouseEnter(w, x, y);
95 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
97 super.OnMouseLeave(w, enterW, x, y);
98 if (
GetGame().GetWorkspace().GetFocusedWidget() == w || IsChildWidget(w, enterW))
101 AnimateWidget.Color(
m_wBackground, Color.FromInt(
UIColors.BACKGROUND_DEFAULT.PackToInt()), m_fAnimationRate);
106 protected void SetupLabel()
111 SizeLayoutWidget size = SizeLayoutWidget.Cast(
m_wRoot.GetChildren());
112 if (!size && !m_sSizeLayout.IsEmpty())
113 size = SizeLayoutWidget.Cast(
m_wRoot.FindAnyWidget(m_sSizeLayout));
117 size.EnableHeightOverride(m_bForceSize);
118 size.SetHeightOverride(m_fSizeWithLabel);
121 Widget contentRoot =
m_wRoot.FindAnyWidget(
"HorizontalLayout");
125 m_wLabelRoot =
GetGame().GetWorkspace().CreateWidgets(m_sLabelLayout, contentRoot);
129 TextWidget text = TextWidget.Cast(m_wLabelRoot.FindAnyWidget(
"Text"));
133 text.SetText(m_sLabel);
137 protected void ClearLabel()
141 m_wLabelRoot.RemoveFromHierarchy();
145 SizeLayoutWidget size = SizeLayoutWidget.Cast(
m_wRoot.GetChildren());
148 size.EnableHeightOverride(m_bForceSize);
149 size.SetHeightOverride(m_fSizeWithoutLabel);
154 AlignableSlot.SetPadding(
layout, 2, 2, 2, 2);
158 TextWidget GetLabel()
160 return TextWidget.Cast(m_wLabelRoot.FindAnyWidget(
"Text"));
164 void SetLabel(
string label)
169 TextWidget w = TextWidget.Cast(m_wLabelRoot.FindAnyWidget(
"Text"));
179 void UseLabel(
bool use)
181 if (use == m_bUseLabel)
198 Widget GetLabelWidget()