Exemplo n.º 1
0
Vec2f BorderLayout::layoutSize(const MFUnrecChildComponentPtr* Components, const Component* ParentComponent, SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

    Vec2f WestSize(0.0,0.0),
        EastSize(0.0,0.0),
        NorthSize(0.0,0.0),
        SouthSize(0.0,0.0),
        CenterSize(0.0,0.0);
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        switch(dynamic_cast<BorderLayoutConstraints*>((*Components)[i]->getConstraints())->getRegion())
        {
        case BorderLayoutConstraints::BORDER_WEST:
            WestSize = getComponentSize((*Components)[i],TheSizeType);
            break;
        case BorderLayoutConstraints::BORDER_EAST:
            EastSize = getComponentSize((*Components)[i],TheSizeType);
            break;
        case BorderLayoutConstraints::BORDER_NORTH:
            NorthSize = getComponentSize((*Components)[i],TheSizeType);
            break;
        case BorderLayoutConstraints::BORDER_SOUTH:
            SouthSize = getComponentSize((*Components)[i],TheSizeType);
            break;
        case BorderLayoutConstraints::BORDER_CENTER:
            CenterSize = getComponentSize((*Components)[i],TheSizeType);
            break;
        }
    }

    switch(TheSizeType)
    {
    case MAX_SIZE:
        Result[0] = osgMin(osgMin(EastSize.x() + CenterSize.x() + WestSize.x(),NorthSize.x()),SouthSize.x());
        Result[1] = osgMin(osgMin(EastSize.y(), CenterSize.y()), WestSize.y()) + NorthSize.y() + SouthSize.y();
        break;
    case MIN_SIZE:
    case PREFERRED_SIZE:
    case REQUESTED_SIZE:
    default:
        Result[0] = osgMax(osgMax(EastSize.x() + CenterSize.x() + WestSize.x(),NorthSize.x()),SouthSize.x());
        Result[1] = osgMax(osgMax(EastSize.y(), CenterSize.y()), WestSize.y()) + NorthSize.y() + SouthSize.y();
        break;
    }

    return Result;
}
Exemplo n.º 2
0
Vec2f GridLayout::layoutSize(const MFUnrecChildComponentPtr* Components, const Component* ParentComponent, SizeType TheSizeType) const
{
    if(getRows() == 0 || getColumns() == 0)
    {
        return Vec2f(1.0f,1.0f);
    }

	Real32 maxSizeX = 0.0f;
	Real32 maxSizeY = 0.0f;

    Vec2f ComponentSize;
	//set the size to the perfered sizes for the buttons
	for(UInt16 i = 0; i<Components->size(); i++){
		if ((*Components)[i] != NULL) 
		{
            ComponentSize = getComponentSize((*Components)[i],TheSizeType);
			if(ComponentSize.x()>maxSizeX)
				maxSizeX = ComponentSize.x();
			if(ComponentSize.y()>maxSizeY)
				maxSizeY = ComponentSize.y();
		}
	}

    return Vec2f(maxSizeX * static_cast<Real32>(getColumns()) + getHorizontalGap() * static_cast<Real32>(getColumns()-1),
                 maxSizeY * static_cast<Real32>(getRows()) + getVerticalGap() * static_cast<Real32>(getRows()-1));
}
Exemplo n.º 3
0
Vec2f FlowLayout::layoutSize(const MFUnrecComponentPtr* Components, const Component* ParentComponent, SizeType TheSizeType) const
{
    Real32 MinorAxisMax(0.0f);
    Real32 MajorAxisSum(0.0f);

    UInt32 MajorAxisIndex(0);
    if(getOrientation() != HORIZONTAL_ORIENTATION ) MajorAxisIndex = 1;

    UInt32 MinorAxisIndex((MajorAxisIndex+1)%2);

    Vec2f ComponentSize;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentSize[MinorAxisIndex] > MinorAxisMax)
        {
            MinorAxisMax = ComponentSize[MinorAxisIndex];
        }
        MajorAxisSum += ComponentSize[MajorAxisIndex];
    }

    Vec2f Result;
    Result[MajorAxisIndex] = MajorAxisSum;
    Result[MinorAxisIndex] = MinorAxisMax;
    return Result;
}
Exemplo n.º 4
0
Vec2f AbsoluteLayout::layoutSize(const MFUnrecChildComponentPtr* Components,
                                 const Component* ParentComponent,
                                 SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

	Pnt2f borderTopLeft, borderBottomRight;
	dynamic_cast<const ComponentContainer*>(ParentComponent)->getInsideInsetsBounds(borderTopLeft, borderBottomRight);
	Vec2f borderSize(borderBottomRight-borderTopLeft);

    Vec2f ComponentSize;
    Pnt2f ComponentPosition;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentPosition = dynamic_cast<AbsoluteLayoutConstraints*>((*Components)[i]->getConstraints())->getPosition();

        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentPosition.x() + ComponentSize.x() > Result.x())
        {
            Result[0] = ComponentPosition.x() + ComponentSize.x();
        }
        if(ComponentPosition.y() + ComponentSize.y() > Result.y())
        {
            Result[1] = ComponentPosition.y() + ComponentSize.y();
        }
    }

    return Result;
}
Exemplo n.º 5
0
Vec2f AbsoluteLayout::layoutSize(const MFUnrecComponentPtr* Components,
                                 const Component* ParentComponent,
                                 SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

    Vec2f ComponentSize;
    Pnt2f ComponentPosition;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentPosition = dynamic_cast<AbsoluteLayoutConstraints*>((*Components)[i]->getConstraints())->getPosition();

        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentPosition.x() + ComponentSize.x() > Result.x())
        {
            Result[0] = ComponentPosition.x() + ComponentSize.x();
        }
        if(ComponentPosition.y() + ComponentSize.y() > Result.y())
        {
            Result[1] = ComponentPosition.y() + ComponentSize.y();
        }
    }

    return Result;
}
Exemplo n.º 6
0
Vec2f CardLayout::layoutSize(const MFUnrecChildComponentPtr* Components, const Component* ParentComponent, SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

    Vec2f ComponentSize;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentSize.x() > Result.x())
        {
            Result[0] = ComponentSize.x();
        }
        if(ComponentSize.y() > Result.y())
        {
            Result[1] = ComponentSize.y();
        }
    }

    return Result;
}