ofxMUI
A Multi-touch GUI implementation built with ofxDOM for openFrameworks.
ofx::MUI::Slider< Type > Class Template Reference

Slider. More...

#include <Slider.h>

Inheritance diagram for ofx::MUI::Slider< Type >:
ofx::MUI::Widget

Public Types

enum  { DEFAULT_WIDTH = 15, DEFAULT_HEIGHT = 300 }
 

Public Member Functions

 Slider (const std::string &id, DOM::Orientation orientation, DragMode mode=DragMode::ABSOLUTE)
 Create a Slider with the given parameters. More...
 
 Slider (const std::string &id="", float x=0, float y=0, float width=DEFAULT_WIDTH, float height=DEFAULT_HEIGHT, DOM::Orientation orientation=DOM::Orientation::DEFAULT, DragMode mode=DragMode::ABSOLUTE)
 Create a Slider with the given parameters. More...
 
virtual ~Slider ()
 Destroy the Slider.
 
virtual void onDraw () const override
 
DragMode getDragMode () const
 
void setDragMode (DragMode mode)
 Set the current DragMode. More...
 
DOM::Orientation getOrientation () const
 
void setOrientation (DOM::Orientation orientation)
 Set the Orientation of the slider. More...
 
bool isInverted () const
 Determine if the slider direction inverted. More...
 
void setInverted (bool inverted)
 Invert the Slider direction. More...
 
void onPointerEvent (DOM::PointerUIEventArgs &e)
 Pointer event callback. More...
 
void onPointerCaptureEvent (DOM::PointerCaptureUIEventArgs &e)
 Pointer event callback. More...
 
template<class ListenerClass , typename ListenerMethod >
void addListener (ListenerClass *listener, ListenerMethod method, int priority=OF_EVENT_ORDER_AFTER_APP)
 Bind this adapter to an existing parameter. More...
 
template<class ListenerClass , typename ListenerMethod >
void removeListener (ListenerClass *listener, ListenerMethod method, int priority=OF_EVENT_ORDER_AFTER_APP)
 Remove listeners to this onValueChanged event. More...
 
void setValueWithoutEventNotifications (const Type &value)
 
void setValue (const Type &value)
 
Type getValue () const
 
void setMin (const Type &min)
 
Type getMin () const
 
void setMax (const Type &max)
 
Type getMax () const
 
- Public Member Functions inherited from ofx::MUI::Widget
 Widget (float x, float y, float width, float height)
 
 Widget (const std::string &id, float x, float y, float width, float height)
 
virtual ~Widget ()
 Destroy this Widget.
 
bool isPointerOver () const
 
bool isPointerDown () const
 
void setDropTarget (bool dropTarget)
 Enable or disable the Widget as a drop target. More...
 
bool isDropTarget () const
 Determine if this Widget is a drop target. More...
 
void setDraggable (bool draggable)
 Set draggability for this Widget. More...
 
bool isDraggable () const
 Determine if draggability is enabled for this Widget. More...
 
bool isDragging () const
 Determine if this Widget is being dragged. More...
 
std::shared_ptr< StylesgetStyles () const
 Get the Styles for this Widget. More...
 
void setStyles (std::shared_ptr< Styles > styles)
 Set the Styles for this Widget. More...
 

Static Public Member Functions

static float defaultWidthForOrientation (DOM::Orientation orientation)
 
static float defaultHeightForOrientation (DOM::Orientation orientation)
 

Public Attributes

ofEvent< Type > onValueChanged
 A callback for the parameter change.
 

Static Public Attributes

static const DOM::Orientation DEFAULT_ORIENTATION = DOM::Orientation::HORIZONTAL
 

Protected Member Functions

DOM::Orientation _getEffectiveOrientation () const
 Get the effective orientation. More...
 
std::size_t _getActiveAxisIndex () const
 Get the active axis index. More...
 
void _onResize (DOM::ResizeEventArgs &)
 A callback for any resize events. More...
 
void _onValueChanged (const void *sender, Type &value)
 A callback for the ParameterWidget's value. More...
 
- Protected Member Functions inherited from ofx::MUI::Widget
void _onPointerEvent (DOM::PointerUIEventArgs &e)
 Default callback for built-in events, including dragging.
 
void _onPointerCaptureEvent (DOM::PointerCaptureUIEventArgs &e)
 Default callback for built-in events, including dragging.
 

Protected Attributes

DOM::Orientation _orientation = DOM::Orientation::HORIZONTAL
 The Slider orientation.
 
DragMode _dragMode = DragMode::RELATIVE
 The drag mode.
 
std::size_t _primaryPointerId = 0
 The "primary" pointer id. More...
 
Type _valueOffset = 0
 The start value of the value itself. More...
 
bool _isInverted = false
 Is the Slider direction inverted.
 
ofParameter< Type > _value
 The parameter to watch.
 
- Protected Attributes inherited from ofx::MUI::Widget
bool _isDropTarget = false
 True iff the Widget is a target for dragged Widgets.
 
bool _isDraggable = false
 True iff the Widget is configured to be dragged.
 
bool _isDragging = false
 True iff the widget is currently being dragged.
 
bool _isPointerOver = false
 True iff the pointer is over the widget.
 
bool _moveToFrontOnCapture = true
 True if the element should move to the fron upon pointer capture.
 

Detailed Description

template<typename Type>
class ofx::MUI::Slider< Type >

Slider.

Template Parameters
Typethe data type represented by the Slider.

