|
nux-1.14.0
|
Public Member Functions | |
| VLayout (NUX_FILE_LINE_PROTO) | |
| VLayout (NString name, NUX_FILE_LINE_PROTO) | |
| virtual long | ComputeLayout2 () |
| virtual void | ComputePosition2 (float offsetX, float offsetY) |
| virtual void | VLayoutManagement (int width, int height) |
| virtual t_u32 | GetMaxStretchFactor () |
| virtual void | GetCompositeList (std::list< Area * > *ViewList) |
| void | ComputeStacking (int length, int &offset_space, int &element_margin) |
| Compute the how elements are spread inside the layout. | |
Protected Member Functions | |
| virtual Area * | KeyNavIteration (KeyNavDirection direction) |
| virtual long | DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
| virtual long | DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
| void nux::VLayout::ComputeStacking | ( | int | remaining_height, |
| int & | offset_space, | ||
| int & | element_margin | ||
| ) |
Compute the how elements are spread inside the layout.
| remaining_height | Size that remains after subtracting elements height, inner and outer margins from the content height. |
| offset_space | The space at the top of all elements. |
| element_margin | The margin between elements. |
| remaining_height | Height that remains after subtracting elements height, inner and outer margins from the content height. |
| offset_space | The space at the top of all elements. |
| element_margin | The margin between elements. |
Definition at line 114 of file VLayout.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 n_elements = 0;
std::list<Area *>::iterator it;
for (it = _layout_element_list.begin(); it != _layout_element_list.end(); it++)
{
// gather all the space used by elements
if ((*it)->IsVisible ())
{
total_used_space += (*it)->GetBaseHeight();
n_elements++;
}
}
if (n_elements != 0)
{
// Compute the space available for each element
per_element_space = (remaining_height - total_used_space) / int (n_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_height - total_used_space);
if (offset_space < 0)
offset_space = 0;
element_margin = 0;
}
break;
case eStackCenter:
{
offset_space = (remaining_height - 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;
}
}