From 8e715772596fdeb7a885193a0c6e586a492c0a3d Mon Sep 17 00:00:00 2001 From: Nikita Pavlov Date: Mon, 15 Aug 2005 22:44:26 +0000 Subject: [PATCH] Moved multiwindow support from branch to trunk --- direct/src/showbase/ShowBase.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index a50c13238e..302d3a1c95 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -110,6 +110,7 @@ class ShowBase(DirectObject.DirectObject): self.win = None self.frameRateMeter = None self.winList = [] + self.winControls = [] self.mainWinMinimized = 0 self.pipe = None self.pipeList = [] @@ -254,6 +255,9 @@ class ShowBase(DirectObject.DirectObject): import Transitions self.transitions = Transitions.Transitions(self.loader) + # Setup the window controls - handy for multiwindow applications + self.setupWindowControls() + # Start Tk and DIRECT if specified by Config.prc fTk = self.config.GetBool('want-tk', 0) # Start DIRECT if specified in Config.prc or in cluster mode @@ -592,6 +596,13 @@ class ShowBase(DirectObject.DirectObject): self.frameRateMeter.clearWindow() self.frameRateMeter = None + def setupWindowControls(self): + if not self.winControls: + winCtrl = WindowControls(self.win, mouseWatcher=self.mouseWatcher, + cam=self.camera, cam2d=self.camera2d, + mouseKeyboard = self.dataRoot.find("**/*")) + self.winControls.append(winCtrl) + def setupRender(self): """ @@ -1612,3 +1623,22 @@ class ShowBase(DirectObject.DirectObject): self.taskMgr.run() +# A class to encapsulate information necessary for multiwindow support. +class WindowControls: + def __init__(self, win, cam=None, cam2d=None, mouseWatcher=None, mouseKeyboard=None, closeCmd=lambda : 0): + self.win = win + self.camera = cam + self.camera2d = cam2d + self.mouseWatcher = mouseWatcher + self.mouseKeyboard = mouseKeyboard + self.closeCommand = closeCmd + + def __str__(self): + s = "window = " + str(self.win) + "\n" + s += "camera = " + str(self.camera) + "\n" + s += "camera2d = " + str(self.camera2d) + "\n" + s += "mouseWatcher = " + str(self.mouseWatcher) + "\n" + s += "mouseAndKeyboard = " + str(self.mouseKeyboard) + "\n" + return s + +