Panda3D
|
This TFormer maintains a list of rectangular regions on the screen that are considered special mouse regions; typically these will be click buttons. More...
#include "mouseWatcher.h"
Public Member Functions | |
MouseWatcher (const string &name="") | |
bool | add_group (MouseWatcherGroup *group) |
Adds the indicated group of regions to the set of regions the MouseWatcher will monitor each frame. | |
void | clear_display_region () |
Removes the display region constraint from the MouseWatcher, and restores it to the default behavior of watching the whole window. | |
void | clear_geometry () |
Stops the use of the software cursor set up via set_geometry(). | |
void | clear_inactivity_timeout () |
Removes the inactivity timeout and restores the MouseWatcher to its default behavior of allowing a key to be held indefinitely. | |
void | clear_trail_log () |
Clears the mouse trail log. | |
void | clear_trail_node () |
If you have previously fetched the trail node using get_trail_node, then the MouseWatcher is continually updating the trail node every frame. | |
CPT (PointerEventList) get_trail_log() const | |
virtual TypeHandle | force_init_type () |
const string & | get_button_down_pattern () const |
Returns the string that indicates how event names are generated when a button is depressed. | |
const string & | get_button_repeat_pattern () const |
Returns the string that indicates how event names are names are generated when a button is continuously held and generates keyrepeat "down" events. | |
const string & | get_button_up_pattern () const |
Returns the string that indicates how event names are generated when a button is released. | |
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. | |
const string & | get_enter_pattern () const |
Returns the string that indicates how event names are generated when the mouse enters a region. | |
EventHandler * | get_extra_handler () const |
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that events can be dealt with much sooner. | |
const LVecBase4 & | get_frame () const |
Returns the frame of the MouseWatcher. | |
PandaNode * | get_geometry () const |
Returns the node that has been set as the software mouse pointer, or NULL if no node has been set. | |
MouseWatcherGroup * | get_group (int n) const |
Returns the nth group added to the MouseWatcher via add_group(). | |
double | get_inactivity_timeout () const |
Returns the inactivity timeout that has been set. | |
const string & | get_inactivity_timeout_event () const |
Returns the event string that will be generated when the inactivity timeout counter expires. | |
const string & | get_leave_pattern () const |
Returns the string that indicates how event names are generated when the mouse leaves a region. | |
ModifierButtons | get_modifier_buttons () const |
Returns the set of buttons that are being monitored as modifier buttons, as well as their current state. | |
const LPoint2 & | get_mouse () const |
It is only valid to call this if has_mouse() returns true. | |
PN_stdfloat | get_mouse_x () const |
It is only valid to call this if has_mouse() returns true. | |
PN_stdfloat | get_mouse_y () const |
It is only valid to call this if has_mouse() returns true. | |
int | get_num_groups () const |
Returns the number of separate groups added to the MouseWatcher via add_group(). | |
MouseWatcherRegion * | get_over_region () const |
Returns the smallest region the mouse is currently over, or NULL if it is over no region. | |
MouseWatcherRegion * | get_over_region (PN_stdfloat x, PN_stdfloat y) const |
Returns the smallest region the indicated point is over, or NULL if it is over no region. | |
MouseWatcherRegion * | get_over_region (const LPoint2 &pos) const |
Returns the preferred region the mouse is over. | |
virtual TypeHandle | get_type () const |
const string & | get_within_pattern () const |
Returns the string that indicates how event names are generated when the mouse wanders over a region. | |
const string & | get_without_pattern () const |
Returns the string that indicates how event names are generated when the mouse wanders out of a region. | |
bool | has_display_region () const |
Returns true if the MouseWatcher has been constrained to a particular region of the screen via set_display_region(), or false otherwise. | |
bool | has_geometry () const |
Returns true if a software mouse pointer has been setup via set_geometry(), or false otherwise. | |
bool | has_inactivity_timeout () const |
Returns true if an inactivity timeout has been set, false otherwise. | |
bool | has_mouse () const |
Returns true if the mouse is anywhere within the window, false otherwise. | |
bool | is_button_down (ButtonHandle button) const |
Returns true if the indicated button is currently being held down, false otherwise. | |
bool | is_mouse_open () const |
Returns true if the mouse is within the window and not over some particular MouseWatcherRegion that is marked to suppress mouse events; that is, that the mouse is in open space within the window. | |
bool | is_over_region () const |
Returns true if the mouse is over any rectangular region, false otherwise. | |
bool | is_over_region (PN_stdfloat x, PN_stdfloat y) const |
Returns true if the mouse is over any rectangular region, false otherwise. | |
bool | is_over_region (const LPoint2 &pos) const |
Returns true if the mouse is over any rectangular region, false otherwise. | |
MAKE_SEQ (get_groups, get_num_groups, get_group) | |
void | note_activity () |
Can be used in conjunction with the inactivity timeout to inform the MouseWatcher that the user has just performed some action which proves he/she is present. | |
int | num_trail_recent () const |
This counter indicates how many events were added to the trail log this frame. | |
virtual void | output (ostream &out) const |
PT (GeomNode) get_trail_node() | |
bool | remove_group (MouseWatcherGroup *group) |
Removes the indicated group from the set of extra groups associated with the MouseWatcher. | |
bool | remove_region (MouseWatcherRegion *region) |
Removes the indicated region from the group. | |
bool | replace_group (MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) |
Atomically removes old_group from the MouseWatcher, and replaces it with new_group. | |
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. | |
void | set_button_repeat_pattern (const string &pattern) |
Sets the pattern string that indicates how the event names are generated when a button is continuously held and generates keyrepeat "down" events. | |
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. | |
void | set_display_region (DisplayRegion *dr) |
Constrains the MouseWatcher to watching the mouse within a particular indicated region of the screen. | |
void | set_enter_pattern (const string &pattern) |
Sets the pattern string that indicates how the event names are generated when the mouse enters a region. | |
void | set_extra_handler (EventHandler *eh) |
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that events can be dealt with much sooner. | |
void | set_frame (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) |
Sets the frame of the MouseWatcher. | |
void | set_frame (const LVecBase4 &frame) |
Sets the frame of the MouseWatcher. | |
void | set_geometry (PandaNode *node) |
Sets the node that will be transformed each frame by the mouse's coordinates. | |
void | set_inactivity_timeout (double timeout) |
Sets an inactivity timeout on the mouse activity. | |
void | set_inactivity_timeout_event (const string &event) |
Specifies the event string that will be generated when the inactivity timeout counter expires. | |
void | set_leave_pattern (const string &pattern) |
Sets the pattern string that indicates how the event names are generated when the mouse leaves a region. | |
void | set_modifier_buttons (const ModifierButtons &mods) |
Sets the buttons that should be monitored as modifier buttons for generating events to the MouseWatcherRegions. | |
void | set_trail_log_duration (double duration) |
If the duration is nonzero, causes the MouseWatcher to log the mouse's trail. | |
void | set_within_pattern (const string &pattern) |
Sets the pattern string that indicates how the event names are generated when the mouse wanders over a region. | |
void | set_without_pattern (const string &pattern) |
Sets the pattern string that indicates how the event names are generated when the mouse wanders out of a region. | |
virtual void | write (ostream &out, int indent_level=0) const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
void | candidate (const wstring &candidate, size_t highlight_start, size_t highlight_end, size_t cursor_pos) |
Records that the indicated candidate string has been highlighted in the IME. | |
void | clear_current_regions () |
Empties the set of current regions. | |
virtual void | do_hide_regions () |
The protected implementation of hide_regions(). | |
virtual void | do_show_regions (const NodePath &render2d, const string &bin_name, int draw_order) |
The protected implementation of show_regions(). | |
virtual void | do_transmit_data (DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output) |
The virtual implementation of transmit_data(). | |
void | enter_region (MouseWatcherRegion *region, const MouseWatcherParameter ¶m) |
Called internally to indicate the mouse pointer is favoring the indicated region. | |
void | exit_region (MouseWatcherRegion *region, const MouseWatcherParameter ¶m) |
Called internally to indicate the mouse pointer is no longer favoring the indicated region. | |
void | get_over_regions (Regions ®ions, const LPoint2 &pos) const |
Fills up the "regions" list with the set of regions that the indicated point is over, sorted in order by pointer. | |
void | global_keyboard_press (const MouseWatcherParameter ¶m) |
Calls press() on all regions that are interested in receiving global keyboard events, except for the current region (which already received this one). | |
void | global_keyboard_release (const MouseWatcherParameter ¶m) |
Calls release() on all regions that are interested in receiving global keyboard events, except for the current region (which already received this one). | |
void | keystroke (int keycode) |
Records that the indicated keystroke has been generated. | |
void | move () |
Records the indicated mouse or keyboard button as being moved from last position. | |
void | press (ButtonHandle button, bool keyrepeat) |
Records the indicated mouse or keyboard button as being depressed. | |
void | release (ButtonHandle button) |
Records the indicated mouse or keyboard button as being released. | |
void | set_current_regions (Regions ®ions) |
Changes the "current" regions--the one we consider the mouse to be over--to the indicated list, and throws whatever events are appropriate because of that. | |
void | set_mouse (const LVecBase2 &xy, const LVecBase2 &pixel_xy) |
Called from do_transmit_data() to indicate the mouse is within the window, and to specify its current position. | |
void | set_no_mouse () |
Called from do_transmit_data() to indicate the mouse is not within the window. | |
void | throw_event_pattern (const string &pattern, const MouseWatcherRegion *region, const ButtonHandle &button) |
Throws an event associated with the indicated region, using the given pattern. | |
void | within_region (MouseWatcherRegion *region, const MouseWatcherParameter ¶m) |
Called internally to indicate the mouse pointer has moved within the indicated region's boundaries. | |
void | without_region (MouseWatcherRegion *region, const MouseWatcherParameter ¶m) |
Called internally to indicate the mouse pointer has moved outside of the indicated region's boundaries. | |
Static Protected Member Functions | |
static MouseWatcherRegion * | get_preferred_region (const Regions ®ions) |
Returns the innermost region of all the regions indicated in the given vector (usually, the regions the mouse is over). | |
static bool | has_region_in (const Regions ®ions, MouseWatcherRegion *region) |
Returns true if the indicated region is a member of the given sorted list, false otherwise. | |
static void | intersect_regions (Regions &only_a, Regions &only_b, Regions &both, const Regions ®ions_a, const Regions ®ions_b) |
Computes the list of regions that are in both regions_a and regions_b, as well as the list of regions only in regions_a, and the list of regions only in regions_b. | |
static bool | remove_region_from (Regions ®ions, MouseWatcherRegion *region) |
Removes the indicated region from the given vector. |
This TFormer maintains a list of rectangular regions on the screen that are considered special mouse regions; typically these will be click buttons.
When the mouse passes in or out of one of these regions, or when a button is clicked while the mouse is in one of these regions, an event is thrown.
Mouse events may also be suppressed from the rest of the datagraph in these special regions.
This class can also implement a software mouse pointer by automatically generating a transform to apply to a piece of geometry placed under the 2-d scene graph. It will move the geometry around according to the mouse's known position.
Finally, this class can keep a record of the mouse trail. This is useful if you want to know, not just where the mouse is, but the exact sequence of movements it took to get there. This information is mainly useful for gesture-recognition code. To use trail logging, you need to enable the generation of pointer events in the GraphicsWindowInputDevice and set the trail log duration in the MouseWatcher. Otherwise, the trail log will be empty.
Definition at line 68 of file mouseWatcher.h.
bool MouseWatcher::add_group | ( | MouseWatcherGroup * | group | ) |
Adds the indicated group of regions to the set of regions the MouseWatcher will monitor each frame.
Since the MouseWatcher itself inherits from MouseWatcherGroup, this operation is normally not necessary--you can simply add the Regions you care about one at a time. Adding a complete group is useful when you may want to explicitly remove the regions as a group later.
Returns true if the group was successfully added, or false if it was already on the list.
Definition at line 168 of file mouseWatcher.cxx.
References NodePath::is_empty(), and MouseWatcherGroup::show_regions().
void MouseWatcher::candidate | ( | const wstring & | candidate, |
size_t | highlight_start, | ||
size_t | highlight_end, | ||
size_t | cursor_pos | ||
) | [protected] |
Records that the indicated candidate string has been highlighted in the IME.
Definition at line 1168 of file mouseWatcher.cxx.
References MouseWatcherRegion::candidate(), LightMutexDirect::debug_is_locked(), MouseWatcherRegion::get_keyboard(), and MouseWatcherParameter::set_candidate().
Referenced by do_transmit_data().
void MouseWatcher::clear_current_regions | ( | ) | [protected] |
Empties the set of current regions.
Assumes the lock is already held.
Definition at line 780 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::exit_region(), ButtonHandle::none(), MouseWatcherParameter::set_modifier_buttons(), MouseWatcherParameter::set_mouse(), and throw_event_pattern().
Referenced by set_no_mouse().
void MouseWatcher::clear_display_region | ( | ) | [inline] |
Removes the display region constraint from the MouseWatcher, and restores it to the default behavior of watching the whole window.
Definition at line 519 of file mouseWatcher.I.
void MouseWatcher::clear_geometry | ( | ) | [inline] |
Stops the use of the software cursor set up via set_geometry().
Definition at line 441 of file mouseWatcher.I.
void MouseWatcher::clear_inactivity_timeout | ( | ) | [inline] |
Removes the inactivity timeout and restores the MouseWatcher to its default behavior of allowing a key to be held indefinitely.
Definition at line 602 of file mouseWatcher.I.
References note_activity().
void MouseWatcher::clear_trail_log | ( | ) | [inline] |
Clears the mouse trail log.
This does not prevent further accumulation of the log given future events.
Definition at line 669 of file mouseWatcher.I.
void MouseWatcher::clear_trail_node | ( | ) |
If you have previously fetched the trail node using get_trail_node, then the MouseWatcher is continually updating the trail node every frame.
Using clear_trail_node causes the MouseWatcher to forget the trail node and stop updating it.
Definition at line 459 of file mouseWatcher.cxx.
void MouseWatcher::do_hide_regions | ( | ) | [protected, virtual] |
The protected implementation of hide_regions().
This assumes the lock is already held.
Reimplemented from MouseWatcherGroup.
Definition at line 840 of file mouseWatcher.cxx.
References MouseWatcherGroup::hide_regions().
void MouseWatcher::do_show_regions | ( | const NodePath & | render2d, |
const string & | bin_name, | ||
int | draw_order | ||
) | [protected, virtual] |
The protected implementation of show_regions().
This assumes the lock is already held.
Reimplemented from MouseWatcherGroup.
Definition at line 817 of file mouseWatcher.cxx.
References MouseWatcherGroup::show_regions().
void MouseWatcher::do_transmit_data | ( | DataGraphTraverser * | trav, |
const DataNodeTransmit & | input, | ||
DataNodeTransmit & | output | ||
) | [protected, virtual] |
The virtual implementation of transmit_data().
This function receives an array of input parameters and should generate an array of output parameters. The input parameters may be accessed with the index numbers returned by the define_input() calls that were made earlier (presumably in the constructor); likewise, the output parameters should be set with the index numbers returned by the define_output() calls.
Reimplemented from DataNode.
Definition at line 1395 of file mouseWatcher.cxx.
References ButtonEventList::add_event(), candidate(), BitArray::clear_bit(), BitArray::get_bit(), DataGraphTraverser::get_current_thread(), DataNodeTransmit::get_data(), ButtonEventList::get_event(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), PointerEventList::get_in_window(), ButtonHandle::get_index(), BitArray::get_num_bits(), PointerEventList::get_num_events(), ButtonEventList::get_num_events(), EventParameter::get_ptr(), PointerEventList::get_sequence(), PointerEventList::get_time(), EventStoreValue< Type >::get_value(), PointerEventList::get_xpos(), PointerEventList::get_ypos(), DataNodeTransmit::has_data(), MouseButton::is_mouse_button(), keystroke(), move(), note_activity(), press(), release(), BitArray::set_bit(), DataNodeTransmit::set_data(), set_mouse(), set_no_mouse(), and ButtonEvent::update_mods().
void MouseWatcher::enter_region | ( | MouseWatcherRegion * | region, |
const MouseWatcherParameter & | param | ||
) | [protected] |
Called internally to indicate the mouse pointer is favoring the indicated region.
Definition at line 1281 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::enter_region(), ButtonHandle::none(), MouseButton::one(), MouseWatcherRegion::press(), MouseWatcherParameter::set_button(), and throw_event_pattern().
Referenced by set_current_regions(), and within_region().
void MouseWatcher::exit_region | ( | MouseWatcherRegion * | region, |
const MouseWatcherParameter & | param | ||
) | [protected] |
Called internally to indicate the mouse pointer is no longer favoring the indicated region.
Definition at line 1300 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::exit_region(), ButtonHandle::none(), MouseButton::one(), MouseWatcherRegion::release(), MouseWatcherParameter::set_button(), and throw_event_pattern().
Referenced by remove_group(), remove_region(), replace_group(), set_current_regions(), and without_region().
const string & MouseWatcher::get_button_down_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when a button is depressed.
See set_button_down_pattern().
Definition at line 218 of file mouseWatcher.I.
const string & MouseWatcher::get_button_repeat_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are names are generated when a button is continuously held and generates keyrepeat "down" events.
See set_button_repeat_pattern().
Definition at line 275 of file mouseWatcher.I.
const string & MouseWatcher::get_button_up_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when a button is released.
See set_button_down_pattern().
Definition at line 242 of file mouseWatcher.I.
DisplayRegion * MouseWatcher::get_display_region | ( | ) | const [inline] |
Returns the display region the MouseWatcher is constrained to by set_display_region(), or NULL if it is not constrained.
Definition at line 531 of file mouseWatcher.I.
const string & MouseWatcher::get_enter_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when the mouse enters a region.
This is different from within_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 304 of file mouseWatcher.I.
EventHandler * MouseWatcher::get_extra_handler | ( | ) | const [inline] |
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that events can be dealt with much sooner.
Definition at line 465 of file mouseWatcher.I.
const LVecBase4 & MouseWatcher::get_frame | ( | ) | const [inline] |
Returns the frame of the MouseWatcher.
See set_frame().
Definition at line 121 of file mouseWatcher.I.
PandaNode * MouseWatcher::get_geometry | ( | ) | const [inline] |
Returns the node that has been set as the software mouse pointer, or NULL if no node has been set.
See has_geometry() and set_geometry().
Definition at line 430 of file mouseWatcher.I.
MouseWatcherGroup * MouseWatcher::get_group | ( | int | n | ) | const |
Returns the nth group added to the MouseWatcher via add_group().
Definition at line 373 of file mouseWatcher.cxx.
double MouseWatcher::get_inactivity_timeout | ( | ) | const [inline] |
Returns the inactivity timeout that has been set.
It is an error to call this if has_inactivity_timeout() returns false.
Definition at line 589 of file mouseWatcher.I.
const string & MouseWatcher::get_inactivity_timeout_event | ( | ) | const [inline] |
Returns the event string that will be generated when the inactivity timeout counter expires.
Definition at line 628 of file mouseWatcher.I.
const string & MouseWatcher::get_leave_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when the mouse leaves a region.
This is different from without_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 333 of file mouseWatcher.I.
ModifierButtons MouseWatcher::get_modifier_buttons | ( | ) | const [inline] |
Returns the set of buttons that are being monitored as modifier buttons, as well as their current state.
Definition at line 488 of file mouseWatcher.I.
const LPoint2 & MouseWatcher::get_mouse | ( | ) | const [inline] |
It is only valid to call this if has_mouse() returns true.
If so, this returns the current position of the mouse within the window.
Definition at line 48 of file mouseWatcher.I.
PN_stdfloat MouseWatcher::get_mouse_x | ( | ) | const [inline] |
It is only valid to call this if has_mouse() returns true.
If so, this returns the current X position of the mouse within the window.
Definition at line 64 of file mouseWatcher.I.
PN_stdfloat MouseWatcher::get_mouse_y | ( | ) | const [inline] |
It is only valid to call this if has_mouse() returns true.
If so, this returns the current Y position of the mouse within the window.
Definition at line 77 of file mouseWatcher.I.
int MouseWatcher::get_num_groups | ( | ) | const |
Returns the number of separate groups added to the MouseWatcher via add_group().
Definition at line 361 of file mouseWatcher.cxx.
MouseWatcherRegion * MouseWatcher::get_over_region | ( | ) | const [inline] |
Returns the smallest region the mouse is currently over, or NULL if it is over no region.
Definition at line 165 of file mouseWatcher.I.
Referenced by get_over_region(), and is_over_region().
MouseWatcherRegion * MouseWatcher::get_over_region | ( | PN_stdfloat | x, |
PN_stdfloat | y | ||
) | const [inline] |
Returns the smallest region the indicated point is over, or NULL if it is over no region.
Definition at line 176 of file mouseWatcher.I.
References get_over_region().
MouseWatcherRegion * MouseWatcher::get_over_region | ( | const LPoint2 & | pos | ) | const |
Returns the preferred region the mouse is over.
In the case of overlapping regions, the region with the largest sort order is preferred; if two regions have the same sort order, then the smaller region is preferred.
Definition at line 143 of file mouseWatcher.cxx.
References get_over_regions(), and get_preferred_region().
void MouseWatcher::get_over_regions | ( | MouseWatcher::Regions & | regions, |
const LPoint2 & | pos | ||
) | const [protected] |
Fills up the "regions" list with the set of regions that the indicated point is over, sorted in order by pointer.
Assumes the lock is held.
Definition at line 589 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), and MouseWatcherRegion::get_active().
Referenced by get_over_region(), and set_mouse().
MouseWatcherRegion * MouseWatcher::get_preferred_region | ( | const Regions & | regions | ) | [static, protected] |
Returns the innermost region of all the regions indicated in the given vector (usually, the regions the mouse is over).
This is the "preferred" region that gets some special treatment. Assumes the lock is already held.
Definition at line 648 of file mouseWatcher.cxx.
Referenced by get_over_region(), and set_current_regions().
const string & MouseWatcher::get_within_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when the mouse wanders over a region.
This is different from enter_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 362 of file mouseWatcher.I.
const string & MouseWatcher::get_without_pattern | ( | ) | const [inline] |
Returns the string that indicates how event names are generated when the mouse wanders out of a region.
This is different from leave_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 392 of file mouseWatcher.I.
void MouseWatcher::global_keyboard_press | ( | const MouseWatcherParameter & | param | ) | [protected] |
Calls press() on all regions that are interested in receiving global keyboard events, except for the current region (which already received this one).
Definition at line 1213 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::get_keyboard(), and MouseWatcherRegion::press().
Referenced by press().
void MouseWatcher::global_keyboard_release | ( | const MouseWatcherParameter & | param | ) | [protected] |
Calls release() on all regions that are interested in receiving global keyboard events, except for the current region (which already received this one).
Definition at line 1248 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::get_keyboard(), and MouseWatcherRegion::release().
Referenced by release().
bool MouseWatcher::has_display_region | ( | ) | const [inline] |
Returns true if the MouseWatcher has been constrained to a particular region of the screen via set_display_region(), or false otherwise.
If this returns true, get_display_region() may be used to return the particular region.
Definition at line 545 of file mouseWatcher.I.
bool MouseWatcher::has_geometry | ( | ) | const [inline] |
Returns true if a software mouse pointer has been setup via set_geometry(), or false otherwise.
See set_geometry().
Definition at line 418 of file mouseWatcher.I.
bool MouseWatcher::has_inactivity_timeout | ( | ) | const [inline] |
Returns true if an inactivity timeout has been set, false otherwise.
Definition at line 577 of file mouseWatcher.I.
bool MouseWatcher::has_mouse | ( | ) | const [inline] |
Returns true if the mouse is anywhere within the window, false otherwise.
Also see is_mouse_open().
Definition at line 23 of file mouseWatcher.I.
bool MouseWatcher::has_region_in | ( | const Regions & | regions, |
MouseWatcherRegion * | region | ||
) | [static, protected] |
Returns true if the indicated region is a member of the given sorted list, false otherwise.
Definition at line 927 of file mouseWatcher.cxx.
Referenced by remove_group(), and replace_group().
void MouseWatcher::intersect_regions | ( | MouseWatcher::Regions & | only_a, |
MouseWatcher::Regions & | only_b, | ||
MouseWatcher::Regions & | both, | ||
const Regions & | regions_a, | ||
const Regions & | regions_b | ||
) | [static, protected] |
Computes the list of regions that are in both regions_a and regions_b, as well as the list of regions only in regions_a, and the list of regions only in regions_b.
Any or all of the three output lists may be the same object, but they must be different objects from both of the input lists.
It is assumed that both vectors are already sorted in pointer order. It is also assumed that any relevant locks are already held.
Definition at line 869 of file mouseWatcher.cxx.
Referenced by remove_group(), and replace_group().
bool MouseWatcher::is_button_down | ( | ButtonHandle | button | ) | const [inline] |
Returns true if the indicated button is currently being held down, false otherwise.
Definition at line 187 of file mouseWatcher.I.
References BitArray::get_bit(), and ButtonHandle::get_index().
bool MouseWatcher::is_mouse_open | ( | ) | const [inline] |
Returns true if the mouse is within the window and not over some particular MouseWatcherRegion that is marked to suppress mouse events; that is, that the mouse is in open space within the window.
Definition at line 36 of file mouseWatcher.I.
bool MouseWatcher::is_over_region | ( | ) | const [inline] |
Returns true if the mouse is over any rectangular region, false otherwise.
Definition at line 132 of file mouseWatcher.I.
References get_over_region().
bool MouseWatcher::is_over_region | ( | PN_stdfloat | x, |
PN_stdfloat | y | ||
) | const [inline] |
Returns true if the mouse is over any rectangular region, false otherwise.
Definition at line 143 of file mouseWatcher.I.
References get_over_region().
bool MouseWatcher::is_over_region | ( | const LPoint2 & | pos | ) | const [inline] |
Returns true if the mouse is over any rectangular region, false otherwise.
Definition at line 154 of file mouseWatcher.I.
References get_over_region().
void MouseWatcher::keystroke | ( | int | keycode | ) | [protected] |
Records that the indicated keystroke has been generated.
Definition at line 1120 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), MouseWatcherRegion::get_keyboard(), MouseWatcherRegion::keystroke(), and MouseWatcherParameter::set_keycode().
Referenced by do_transmit_data().
void MouseWatcher::move | ( | ) | [protected] |
Records the indicated mouse or keyboard button as being moved from last position.
Definition at line 999 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), and MouseWatcherParameter::set_modifier_buttons().
Referenced by do_transmit_data().
void MouseWatcher::note_activity | ( | ) |
Can be used in conjunction with the inactivity timeout to inform the MouseWatcher that the user has just performed some action which proves he/she is present.
It may be necessary to call this for external events, such as joystick action, that the MouseWatcher might otherwise not know about. This will reset the current inactivity timer. When the inactivity timer reaches the length of time specified by set_inactivity_timeout(), with no keyboard or mouse activity and no calls to note_activity(), then any buttons held will be automatically released.
Definition at line 518 of file mouseWatcher.cxx.
References ClockObject::get_frame_time(), and ClockObject::get_global_clock().
Referenced by clear_inactivity_timeout(), do_transmit_data(), and set_inactivity_timeout().
int MouseWatcher::num_trail_recent | ( | ) | const [inline] |
This counter indicates how many events were added to the trail log this frame.
The trail log is updated once per frame, during the process_events operation.
Definition at line 700 of file mouseWatcher.I.
void MouseWatcher::press | ( | ButtonHandle | button, |
bool | keyrepeat | ||
) | [protected] |
Records the indicated mouse or keyboard button as being depressed.
Definition at line 1018 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), global_keyboard_press(), MouseButton::is_mouse_button(), MouseWatcherParameter::set_button(), and throw_event_pattern().
Referenced by do_transmit_data().
void MouseWatcher::release | ( | ButtonHandle | button | ) | [protected] |
Records the indicated mouse or keyboard button as being released.
Definition at line 1075 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), global_keyboard_release(), MouseButton::is_mouse_button(), MouseWatcherRegion::release(), MouseWatcherParameter::set_button(), and throw_event_pattern().
Referenced by do_transmit_data().
bool MouseWatcher::remove_group | ( | MouseWatcherGroup * | group | ) |
Removes the indicated group from the set of extra groups associated with the MouseWatcher.
Returns true if successful, or false if the group was already removed or was never added via add_group().
Definition at line 201 of file mouseWatcher.cxx.
References MouseWatcherGroup::do_hide_regions(), MouseWatcherGroup::do_sort_regions(), exit_region(), has_region_in(), intersect_regions(), NodePath::is_empty(), and set_current_regions().
bool MouseWatcher::remove_region | ( | MouseWatcherRegion * | region | ) |
Removes the indicated region from the group.
Returns true if it was successfully removed, or false if it wasn't there in the first place.
Reimplemented from MouseWatcherGroup.
Definition at line 116 of file mouseWatcher.cxx.
References MouseWatcherGroup::do_remove_region(), exit_region(), and remove_region_from().
bool MouseWatcher::remove_region_from | ( | MouseWatcher::Regions & | regions, |
MouseWatcherRegion * | region | ||
) | [static, protected] |
Removes the indicated region from the given vector.
Assumes the vector is sorted in pointer order. Returns true if removed, false if it wasn't there. Assumes any relevent locks are already held.
Definition at line 907 of file mouseWatcher.cxx.
Referenced by remove_region().
bool MouseWatcher::replace_group | ( | MouseWatcherGroup * | old_group, |
MouseWatcherGroup * | new_group | ||
) |
Atomically removes old_group from the MouseWatcher, and replaces it with new_group.
Presumably old_group and new_group might have some regions in common; these are handled properly.
If old_group is not already present, simply adds new_group and returns false. Otherwise, removes old_group and adds new_group, and then returns true.
Definition at line 255 of file mouseWatcher.cxx.
References MouseWatcherGroup::do_hide_regions(), MouseWatcherGroup::do_show_regions(), MouseWatcherGroup::do_sort_regions(), MouseWatcherGroup::do_update_regions(), exit_region(), has_region_in(), intersect_regions(), NodePath::is_empty(), and set_current_regions().
void MouseWatcher::set_button_down_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when a button is depressed.
This is a string that may contain any of the following:
r - the name of the region the mouse is over b - the name of the button pressed.
The event name will be based on the in_pattern string specified here, with all occurrences of the above strings replaced with the corresponding values.
Definition at line 206 of file mouseWatcher.I.
void MouseWatcher::set_button_repeat_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when a button is continuously held and generates keyrepeat "down" events.
This is a string that may contain any of the following:
r - the name of the region the mouse is over b - the name of the button pressed.
The event name will be based on the in_pattern string specified here, with all occurrences of the above strings replaced with the corresponding values.
Definition at line 262 of file mouseWatcher.I.
void MouseWatcher::set_button_up_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when a button is released.
See set_button_down_pattern().
Definition at line 230 of file mouseWatcher.I.
void MouseWatcher::set_current_regions | ( | MouseWatcher::Regions & | regions | ) | [protected] |
Changes the "current" regions--the one we consider the mouse to be over--to the indicated list, and throws whatever events are appropriate because of that.
The list passed in is destroyed. Assumes the lock is already held.
Definition at line 680 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), enter_region(), exit_region(), get_preferred_region(), MouseWatcherParameter::set_modifier_buttons(), within_region(), and without_region().
Referenced by remove_group(), replace_group(), and set_mouse().
void MouseWatcher::set_display_region | ( | DisplayRegion * | dr | ) | [inline] |
Constrains the MouseWatcher to watching the mouse within a particular indicated region of the screen.
DataNodes parented under the MouseWatcher will observe the mouse and keyboard events only when the mouse is within the indicated region, and the observed range will be from -1 .. 1 across the region.
Do not delete the DisplayRegion while it is owned by the MouseWatcher.
Definition at line 507 of file mouseWatcher.I.
void MouseWatcher::set_enter_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when the mouse enters a region.
This is different from within_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 290 of file mouseWatcher.I.
void MouseWatcher::set_extra_handler | ( | EventHandler * | eh | ) | [inline] |
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that events can be dealt with much sooner.
Definition at line 453 of file mouseWatcher.I.
void MouseWatcher::set_frame | ( | PN_stdfloat | left, |
PN_stdfloat | right, | ||
PN_stdfloat | bottom, | ||
PN_stdfloat | top | ||
) | [inline] |
Sets the frame of the MouseWatcher.
See the next flavor of this method for a more verbose explanation.
Definition at line 89 of file mouseWatcher.I.
void MouseWatcher::set_frame | ( | const LVecBase4 & | frame | ) | [inline] |
Sets the frame of the MouseWatcher.
This determines the coordinate space in which the MouseWatcherRegions should be expected to live. Normally, this is left at -1, 1, -1, 1, which is the default setting, and matches the mouse coordinate range.
Whatever values you specify here indicate the shape of the full screen, and the MouseWatcherRegions will be given in coordinate space matching it. For instance, if you specify (0, 1, 0, 1), then a MouseWatcherRegion with the frame (0, 1, 0, .5) will cover the lower half of the screen.
Definition at line 110 of file mouseWatcher.I.
void MouseWatcher::set_geometry | ( | PandaNode * | node | ) | [inline] |
Sets the node that will be transformed each frame by the mouse's coordinates.
It will also be hidden when the mouse goes outside the window. This can be used to implement a software mouse pointer for when a hardware (or system) mouse pointer is unavailable.
Definition at line 406 of file mouseWatcher.I.
void MouseWatcher::set_inactivity_timeout | ( | double | timeout | ) | [inline] |
Sets an inactivity timeout on the mouse activity.
When this timeout (in seconds) is exceeded with no keyboard or mouse activity, all currently-held buttons are automatically released. This is intended to help protect against people who inadvertently (or intentionally) leave a keyboard key stuck down and then wander away from the keyboard.
Also, when this timeout expires, the event specified by set_inactivity_timeout_event() will be generated.
Definition at line 564 of file mouseWatcher.I.
References note_activity().
void MouseWatcher::set_inactivity_timeout_event | ( | const string & | event | ) | [inline] |
Specifies the event string that will be generated when the inactivity timeout counter expires.
Definition at line 616 of file mouseWatcher.I.
void MouseWatcher::set_leave_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when the mouse leaves a region.
This is different from without_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 319 of file mouseWatcher.I.
void MouseWatcher::set_modifier_buttons | ( | const ModifierButtons & | mods | ) | [inline] |
Sets the buttons that should be monitored as modifier buttons for generating events to the MouseWatcherRegions.
Definition at line 477 of file mouseWatcher.I.
void MouseWatcher::set_mouse | ( | const LVecBase2 & | xy, |
const LVecBase2 & | pixel_xy | ||
) | [protected] |
Called from do_transmit_data() to indicate the mouse is within the window, and to specify its current position.
Definition at line 1341 of file mouseWatcher.cxx.
References LightMutexDirect::debug_is_locked(), get_over_regions(), and set_current_regions().
Referenced by do_transmit_data().
void MouseWatcher::set_no_mouse | ( | ) | [protected] |
Called from do_transmit_data() to indicate the mouse is not within the window.
Definition at line 1319 of file mouseWatcher.cxx.
References clear_current_regions(), and LightMutexDirect::debug_is_locked().
Referenced by do_transmit_data().
void MouseWatcher::set_trail_log_duration | ( | double | duration | ) |
If the duration is nonzero, causes the MouseWatcher to log the mouse's trail.
Events older than the specified duration are discarded. If the duration is zero, logging is disabled.
Definition at line 388 of file mouseWatcher.cxx.
void MouseWatcher::set_within_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when the mouse wanders over a region.
This is different from enter_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 348 of file mouseWatcher.I.
void MouseWatcher::set_without_pattern | ( | const string & | pattern | ) | [inline] |
Sets the pattern string that indicates how the event names are generated when the mouse wanders out of a region.
This is different from leave_pattern, in that a mouse is only "entered" in the topmost region at a given time, while it might be "within" multiple nested regions.
Definition at line 377 of file mouseWatcher.I.
void MouseWatcher::throw_event_pattern | ( | const string & | pattern, |
const MouseWatcherRegion * | region, | ||
const ButtonHandle & | button | ||
) | [protected] |
Throws an event associated with the indicated region, using the given pattern.
Definition at line 941 of file mouseWatcher.cxx.
References ButtonHandle::get_name(), ModifierButtons::get_prefix(), ModifierButtons::has_button(), ButtonHandle::none(), and ReferenceCount::test_ref_count_integrity().
Referenced by clear_current_regions(), enter_region(), exit_region(), press(), release(), within_region(), and without_region().
void MouseWatcher::within_region | ( | MouseWatcherRegion * | region, |
const MouseWatcherParameter & | param | ||
) | [inline, protected] |
Called internally to indicate the mouse pointer has moved within the indicated region's boundaries.
Definition at line 639 of file mouseWatcher.I.
References enter_region(), ButtonHandle::none(), throw_event_pattern(), and MouseWatcherRegion::within_region().
Referenced by set_current_regions().
void MouseWatcher::without_region | ( | MouseWatcherRegion * | region, |
const MouseWatcherParameter & | param | ||
) | [inline, protected] |
Called internally to indicate the mouse pointer has moved outside of the indicated region's boundaries.
Definition at line 654 of file mouseWatcher.I.
References exit_region(), ButtonHandle::none(), throw_event_pattern(), and MouseWatcherRegion::without_region().
Referenced by set_current_regions().