5 protected static const float ANIMATION_THRESHOLD = 0.01;
8 private string m_sActiveWidgetName;
11 private string m_sExpandWidgetName;
13 [
Attribute(defvalue:
"0.2", uiwidget: UIWidgets.Slider,
params:
"0 1 0.01")]
14 private float m_fHideCoef;
17 private float m_fAnimationStrength;
19 private Widget m_wExpandWidget;
20 private float m_fDefaultOffset;
21 private float m_fCurrentCoef;
22 private bool m_bShown;
25 protected void Show(
bool show)
38 protected void SetCoef(
float coef,
bool instant =
false)
40 m_fCurrentCoef = coef;
49 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
54 protected bool SetOffsets(
float progress)
56 float offsetLeft, offsetTop, offsetRight, offsetBottom;
57 FrameSlot.GetOffsets(m_wExpandWidget, offsetLeft, offsetTop, offsetRight, offsetBottom);
59 offsetTop = Math.Lerp(offsetTop, m_fDefaultOffset * m_fCurrentCoef, progress);
60 offsetBottom = Math.Lerp(offsetBottom, m_fDefaultOffset * (1 - m_fCurrentCoef), progress);
62 FrameSlot.SetOffsets(m_wExpandWidget, offsetLeft, offsetTop, offsetRight, offsetBottom);
64 return Math.AbsFloat(offsetTop - m_fDefaultOffset * m_fCurrentCoef) < ANIMATION_THRESHOLD;
68 protected void OnMenuUpdate(
float tDelta)
70 if (SetOffsets(tDelta / m_fAnimationStrength))
74 menu.GetOnMenuUpdate().Remove(OnMenuUpdate);
79 protected void OnShortcut(Widget w)
85 override bool OnMouseEnter(Widget w,
int x,
int y)
87 if (w.GetName() == m_sActiveWidgetName && m_wExpandWidget)
94 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
96 if (w.GetName() == m_sActiveWidgetName && m_wExpandWidget)
103 override void HandlerAttachedScripted(Widget w)
105 m_wExpandWidget = w.FindAnyWidget(m_sExpandWidgetName);
106 if (!m_wExpandWidget)
109 float offsetLeft, offsetTop, offsetRight, offsetBottom;
110 FrameSlot.GetOffsets(m_wExpandWidget, offsetLeft, m_fDefaultOffset, offsetRight, offsetBottom);
112 SetCoef(m_fHideCoef,
true);
116 onToggle.Insert(OnShortcut);
120 override void HandlerDeattached(Widget w)