Panda3D
|
This class monitors the state of a number of individual buttons and tracks whether each button is known to be down or up. More...
#include "modifierButtons.h"
Public Member Functions | |
ModifierButtons (const ModifierButtons ©) | |
bool | add_button (ButtonHandle button) |
Adds the indicated button to the set of buttons that will be monitored for upness and downness. More... | |
void | all_buttons_up () |
Marks all monitored buttons as being in the "up" state. More... | |
bool | button_down (ButtonHandle button) |
Records that a particular button has been pressed. More... | |
bool | button_up (ButtonHandle button) |
Records that a particular button has been released. More... | |
ButtonHandle | get_button (int index) const |
Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_button()). More... | |
int | get_num_buttons () const |
Returns the number of buttons that the ModifierButtons object is monitoring (e.g. More... | |
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. More... | |
bool | has_button (ButtonHandle button) const |
Returns true if the indicated button is in the set of buttons being monitored, false otherwise. More... | |
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. More... | |
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. More... | |
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. More... | |
MAKE_SEQ (get_buttons, get_num_buttons, get_button) | |
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. More... | |
bool | operator!= (const ModifierButtons &other) const |
ModifierButtons | operator& (const ModifierButtons &other) const |
void | operator&= (const ModifierButtons &other) |
bool | operator< (const ModifierButtons &other) const |
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. More... | |
ModifierButtons | operator| (const ModifierButtons &other) const |
Returns a new ModifierButtons object for which is_down() will be true if it is true on either of the source objects. More... | |
void | operator|= (const ModifierButtons &other) |
Sets is_down() true for any button that is already true for this object and the other object. More... | |
void | output (ostream &out) const |
Writes a one-line summary of the buttons known to be down. More... | |
bool | remove_button (ButtonHandle button) |
Removes the indicated button from the set of buttons being monitored. More... | |
void | set_button_list (const ModifierButtons &other) |
Sets the list of buttons to watch to be the same as that of the other ModifierButtons object. More... | |
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. More... | |
This class monitors the state of a number of individual buttons and tracks whether each button is known to be down or up.
Definition at line 29 of file modifierButtons.h.
bool ModifierButtons::add_button | ( | ButtonHandle | button | ) |
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 203 of file modifierButtons.cxx.
References has_button(), and ButtonHandle::none().
Referenced by WindowFramework::enable_keyboard(), and matches().
|
inline |
Marks all monitored buttons as being in the "up" state.
Definition at line 131 of file modifierButtons.I.
References is_down().
Referenced by get_button().
bool ModifierButtons::button_down | ( | ButtonHandle | button | ) |
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 290 of file modifierButtons.cxx.
References button_up(), and ButtonHandle::matches().
Referenced by remove_button(), and ButtonEvent::update_mods().
bool ModifierButtons::button_up | ( | ButtonHandle | 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 312 of file modifierButtons.cxx.
References is_down(), and ButtonHandle::matches().
Referenced by button_down(), and ButtonEvent::update_mods().
|
inline |
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 119 of file modifierButtons.I.
References all_buttons_up(), and ButtonHandle::none().
Referenced by get_num_buttons(), operator|=(), and set_button_list().
|
inline |
Returns the number of buttons that the ModifierButtons object is monitoring (e.g.
the number of buttons passed to add_button()).
Definition at line 106 of file modifierButtons.I.
References get_button().
Referenced by matches(), operator|(), operator|=(), and set_button_list().
string ModifierButtons::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.
Definition at line 349 of file modifierButtons.cxx.
References output().
Referenced by is_down().
bool ModifierButtons::has_button | ( | ButtonHandle | button | ) | const |
Returns true if the indicated button is in the set of buttons being monitored, false otherwise.
Definition at line 231 of file modifierButtons.cxx.
References ButtonHandle::matches(), and remove_button().
Referenced by add_button().
|
inline |
Returns true if any of the tracked button are known to be down, or false if all of them are up.
Definition at line 154 of file modifierButtons.I.
Referenced by is_down().
bool ModifierButtons::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.
Definition at line 331 of file modifierButtons.cxx.
References get_prefix(), and ButtonHandle::matches().
Referenced by all_buttons_up(), button_up(), matches(), and operator|=().
|
inline |
Returns true if the indicated button is known to be down, or false if it is known to be up.
Definition at line 142 of file modifierButtons.I.
References is_any_down().
bool ModifierButtons::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.
The buttons indicated as up are not relevant.
Definition at line 153 of file modifierButtons.cxx.
References add_button(), get_num_buttons(), and is_down().
Referenced by ButtonThrower::add_throw_button(), ButtonThrower::has_throw_button(), ButtonThrower::remove_throw_button(), and set_button_list().
|
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 37 of file modifierButtons.I.
References operator|().
|
inline |
Returns a new ModifierButtons object for which is_down() will be true if it is true on either of the source objects.
The set of buttons reported by has_button() is not completely defined if both source objects have a different set.
Definition at line 92 of file modifierButtons.I.
References get_num_buttons().
Referenced by operator==().
void ModifierButtons::operator|= | ( | const ModifierButtons & | other | ) |
Sets is_down() true for any button that is already true for this object and the other object.
Adds whatever buttons are necessary to the list to make this so
Definition at line 88 of file modifierButtons.cxx.
References get_button(), get_num_buttons(), is_down(), and set_button_list().
void ModifierButtons::output | ( | ostream & | out | ) | const |
Writes a one-line summary of the buttons known to be down.
Definition at line 368 of file modifierButtons.cxx.
References write().
Referenced by get_prefix().
bool ModifierButtons::remove_button | ( | ButtonHandle | button | ) |
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.
Unlike the other methods, you cannot remove a button by removing its alias; you have to remove exactly the button itself.
Definition at line 255 of file modifierButtons.cxx.
References button_down().
Referenced by has_button().
void ModifierButtons::set_button_list | ( | const ModifierButtons & | other | ) |
Sets the list of buttons to watch to be the same as that of the other ModifierButtons object.
This makes the lists pointer equivalent (until one or the other is later modified).
This will preserve the state of any button that was on the original list and is also on the new lists. Any other buttons will get reset to the default state of "up".
Definition at line 123 of file modifierButtons.cxx.
References get_button(), get_num_buttons(), and matches().
Referenced by operator|=().
void ModifierButtons::write | ( | ostream & | out | ) | const |
Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down.
Definition at line 386 of file modifierButtons.cxx.
Referenced by output().