Browse Source

Added direct light mode to enable selection via mouse click

Mark Mine 22 years ago
parent
commit
25e98200a3

+ 18 - 0
direct/src/directtools/DirectSession.py

@@ -204,6 +204,24 @@ class DirectSession(PandaObject):
         # Set flag
         self.fEnabled = 1
 
+    def enableLight(self):
+        if self.fEnabled:
+            return
+        # Make sure old tasks are shut down
+        self.disable()
+        # Start all display region context tasks
+        self.drList.spawnContextTask()
+        # Turn on object manipulation
+        self.manipulationControl.enableManipulation()
+        # Make sure list of selected items is reset
+        self.deselectAll()
+        self.selected.reset()
+        # Accept appropriate hooks
+        self.enableMouseEvents()
+        self.enableActionEvents()
+        # Set flag
+        self.fEnabled = 1
+
     def disable(self):
         # Shut down all display region context tasks
         self.drList.removeContextTask()

+ 4 - 0
direct/src/level/BasicEntities.py

@@ -38,6 +38,8 @@ class privNodePathImpl(NodePath.NodePath):
     def __init__(self, name):
         node = hidden.attachNewNode(name)
         NodePath.NodePath.__init__(self, node)
+        if __debug__:
+            self.setTag('entity', '1')
 
     def initNodePathAttribs(self):
         """Call this after the entity has been initialized, and all
@@ -48,6 +50,8 @@ class privNodePathImpl(NodePath.NodePath):
         self.level.requestReparent(self, self.parent)
         
     def destroy(self):
+        if __debug__:
+            self.clearTag('entity')
         self.removeNode()
 
     def getNodePath(self):

+ 27 - 0
direct/src/tkwidgets/Tree.py

@@ -161,6 +161,17 @@ class TreeNode:
         fraction = float(fraction) / y1
         self.canvas.yview_moveto(fraction)
 
+    def reveal(self):
+        parent = self.parent
+        while parent:
+            if parent.state == 'collapsed':
+                parent.state = 'expanded'
+                parent = parent.parent
+            else:
+                break
+        self.update()
+        self.view()
+
     def lastvisiblechild(self):
         if self.kidKeys and self.state == 'expanded':
             return self.children[self.kidKeys[-1]].lastvisiblechild()
@@ -317,6 +328,22 @@ class TreeNode:
         self.drawtext()
         self.canvas.focus_set()
 
+    def find(self, searchKey):
+        if searchKey == self.item.GetKey():
+            return self
+        sublist = self.item._GetSubList()
+        for item in sublist:
+            key = item.GetKey()
+            if self.children.has_key(key):
+                child = self.children[key]
+            else:
+                child = TreeNode(self.canvas, self, item, self.menuList)
+                self.children[key] = child
+                self.kidKeys.append(key)
+            retVal = child.find(searchKey)
+            if retVal:
+                return retVal
+        return None
 
 class TreeItem: