Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
73245f4743
1 changed files with 27 additions and 0 deletions
  1. 27 0
      direct/src/extensions/MouseWatcherRegion-extensions.py

+ 27 - 0
direct/src/extensions/MouseWatcherRegion-extensions.py

@@ -0,0 +1,27 @@
+
+    """
+    MouseWatcherRegion-extensions module: contains methods to extend
+    functionality of the MouseWatcherRegion class
+    """
+
+    def setRelative(self, np, left, right, bottom, top):
+        """setRelation(NodePath np, float left, float right,
+                       float bottom, float top)
+
+        Sets the region to represnt the indicated rectangle, relative
+        to the given NodePath.  It is assumed that np represents some
+        node parented within the render2d hierarchy.
+
+        """
+        from PandaModules import *
+        
+        # Get the relative transform to the node.
+        mat = np.getMat(render2d)
+
+        # Use this matrix to transform the corners of the region.
+        ll = mat.xformPoint(Point3(left, 0, bottom))
+        ur = mat.xformPoint(Point3(right, 0, top))
+
+        # Set the frame to the transformed coordinates.
+        self.setFrame(ll[0], ur[0], ll[2], ur[2])
+