11 protected ref SCR_ModularButtonComponent m_FavComponent;
13 protected bool m_bIsInErrorState;
16 protected ref array<ref SCR_HorizontalScrollAnimationComponent> m_aScrollAnimations = {};
20 protected bool m_bInnerButtonInteraction;
21 protected ref array<SCR_ModularButtonComponent> m_aMouseButtons = {};
22 protected ref array<SCR_ModularButtonComponent> m_aMouseButtonsError = {};
25 protected SCR_ModularButtonComponent m_MainModularButton;
26 protected bool m_bFavorite;
27 protected bool m_bDisabled;
28 protected bool m_bFocused;
29 protected bool m_bMouseButtonsEnabled =
true;
44 override void HandlerAttached(Widget w)
47 EnableTextAnimations(
false);
51 foreach (SCR_ModularButtonComponent button : m_aMouseButtons)
53 button.m_OnMouseEnter.Insert(OnInnerButtonHover);
54 button.m_OnMouseLeave.Insert(OnInnerButtonLeave);
59 m_FavComponent.m_OnClicked.Insert(OnFavoriteClicked);
61 super.HandlerAttached(w);
65 override void HandlerDeattached(Widget w)
75 super.HandlerDeattached(w);
79 override bool OnClick(Widget w,
int x,
int y,
int button)
82 if (button != 0 || m_bInnerButtonInteraction)
85 return super.OnClick(w, x, y, button);
89 override bool OnDoubleClick(Widget w,
int x,
int y,
int button)
92 if (button != 0 || m_bInnerButtonInteraction)
95 return super.OnDoubleClick(w, x, y, button);
99 override bool OnFocus(Widget w,
int x,
int y)
105 UpdateModularButtons();
107 if (!m_aScrollAnimations.IsEmpty())
108 EnableTextAnimations(
true);
113 return super.OnFocus(w, x, y);
117 override bool OnFocusLost(Widget w,
int x,
int y)
123 UpdateModularButtons();
126 EnableTextAnimations(
false);
131 return super.OnFocusLost(w, x, y);
136 protected void OnTooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
138 m_CurrentTooltip = tooltipClass;
142 protected void OnInnerButtonHover()
144 m_bInnerButtonInteraction =
true;
148 protected void OnInnerButtonLeave()
150 m_bInnerButtonInteraction =
false
154 protected void OnFavoriteClicked(SCR_ModularButtonComponent comp)
156 SetFavorite(!m_bFavorite);
162 protected void EnableTextAnimations(
bool enable)
166 HandleTextAnimation(anim, enable);
180 if (!anim.GetContentFit())
182 anim.AnimationStart();
186 anim.AnimationStop();
187 anim.ResetPosition();
194 anim.AnimationStop();
195 anim.ResetPosition();
199 protected void UpdateModularButtons()
201 SCR_ListEntryHelper.UpdateMouseButtons(m_aMouseButtons, m_aMouseButtonsError, m_bIsInErrorState, m_bFocused);
205 if (!m_MainModularButton)
206 m_MainModularButton = SCR_ModularButtonComponent.FindComponent(
m_wRoot);
207 if (!m_MainModularButton)
210 m_MainModularButton.SetToggled(m_bDisabled,
false);
213 Color color = Color.FromInt(
UIColors.NEUTRAL_INFORMATION.PackToInt());
215 color = Color.FromInt(
UIColors.IDLE_DISABLED.PackToInt());
219 nameEffect.m_cFocusLost = color;
223 color = Color.FromInt(
UIColors.NEUTRAL_ACTIVE_STANDBY.PackToInt());
225 array<SCR_ButtonEffectBase> effects = m_MainModularButton.FindAllEffects(
SCR_ListEntryHelper.EFFECT_WRAPPER_COLOR);
226 if (effects.IsEmpty())
229 foreach (SCR_ButtonEffectBase effect : effects)
233 colorEffect.m_cFocusLost = color;
236 m_MainModularButton.InvokeAllEnabledEffects(
false);
240 protected void OpacityAnimation(
int time,
float opacityEnd)
248 void AnimateOpacity(
int delay,
float animationTime,
float opacityEnd,
float opacityStart = -1)
250 if (opacityStart != -1)
253 GetGame().GetCallqueue().Remove(OpacityAnimation);
256 GetGame().GetCallqueue().CallLater(OpacityAnimation, delay,
false, animationTime, opacityEnd);
260 void ShowMouseInteractionButtons(
bool show)
262 m_bMouseButtonsEnabled = show;
263 UpdateModularButtons();
267 bool SetFavorite(
bool favorite)
270 m_FavComponent.SetToggled(favorite);
272 if (m_bFavorite == favorite)
275 m_bFavorite = favorite;
284 bool IsInnerButtonInteraction()
286 return m_bInnerButtonInteraction;
296 bool IsInErrorState()
298 return m_bIsInErrorState;
304 if (!m_OnMouseInteractionButtonClicked)
307 return m_OnMouseInteractionButtonClicked;