Constructor & Destructor Documentation

template<typename Type >
ofx::MUI::Slider< Type >::Slider ( const std::string &  id,
DOM::Orientation  orientation,
DragMode  mode = DragMode::ABSOLUTE 
)

Create a Slider with the given parameters.

Parameters
idThe Widget's id string.
orientationThe orientation of the Slider.
modeThe DragMode of the Slider.
template<typename Type >
ofx::MUI::Slider< Type >::Slider ( const std::string &  id = "",
float  x = 0,
float  y = 0,
float  width = DEFAULT_WIDTH,
float  height = DEFAULT_HEIGHT,
DOM::Orientation  orientation = DOM::Orientation::DEFAULT,
DragMode  mode = DragMode::ABSOLUTE 
)

Create a Slider with the given parameters.

Parameters
idThe Widget's id string.
xx-position in parent coordinates.
yy-position in parent coordinates.
widthThe width (x-dimension) of Widget.
heightThe height (y-dimension) of Widget.
orientationThe orientation of the Slider.
modeThe DragMode of the Slider.

Member Function Documentation

template<typename Type >
std::size_t ofx::MUI::Slider< Type >::_getActiveAxisIndex ( ) const
protected

Get the active axis index.

Returns
0 for X or 1 for Y.
template<typename Type >
DOM::Orientation ofx::MUI::Slider< Type >::_getEffectiveOrientation ( ) const
protected

Get the effective orientation.

Returns
only Orientation::LANDSCAPE or Orientation::HORIZONTAL.
template<typename Type >
void ofx::MUI::Slider< Type >::_onResize ( DOM::ResizeEventArgs &  )
protected

A callback for any resize events.

Parameters
valueThe DOM::ResizeEvent arguments.
template<typename Type >
void ofx::MUI::Slider< Type >::_onValueChanged ( const void *  sender,
Type &  value 
)
protected

A callback for the ParameterWidget's value.

Parameters
valueThe the updated value.
template<typename Type >
template<class ListenerClass , typename ListenerMethod >
void ofx::MUI::Slider< Type >::addListener ( ListenerClass *  listener,
ListenerMethod  method,
int  priority = OF_EVENT_ORDER_AFTER_APP 
)
inline

Bind this adapter to an existing parameter.

Parameters
parameterThe parameter to bind to. void makeReferenceTo(ofParameter<Type>& parameter); Add listeners to this onValueChanged event.
Template Parameters
ListenerClassThe class type of the listener.
ListenerMethodThe name of the listener method.
Parameters
listenerA pointer to the listener instance.
methodA pointer to the listener method.
prioirtyThe order priority of this listener.
template<typename Type >
DragMode ofx::MUI::Slider< Type >::getDragMode ( ) const
Returns
the current DragMode.
template<typename Type >
DOM::Orientation ofx::MUI::Slider< Type >::getOrientation ( ) const
Returns
the current orientation.
template<typename Type >
bool ofx::MUI::Slider< Type >::isInverted ( ) const

Determine if the slider direction inverted.

By default the Slider direction is mapped from 0 (left) to 1 (right) in Orientation::LANDSCAPE mode and from 0 (bottom) to 1 (top) in Orientation::PORTRAIT mode. Inverted Sliders map in the opposite way.

Returns
true if the Slider is inverted.
template<typename Type >
void ofx::MUI::Slider< Type >::onPointerCaptureEvent ( DOM::PointerCaptureUIEventArgs &  e)

Pointer event callback.

Parameters
evtThe event data.
template<typename Type >
void ofx::MUI::Slider< Type >::onPointerEvent ( DOM::PointerUIEventArgs &  e)

Pointer event callback.

Parameters
evtThe event data.
template<typename Type >
template<class ListenerClass , typename ListenerMethod >
void ofx::MUI::Slider< Type >::removeListener ( ListenerClass *  listener,
ListenerMethod  method,
int  priority = OF_EVENT_ORDER_AFTER_APP 
)
inline

Remove listeners to this onValueChanged event.

Template Parameters
ListenerClassThe class type of the listener.
ListenerMethodThe name of the listener method.
Parameters
listenerA pointer to the listener instance.
methodA pointer to the listener method.
prioirtyThe order priority of this listener.
template<typename Type >
void ofx::MUI::Slider< Type >::setDragMode ( DragMode  mode)

Set the current DragMode.

DragMode affects how a slider interprets drags.

Parameters
modeThe DragMode to set.
template<typename Type >
void ofx::MUI::Slider< Type >::setInverted ( bool  inverted)

Invert the Slider direction.

By default the Slider direction is mapped from 0 (left) to 1 (right) in Orientation::LANDSCAPE mode and from 0 (bottom) to 1 (top) in Orientation::PORTRAIT mode. Inverted Sliders map in the opposite way.

Parameters
invertedtrue if the Slider direction should be inverted.
template<typename Type >
void ofx::MUI::Slider< Type >::setOrientation ( DOM::Orientation  orientation)

Set the Orientation of the slider.

Parameters
theDesired Orientation.

Member Data Documentation

template<typename Type >
std::size_t ofx::MUI::Slider< Type >::_primaryPointerId = 0
protected

The "primary" pointer id.

This is the first pointer that was captured when dragging.

template<typename Type >
Type ofx::MUI::Slider< Type >::_valueOffset = 0
protected

The start value of the value itself.

Used when computing offsets in Mode::RELATIVE.


The documentation for this class was generated from the following file: