nux-1.16.0
nux::VLayout Class Reference
Inheritance diagram for nux::VLayout:
nux::Layout nux::Area nux::InitiallyUnownedObject nux::Focusable nux::Object nux::Trackable nux::Introspectable

List of all members.

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 AreaKeyNavIteration (KeyNavDirection direction)
virtual long DoFocusLeft (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
virtual long DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)

Detailed Description

Definition at line 31 of file VLayout.h.


Member Function Documentation

void nux::VLayout::ComputeStacking ( int  remaining_height,
int &  offset_space,
int &  element_margin 
)

Compute the how elements are spread inside the layout.

Parameters:
remaining_heightSize that remains after subtracting elements height, inner and outer margins from the content height.
offset_spaceThe space at the top of all elements.
element_marginThe margin between elements.
remaining_heightHeight that remains after subtracting elements height, inner and outer margins from the content height.
offset_spaceThe space at the top of all elements.
element_marginThe 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;
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends