[Alpha] TreeGUI

Here’s the patch for mouse cursors. Ensuring that the cursor is offset properly is left to the theme.

=== modified file treegui/core.py
--- treegui/core.py	2009-09-07 16:30:30 +0000
+++ treegui/core.py	2009-10-02 16:31:54 +0000
@@ -127,6 +127,7 @@
         self.parent = False
         self.children = []
         self.idToFrame = {}
+        self.cursor = None
         
         self.pos = Vec2(0,0)
         self.windowsize = 800,600
@@ -170,8 +171,11 @@
         
     def _draw(self):
         """ prods drawer to do its thing """
-        self.drawer.draw(self.children)
-    
+        if self.cursor is not None:
+            self.drawer.draw(self.children + [self.cursor])
+        else:
+            self.drawer.draw(self.children)
+            
     def _reSize(self):
         """ resize the window via panda3d internal events"""
         self.windowsize = base.win.getXSize(),base.win.getYSize()
@@ -201,7 +205,10 @@
             if gui.hoveringOver and gui.hoveringOver.onOut:
                 gui.hoveringOver.onOut()
             gui.hoveringOver = None
-        
+        if self.cursor is not None:
+            self.cursor._x = self.mouseX
+            self.cursor._y = self.mouseY
+            self.cursor.visable = self.mouseInWindow        
         
     def drag(self,widget,dragSnap=False):
         """ drags a widget """ 
@@ -269,3 +276,11 @@
             self.node.show()
         else:
             self.node.hide()      
+
+    def setCursorStyle(self, style):
+        if style is not None:
+            if self.cursor is None:
+                self.cursor = Cursor()
+            self.cursor.style = style
+        else:
+            self.cursor = None
\ No newline at end of file

=== modified file treegui/widgets.py
--- treegui/widgets.py	2009-09-08 17:31:46 +0000
+++ treegui/widgets.py	2009-10-02 16:31:34 +0000
@@ -120,7 +120,12 @@
     def __init__(self, icon, **placement):
         self.doPlacement(placement)    
         self.icon = icon
-        
+
+class Cursor(Widget):
+    """ a theme-driven image used for the mouse pointer """
+    clips = False
+    style = None
+    
 class Label(Widget):
     """ display a string of text in the ui """
     clips = False