osgEarth 2.1.1
Public Member Functions | Private Attributes

osgEarth::Util::Controls::HBox Class Reference

Inheritance diagram for osgEarth::Util::Controls::HBox:
Collaboration diagram for osgEarth::Util::Controls::HBox:

List of all members.

Public Member Functions

 HBox ()
virtual void addControl (Control *control, int index=-1)
virtual const ControlListchildren () const
virtual void clearControls ()
virtual void calcSize (const ControlContext &context, osg::Vec2f &out_size)
virtual void calcFill (const ControlContext &context)
virtual void calcPos (const ControlContext &context, const osg::Vec2f &cursor, const osg::Vec2f &parentSize)
virtual void draw (const ControlContext &context, DrawableList &drawables)

Private Attributes

ControlList _controls

Detailed Description

Container that stacks controls horizontally.

Definition at line 503 of file Controls.


Constructor & Destructor Documentation

HBox::HBox ( )

Definition at line 1366 of file Controls.cpp.

{
    //nop
}

Member Function Documentation

void HBox::addControl ( Control control,
int  index = -1 
) [virtual]

Implements osgEarth::Util::Controls::Container.

Definition at line 1372 of file Controls.cpp.

{
    if ( index < 0 )
        _controls.push_back( control );
    else
        _controls.insert( _controls.begin() + osg::minimum(index,(int)_controls.size()-1), control );
    
    control->setParent( this );
    applyChildAligns();

    dirty();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void HBox::calcFill ( const ControlContext context) [virtual]

Reimplemented from osgEarth::Util::Controls::Container.

Definition at line 1425 of file Controls.cpp.

{
    //Container::calcFill( cx );

    float used_x = padding().x() - childSpacing();
    float used_y = padding().y();

    Control* hc = 0L;
    Control* vc = 0L;

    for( ControlList::const_iterator i = _controls.begin(); i != _controls.end() && (!hc || !vc); ++i )
    {
        Control* child = i->get();

        //child->calcFill(cx);

        used_x += child->margin().x() + childSpacing();
        if ( !hc && child->horizFill() )
            hc = child;
        else
            used_x += child->renderSize().x();

        if ( !vc && child->vertFill() )
        {
            vc = child;
            used_y += child->margin().y();
        }
    }

    if ( hc && renderWidth(hc) < (_renderSize.x() - used_x) )
        renderWidth(hc) = _renderSize.x() - used_x;

    if ( vc && renderHeight(vc) < (_renderSize.y() - used_y) )
        renderHeight(vc) = _renderSize.y() - used_y;
   
    Container::calcFill( cx );
}

Here is the call graph for this function:

void HBox::calcPos ( const ControlContext context,
const osg::Vec2f &  cursor,
const osg::Vec2f &  parentSize 
) [virtual]

Reimplemented from osgEarth::Util::Controls::Container.

Definition at line 1464 of file Controls.cpp.

{
    Container::calcPos( cx, cursor, parentSize );

    osg::Vec2f childCursor = _renderPos;

#if 0
    // collect all the members
    for( ControlList::const_iterator i = _controls.begin(); i != _controls.end(); ++i )
    {
        Control* child = i->get();
        child->calcPos( cx, childCursor, _renderSize - padding().size() ); // GW1
        childCursor.x() += child->margin().left() + child->renderSize().x() + child->margin().right() + childSpacing();
    }
#endif

    osg::Vec2f renderArea = _renderSize - padding().size();
    for( ControlList::const_iterator i = _controls.begin(); i != _controls.end(); ++i )
    {
        Control* child = i->get();
        child->calcPos( cx, childCursor, renderArea );
        float deltaX = child->margin().left() + child->renderSize().x() + child->margin().right() + childSpacing();
        childCursor.x() += deltaX;
        renderArea.x() -= deltaX;        
    }
}

Here is the call graph for this function:

void HBox::calcSize ( const ControlContext context,
osg::Vec2f &  out_size 
) [virtual]

Reimplemented from osgEarth::Util::Controls::Container.

Definition at line 1393 of file Controls.cpp.

{
    if ( visible() == true )
    {
        _renderSize.set( 0, 0 );

        // collect all the members, growing the container is its orientation.
        for( ControlList::const_iterator i = _controls.begin(); i != _controls.end(); ++i )
        {
            Control* child = i->get();
            osg::Vec2f childSize;
            bool first = i == _controls.begin();

            child->calcSize( cx, childSize );

            _renderSize.x() += first ? childSize.x() : childSpacing() + childSize.x();
            _renderSize.y() = osg::maximum( _renderSize.y(), childSize.y() );
        }

        _renderSize.set(
            _renderSize.x() + padding().x(),
            _renderSize.y() + padding().y() );

        out_size.set(
            _renderSize.x() + margin().x(),
            _renderSize.y() + margin().y() );

        Container::calcSize( cx, out_size );
    }
}

Here is the call graph for this function:

virtual const ControlList& osgEarth::Util::Controls::HBox::children ( ) const [inline, virtual]

Implements osgEarth::Util::Controls::Container.

Definition at line 510 of file Controls.

{ return _controls; }
void HBox::clearControls ( ) [virtual]

Implements osgEarth::Util::Controls::Container.

Definition at line 1386 of file Controls.cpp.

{
    _controls.clear();
    dirty();
}

Here is the call graph for this function:

void HBox::draw ( const ControlContext context,
DrawableList drawables 
) [virtual]

Reimplemented from osgEarth::Util::Controls::Container.

Definition at line 1492 of file Controls.cpp.

{
    Container::draw( cx, out );
    for( ControlList::const_iterator i = _controls.begin(); i != _controls.end(); ++i )
        i->get()->draw( cx, out );
}

Member Data Documentation

Definition at line 520 of file Controls.


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