From c760784dbb7d9553dea9107f7b8e7ae05243a1db Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 13 Jul 2001 00:50:03 +0000 Subject: [PATCH] is_mouse_open --- panda/src/tform/mouseWatcher.I | 15 ++++++++++++++- panda/src/tform/mouseWatcher.cxx | 7 ++++--- panda/src/tform/mouseWatcher.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 69f49bbddc..4818087291 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -21,13 +21,26 @@ // Function: MouseWatcher::has_mouse // Access: Published // Description: Returns true if the mouse is anywhere within the -// window, false otherwise. +// window, false otherwise. Also see is_mouse_open(). //////////////////////////////////////////////////////////////////// INLINE bool MouseWatcher:: has_mouse() const { return _has_mouse; } +//////////////////////////////////////////////////////////////////// +// Function: MouseWatcher::is_mouse_open +// Access: Published +// Description: 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. +//////////////////////////////////////////////////////////////////// +INLINE bool MouseWatcher:: +is_mouse_open() const { + return _has_mouse && !_suppressed; +} + //////////////////////////////////////////////////////////////////// // Function: MouseWatcher::get_mouse // Access: Published diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 0f7085f473..6229d8380d 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -44,6 +44,7 @@ TypeHandle MouseWatcher::_button_events_type; MouseWatcher:: MouseWatcher(const string &name) : DataNode(name) { _has_mouse = false; + _suppressed = false; _current_region = (MouseWatcherRegion *)NULL; _button_down_region = (MouseWatcherRegion *)NULL; _button_down = false; @@ -526,12 +527,12 @@ transmit_data(NodeAttributes &data) { } } - bool suppress_below = false; + _suppressed = false; if (_current_region != (MouseWatcherRegion *)NULL) { - suppress_below = _current_region->get_suppress_below(); + _suppressed = _current_region->get_suppress_below(); } - if (suppress_below) { + if (_suppressed) { // We used to suppress *everything* below, but on reflection we // really only want to suppress the mouse position information. // Button events must still get through. diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index 039209ed9c..7df4c75049 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -65,6 +65,7 @@ PUBLISHED: bool remove_region(MouseWatcherRegion *region); INLINE bool has_mouse() const; + INLINE bool is_mouse_open() const; INLINE const LPoint2f &get_mouse() const; INLINE float get_mouse_x() const; INLINE float get_mouse_y() const; @@ -122,6 +123,7 @@ private: Groups _groups; bool _has_mouse; + bool _suppressed; LPoint2f _mouse; PT(MouseWatcherRegion) _current_region;