osgEarth 2.1.1
Public Member Functions

osgEarth::Util::Controls::RoundedFrame Class Reference

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

List of all members.

Public Member Functions

 RoundedFrame ()
virtual void draw (const ControlContext &cx, DrawableList &drawables)

Detailed Description

A Frame with nice rounded corners.

Definition at line 406 of file Controls.


Constructor & Destructor Documentation

RoundedFrame::RoundedFrame ( )

Definition at line 1045 of file Controls.cpp.

{
    //nop
}

Member Function Documentation

void RoundedFrame::draw ( const ControlContext cx,
DrawableList drawables 
) [virtual]

Reimplemented from osgEarth::Util::Controls::Frame.

Definition at line 1051 of file Controls.cpp.

{
    if ( Geometry::hasBufferOperation() )
    {
        if ( !getImage() || getImage()->s() != _renderSize.x() || getImage()->t() != _renderSize.y() )
        {
            // create a rounded rectangle by buffering a rectangle. "buffer" value affects how rounded
            // the corners are.
            float buffer = Geometry::hasBufferOperation() ? 10.0f : 0.0f;

            osg::ref_ptr<Geometry> geom = new Polygon();
            geom->push_back( osg::Vec3d( buffer, buffer, 0 ) );
            geom->push_back( osg::Vec3d( _renderSize.x()-1-buffer, buffer, 0 ) );
            geom->push_back( osg::Vec3d( _renderSize.x()-1-buffer, _renderSize.y()-1-buffer, 0 ) );
            geom->push_back( osg::Vec3d( buffer, _renderSize.y()-1-buffer, 0 ) );

            BufferParameters bp;
            bp._capStyle = BufferParameters::CAP_ROUND;
            geom->buffer( buffer-1.0f, geom, bp );

            GeometryRasterizer ras( (int)_renderSize.x(), (int)_renderSize.y() );
            ras.draw( geom.get(), backColor().value() );

            osg::Image* image = ras.finalize();
            const_cast<RoundedFrame*>(this)->setImage( image );
        }

        ImageControl::draw( cx, out );
    }
    else
    {
        // fallback: draw a non-rounded frame.
        Frame::draw( cx, out );
    }
}

Here is the call graph for this function:


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