|
nux-1.14.0
|
Public Member Functions | |
| HLayout (NUX_FILE_LINE_PROTO) | |
| HLayout (NString name, NUX_FILE_LINE_PROTO) | |
| virtual long | ComputeLayout2 () |
| virtual void | ComputePosition2 (float offsetX, float offsetY) |
| virtual void | HLayoutManagement (int width, int height) |
| virtual t_u32 | GetMaxStretchFactor () |
| virtual void | GetCompositeList (std::list< Area * > *ViewList) |
| void | ComputeStacking (int remaining_width, int &offset_space, int &element_margin) |
| Compute the how elements are spread inside the layout. | |
Protected Member Functions | |
| virtual long | DoFocusUp (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
| virtual long | DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
| virtual Area * | KeyNavIteration (KeyNavDirection direction) |
| void nux::HLayout::ComputeStacking | ( | int | remaining_width, |
| int & | offset_space, | ||
| int & | element_margin | ||
| ) |
Compute the how elements are spread inside the layout.
| remaining_width | Size that remains after subtracting elements width, inner and outer margins from the content width. |
| offset_space | The space at the left of all elements. |
| element_margin | The margin between elements. |
Definition at line 108 of file HLayout.cpp.
References nux::eStackBottom, nux::eStackCenter, nux::eStackExpand, nux::eStackLeft, nux::eStackRight, and nux::eStackTop.
{
int per_element_space = 0;
int total_used_space = 0;
int num_elements = 0;
std::list<Area *>::iterator it;
for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
{
if ((*it)->IsVisible ())
{
// gather all the space used by elements
total_used_space += (*it)->GetBaseWidth();
num_elements++;
}
}
if (num_elements)
{
// Compute the space available for each element
per_element_space = (remaining_width - total_used_space) / int (num_elements);
}
if (per_element_space < 0)
{
per_element_space = 0;
}
int margin;
if (per_element_space > 0)
{
margin = (per_element_space) / 2;
}
else
{
margin = 0;
}
LayoutContentDistribution stacking = GetContentDistribution();
switch (stacking)
{
case eStackTop:
case eStackLeft:
{
offset_space = 0;
element_margin = 0;
}
break;
case eStackBottom:
case eStackRight:
{
offset_space = (remaining_width - total_used_space);
if (offset_space < 0)
offset_space = 0;
element_margin = 0;
}
break;
case eStackCenter:
{
offset_space = (remaining_width - total_used_space) / 2;
if (offset_space < 0)
offset_space = 0;
element_margin = 0;
}
break;
case eStackExpand:
default:
{
offset_space = 0;
element_margin = margin;
}
break;
}
}