10 protected float m_fPadding;
13 protected string m_sLeftFooter;
16 protected string m_sRightFooter;
18 protected ref map<string, SCR_InputButtonComponent> m_Buttons =
new map<string, SCR_InputButtonComponent>();
20 protected Widget m_wLeftFooter;
21 protected Widget m_wRightFooter;
27 override void HandlerAttached(Widget w)
29 super.HandlerAttached(w);
32 Widget root = w.GetParent();
36 m_wLeftFooter = root.FindAnyWidget(m_sLeftFooter);
37 m_wRightFooter = root.FindAnyWidget(m_sRightFooter);
43 RegisterButton(button);
46 UpdateAllButtonsPadding(m_wLeftFooter);
47 UpdateAllButtonsPadding(m_wRightFooter, SCR_EDynamicFooterButtonAlignment.RIGHT);
56 if(m_OnButtonActivated)
57 m_OnButtonActivated.Invoke(button.GetRootWidget().GetName());
61 private void UpdateAllButtonsPadding(Widget wrapper, SCR_EDynamicFooterButtonAlignment alignment = 0)
70 UpdateButtonPadding(button, alignment);
80 float paddingRight, paddingLeft;
81 float left, top, right, bottom;
85 case SCR_EDynamicFooterButtonAlignment.LEFT:
86 paddingRight = m_fPadding;
89 case SCR_EDynamicFooterButtonAlignment.RIGHT:
90 paddingLeft = m_fPadding;
94 Widget widget = button.GetRootWidget();
95 AlignableSlot.GetPadding(widget, left, top, right, bottom);
97 AlignableSlot.SetPadding(widget, paddingLeft, top, paddingRight, bottom);
102 SCR_InputButtonComponent CreateButton(ResourceName
layout,
string tag,
string label,
string action, SCR_EDynamicFooterButtonAlignment alignment = 0,
bool visible =
true)
108 case SCR_EDynamicFooterButtonAlignment.LEFT:
109 wrapper = m_wLeftFooter;
112 case SCR_EDynamicFooterButtonAlignment.RIGHT:
113 wrapper = m_wRightFooter;
118 Widget buttonWidget =
GetGame().GetWorkspace().CreateWidgets(
layout, wrapper);
127 RegisterButton(button);
128 UpdateButtonPadding(button, alignment);
130 buttonWidget.SetName(tag);
132 button.SetVisible(visible,
false);
133 button.SetLabel(label);
134 button.SetAction(action);
137 if (m_wRightFooter && wrapper == m_wLeftFooter)
138 m_wRightFooter.SetZOrder(buttonWidget.GetZOrder() + 1);
144 SCR_InputButtonComponent CreateButtonAtPosition(ResourceName
layout,
string tag,
string label,
string action,
int position, SCR_EDynamicFooterButtonAlignment alignment = 0,
bool visible =
true)
150 case SCR_EDynamicFooterButtonAlignment.LEFT:
151 wrapper = m_wLeftFooter;
154 case SCR_EDynamicFooterButtonAlignment.RIGHT:
155 wrapper = m_wRightFooter;
160 array<ref Widget> existingButtons = {};
164 foreach (Widget existingButton : existingButtons)
169 existingButton.SetZOrder(count);
176 button.GetRootWidget().SetZOrder(
position);
179 if (wrapper == m_wLeftFooter)
180 m_wRightFooter.SetZOrder(button.GetRootWidget().GetZOrder() + 1);
182 UpdateButtonPadding(button, alignment);
191 Widget w = button.GetRootWidget();
192 m_Buttons.Insert(w.GetName(), button);
194 button.m_OnActivated.Insert(OnButtonActivated);
201 return m_Buttons.Get(tag);
211 return m_Buttons.GetKeyByValue(button);
216 bool RemoveButton(
string tag)
223 m_Buttons.Remove(tag);
224 m_wRoot.RemoveChild(button.GetRootWidget());
235 m_wRoot.RemoveChild(comp.GetRootWidget());
242 array<SCR_InputButtonComponent> GetButtonsInFooter(SCR_EDynamicFooterButtonAlignment alignment)
247 case SCR_EDynamicFooterButtonAlignment.LEFT:
248 wrapper = m_wLeftFooter;
251 case SCR_EDynamicFooterButtonAlignment.RIGHT:
252 wrapper = m_wRightFooter;
263 Widget GetLeftFooter()
265 return m_wLeftFooter;
269 Widget GetRightFooter()
271 return m_wRightFooter;
278 if (!m_OnButtonActivated)
281 return m_OnButtonActivated;
287 static array<SCR_InputButtonComponent> FindChildrenButtons(notnull Widget w,
bool searchImmediateChildrenOnly =
true)
289 array<SCR_InputButtonComponent> buttons = {};
290 array<ref Widget> children = {};
294 foreach (Widget child : children)
298 buttons.Insert(comp);
323 enum SCR_EDynamicFooterButtonAlignment