Exemple #1
0
void GUIPanel::packFreeLayout()
{
  if(!update || !parent)
    return;

  Tuple4i newBounds = getWindowBounds();
  size_t  t         = 0;
  int     temp1     = 0,
          temp2     = 0;

  for(t = 0; t < elements.size(); t++)
  {
    elements[t]->forceUpdate(update);
    const Tuple4i &childBounds = elements[t]->getWindowBounds();

    newBounds.x = (childBounds.x - clipSize) < newBounds.x ?
                   childBounds.x - clipSize : newBounds.x;
    newBounds.y = (childBounds.y - clipSize) < newBounds.y ?
                   childBounds.y - clipSize : newBounds.y;
    newBounds.z = (childBounds.z + clipSize) > newBounds.z ?
                   childBounds.z + clipSize: newBounds.z;
    newBounds.w = (childBounds.w + clipSize) > newBounds.w ?
                   childBounds.w + clipSize : newBounds.w;
  }

  windowBounds = newBounds;
  update       = false;

  correctPosition();
  computeClippedBounds(windowBounds);

  for(t = 0; t < elements.size(); t++)
    elements[t]->computeWindowBounds();
}
Exemple #2
0
void GUIPanel::packXAxisLayout()
{
  computeWindowBounds();

  std::vector<int> childrenWidths,
              childrenHeights;
  float       offset      = 0;
  size_t      t           = 0;
  int         height      = 0,
              width       = 0,
              panelHeight = windowBounds.w - windowBounds.y;

  for(t = 0; t < elements.size(); t++)
  {
    const Tuple4i &childBounds = elements[t]->getWindowBounds();
    childrenHeights.push_back(childBounds.w - childBounds.y);
    childrenWidths.push_back (childBounds.z - childBounds.x + interval.x);

    width       += childrenWidths[t];
    height       = childBounds.w - childBounds.y;
    panelHeight  = height > panelHeight ? height : panelHeight;
  }

  dimensions.set(float(width), float(panelHeight));
  GUIRectangle::computeWindowBounds();

  windowBounds.z += interval.x;
  windowBounds.w += interval.y*2;

  update = false;
  width  = interval.x;

  correctPosition();
  computeClippedBounds(windowBounds);

  for(t = 0; t < elements.size(); t++)
  {
    offset = clamp(float(panelHeight - childrenHeights[t])/2.0f + interval.y, 0.0f, 1000.0f);
    elements[t]->setAnchorPoint(AT_CORNERLU);
    elements[t]->setPosition(float(width), offset);
    elements[t]->computeWindowBounds();
    width += childrenWidths[t];
  }
}
Exemple #3
0
void GUIPanel::packYAxisLayout()
{
  computeWindowBounds();

  std::vector<int> childrenHeights,
              childrenWidths;

  size_t      t          = 0;
  int         height     = 0,
              xOffset    = 0,
              panelWidth = getWidth();

  for(t = 0; t < elements.size(); t++)
  {
    const Tuple4i &childBounds = elements[t]->getWindowBounds();
    childrenHeights.push_back(childBounds.w - childBounds.y + interval.y);
    childrenWidths.push_back(childBounds.z - childBounds.x);
    height       += childrenHeights[t];
    panelWidth    = childrenWidths[t] > panelWidth ? childrenWidths[t] : panelWidth;
  }

  dimensions.set(float(panelWidth), float(height));
  GUIRectangle::computeWindowBounds();

  windowBounds.z += interval.x*2;
  windowBounds.w += interval.y;

  update = false;
  height = interval.y;

  correctPosition();
  computeClippedBounds(windowBounds);

  for(t = 0; t < elements.size(); t++)
  {
    xOffset = (layout == PL_YAXIS_CEN_LAYOUT) * (panelWidth - childrenWidths[t])/2;

    elements[t]->setAnchorPoint(AT_CORNERLU);
    elements[t]->setPosition(float(interval.x + xOffset), float(height));
    elements[t]->computeWindowBounds();
    height += childrenHeights[t];
  }
}
Exemple #4
0
const void GUIButton::computeWindowBounds()
{
  if(parent && update)
  {
    GUIRectangle::computeWindowBounds();
    label.computeDimensions();

    int width  = windowBounds.z - windowBounds.x,
        height = windowBounds.w - windowBounds.y;

    if(width  <= label.getWidth() + 2*clipSize)
    {
      if(anchor == AT_CENTER)
      {
        width = (label.getWidth() - width)/2 + clipSize + 2;
        windowBounds.x -=width;
        windowBounds.z +=width;
      }
      if((anchor == AT_CORNERLU) || (anchor == AT_CORNERLD))
      {
        width = (label.getWidth() - width)/2 + clipSize + 2;
        windowBounds.z +=2*width;
      }
    }

    if(height + 2*clipSize <  label.getHeight())
    {

      height = (label.getHeight() - height)/2 + clipSize + 2;
      windowBounds.y -= height;
      windowBounds.w += height;
    }

    computeClippedBounds(windowBounds);
  }
}