ofxMUI
A Multi-touch GUI implementation built with ofxDOM for openFrameworks.
ofx::MUI::Button Class Reference

A simple one state push button. More...

#include <Button.h>

Inheritance diagram for ofx::MUI::Button:
ofx::MUI::Widget ofx::MUI::RadioButton ofx::MUI::ToggleButton

Public Types

enum  { DEFAULT_WIDTH = 40, DEFAULT_HEIGHT = 40 }
 

Public Member Functions

 Button (const std::string &id="", float x=0, float y=0, float width=DEFAULT_WIDTH, float height=DEFAULT_HEIGHT, bool autoExclusive=false, bool triggersOnRelease=false, bool requirePointerOverOnRelease=true, std::size_t stateCount=1)
 Create a Button with the given parameters. More...
 
virtual ~Button ()
 Destroy the Button.
 
bool triggersOnRelease () const
 
bool requirePointerOverOnRelease () const
 
bool autoExclusive () const
 
std::size_t stateCount () const
 Return the number of Button states.
 
virtual void onDraw () const override
 
void onPointerEvent (DOM::PointerUIEventArgs &e)
 Default callback for built-in events, including dragging. More...
 
void onPointerCaptureEvent (DOM::PointerCaptureUIEventArgs &e)
 Default callback for built-in events, including dragging. More...
 
template<class ListenerClass , typename ListenerMethod >
void addListener (ListenerClass *listener, ListenerMethod method, int priority=OF_EVENT_ORDER_AFTER_APP)
 Add listeners to this onValueChanged event. 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...
 
int operator= (int v)
 The assignment operator. More...
 
 operator const int & ()
 Dereference operator.
 
- 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...
 

Public Attributes

DOM::DOMEvent< ButtonEventArgsonButtonPressed
 Event called when button is pressed and released. More...
 
DOM::DOMEvent< ButtonEventArgsonButtonDown
 The event called when the button goes from an up to down state.
 
DOM::DOMEvent< ButtonEventArgsonButtonUp
 The event called when the button goes from down to up state.
 
ofEvent< int > onValueChanged
 The event that is set when the value of a button changes.
 

Protected Member Functions

void _onValueChanged (const void *sender, int &value)
 A callback for the ParameterWidget's value. More...
 
void _incrementState ()
 Increment the current button state.
 
- 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

bool _autoExclusive = true
 If true, will act as a radio button. More...
 
bool _triggersOnRelease = false
 Update the value immediately on press.
 
bool _requirePointerOverOnRelease = true
 Require that release is over the button.
 
std::size_t _stateCount = 1
 How many states can this button represent?
 
std::size_t _primaryPointerId = 0
 The "primary" pointer id. More...
 
ofParameter< int > _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.
 

Friends

class ButtonGroup
 

Detailed Description

A simple one state push button.

In addition to the standard Pointer events, the following button events are triggered when a button is pressed:

onButtonDown // When the button is pressed.
onButtonUp // When the button is released.

onButtonPressed // If the button is pressed and released according to
    the `PointerOverOnRelease` policy.

onButtonStateChanged // Called
if  

Constructor & Destructor Documentation

ofx::MUI::Button::Button ( const std::string &  id = "",
float  x = 0,
float  y = 0,
float  width = DEFAULT_WIDTH,
float  height = DEFAULT_HEIGHT,
bool  autoExclusive = false,
bool  triggersOnRelease = false,
bool  requirePointerOverOnRelease = true,
std::size_t  stateCount = 1 
)

Create a Button 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.
autoExclusiveIf true, behaves like an exclusive radio button.
triggersOnReleaseIf true, the button is toggled only on release.
requirePointerOverOnReleaseRequire a pointer to be over the button to trigger to change states.
stateCountThe number of values for multi-state buttons.

Member Function Documentation

void ofx::MUI::Button::_onValueChanged ( const void *  sender,
int &  value 
)
protected

A callback for the ParameterWidget's value.

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

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.
void ofx::MUI::Button::onPointerCaptureEvent ( DOM::PointerCaptureUIEventArgs &  e)

Default callback for built-in events, including dragging.

Parameters
eThe event data.
void ofx::MUI::Button::onPointerEvent ( DOM::PointerUIEventArgs &  e)

Default callback for built-in events, including dragging.

Parameters
eThe event data.
int ofx::MUI::Button::operator= ( int  v)

The assignment operator.

Parameters
vValue to assign.
Returns
the assigned value.
template<class ListenerClass , typename ListenerMethod >
void ofx::MUI::Button::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.
bool ofx::MUI::Button::triggersOnRelease ( ) const
Returns
true iff the value should be changed on Button release.

Member Data Documentation

bool ofx::MUI::Button::_autoExclusive = true
protected

If true, will act as a radio button.

It will disable all sibling autoExlusive buttons on press.

std::size_t ofx::MUI::Button::_primaryPointerId = 0
protected

The "primary" pointer id.

This is the first pointer that was captured when dragging.

DOM::DOMEvent<ButtonEventArgs> ofx::MUI::Button::onButtonPressed

Event called when button is pressed and released.

This event follows the require release over policy.


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