ofxMUI
A Multi-touch GUI implementation built with ofxDOM for openFrameworks.
|
A simple one state push button. More...
#include <Button.h>
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< Styles > | getStyles () 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< ButtonEventArgs > | onButtonPressed |
Event called when button is pressed and released. More... | |
DOM::DOMEvent< ButtonEventArgs > | onButtonDown |
The event called when the button goes from an up to down state. | |
DOM::DOMEvent< ButtonEventArgs > | onButtonUp |
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 |
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
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.
id | The Widget's id string. |
x | x-position in parent coordinates. |
y | y-position in parent coordinates. |
width | The width (x-dimension) of Widget. |
height | The height (y-dimension) of Widget. |
autoExclusive | If true, behaves like an exclusive radio button. |
triggersOnRelease | If true, the button is toggled only on release. |
requirePointerOverOnRelease | Require a pointer to be over the button to trigger to change states. |
stateCount | The number of values for multi-state buttons. |
|
protected |
A callback for the ParameterWidget's value.
value | The the updated value. |
|
inline |
Add listeners to this onValueChanged event.
ListenerClass | The class type of the listener. |
ListenerMethod | The name of the listener method. |
listener | A pointer to the listener instance. |
method | A pointer to the listener method. |
prioirty | The order priority of this listener. |
void ofx::MUI::Button::onPointerCaptureEvent | ( | DOM::PointerCaptureUIEventArgs & | e | ) |
Default callback for built-in events, including dragging.
e | The event data. |
void ofx::MUI::Button::onPointerEvent | ( | DOM::PointerUIEventArgs & | e | ) |
Default callback for built-in events, including dragging.
e | The event data. |
int ofx::MUI::Button::operator= | ( | int | v | ) |
The assignment operator.
v | Value to assign. |
|
inline |
Remove listeners to this onValueChanged event.
ListenerClass | The class type of the listener. |
ListenerMethod | The name of the listener method. |
listener | A pointer to the listener instance. |
method | A pointer to the listener method. |
prioirty | The order priority of this listener. |
bool ofx::MUI::Button::triggersOnRelease | ( | ) | const |
|
protected |
If true, will act as a radio button.
It will disable all sibling autoExlusive buttons on press.
|
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.