12 protected bool m_bCollapsed;
14 [
Attribute(
"0", UIWidgets.ComboBox,
"Direction of the collapse",
"", ParamEnumArray.FromEnum(
EDirection))]
18 protected float m_fCollapseTime;
20 [
Attribute(
desc:
"Is widget slot a frame, or if it's inside a layout slot. FRAME SLOT NOT IMPLEMENTED!")]
21 protected bool m_bIsFrameSlot;
23 protected float m_fDefaultValue =
float.MAX;
24 protected Widget m_wRoot;
25 protected float m_fTimeout = 50;
30 override void HandlerAttached(Widget w)
33 SetCollapseTime(m_fCollapseTime);
39 if (m_fCollapseTime !=
float.MAX)
41 float opacity = w.GetOpacity();
43 GetGame().GetCallqueue().CallLater(ShowWidgetDelayed, m_fTimeout,
false, opacity);
47 SetCollapsed(m_bCollapsed,
false);
52 void ShowWidgetDelayed(
float opacity)
55 SetCollapsed(
true,
false);
59 Widget GetRootWidget()
65 void SetCollapsed(
bool collapsed,
bool animate =
true)
67 if (m_bCollapsed == collapsed && animate)
70 m_bCollapsed = collapsed;
73 Print(
"CollapseWidgetComponent frameSlot not implemented", LogLevel.WARNING);
75 SetupLayoutAnimation(m_fCollapseTime, animate);
85 void SetCollapseTime(
float time)
89 m_fCollapseTime =
float.MAX;
91 m_fCollapseTime = 1 / time;
95 float GetCollapseTime()
98 return 1 / m_fCollapseTime;
110 return m_eCollapseDirection;
114 protected void SetupLayoutAnimation(
float speed,
bool animate)
120 if (m_fCollapseTime ==
float.MAX)
123 float left, top, right, bottom, w, h;
124 AlignableSlot.GetPadding(
m_wRoot, left, top, right, bottom);
126 if (w <= 0 || h <= 0)
132 w =
GetGame().GetWorkspace().DPIUnscale(w);
133 h =
GetGame().GetWorkspace().DPIUnscale(h);
137 switch (m_eCollapseDirection)
142 if (m_fDefaultValue ==
float.MAX)
143 m_fDefaultValue = left;
145 paddings = {-w - right, top, right, bottom};
149 paddings = {m_fDefaultValue, top, right, bottom};
155 if (m_fDefaultValue ==
float.MAX)
156 m_fDefaultValue = top;
158 paddings = {left, -h - bottom, right, bottom};
162 paddings = {left, m_fDefaultValue, right, bottom};
168 if (m_fDefaultValue ==
float.MAX)
169 m_fDefaultValue = right;
171 paddings = {left, top, -w - left, bottom};
175 paddings = {left, top, m_fDefaultValue, bottom};
181 if (m_fDefaultValue ==
float.MAX)
182 m_fDefaultValue = bottom;
184 paddings = {left, top, right, -h - top};
188 paddings = {left, top, right, m_fDefaultValue};
194 AnimateWidget.Padding(
m_wRoot, paddings, speed);
196 m_wRoot.SetVisible(!m_bCollapsed);