remove-callback-window

This commit is contained in:
David Rose 2012-01-18 19:25:16 +00:00
parent 19a0d3bdb9
commit 38de5011e1
2 changed files with 26 additions and 19 deletions

View File

@ -792,12 +792,14 @@ class ShowBase(DirectObject.DirectObject):
return win
def closeWindow(self, win, keepCamera = 0):
def closeWindow(self, win, keepCamera = False, removeWindow = True):
"""
Closes the indicated window and removes it from the list of
windows. If it is the main window, clears the main window
pointer to None.
"""
win.setActive(False)
# First, remove all of the cameras associated with display
# regions on the window.
numRegions = win.getNumDisplayRegions()
@ -838,7 +840,8 @@ class ShowBase(DirectObject.DirectObject):
self.winControls.remove(winCtrl)
break
# Now we can actually close the window.
self.graphicsEngine.removeWindow(win)
if removeWindow:
self.graphicsEngine.removeWindow(win)
self.winList.remove(win)
mainWindow = False
@ -896,7 +899,7 @@ class ShowBase(DirectObject.DirectObject):
which case base.win may be either None, or the previous,
closed window).
"""
keepCamera = kw.get('keepCamera', 0)
keepCamera = kw.get('keepCamera', False)
success = 1
oldWin = self.win

View File

@ -54,13 +54,12 @@ class EmbeddedPandaWindow(wx.Window):
event.Skip()
def cleanup(self):
""" Parent windows should call cleanp() to clean up the
""" Parent windows should call cleanup() to clean up the
wxPandaWindow explicitly (since we can't catch EVT_CLOSE
directly). """
if self.win:
base.closeWindow(self.win)
self.win = None
self.Destroy()
def onSize(self, event):
wp = WindowProperties()
@ -77,6 +76,8 @@ else:
within the wx GLCanvas object. It is supported whenever OpenGL is
Panda's rendering engine, and GLCanvas is available in wx. """
removeCallbackWindow = ConfigVariableBool('remove-callback-window', True)
Keymap = {
wx.WXK_BACK : KeyboardButton.backspace(),
wx.WXK_TAB : KeyboardButton.tab(),
@ -204,13 +205,15 @@ else:
event.Skip()
def cleanup(self):
""" Parent windows should call cleanp() to clean up the
""" Parent windows should call cleanup() to clean up the
wxPandaWindow explicitly (since we can't catch EVT_CLOSE
directly). """
if self.win:
base.closeWindow(self.win)
self.win.clearEventsCallback()
self.win.clearPropertiesCallback()
self.win.clearRenderCallback()
base.closeWindow(self.win, removeWindow = self.removeCallbackWindow)
self.win = None
self.Destroy()
def __buttonDown(self, button):
self.inputDevice.buttonDown(button)
@ -304,7 +307,7 @@ else:
event.Skip()
def onPaint(self, event):
""" This is called whenever we get the fisrt paint event,
""" This is called whenever we get the first paint event,
at which point we can conclude that the window has
actually been manifested onscreen. (In X11, there appears
to be no way to know this otherwise.) """
@ -315,17 +318,18 @@ else:
#event.Skip()
def onIdle(self, event):
size = None
properties = self.win.getProperties()
if properties.hasSize():
size = (properties.getXSize(), properties.getYSize())
if self.win:
size = None
properties = self.win.getProperties()
if properties.hasSize():
size = (properties.getXSize(), properties.getYSize())
if tuple(self.GetClientSize()) != size:
# The window has changed size during the idle call.
# This seems to be possible in Linux.
wp = WindowProperties()
wp.setSize(*self.GetClientSize())
self.win.requestProperties(wp)
if tuple(self.GetClientSize()) != size:
# The window has changed size during the idle call.
# This seems to be possible in Linux.
wp = WindowProperties()
wp.setSize(*self.GetClientSize())
self.win.requestProperties(wp)
event.Skip()