|
osgEarth 2.1.1
|
Inheritance diagram for osgEarth::Util::Controls::HSliderControl:
Collaboration diagram for osgEarth::Util::Controls::HSliderControl: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 |
A control that provides a horizontal sliding value controller.
| HSliderControl::HSliderControl | ( | float | min = 0.0f, |
| float | max = 100.0f, |
||
| float | value = 50.0f |
||
| ) |
| 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] |
| float osgEarth::Util::Controls::HSliderControl::getMin | ( | ) | const [inline] |
| float osgEarth::Util::Controls::HSliderControl::getValue | ( | ) | const [inline] |
| 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 |
||
| ) |
| void HSliderControl::setMin | ( | float | min, |
| bool | notify = true |
||
| ) |
| 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:float osgEarth::Util::Controls::HSliderControl::_max [private] |
float osgEarth::Util::Controls::HSliderControl::_min [private] |
float osgEarth::Util::Controls::HSliderControl::_value [private] |
1.7.3