mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Add ability to flush cached children to support dynamic trees
This commit is contained in:
parent
80862fe41a
commit
03e8cbc717
@ -85,9 +85,9 @@ class SceneGraphExplorer(Pmw.MegaWidget, PandaObject):
|
||||
# Check keywords and initialise options based on input values.
|
||||
self.initialiseoptions(SceneGraphExplorer)
|
||||
|
||||
def update(self):
|
||||
def update(self, fUseCachedChildren = 1):
|
||||
""" Refresh scene graph explorer """
|
||||
self._node.update()
|
||||
self._node.update(fUseCachedChildren)
|
||||
|
||||
def mouse2Down(self, event):
|
||||
self._width = 1.0 * self._canvas.winfo_width()
|
||||
|
@ -181,20 +181,20 @@ class TreeNode:
|
||||
else:
|
||||
return self
|
||||
|
||||
def update(self):
|
||||
def update(self, fUseCachedChildren = 1):
|
||||
if self.parent:
|
||||
self.parent.update()
|
||||
self.parent.update(fUseCachedChildren)
|
||||
else:
|
||||
oldcursor = self.canvas['cursor']
|
||||
self.canvas['cursor'] = "watch"
|
||||
self.canvas.update()
|
||||
self.canvas.delete(ALL) # XXX could be more subtle
|
||||
self.draw(7, 2)
|
||||
self.draw(7, 2, fUseCachedChildren)
|
||||
x0, y0, x1, y1 = self.canvas.bbox(ALL)
|
||||
self.canvas.configure(scrollregion=(0, 0, x1, y1))
|
||||
self.canvas['cursor'] = oldcursor
|
||||
|
||||
def draw(self, x, y):
|
||||
def draw(self, x, y, fUseCachedChildren = 1):
|
||||
# XXX This hard-codes too many geometry constants!
|
||||
self.x, self.y = x, y
|
||||
self.drawicon()
|
||||
@ -209,7 +209,7 @@ class TreeNode:
|
||||
self.kidKeys = []
|
||||
for item in sublist:
|
||||
key = item.GetKey()
|
||||
if self.children.has_key(key):
|
||||
if fUseCachedChildren and self.children.has_key(key):
|
||||
child = self.children[key]
|
||||
else:
|
||||
child = TreeNode(self.canvas, self, item, self.menuList)
|
||||
@ -226,7 +226,7 @@ class TreeNode:
|
||||
child = self.children[key]
|
||||
cylast = cy
|
||||
self.canvas.create_line(x+9, cy+7, cx, cy+7, fill="gray50")
|
||||
cy = child.draw(cx, cy)
|
||||
cy = child.draw(cx, cy, fUseCachedChildren)
|
||||
if child.item.IsExpandable():
|
||||
if child.state == 'expanded':
|
||||
iconname = "minusnode"
|
||||
|
Loading…
x
Reference in New Issue
Block a user