33 _button_list(copy._button_list),
51 if (_button_list == other._button_list) {
54 _state &= other._state;
62 for (
int i = 0; i < num_buttons; i++) {
64 _state &= ~((BitmaskType)1 << i);
77 if (_button_list == other._button_list) {
80 _state |= other._state;
88 for (
int i = 0; i < num_buttons; i++) {
108 if (_button_list != other._button_list) {
112 BitmaskType new_state = 0;
114 for (
int i = 0; i < num_buttons; i++) {
116 new_state |= ((BitmaskType)1 << i);
123 _button_list = other._button_list;
135 if (_button_list == other._button_list) {
138 return (_state == other._state);
150 for (i = 0; i < (int)_button_list.size(); i++) {
152 if (!other.
is_down(_button_list[i])) {
163 int num_other_down = 0;
164 for (i = 0; i < num_other_buttons; i++) {
170 return (num_down == num_other_down);
181 nassertr(button != ButtonHandle::none(),
false);
183 static const int max_buttons =
sizeof(BitmaskType) * 8;
185 if ((
int)_button_list.size() >= max_buttons) {
195 modify_button_list();
196 _button_list.push_back(button);
208 for (bi = _button_list.begin(); bi != _button_list.end(); ++bi) {
231 for (
int i = 0; i < (int)_button_list.size(); i++) {
232 if (button == _button_list[i]) {
233 modify_button_list();
234 _button_list.erase(_button_list.begin() + i);
238 BitmaskType mask = ((BitmaskType)1 << i);
239 BitmaskType below = mask - 1;
240 BitmaskType above = (~below) & (~mask);
242 _state = ((_state & above) >> 1) | (_state & below);
258 for (
int i = 0; i < (int)_button_list.size(); i++) {
259 if (button.
matches(_button_list[i])) {
260 _state |= ((BitmaskType)1 << i);
276 for (
int i = 0; i < (int)_button_list.size(); i++) {
277 if (button.
matches(_button_list[i])) {
278 _state &= ~((BitmaskType)1 << i);
292 for (
int i = 0; i < (int)_button_list.size(); i++) {
293 if (button.
matches(_button_list[i])) {
294 return ((_state & ((BitmaskType)1 << i)) != 0);
308 for (
int i = 0; i < (int)_button_list.size(); i++) {
309 if ((_state & ((BitmaskType)1 << i)) != 0) {
310 prefix += _button_list[i].get_name();
324 for (
int i = 0; i < (int)_button_list.size(); i++) {
325 if ((_state & ((BitmaskType)1 << i)) != 0) {
326 out <<
" " << _button_list[i];
338 out <<
"ModifierButtons:\n";
339 for (
int i = 0; i < (int)_button_list.size(); i++) {
340 out <<
" " << _button_list[i];
341 if ((_state & ((BitmaskType)1 << i)) != 0) {
356 void ModifierButtons::
357 modify_button_list() {
358 if (_button_list.get_ref_count() > 1) {
365 _button_list.v() = old_list.v();
369 nassertv(_button_list.get_ref_count() == 1);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.