Panda3D
 All Classes Functions Variables Enumerations
mouseWatcher.I
1 // Filename: mouseWatcher.I
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: MouseWatcher::has_mouse
18 // Access: Published
19 // Description: Returns true if the mouse is anywhere within the
20 // window, false otherwise. Also see is_mouse_open().
21 ////////////////////////////////////////////////////////////////////
22 INLINE bool MouseWatcher::
23 has_mouse() const {
24  return _has_mouse;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: MouseWatcher::is_mouse_open
29 // Access: Published
30 // Description: Returns true if the mouse is within the window and
31 // not over some particular MouseWatcherRegion that is
32 // marked to suppress mouse events; that is, that the
33 // mouse is in open space within the window.
34 ////////////////////////////////////////////////////////////////////
35 INLINE bool MouseWatcher::
36 is_mouse_open() const {
37  return _has_mouse && (_internal_suppress & MouseWatcherRegion::SF_mouse_position) == 0;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: MouseWatcher::get_mouse
42 // Access: Published
43 // Description: It is only valid to call this if has_mouse() returns
44 // true. If so, this returns the current position of
45 // the mouse within the window.
46 ////////////////////////////////////////////////////////////////////
47 INLINE const LPoint2 &MouseWatcher::
48 get_mouse() const {
49 #ifndef NDEBUG
50  static LPoint2 bogus_mouse(0.0f, 0.0f);
51  nassertr(_has_mouse, bogus_mouse);
52 #endif
53  return _mouse;
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: MouseWatcher::get_mouse_x
58 // Access: Published
59 // Description: It is only valid to call this if has_mouse() returns
60 // true. If so, this returns the current X position of
61 // the mouse within the window.
62 ////////////////////////////////////////////////////////////////////
63 INLINE PN_stdfloat MouseWatcher::
64 get_mouse_x() const {
65  nassertr(_has_mouse, 0.0f);
66  return _mouse[0];
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: MouseWatcher::get_mouse_y
71 // Access: Published
72 // Description: It is only valid to call this if has_mouse() returns
73 // true. If so, this returns the current Y position of
74 // the mouse within the window.
75 ////////////////////////////////////////////////////////////////////
76 INLINE PN_stdfloat MouseWatcher::
77 get_mouse_y() const {
78  nassertr(_has_mouse, 0.0f);
79  return _mouse[1];
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: MouseWatcher::set_frame
84 // Access: Published
85 // Description: Sets the frame of the MouseWatcher. See the next
86 // flavor of this method for a more verbose explanation.
87 ////////////////////////////////////////////////////////////////////
88 INLINE void MouseWatcher::
89 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
90  set_frame(LVecBase4(left, right, bottom, top));
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: MouseWatcher::set_frame
95 // Access: Published
96 // Description: Sets the frame of the MouseWatcher. This determines
97 // the coordinate space in which the MouseWatcherRegions
98 // should be expected to live. Normally, this is left
99 // at -1, 1, -1, 1, which is the default setting, and
100 // matches the mouse coordinate range.
101 //
102 // Whatever values you specify here indicate the shape
103 // of the full screen, and the MouseWatcherRegions will
104 // be given in coordinate space matching it. For
105 // instance, if you specify (0, 1, 0, 1), then a
106 // MouseWatcherRegion with the frame (0, 1, 0, .5) will
107 // cover the lower half of the screen.
108 ////////////////////////////////////////////////////////////////////
109 INLINE void MouseWatcher::
110 set_frame(const LVecBase4 &frame) {
111  _frame = frame;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: MouseWatcher::get_frame
116 // Access: Published
117 // Description: Returns the frame of the MouseWatcher. See
118 // set_frame().
119 ////////////////////////////////////////////////////////////////////
120 INLINE const LVecBase4 &MouseWatcher::
121 get_frame() const {
122  return _frame;
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: MouseWatcher::is_over_region
127 // Access: Published
128 // Description: Returns true if the mouse is over any rectangular
129 // region, false otherwise.
130 ////////////////////////////////////////////////////////////////////
131 INLINE bool MouseWatcher::
132 is_over_region() const {
133  return get_over_region() != (MouseWatcherRegion *)NULL;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: MouseWatcher::is_over_region
138 // Access: Published
139 // Description: Returns true if the mouse is over any rectangular
140 // region, false otherwise.
141 ////////////////////////////////////////////////////////////////////
142 INLINE bool MouseWatcher::
143 is_over_region(PN_stdfloat x, PN_stdfloat y) const {
144  return get_over_region(x, y) != (MouseWatcherRegion *)NULL;
145 }
146 
147 ////////////////////////////////////////////////////////////////////
148 // Function: MouseWatcher::is_over_region
149 // Access: Published
150 // Description: Returns true if the mouse is over any rectangular
151 // region, false otherwise.
152 ////////////////////////////////////////////////////////////////////
153 INLINE bool MouseWatcher::
154 is_over_region(const LPoint2 &pos) const {
155  return get_over_region(pos) != (MouseWatcherRegion *)NULL;
156 }
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: MouseWatcher::get_over_region
160 // Access: Published
161 // Description: Returns the smallest region the mouse is currently
162 // over, or NULL if it is over no region.
163 ////////////////////////////////////////////////////////////////////
166  return _preferred_region;
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: MouseWatcher::get_over_region
171 // Access: Published
172 // Description: Returns the smallest region the indicated point is
173 // over, or NULL if it is over no region.
174 ////////////////////////////////////////////////////////////////////
176 get_over_region(PN_stdfloat x, PN_stdfloat y) const {
177  return get_over_region(LPoint2(x, y));
178 }
179 
180 ////////////////////////////////////////////////////////////////////
181 // Function: MouseWatcher::is_button_down
182 // Access: Published
183 // Description: Returns true if the indicated button is currently
184 // being held down, false otherwise.
185 ////////////////////////////////////////////////////////////////////
186 INLINE bool MouseWatcher::
188  return _inactivity_state != IS_inactive && _current_buttons_down.get_bit(button.get_index());
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: MouseWatcher::set_button_down_pattern
193 // Access: Published
194 // Description: Sets the pattern string that indicates how the event
195 // names are generated when a button is depressed. This
196 // is a string that may contain any of the following:
197 //
198 // %r - the name of the region the mouse is over
199 // %b - the name of the button pressed.
200 //
201 // The event name will be based on the in_pattern
202 // string specified here, with all occurrences of the
203 // above strings replaced with the corresponding values.
204 ////////////////////////////////////////////////////////////////////
205 INLINE void MouseWatcher::
206 set_button_down_pattern(const string &pattern) {
207  _button_down_pattern = pattern;
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: MouseWatcher::get_button_down_pattern
212 // Access: Published
213 // Description: Returns the string that indicates how event names are
214 // generated when a button is depressed. See
215 // set_button_down_pattern().
216 ////////////////////////////////////////////////////////////////////
217 INLINE const string &MouseWatcher::
219  return _button_down_pattern;
220 }
221 
222 ////////////////////////////////////////////////////////////////////
223 // Function: MouseWatcher::set_button_up_pattern
224 // Access: Published
225 // Description: Sets the pattern string that indicates how the event
226 // names are generated when a button is released. See
227 // set_button_down_pattern().
228 ////////////////////////////////////////////////////////////////////
229 INLINE void MouseWatcher::
230 set_button_up_pattern(const string &pattern) {
231  _button_up_pattern = pattern;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: MouseWatcher::get_button_up_pattern
236 // Access: Published
237 // Description: Returns the string that indicates how event names are
238 // generated when a button is released. See
239 // set_button_down_pattern().
240 ////////////////////////////////////////////////////////////////////
241 INLINE const string &MouseWatcher::
243  return _button_up_pattern;
244 }
245 
246 ////////////////////////////////////////////////////////////////////
247 // Function: MouseWatcher::set_button_repeat_pattern
248 // Access: Published
249 // Description: Sets the pattern string that indicates how the event
250 // names are generated when a button is continuously
251 // held and generates keyrepeat "down" events. This is
252 // a string that may contain any of the following:
253 //
254 // %r - the name of the region the mouse is over
255 // %b - the name of the button pressed.
256 //
257 // The event name will be based on the in_pattern
258 // string specified here, with all occurrences of the
259 // above strings replaced with the corresponding values.
260 ////////////////////////////////////////////////////////////////////
261 INLINE void MouseWatcher::
262 set_button_repeat_pattern(const string &pattern) {
263  _button_repeat_pattern = pattern;
264 }
265 
266 ////////////////////////////////////////////////////////////////////
267 // Function: MouseWatcher::get_button_repeat_pattern
268 // Access: Published
269 // Description: Returns the string that indicates how event names are
270 // names are generated when a button is continuously
271 // held and generates keyrepeat "down" events. See
272 // set_button_repeat_pattern().
273 ////////////////////////////////////////////////////////////////////
274 INLINE const string &MouseWatcher::
276  return _button_repeat_pattern;
277 }
278 
279 ////////////////////////////////////////////////////////////////////
280 // Function: MouseWatcher::set_enter_pattern
281 // Access: Published
282 // Description: Sets the pattern string that indicates how the event
283 // names are generated when the mouse enters a region.
284 // This is different from within_pattern, in that a
285 // mouse is only "entered" in the topmost region at a
286 // given time, while it might be "within" multiple
287 // nested regions.
288 ////////////////////////////////////////////////////////////////////
289 INLINE void MouseWatcher::
290 set_enter_pattern(const string &pattern) {
291  _enter_pattern = pattern;
292 }
293 
294 ////////////////////////////////////////////////////////////////////
295 // Function: MouseWatcher::get_enter_pattern
296 // Access: Published
297 // Description: Returns the string that indicates how event names are
298 // generated when the mouse enters a region. This is
299 // different from within_pattern, in that a mouse is
300 // only "entered" in the topmost region at a given time,
301 // while it might be "within" multiple nested regions.
302 ////////////////////////////////////////////////////////////////////
303 INLINE const string &MouseWatcher::
305  return _enter_pattern;
306 }
307 
308 ////////////////////////////////////////////////////////////////////
309 // Function: MouseWatcher::set_leave_pattern
310 // Access: Published
311 // Description: Sets the pattern string that indicates how the event
312 // names are generated when the mouse leaves a region.
313 // This is different from without_pattern, in that a
314 // mouse is only "entered" in the topmost region at a
315 // given time, while it might be "within" multiple
316 // nested regions.
317 ////////////////////////////////////////////////////////////////////
318 INLINE void MouseWatcher::
319 set_leave_pattern(const string &pattern) {
320  _leave_pattern = pattern;
321 }
322 
323 ////////////////////////////////////////////////////////////////////
324 // Function: MouseWatcher::get_leave_pattern
325 // Access: Published
326 // Description: Returns the string that indicates how event names are
327 // generated when the mouse leaves a region. This is
328 // different from without_pattern, in that a mouse is
329 // only "entered" in the topmost region at a given time,
330 // while it might be "within" multiple nested regions.
331 ////////////////////////////////////////////////////////////////////
332 INLINE const string &MouseWatcher::
334  return _leave_pattern;
335 }
336 
337 ////////////////////////////////////////////////////////////////////
338 // Function: MouseWatcher::set_within_pattern
339 // Access: Published
340 // Description: Sets the pattern string that indicates how the event
341 // names are generated when the mouse wanders over a
342 // region. This is different from enter_pattern, in
343 // that a mouse is only "entered" in the topmost region
344 // at a given time, while it might be "within" multiple
345 // nested regions.
346 ////////////////////////////////////////////////////////////////////
347 INLINE void MouseWatcher::
348 set_within_pattern(const string &pattern) {
349  _within_pattern = pattern;
350 }
351 
352 ////////////////////////////////////////////////////////////////////
353 // Function: MouseWatcher::get_within_pattern
354 // Access: Published
355 // Description: Returns the string that indicates how event names are
356 // generated when the mouse wanders over a region. This
357 // is different from enter_pattern, in that a mouse is
358 // only "entered" in the topmost region at a given time,
359 // while it might be "within" multiple nested regions.
360 ////////////////////////////////////////////////////////////////////
361 INLINE const string &MouseWatcher::
363  return _within_pattern;
364 }
365 
366 ////////////////////////////////////////////////////////////////////
367 // Function: MouseWatcher::set_without_pattern
368 // Access: Published
369 // Description: Sets the pattern string that indicates how the event
370 // names are generated when the mouse wanders out of a
371 // region. This is different from leave_pattern, in
372 // that a mouse is only "entered" in the topmost region
373 // at a given time, while it might be "within" multiple
374 // nested regions.
375 ////////////////////////////////////////////////////////////////////
376 INLINE void MouseWatcher::
377 set_without_pattern(const string &pattern) {
378  _without_pattern = pattern;
379 }
380 
381 ////////////////////////////////////////////////////////////////////
382 // Function: MouseWatcher::get_without_pattern
383 // Access: Published
384 // Description: Returns the string that indicates how event names are
385 // generated when the mouse wanders out of a region.
386 // This is different from leave_pattern, in that a mouse
387 // is only "entered" in the topmost region at a given
388 // time, while it might be "within" multiple nested
389 // regions.
390 ////////////////////////////////////////////////////////////////////
391 INLINE const string &MouseWatcher::
393  return _without_pattern;
394 }
395 
396 ////////////////////////////////////////////////////////////////////
397 // Function: MouseWatcher::set_geometry
398 // Access: Published
399 // Description: Sets the node that will be transformed each frame by
400 // the mouse's coordinates. It will also be hidden when
401 // the mouse goes outside the window. This can be used
402 // to implement a software mouse pointer for when a
403 // hardware (or system) mouse pointer is unavailable.
404 ////////////////////////////////////////////////////////////////////
405 INLINE void MouseWatcher::
407  _geometry = node;
408 }
409 
410 ////////////////////////////////////////////////////////////////////
411 // Function: MouseWatcher::has_geometry
412 // Access: Published
413 // Description: Returns true if a software mouse pointer has been
414 // setup via set_geometry(), or false otherwise. See
415 // set_geometry().
416 ////////////////////////////////////////////////////////////////////
417 INLINE bool MouseWatcher::
418 has_geometry() const {
419  return !_geometry.is_null();
420 }
421 
422 ////////////////////////////////////////////////////////////////////
423 // Function: MouseWatcher::get_geometry
424 // Access: Published
425 // Description: Returns the node that has been set as the software
426 // mouse pointer, or NULL if no node has been set. See
427 // has_geometry() and set_geometry().
428 ////////////////////////////////////////////////////////////////////
430 get_geometry() const {
431  return _geometry;
432 }
433 
434 ////////////////////////////////////////////////////////////////////
435 // Function: MouseWatcher::clear_geometry
436 // Access: Published
437 // Description: Stops the use of the software cursor set up via
438 // set_geometry().
439 ////////////////////////////////////////////////////////////////////
440 INLINE void MouseWatcher::
442  _geometry.clear();
443 }
444 
445 ////////////////////////////////////////////////////////////////////
446 // Function: MouseWatcher::set_extra_handler
447 // Access: Published
448 // Description: As an optimization for the C++ Gui, an extra handler
449 // can be registered with a mouseWatcher so that events
450 // can be dealt with much sooner.
451 ////////////////////////////////////////////////////////////////////
452 INLINE void MouseWatcher::
454  _eh = eh;
455 }
456 
457 ////////////////////////////////////////////////////////////////////
458 // Function: MouseWatcher::get_extra_handler
459 // Access: Published
460 // Description: As an optimization for the C++ Gui, an extra handler
461 // can be registered with a mouseWatcher so that events
462 // can be dealt with much sooner.
463 ////////////////////////////////////////////////////////////////////
466  return _eh;
467 }
468 
469 ////////////////////////////////////////////////////////////////////
470 // Function: MouseWatcher::set_modifier_buttons
471 // Access: Public
472 // Description: Sets the buttons that should be monitored as modifier
473 // buttons for generating events to the
474 // MouseWatcherRegions.
475 ////////////////////////////////////////////////////////////////////
476 INLINE void MouseWatcher::
478  _mods = mods;
479 }
480 
481 ////////////////////////////////////////////////////////////////////
482 // Function: MouseWatcher::get_modifier_buttons
483 // Access: Published
484 // Description: Returns the set of buttons that are being monitored
485 // as modifier buttons, as well as their current state.
486 ////////////////////////////////////////////////////////////////////
489  return _mods;
490 }
491 
492 ////////////////////////////////////////////////////////////////////
493 // Function: MouseWatcher::set_display_region
494 // Access: Published
495 // Description: Constrains the MouseWatcher to watching the mouse
496 // within a particular indicated region of the screen.
497 // DataNodes parented under the MouseWatcher will
498 // observe the mouse and keyboard events only when the
499 // mouse is within the indicated region, and the
500 // observed range will be from -1 .. 1 across the
501 // region.
502 //
503 // Do not delete the DisplayRegion while it is owned by
504 // the MouseWatcher.
505 ////////////////////////////////////////////////////////////////////
506 INLINE void MouseWatcher::
508  _display_region = dr;
509  _button_down_display_region = NULL;
510 }
511 
512 ////////////////////////////////////////////////////////////////////
513 // Function: MouseWatcher::clear_display_region
514 // Access: Published
515 // Description: Removes the display region constraint from the
516 // MouseWatcher, and restores it to the default behavior
517 // of watching the whole window.
518 ////////////////////////////////////////////////////////////////////
519 INLINE void MouseWatcher::
521  _display_region = NULL;
522  _button_down_display_region = NULL;
523 }
524 
525 ////////////////////////////////////////////////////////////////////
526 // Function: MouseWatcher::get_display_region
527 // Access: Published
528 // Description: Returns the display region the MouseWatcher is
529 // constrained to by set_display_region(), or NULL if it
530 // is not constrained.
531 ////////////////////////////////////////////////////////////////////
534  return _display_region;
535 }
536 
537 ////////////////////////////////////////////////////////////////////
538 // Function: MouseWatcher::has_display_region
539 // Access: Published
540 // Description: Returns true if the MouseWatcher has been constrained
541 // to a particular region of the screen via
542 // set_display_region(), or false otherwise. If this
543 // returns true, get_display_region() may be used to
544 // return the particular region.
545 ////////////////////////////////////////////////////////////////////
546 INLINE bool MouseWatcher::
548  return (_display_region != (DisplayRegion *)NULL);
549 }
550 
551 ////////////////////////////////////////////////////////////////////
552 // Function: MouseWatcher::set_inactivity_timeout
553 // Access: Published
554 // Description: Sets an inactivity timeout on the mouse activity.
555 // When this timeout (in seconds) is exceeded with no
556 // keyboard or mouse activity, all currently-held
557 // buttons are automatically released. This is intended
558 // to help protect against people who inadvertently (or
559 // intentionally) leave a keyboard key stuck down and
560 // then wander away from the keyboard.
561 //
562 // Also, when this timeout expires, the event specified
563 // by set_inactivity_timeout_event() will be generated.
564 ////////////////////////////////////////////////////////////////////
565 INLINE void MouseWatcher::
566 set_inactivity_timeout(double timeout) {
567  _has_inactivity_timeout = true;
568  _inactivity_timeout = timeout;
569  note_activity();
570 }
571 
572 ////////////////////////////////////////////////////////////////////
573 // Function: MouseWatcher::has_inactivity_timeout
574 // Access: Published
575 // Description: Returns true if an inactivity timeout has been set,
576 // false otherwise.
577 ////////////////////////////////////////////////////////////////////
578 INLINE bool MouseWatcher::
580  return _has_inactivity_timeout;
581 }
582 
583 ////////////////////////////////////////////////////////////////////
584 // Function: MouseWatcher::get_inactivity_timeout
585 // Access: Published
586 // Description: Returns the inactivity timeout that has been set.
587 // It is an error to call this if
588 // has_inactivity_timeout() returns false.
589 ////////////////////////////////////////////////////////////////////
590 INLINE double MouseWatcher::
592  nassertr(_has_inactivity_timeout, 0.0);
593  return _inactivity_timeout;
594 }
595 
596 ////////////////////////////////////////////////////////////////////
597 // Function: MouseWatcher::clear_inactivity_timeout
598 // Access: Published
599 // Description: Removes the inactivity timeout and restores the
600 // MouseWatcher to its default behavior of allowing a
601 // key to be held indefinitely.
602 ////////////////////////////////////////////////////////////////////
603 INLINE void MouseWatcher::
605  _has_inactivity_timeout = false;
606  _inactivity_timeout = 0.0;
607  note_activity();
608 }
609 
610 ////////////////////////////////////////////////////////////////////
611 // Function: MouseWatcher::set_inactivity_timeout_event
612 // Access: Published
613 // Description: Specifies the event string that will be generated
614 // when the inactivity timeout counter expires. See
615 // set_inactivity_timeout().
616 ////////////////////////////////////////////////////////////////////
617 INLINE void MouseWatcher::
618 set_inactivity_timeout_event(const string &event) {
619  _inactivity_timeout_event = event;
620 }
621 
622 ////////////////////////////////////////////////////////////////////
623 // Function: MouseWatcher::get_inactivity_timeout_event
624 // Access: Published
625 // Description: Returns the event string that will be generated
626 // when the inactivity timeout counter expires. See
627 // set_inactivity_timeout().
628 ////////////////////////////////////////////////////////////////////
629 INLINE const string &MouseWatcher::
631  return _inactivity_timeout_event;
632 }
633 
634 ////////////////////////////////////////////////////////////////////
635 // Function: MouseWatcher::within_region
636 // Access: Protected
637 // Description: Called internally to indicate the mouse pointer has
638 // moved within the indicated region's boundaries.
639 ////////////////////////////////////////////////////////////////////
640 INLINE void MouseWatcher::
641 within_region(MouseWatcherRegion *region, const MouseWatcherParameter &param) {
642  region->within_region(param);
643  throw_event_pattern(_within_pattern, region, ButtonHandle::none());
644  if (_enter_multiple) {
645  enter_region(region, param);
646  }
647 }
648 
649 ////////////////////////////////////////////////////////////////////
650 // Function: MouseWatcher::without_region
651 // Access: Protected
652 // Description: Called internally to indicate the mouse pointer has
653 // moved outside of the indicated region's boundaries.
654 ////////////////////////////////////////////////////////////////////
655 INLINE void MouseWatcher::
656 without_region(MouseWatcherRegion *region, const MouseWatcherParameter &param) {
657  if (_enter_multiple) {
658  exit_region(region, param);
659  }
660  region->without_region(param);
661  throw_event_pattern(_without_pattern, region, ButtonHandle::none());
662 }
663 
664 ////////////////////////////////////////////////////////////////////
665 // Function: MouseWatcher::clear_trail_log
666 // Access: Published
667 // Description: Clears the mouse trail log. This does not prevent
668 // further accumulation of the log given future events.
669 ////////////////////////////////////////////////////////////////////
670 INLINE void MouseWatcher::
672  _trail_log->clear();
673 }
674 
675 ////////////////////////////////////////////////////////////////////
676 // Function: MouseWatcher::get_trail_log
677 // Access: Published
678 // Description: Obtain the mouse trail log. This is a PointerEventList.
679 // Does not make a copy, therefore, this PointerEventList
680 // will be updated each time process_events gets called.
681 //
682 // To use trail logging, you need to enable the
683 // generation of pointer events in the
684 // GraphicsWindowInputDevice and set the trail log
685 // duration in the MouseWatcher. Otherwise, the
686 // trail log will be empty.
687 ////////////////////////////////////////////////////////////////////
688 INLINE CPT(PointerEventList) MouseWatcher::
689 get_trail_log() const {
690  return _trail_log;
691 }
692 
693 ////////////////////////////////////////////////////////////////////
694 // Function: MouseWatcher::num_trail_recent
695 // Access: Published
696 // Description: This counter indicates how many events were added
697 // to the trail log this frame. The trail log is
698 // updated once per frame, during the process_events
699 // operation.
700 ////////////////////////////////////////////////////////////////////
701 INLINE int MouseWatcher::
702 num_trail_recent() const {
703  return _num_trail_recent;
704 }
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
Definition: bitArray.I:207
void set_modifier_buttons(const ModifierButtons &mods)
Sets the buttons that should be monitored as modifier buttons for generating events to the MouseWatch...
Definition: mouseWatcher.I:477
This TFormer maintains a list of rectangular regions on the screen that are considered special mouse ...
Definition: mouseWatcher.h:68
static ButtonHandle none()
Returns a special zero-valued ButtonHandle that is used to indicate no button.
Definition: buttonHandle.I:205
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void without_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves completely outside the boundaries o...
bool has_geometry() const
Returns true if a software mouse pointer has been setup via set_geometry(), or false otherwise...
Definition: mouseWatcher.I:418
int get_index() const
Returns the integer index associated with this ButtonHandle.
Definition: buttonHandle.I:184
PandaNode * get_geometry() const
Returns the node that has been set as the software mouse pointer, or NULL if no node has been set...
Definition: mouseWatcher.I:430
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
EventHandler * get_extra_handler() const
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that ev...
Definition: mouseWatcher.I:465
A class to monitor events from the C++ side of things.
Definition: eventHandler.h:41
bool is_over_region() const
Returns true if the mouse is over any rectangular region, false otherwise.
Definition: mouseWatcher.I:132
ModifierButtons get_modifier_buttons() const
Returns the set of buttons that are being monitored as modifier buttons, as well as their current sta...
Definition: mouseWatcher.I:488
void set_inactivity_timeout(double timeout)
Sets an inactivity timeout on the mouse activity.
Definition: mouseWatcher.I:566
void set_inactivity_timeout_event(const string &event)
Specifies the event string that will be generated when the inactivity timeout counter expires...
Definition: mouseWatcher.I:618
void set_button_up_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is released...
Definition: mouseWatcher.I:230
Records a set of pointer events that happened recently.
const string & get_button_down_pattern() const
Returns the string that indicates how event names are generated when a button is depressed.
Definition: mouseWatcher.I:218
double get_inactivity_timeout() const
Returns the inactivity timeout that has been set.
Definition: mouseWatcher.I:591
void clear_inactivity_timeout()
Removes the inactivity timeout and restores the MouseWatcher to its default behavior of allowing a ke...
Definition: mouseWatcher.I:604
void set_button_down_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is depressed...
Definition: mouseWatcher.I:206
virtual void within_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves within the boundaries of the region...
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
const string & get_button_repeat_pattern() const
Returns the string that indicates how event names are names are generated when a button is continuous...
Definition: mouseWatcher.I:275
const LVecBase4 & get_frame() const
Returns the frame of the MouseWatcher.
Definition: mouseWatcher.I:121
PN_stdfloat get_mouse_y() const
It is only valid to call this if has_mouse() returns true.
Definition: mouseWatcher.I:77
bool is_button_down(ButtonHandle button) const
Returns true if the indicated button is currently being held down, false otherwise.
Definition: mouseWatcher.I:187
void set_display_region(DisplayRegion *dr)
Constrains the MouseWatcher to watching the mouse within a particular indicated region of the screen...
Definition: mouseWatcher.I:507
void set_enter_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse enters a regi...
Definition: mouseWatcher.I:290
const LPoint2 & get_mouse() const
It is only valid to call this if has_mouse() returns true.
Definition: mouseWatcher.I:48
This is the class that defines a rectangular region on the screen for the MouseWatcher.
DisplayRegion * get_display_region() const
Returns the display region the MouseWatcher is constrained to by set_display_region(), or NULL if it is not constrained.
Definition: mouseWatcher.I:533
void clear_geometry()
Stops the use of the software cursor set up via set_geometry().
Definition: mouseWatcher.I:441
PN_stdfloat get_mouse_x() const
It is only valid to call this if has_mouse() returns true.
Definition: mouseWatcher.I:64
void set_button_repeat_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is continuousl...
Definition: mouseWatcher.I:262
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the frame of the MouseWatcher.
Definition: mouseWatcher.I:89
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
const string & get_without_pattern() const
Returns the string that indicates how event names are generated when the mouse wanders out of a regio...
Definition: mouseWatcher.I:392
MouseWatcherRegion * get_over_region() const
Returns the smallest region the mouse is currently over, or NULL if it is over no region...
Definition: mouseWatcher.I:165
void note_activity()
Can be used in conjunction with the inactivity timeout to inform the MouseWatcher that the user has j...
const string & get_within_pattern() const
Returns the string that indicates how event names are generated when the mouse wanders over a region...
Definition: mouseWatcher.I:362
void clear_trail_log()
Clears the mouse trail log.
Definition: mouseWatcher.I:671
const string & get_leave_pattern() const
Returns the string that indicates how event names are generated when the mouse leaves a region...
Definition: mouseWatcher.I:333
void set_leave_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse leaves a regi...
Definition: mouseWatcher.I:319
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:61
void set_without_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse wanders out o...
Definition: mouseWatcher.I:377
const string & get_inactivity_timeout_event() const
Returns the event string that will be generated when the inactivity timeout counter expires...
Definition: mouseWatcher.I:630
void set_extra_handler(EventHandler *eh)
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that ev...
Definition: mouseWatcher.I:453
bool has_mouse() const
Returns true if the mouse is anywhere within the window, false otherwise.
Definition: mouseWatcher.I:23
This is a two-component point in space.
Definition: lpoint2.h:92
bool has_inactivity_timeout() const
Returns true if an inactivity timeout has been set, false otherwise.
Definition: mouseWatcher.I:579
This is sent along as a parameter to most events generated for a region to indicate the mouse and but...
const string & get_enter_pattern() const
Returns the string that indicates how event names are generated when the mouse enters a region...
Definition: mouseWatcher.I:304
void set_geometry(PandaNode *node)
Sets the node that will be transformed each frame by the mouse's coordinates.
Definition: mouseWatcher.I:406
void set_within_pattern(const string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse wanders over ...
Definition: mouseWatcher.I:348
bool is_mouse_open() const
Returns true if the mouse is within the window and not over some particular MouseWatcherRegion that i...
Definition: mouseWatcher.I:36
void clear_display_region()
Removes the display region constraint from the MouseWatcher, and restores it to the default behavior ...
Definition: mouseWatcher.I:520
const string & get_button_up_pattern() const
Returns the string that indicates how event names are generated when a button is released.
Definition: mouseWatcher.I:242
bool has_display_region() const
Returns true if the MouseWatcher has been constrained to a particular region of the screen via set_di...
Definition: mouseWatcher.I:547