nux-1.14.0
nux::HLayout Class Reference
Inheritance diagram for nux::HLayout:
nux::Layout nux::Area nux::InitiallyUnownedObject nux::Focusable nux::Object nux::Trackable nux::Introspectable

List of all members.

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 AreaKeyNavIteration (KeyNavDirection direction)

Detailed Description

Definition at line 31 of file HLayout.h.


Member Function Documentation

void nux::HLayout::ComputeStacking ( int  remaining_width,
int &  offset_space,
int &  element_margin 
)

Compute the how elements are spread inside the layout.

Parameters:
remaining_widthSize that remains after subtracting elements width, inner and outer margins from the content width.
offset_spaceThe space at the left of all elements.
element_marginThe 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;
    }
  }

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