DayZ_Scripts / scripts /3_Game /DayZ /GUI /Spacers /HorizontalSpacerWithFixedAspect.c
D3ltaQ's picture
Upload 2197 files
24b81cb verified
raw
history blame contribute delete
946 Bytes
// -----------------------------------------------------------
class HorizontalSpacerWithFixedAspect: ScriptedWidgetEventHandler
{
protected Widget m_root;
reference int border;
reference int gap;
reference float coef;
float itemWidth;
float itemHeight;
// -----------------------------------------------------------
void OnWidgetScriptInit(Widget w)
{
m_root = w;
m_root.SetHandler(this);
}
// -----------------------------------------------------------
override bool OnUpdate(Widget w)
{
if (w == m_root) UpdateLayout();
return false;
}
protected void UpdateLayout()
{
Widget child = m_root.GetChildren();
int index = 0;
while (child)
{
if( index == 0 )
{
child.GetScreenSize(itemWidth, itemHeight);
}
else
{
child.SetFlags( WidgetFlags.EXACTPOS, false);
child.SetPos(itemWidth+(itemWidth*coef), 0);
}
index++;
child = child.GetSibling();
}
}
};