9 OverlayWidget m_wDebugOverlay;
10 ImageWidget m_wDebugImg;
11 Widget m_wDebugVertical
12 TextWidget m_wDebugNameText;
13 RichTextWidget m_wDebugHeightText;
14 RichTextWidget m_wDebugWidthText;
15 TextWidget m_wDebugPriorityText;
19 protected bool m_bInitialized;
20 protected WorkspaceWidget m_wWorkspace;
22 protected Widget m_wRoot;
24 protected int m_iHeight;
26 protected int m_iWidth;
32 protected int m_iPriority;
35 ref array<int> m_aHeightSteps;
38 ref array<int> m_aWidthSteps;
40 [
Attribute(
desc:
"Whether the Slot should be sized to its content.")]
41 bool m_bSizeToContent;
74 void SetPriority(
int newPriority)
79 if (m_wDebugPriorityText)
80 m_wDebugPriorityText.SetText(
"Priority: " +
m_iPriority.ToString());
84 m_GroupComponent.ResizeGroup();
100 void SetHeight(
int height,
bool notifyResizing =
true)
102 if (m_iHeight == height)
114 Widget contentWidget = GetContentWidget();
117 if (!m_bSizeToContent && contentWidget)
119 FrameSlot.SetSizeY(contentWidget, m_iHeight);
122 else if (m_bSizeToContent)
124 float contentWidth = 0;
125 float contentHeight = 0;
128 contentWidget.GetScreenSize(contentWidth, contentHeight);
134 m_OnResize.Invoke(
this);
141 void SetWidth(
int width,
bool notifyResizing =
true)
143 if (m_iWidth == width)
154 Widget contentWidget = GetContentWidget();
157 if (!m_bSizeToContent && contentWidget)
159 FrameSlot.SetSizeX(contentWidget, m_iWidth);
162 else if (m_bSizeToContent)
164 float contentWidth = 0;
165 float contentHeight = 0;
168 contentWidget.GetScreenSize(contentWidth, contentHeight);
174 m_OnResize.Invoke(
this);
181 Widget GetContentWidget()
190 Widget GetRootWidget()
204 Widget child =
m_wRoot.GetChildren();
206 Print(
m_wRoot.GetName() +
" Has no Content!", LogLevel.WARNING);
208 if (!GetGroupComponent())
209 Debug.Error2(
"No Group Component",
"A Slot's parent must always have a Group Component! Slot: " +
m_wRoot.GetName());
221 Widget parent =
m_wRoot.GetParent();
223 if (!m_GroupComponent && parent)
225 return m_GroupComponent;
229 override void HandlerAttached(Widget w)
233 m_aHeightSteps.Sort();
234 m_aWidthSteps.Sort();
243 void DebugHeightInfo()
245 if (!m_wDebugHeightText || !
SCR_Global.IsEditMode())
247 Widget contentWidget = GetContentWidget();
250 contentWidget =
m_wRoot.GetChildren();
252 FrameSlot.SetSizeY(contentWidget, m_iHeight);
254 m_wDebugHeightText.SetText(
"Height:");
255 foreach (
int step : m_aHeightSteps)
257 if (step == m_iHeight)
258 m_wDebugHeightText.SetText(m_wDebugHeightText.GetText() +
" <color name='green'>" + step +
"</color>");
260 m_wDebugHeightText.SetText(m_wDebugHeightText.GetText() +
" " + step);
263 if (m_aHeightSteps.IsEmpty())
264 m_wDebugHeightText.SetText(
string.Empty);
266 if (m_bSizeToContent)
268 FrameSlot.SetSizeY(m_wDebugOverlay, m_iHeight);
269 m_wDebugHeightText.SetText(
"Height: <color name='green'>" + m_iHeight +
"</color>");
277 void DebugWidthInfo()
279 if (!m_wDebugWidthText || !
SCR_Global.IsEditMode())
282 FrameSlot.SetSizeX(m_wDebugOverlay, m_iWidth);
284 m_wDebugWidthText.SetText(
"Width:");
285 foreach (
int step : m_aWidthSteps)
287 if (step == m_iWidth)
288 m_wDebugWidthText.SetText(m_wDebugWidthText.GetText() +
" <color name='green'>" + step +
"</color>");
290 m_wDebugWidthText.SetText(m_wDebugWidthText.GetText() +
" " + step);
293 if (m_aWidthSteps.IsEmpty())
294 m_wDebugWidthText.SetText(
string.Empty);
296 if (m_bSizeToContent)
298 if (!m_aWidthSteps.IsEmpty())
300 m_iWidth = m_aWidthSteps[m_aWidthSteps.Count() - 1];
301 FrameSlot.SetSizeX(m_wDebugOverlay, m_iWidth);
304 m_wDebugWidthText.SetText(
"Width: <color name='green'>" + m_iWidth +
"</color>");