David Rose 24 lat temu
rodzic
commit
c760784dbb

+ 14 - 1
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

+ 4 - 3
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.

+ 2 - 0
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;