Provides a group of tweak bar controls as well as event handler methods to control some aspects of a scene. More...
#include <TweakBarHandler.h>
Public Member Functions | |
TweakBarHandler (const char *name, ptr< EventHandler > eventHandler, bool active) | |
Creates a new TweakBarHandler. | |
virtual | ~TweakBarHandler () |
Deletes this TweakBarHandler. | |
const char * | getName () |
Returns the name of this TweakBarHandler. | |
bool | isActive () |
Returns true if this TweakBarHandler is active. | |
virtual void | setActive (bool active) |
Activates or deactivates this TweakBarHandler. | |
virtual void | redisplay (double t, double dt, bool &needUpdate) |
This method is called when a window must be redrawn. | |
virtual void | reshape (int x, int y, bool &needUpdate) |
This method is called when a window is resized. | |
virtual void | idle (bool damaged, bool &needUpdate) |
This method is called periodically when no event occur. | |
virtual bool | mouseClick (EventHandler::button b, EventHandler::state s, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a mouse click occurs. | |
virtual bool | mouseWheel (EventHandler::wheel b, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a mouse wheel event occurs. | |
virtual bool | mouseMotion (int x, int y, bool &needUpdate) |
This method is called periodically when the mouse is moved. | |
virtual bool | mousePassiveMotion (int x, int y, bool &needUpdate) |
This method is called periodically when the mouse is moved. | |
virtual bool | keyTyped (unsigned char c, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a regular key is typed. | |
virtual bool | keyReleased (unsigned char c, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a regular key is released. | |
virtual bool | specialKey (EventHandler::key k, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a special key is typed. | |
virtual bool | specialKeyReleased (EventHandler::key k, EventHandler::modifier m, int x, int y, bool &needUpdate) |
This method is called when a special key is released. | |
virtual void | updateBar (TwBar *bar)=0 |
Adds controls to the given tweak bar. | |
Protected Member Functions | |
TweakBarHandler () | |
Creates an uninitialized TweakBarHandler. | |
virtual void | init (const char *name, ptr< EventHandler > eventHandler, bool active) |
Initializes this TweakBarHandler. | |
Protected Attributes | |
ptr< EventHandler > | eventHandler |
The EventHandler to which the EventHandler like methods of this TweakBarHandler delegate their work. | |
Private Attributes | |
const char * | name |
The name of this TweakBarHandler. | |
bool | active |
True if this TweakBarHandler is active. | |
bool | needUpdate |
True if the tweakbar must be updated. |
Provides a group of tweak bar controls as well as event handler methods to control some aspects of a scene.
A TweakBarHandler can add controls to an existing tweak bar. It also provides EventHandler like methods to control the scene directly with the mouse and keyboard (by default these methods delegate their work to an external EventHandler). A TweakBarHandler is intended to be used with a TweakBarManager. The manager can activate or deactivate a TweakBarHandler, and is responsible to call the EventHandler like methods of the TweakBarHandler that are active. When inactive, these methods are not called, and the tweak bar controls provided by a TweakBarHandler do not appear in the tweak bar.
proland::TweakBarHandler::TweakBarHandler | ( | const char * | name, | |
ptr< EventHandler > | eventHandler, | |||
bool | active | |||
) |
Creates a new TweakBarHandler.
name | the name of this TweakBarHandler. | |
eventHandler | the EventHandler to which the EventHandler like methods of this TweakBarHandler delegate their work. Maybe NULL. | |
active | true if this TweakBarHandler must be initialy active. |
virtual proland::TweakBarHandler::~TweakBarHandler | ( | ) | [virtual] |
Deletes this TweakBarHandler.
proland::TweakBarHandler::TweakBarHandler | ( | ) | [protected] |
Creates an uninitialized TweakBarHandler.
const char* proland::TweakBarHandler::getName | ( | ) |
Returns the name of this TweakBarHandler.
virtual void proland::TweakBarHandler::idle | ( | bool | damaged, | |
bool & | needUpdate | |||
) | [virtual] |
This method is called periodically when no event occur.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
damaged | true if the window (partial) visibility has changed since the last call to this method. This occurs if the window is minized, maximized or if it is partially covered by another window. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual void proland::TweakBarHandler::init | ( | const char * | name, | |
ptr< EventHandler > | eventHandler, | |||
bool | active | |||
) | [protected, virtual] |
Initializes this TweakBarHandler.
See TweakBarHandler.
bool proland::TweakBarHandler::isActive | ( | ) |
Returns true if this TweakBarHandler is active.
virtual bool proland::TweakBarHandler::keyReleased | ( | unsigned char | c, | |
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a regular key is released.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
c | the released character. | |
m | the modifiers that were pressed when the key was released. | |
x | the mouse x coordinate in pixels when the key was released. | |
y | the mouse y coordinate in pixels when the key was released. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual bool proland::TweakBarHandler::keyTyped | ( | unsigned char | c, | |
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a regular key is typed.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
c | the typed character. | |
m | the modifiers that were pressed when the key was typed. | |
x | the mouse x coordinate in pixels when the key was typed. | |
y | the mouse y coordinate in pixels when the key was typed. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual bool proland::TweakBarHandler::mouseClick | ( | EventHandler::button | b, | |
EventHandler::state | s, | |||
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a mouse click occurs.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
b | the button that was clicked. | |
s | the state of this button. | |
m | the modifiers that were pressed when the click occured. | |
x | the mouse x coordinate in pixels when the click occured. | |
y | the mouse y coordinate in pixels when the click occured. | |
[out] | needUpdate | true if the tweakbar must be updated. |
Reimplemented in proland::TweakSceneGraph.
virtual bool proland::TweakBarHandler::mouseMotion | ( | int | x, | |
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called periodically when the mouse is moved.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
x | the mouse x coordinate in pixels. | |
y | the mouse y coordinate in pixels. | |
[out] | needUpdate | true if the tweakbar must be updated. |
Reimplemented in proland::TweakSceneGraph.
virtual bool proland::TweakBarHandler::mousePassiveMotion | ( | int | x, | |
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called periodically when the mouse is moved.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
x | the mouse x coordinate in pixels. | |
y | the mouse y coordinate in pixels. | |
[out] | needUpdate | true if the tweakbar must be updated. |
Reimplemented in proland::TweakSceneGraph.
virtual bool proland::TweakBarHandler::mouseWheel | ( | EventHandler::wheel | b, | |
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a mouse wheel event occurs.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
b | the wheel event that occured (WHEEL_UP or WHEEL_DOWN) | |
m | the modifiers that were pressed when the wheel event occured. | |
x | the mouse x coordinate in pixels when the wheel event occured. | |
y | the mouse y coordinate in pixels when the wheel event occured. | |
[out] | needUpdate | true if the tweakbar must be updated. |
Reimplemented in proland::TweakSceneGraph.
virtual void proland::TweakBarHandler::redisplay | ( | double | t, | |
double | dt, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a window must be redrawn.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to needUpdate (which is then reset to false).
[out] | needUpdate | true if the tweakbar must be updated. |
Reimplemented in proland::TweakSceneGraph.
virtual void proland::TweakBarHandler::reshape | ( | int | x, | |
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a window is resized.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
x | the new window width. | |
y | the new window height. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual void proland::TweakBarHandler::setActive | ( | bool | active | ) | [virtual] |
Activates or deactivates this TweakBarHandler.
active | true to activate this TweakBarHandler, false otherwise. |
virtual bool proland::TweakBarHandler::specialKey | ( | EventHandler::key | k, | |
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a special key is typed.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
k | the typed key. | |
m | the modifiers that were pressed when the key was typed. | |
x | the mouse x coordinate in pixels when the key was typed. | |
y | the mouse y coordinate in pixels when the key was typed. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual bool proland::TweakBarHandler::specialKeyReleased | ( | EventHandler::key | k, | |
EventHandler::modifier | m, | |||
int | x, | |||
int | y, | |||
bool & | needUpdate | |||
) | [virtual] |
This method is called when a special key is released.
The default implementation of this method delegates to eventHandler if it is not NULL, and sets needUpdate to false.
k | the released key. | |
m | the modifiers that were pressed when the key was released. | |
x | the mouse x coordinate in pixels when the key was released. | |
y | the mouse y coordinate in pixels when the key was released. | |
[out] | needUpdate | true if the tweakbar must be updated. |
virtual void proland::TweakBarHandler::updateBar | ( | TwBar * | bar | ) | [pure virtual] |
Adds controls to the given tweak bar.
Implemented in proland::TweakResource, proland::TweakSceneGraph, and proland::TweakViewHandler.
bool proland::TweakBarHandler::active [private] |
True if this TweakBarHandler is active.
ptr<EventHandler> proland::TweakBarHandler::eventHandler [protected] |
The EventHandler to which the EventHandler like methods of this TweakBarHandler delegate their work.
Maybe NULL.
const char* proland::TweakBarHandler::name [private] |
The name of this TweakBarHandler.
bool proland::TweakBarHandler::needUpdate [private] |
True if the tweakbar must be updated.