osgEarth 2.1.1
Public Member Functions | Protected Member Functions | Private Attributes

osgEarth::Util::Controls::HSliderControl Class Reference

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

List of all members.

Public Member Functions

 HSliderControl (float min=0.0f, float max=100.0f, float value=50.0f)
void setMin (float min, bool notify=true)
float getMin () const
void setMax (float max, bool notify=true)
float getMax () const
void setValue (float value, bool notify=true)
float getValue () const
virtual void draw (const ControlContext &cx, DrawableList &out)

Protected Member Functions

virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, ControlContext &cx)
void fireValueChanged ()

Private Attributes

float _min
float _max
float _value

Detailed Description

A control that provides a horizontal sliding value controller.

Definition at line 336 of file Controls.


Constructor & Destructor Documentation

HSliderControl::HSliderControl ( float  min = 0.0f,
float  max = 100.0f,
float  value = 50.0f 
)

Definition at line 778 of file Controls.cpp.

                                                                  :
_min(min),
_max(max),
_value(value)
{
   if ( _max <= _min )
       _max = _min+1.0f;
   if ( _value < _min )
       _value = _min;
   if ( _value > _max )
       _value = _max;

   setHorizFill( true );
}

Here is the call graph for this function:


Member Function Documentation

void HSliderControl::draw ( const ControlContext cx,
DrawableList out 
) [virtual]

Reimplemented from osgEarth::Util::Controls::Control.

Definition at line 854 of file Controls.cpp.

{
    Control::draw( cx, out );

    if ( visible() == true )
    {
        osg::ref_ptr<osg::Geometry> g = new osg::Geometry();

        float rx = osg::round( _renderPos.x() );
        float ry = osg::round( _renderPos.y() );
        float rw = osg::round( _renderSize.x() - padding().x() );
        float rh = osg::round( _renderSize.y() - padding().y() );

        if ( rw > 0.0f && rh > 0.0f )
        {
            float vph = cx._vp->height();

            osg::Vec3Array* verts = new osg::Vec3Array(8);
            g->setVertexArray( verts );

            (*verts)[0].set( rx, vph - ry, 0 );
            (*verts)[1].set( rx + rw, vph - ry, 0 );
            (*verts)[2].set( rx + rw, vph - (ry + rh), 0 );
            (*verts)[3].set( rx, vph - (ry + rh), 0 );
            g->addPrimitiveSet( new osg::DrawArrays( GL_LINE_LOOP, 0, 4 ) );

            float hx = rx + rw * ( (_value-_min)/(_max-_min) );

            (*verts)[4].set( hx-4, vph - ry + 3, 0 );
            (*verts)[5].set( hx+4, vph - ry + 3, 0 );
            (*verts)[6].set( hx+4, vph - (ry + rh + 3), 0 );
            (*verts)[7].set( hx-4, vph - (ry + rh + 3), 0 );
            g->addPrimitiveSet( new osg::DrawArrays( GL_QUADS, 4, 4 ) );

            osg::Vec4Array* c = new osg::Vec4Array(1);
            (*c)[0] = *foreColor();
            g->setColorArray( c );
            g->setColorBinding( osg::Geometry::BIND_OVERALL );

            out.push_back( g.get() );
        }
    }
}

Here is the call graph for this function:

void HSliderControl::fireValueChanged ( ) [protected]

Definition at line 794 of file Controls.cpp.

{
    for( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i )
    {
        i->get()->onValueChanged( this, _value );
    }
}

Here is the caller graph for this function:

float osgEarth::Util::Controls::HSliderControl::getMax ( ) const [inline]

Definition at line 345 of file Controls.

{ return _max; }
float osgEarth::Util::Controls::HSliderControl::getMin ( ) const [inline]

Definition at line 342 of file Controls.

{ return _min; }
float osgEarth::Util::Controls::HSliderControl::getValue ( ) const [inline]

Definition at line 348 of file Controls.

{ return _value; }
bool HSliderControl::handle ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
ControlContext cx 
) [protected, virtual]

Reimplemented from osgEarth::Util::Controls::Control.

Definition at line 899 of file Controls.cpp.

{
    if ( ea.getEventType() == osgGA::GUIEventAdapter::DRAG )
    {
        float relX = ea.getX() - _renderPos.x();

        setValue( _min + (_max-_min) * ( relX/_renderSize.x() ) );
        return true;
    }
    return Control::handle( ea, aa, cx );
}

Here is the call graph for this function:

void HSliderControl::setMax ( float  max,
bool  notify = true 
)

Definition at line 835 of file Controls.cpp.

{
    if ( max != _max )
    {
        _max = max;
        if ( _max <= _min )
            _max = _min+1.0f;

        if ( _value < _min || _value > _max )
        {
            _value = _max;
            if ( notify )
                fireValueChanged();
        }
        dirty();
    }
}

Here is the call graph for this function:

void HSliderControl::setMin ( float  min,
bool  notify = true 
)

Definition at line 816 of file Controls.cpp.

{
    if ( min != _min )
    {
        _min = min;
        if ( _min >= _max )
            _max = _min+1.0f;

        if ( _value < _min || _value > _max ) 
        {
            _value = _min;
            if ( notify )
                fireValueChanged();
        }
        dirty();
    }
}

Here is the call graph for this function:

void HSliderControl::setValue ( float  value,
bool  notify = true 
)

Definition at line 803 of file Controls.cpp.

{
    value = osg::clampBetween( value, _min, _max );
    if ( value != _value )
    {
        _value = value;
        if ( notify )
            fireValueChanged();
        dirty();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 360 of file Controls.

Definition at line 360 of file Controls.

Definition at line 360 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