Panda3D

Loading...
Searching...
No Matches
modifierButtons.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file modifierButtons.h
10 * @author drose
11 * @date 2000-03-01
12 */
13
14#ifndef MODIFIERBUTTONS_H
15#define MODIFIERBUTTONS_H
16
17#include "pandabase.h"
18
19#include "buttonHandle.h"
20#include "pointerToArray.h"
21
22/**
23 * This class monitors the state of a number of individual buttons and tracks
24 * whether each button is known to be down or up.
25 */
26 class EXPCL_PANDA_PUTIL ModifierButtons {
27PUBLISHED:
28 ModifierButtons();
29 ModifierButtons(const ModifierButtons &copy);
30 ~ModifierButtons();
31 INLINE void operator = (const ModifierButtons &copy);
32
33 INLINE bool operator == (const ModifierButtons &other) const;
34 INLINE bool operator != (const ModifierButtons &other) const;
35 INLINE bool operator < (const ModifierButtons &other) const;
36
37 INLINE ModifierButtons operator & (const ModifierButtons &other) const;
38 INLINE ModifierButtons operator | (const ModifierButtons &other) const;
39
40 void operator &= (const ModifierButtons &other);
41 void operator |= (const ModifierButtons &other);
42
43 void set_button_list(const ModifierButtons &other);
44
45 bool matches(const ModifierButtons &other) const;
46
47 bool add_button(ButtonHandle button);
48 bool has_button(ButtonHandle button) const;
49 bool remove_button(ButtonHandle button);
50
51 INLINE int get_num_buttons() const;
52 INLINE ButtonHandle get_button(int index) const;
53 MAKE_SEQ(get_buttons, get_num_buttons, get_button);
54 MAKE_SEQ_PROPERTY(buttons, get_num_buttons, get_button);
55
56 bool button_down(ButtonHandle button);
57 bool button_up(ButtonHandle button);
58 INLINE void all_buttons_up();
59
60 bool is_down(ButtonHandle button) const;
61 INLINE bool is_down(int index) const;
62 INLINE bool is_any_down() const;
63
64 std::string get_prefix() const;
65
66 void output(std::ostream &out) const;
67 void write(std::ostream &out) const;
68
69 private:
70 void modify_button_list();
71
72 PTA(ButtonHandle) _button_list;
73 typedef unsigned long BitmaskType;
74 BitmaskType _state;
75};
76
77INLINE std::ostream &operator << (std::ostream &out, const ModifierButtons &mb) {
78 mb.output(out);
79 return out;
80}
81
82#include "modifierButtons.I"
83
84#endif
buttonHandle.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ButtonHandle
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition buttonHandle.h:26
ModifierButtons
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
Definition modifierButtons.h:26
ModifierButtons::matches
bool matches(const ModifierButtons &other) const
Returns true if the set of buttons indicated as down by this ModifierButtons object is the same set o...
Definition modifierButtons.cxx:134
ModifierButtons::add_button
bool add_button(ButtonHandle button)
Adds the indicated button to the set of buttons that will be monitored for upness and downness.
Definition modifierButtons.cxx:180
ModifierButtons::get_num_buttons
get_num_buttons
Returns the number of buttons that the ModifierButtons object is monitoring (e.g.
Definition modifierButtons.h:53
ModifierButtons::get_button
get_button
Returns the nth button that the ModifierButtons object is monitoring (the nth button passed to add_bu...
Definition modifierButtons.h:53
ModifierButtons::is_down
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 i...
Definition modifierButtons.cxx:291
ModifierButtons::remove_button
bool remove_button(ButtonHandle button)
Removes the indicated button from the set of buttons being monitored.
Definition modifierButtons.cxx:226
ModifierButtons::button_up
bool button_up(ButtonHandle button)
Records that a particular button has been released.
Definition modifierButtons.cxx:275
ModifierButtons::is_any_down
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.
Definition modifierButtons.I:124
ModifierButtons::set_button_list
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.
Definition modifierButtons.cxx:107
ModifierButtons::write
void write(std::ostream &out) const
Writes a multi-line summary including all of the buttons being monitored and which ones are known to ...
Definition modifierButtons.cxx:337
ModifierButtons::get_prefix
std::string get_prefix() const
Returns a string which can be used to prefix any button name or event name with the unique set of mod...
Definition modifierButtons.cxx:306
ModifierButtons::has_button
bool has_button(ButtonHandle button) const
Returns true if the indicated button is in the set of buttons being monitored, false otherwise.
Definition modifierButtons.cxx:206
ModifierButtons::button_down
bool button_down(ButtonHandle button)
Records that a particular button has been pressed.
Definition modifierButtons.cxx:257
ModifierButtons::all_buttons_up
void all_buttons_up()
Marks all monitored buttons as being in the "up" state.
Definition modifierButtons.I:105
ModifierButtons::output
void output(std::ostream &out) const
Writes a one-line summary of the buttons known to be down.
Definition modifierButtons.cxx:322
modifierButtons.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerToArray.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.