4 protected int m_iColumns;
8 protected int m_iItems;
9 protected int m_iSelectedItem;
12 protected int m_iPaddingHorizontal;
14 protected int m_iPaddingVertical;
16 [
Attribute(
"{4FFBD0D5E9A5ED50}UI/layouts/Menus/PlayMenu/PlayMenuTile_Recent.layout", UIWidgets.ResourceNamePicker,
"",
"layout")]
17 protected ResourceName m_sItemLayout;
20 protected float m_fAnimationTime;
22 protected ref array<Widget> m_aWidgets = {};
23 protected GridLayoutWidget m_wContentRoot;
24 protected Widget m_wRoot;
28 override void HandlerAttached(Widget w)
31 m_wContentRoot = GridLayoutWidget.Cast(w.FindAnyWidget(
"Content"));
36 m_iItems = m_iColumns * m_iRows;
44 CreateWidgets(m_iColumns, m_iRows);
47 SetFocusedItem(m_iSelectedItem);
51 protected void CreateWidgets(
int columns,
int rows)
60 w.RemoveFromHierarchy();
65 for (
int r = 0; r < rows; r++)
67 for (
int c = 0; c < columns; c++)
75 protected Widget CreateWidget(
int column,
int row)
80 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sItemLayout, m_wContentRoot);
84 GridSlot.SetColumn(w, column);
85 GridSlot.SetRow(w, row);
86 m_wContentRoot.SetRowFillWeight(row, 1);
87 m_wContentRoot.SetColumnFillWeight(column, 1);
96 comp.GetOnFocus().Insert(OnItemFocused);
99 ButtonWidget button = ButtonWidget.Cast(w);
102 Print(
"Gallery element root has to be a button, otherwise interactivity will not work", LogLevel.WARNING);
105 int left, top, right, bottom;
108 left = m_iPaddingHorizontal;
110 if (column < m_iColumns - 1)
111 right = m_iPaddingHorizontal;
114 top = m_iPaddingVertical;
116 if (row < m_iRows - 1)
117 bottom = m_iPaddingVertical;
119 AlignableSlot.SetPadding(w, left, top, right, bottom);
127 protected void SetAnimationRate()
129 if (m_fAnimationTime <= 0)
130 m_fAnimationRate = 1000;
132 m_fAnimationRate = 1 / m_fAnimationTime;
136 void OnItemFocused(Widget w)
142 void SetFocusedItem(
int index)
152 GetGame().GetWorkspace().SetFocusedWidget(w);
153 m_iSelectedItem =
index;
157 array<Widget> GetWidgets()
167 if (!parent || name ==
string.Empty)
171 if (searchAllChildren)
172 w = parent.FindAnyWidget(name);
174 w = parent.FindWidget(name);