#include <modifierButtons.h>
Public Member Functions | |
ModifierButtons () | |
ModifierButtons (const ModifierButtons ©) | |
~ModifierButtons () | |
void | operator= (const ModifierButtons ©) |
bool | operator== (const ModifierButtons &other) const |
The equality operator is an exact comparision: the two ModifierButtons are equal if they share the same button list--indeed, the same pointer--and they all the buttons have the same state. | |
bool | operator!= (const ModifierButtons &other) const |
bool | operator< (const ModifierButtons &other) const |
bool | matches (const ModifierButtons &other) const |
Returns true if the set of buttons indicated as down by this ModifierButtons object is the same set of buttons indicated as down by the other ModifierButtons object. | |
bool | add_button (ButtonHandle button) |
Adds the indicated button to the set of buttons that will be monitored for upness and downness. | |
bool | has_button (ButtonHandle button) const |
Returns true if the indicated button is in the set of buttons being monitored, false otherwise. | |
bool | remove_button (ButtonHandle button) |
Removes the indicated button from the set of buttons being monitored. | |
int | get_num_buttons () const |
Returns the number of buttons that the ModifierButtons object is monitoring (e.g. | |
ButtonHandle | get_button (int index) const |
Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_button()). | |
bool | button_down (ButtonHandle button) |
Records that a particular button has been pressed. | |
bool | button_up (ButtonHandle button) |
Records that a particular button has been released. | |
bool | add_event (const ButtonEvent &event) |
Calls button_down() or button_up(), as appropriate, according to the indicated ButtonEvent. | |
void | all_buttons_up () |
Marks all monitored buttons as being in the "up" state. | |
bool | is_down (ButtonHandle button) const |
Returns true if the indicated button is known to be down, or false if it is known to be up or if it is not in the set of buttons being tracked. | |
bool | is_down (int index) const |
Returns true if the indicated button is known to be down, or false if it is known to be up. | |
bool | is_any_down () const |
Returns true if any of the tracked button are known to be down, or false if all of them are up. | |
string | get_prefix () const |
Returns a string which can be used to prefix any button name or event name with the unique set of modifier buttons currently being held. | |
void | output (ostream &out) const |
Writes a one-line summary of the buttons known to be down. | |
void | write (ostream &out) const |
Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down. | |
Private Types | |
typedef unsigned long | BitmaskType |
Private Member Functions | |
void | modify_button_list () |
Implements a poor-man's copy-on-write for the ModifierButtons class. | |
Private Attributes | |
PointerToArray< ButtonHandle > | _button_list |
BitmaskType | _state |
Definition at line 42 of file modifierButtons.h.
|
Definition at line 80 of file modifierButtons.h. Referenced by has_button(). |
|
Definition at line 34 of file modifierButtons.cxx. |
|
Definition at line 48 of file modifierButtons.cxx. |
|
Definition at line 62 of file modifierButtons.cxx. References _button_list, and _state. |
|
Adds the indicated button to the set of buttons that will be monitored for upness and downness. Returns true if the button was added, false if it was already being monitored or if too many buttons are currently being monitored. Definition at line 139 of file modifierButtons.cxx. References _button_list, PointerToArray< ButtonHandle >::begin(), PointerToArray< ButtonHandle >::end(), and PTA. |
|
Calls button_down() or button_up(), as appropriate, according to the indicated ButtonEvent.
Definition at line 133 of file modifierButtons.I. References _button_list, _state, nassertr, and PointerToArray< ButtonHandle >::size(). |
|
Marks all monitored buttons as being in the "up" state.
Definition at line 157 of file modifierButtons.I. Referenced by DriveInterface::~DriveInterface(). |
|
Records that a particular button has been pressed. If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise. Definition at line 240 of file modifierButtons.cxx. References _button_list, _state, and PointerToArray< ButtonHandle >::size(). Referenced by get_num_buttons(), and ButtonThrower::has_throw_button(). |
|
Records that a particular button has been released. If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise. Definition at line 270 of file modifierButtons.cxx. References _button_list, _state, and PointerToArray< ButtonHandle >::size(). Referenced by get_num_buttons(). |
|
Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_button()). This must be in the range 0 <= index < get_num_buttons(). Definition at line 117 of file modifierButtons.I. |
|
Returns the number of buttons that the ModifierButtons object is monitoring (e.g. the number of buttons passed to add_button()). Definition at line 98 of file modifierButtons.I. References ButtonEvent::_button, ButtonEvent::_type, button_down(), button_up(), INLINE, ButtonEvent::T_down, and ButtonEvent::T_up. |
|
Returns a string which can be used to prefix any button name or event name with the unique set of modifier buttons currently being held.
Definition at line 317 of file modifierButtons.cxx. References _button_list, PointerToArray< ButtonHandle >::get_ref_count(), nassertv, and PTA. Referenced by ButtonThrower::has_throw_button(). |
|
Returns true if the indicated button is in the set of buttons being monitored, false otherwise.
Definition at line 171 of file modifierButtons.cxx. References _state, and BitmaskType. |
|
Returns true if any of the tracked button are known to be down, or false if all of them are up.
Definition at line 188 of file modifierButtons.I. |
|
Returns true if the indicated button is known to be down, or false if it is known to be up.
Definition at line 172 of file modifierButtons.I. |
|
Returns true if the indicated button is known to be down, or false if it is known to be up or if it is not in the set of buttons being tracked.
Definition at line 294 of file modifierButtons.cxx. References _button_list, _state, and PointerToArray< ButtonHandle >::size(). Referenced by Trackball::apply(). |
|
Returns true if the set of buttons indicated as down by this ModifierButtons object is the same set of buttons indicated as down by the other ModifierButtons object. The buttons indicated as up are not relevant. Definition at line 82 of file modifierButtons.cxx. References _button_list. |
|
Implements a poor-man's copy-on-write for the ModifierButtons class. If any reference counts are held on our _button_list, besides ourselves, then allocates and copies a brand new copy of the _button_list. This should be done in preparation for any modifications to the _button_list, since multiple instances of the ModifierButtons object may share the same _button_list pointer. Definition at line 397 of file modifierButtons.cxx. |
|
Definition at line 66 of file modifierButtons.I. References _state. |
|
Definition at line 78 of file modifierButtons.I. References _button_list. |
|
Definition at line 31 of file modifierButtons.I. References _button_list, _state, and INLINE. |
|
The equality operator is an exact comparision: the two ModifierButtons are equal if they share the same button list--indeed, the same pointer--and they all the buttons have the same state. Use matches() if a less exact equality test is needed. Definition at line 53 of file modifierButtons.I. |
|
Writes a one-line summary of the buttons known to be down.
Definition at line 340 of file modifierButtons.cxx. |
|
Removes the indicated button from the set of buttons being monitored. Returns true if the button was removed, false if it was not being monitored in the first place. Definition at line 197 of file modifierButtons.cxx. References _button_list, _state, and PointerToArray< ButtonHandle >::size(). |
|
Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down.
Definition at line 363 of file modifierButtons.cxx. |
|
Definition at line 79 of file modifierButtons.h. Referenced by add_button(), add_event(), button_down(), button_up(), get_prefix(), is_down(), matches(), operator<(), operator=(), remove_button(), and ~ModifierButtons(). |
|
Definition at line 81 of file modifierButtons.h. Referenced by add_event(), button_down(), button_up(), get_button(), has_button(), is_down(), operator!=(), operator=(), remove_button(), and ~ModifierButtons(). |