4 protected int m_iMaxItemsInRow;
7 float m_fElementHeight;
10 override void HandlerAttached(Widget w)
12 super.HandlerAttached(w);
13 m_iMaxItemsInRow = Math.Max(m_iMaxItemsInRow, 1);
17 override protected void CreateWidgets()
19 float padding = m_fElementSpacing * 0.5;
20 LayoutSlot.SetPadding(m_wButtonRow, -padding, -padding, -padding, -padding);
21 foreach (
int i,
string name : m_aElementNames)
23 Widget button =
GetGame().GetWorkspace().CreateWidgets(m_ElementLayout, m_wButtonRow);
25 int row = Math.Floor(i / m_iMaxItemsInRow);
26 int column = i % m_iMaxItemsInRow;
27 UniformGridSlot.SetRow(button, row);
28 UniformGridSlot.SetColumn(button, column);
34 m_aSelectionElements.Insert(comp);
38 textComp.SetText(name);
40 comp.m_OnClicked.Insert(OnElementClicked);
41 comp.m_OnToggled.Insert(OnElementChanged);
43 SizeLayoutWidget size = SizeLayoutWidget.Cast(comp.GetRootWidget().GetChildren());
47 size.EnableHeightOverride(m_fElementHeight > 0);
48 size.SetHeightOverride(m_fElementHeight);
55 protected void RemoveWidgets()
59 comp.GetRootWidget().RemoveFromHierarchy();
61 m_aSelectionElements.Clear();
65 void SetMaxItemsInRow(
int maxItems)
67 if (m_iMaxItemsInRow == maxItems)
70 m_iMaxItemsInRow = maxItems;
71 m_iMaxItemsInRow = Math.Max(m_iMaxItemsInRow, 1);
77 int GetMaxItemsInRow()
79 return m_iMaxItemsInRow;
83 SizeLayoutWidget FindSizeWidget(Widget root)
85 Widget child = root.GetChildren();
88 SizeLayoutWidget size = SizeLayoutWidget.Cast(child);
91 child = child.GetChildren();