mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
dgui: allow using various GUI items without instantiating ShowBase
This is done by eliminating dependency on the `hidden` built-in, which can now instead be imported from ShowBaseGlobal.
This commit is contained in:
parent
acb0a41049
commit
43a5719bac
@ -3,6 +3,7 @@
|
||||
__all__ = ['findDialog', 'cleanupDialog', 'DirectDialog', 'OkDialog', 'OkCancelDialog', 'YesNoDialog', 'YesNoCancelDialog', 'RetryCancelDialog']
|
||||
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from . import DirectGuiGlobals as DGG
|
||||
from .DirectFrame import *
|
||||
from .DirectButton import *
|
||||
@ -207,7 +208,7 @@ class DirectDialog(DirectFrame):
|
||||
image = None
|
||||
# Get size of text/geom without image (for state 0)
|
||||
if image:
|
||||
image.reparentTo(hidden)
|
||||
image.reparentTo(ShowBaseGlobal.hidden)
|
||||
bounds = self.stateNodePath[0].getTightBounds()
|
||||
if image:
|
||||
image.reparentTo(self.stateNodePath[0])
|
||||
|
@ -4,6 +4,7 @@ text entered using the keyboard."""
|
||||
__all__ = ['DirectEntry']
|
||||
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from . import DirectGuiGlobals as DGG
|
||||
from .DirectFrame import *
|
||||
from .OnscreenText import OnscreenText
|
||||
@ -94,7 +95,7 @@ class DirectEntry(DirectFrame):
|
||||
self.onscreenText = self.createcomponent(
|
||||
'text', (), None,
|
||||
OnscreenText,
|
||||
(), parent = hidden,
|
||||
(), parent = ShowBaseGlobal.hidden,
|
||||
# Pass in empty text to avoid extra work, since its really
|
||||
# The PGEntry which will use the TextNode to generate geometry
|
||||
text = '',
|
||||
|
@ -81,7 +81,6 @@ __all__ = ['DirectGuiBase', 'DirectGuiWidget']
|
||||
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from direct.showbase.ShowBase import ShowBase
|
||||
from . import DirectGuiGlobals as DGG
|
||||
from .OnscreenText import *
|
||||
from .OnscreenGeom import *
|
||||
@ -634,7 +633,7 @@ class DirectGuiBase(DirectObject.DirectObject):
|
||||
"""
|
||||
# Need to tack on gui item specific id
|
||||
gEvent = event + self.guiId
|
||||
if ShowBase.config.GetBool('debug-directgui-msgs', False):
|
||||
if ShowBaseGlobal.config.GetBool('debug-directgui-msgs', False):
|
||||
from direct.showbase.PythonUtil import StackTrace
|
||||
print(gEvent)
|
||||
print(StackTrace())
|
||||
@ -663,7 +662,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
||||
# Determine the default initial state for inactive (or
|
||||
# unclickable) components. If we are in edit mode, these are
|
||||
# actually clickable by default.
|
||||
guiEdit = ShowBase.config.GetBool('direct-gui-edit', False)
|
||||
guiEdit = ShowBaseGlobal.config.GetBool('direct-gui-edit', False)
|
||||
if guiEdit:
|
||||
inactiveInitState = DGG.NORMAL
|
||||
else:
|
||||
@ -729,7 +728,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
||||
guiObjectCollector.addLevel(1)
|
||||
guiObjectCollector.flushLevel()
|
||||
# track gui items by guiId for tracking down leaks
|
||||
if ShowBase.config.GetBool('track-gui-items', False):
|
||||
if ShowBaseGlobal.config.GetBool('track-gui-items', False):
|
||||
if not hasattr(ShowBase, 'guiItems'):
|
||||
ShowBase.guiItems = {}
|
||||
if self.guiId in ShowBase.guiItems:
|
||||
|
@ -3,6 +3,7 @@
|
||||
__all__ = ['DirectScrolledListItem', 'DirectScrolledList']
|
||||
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from . import DirectGuiGlobals as DGG
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.task.Task import Task
|
||||
@ -369,7 +370,7 @@ class DirectScrolledList(DirectFrame):
|
||||
del self.currentSelected
|
||||
self["items"].remove(item)
|
||||
if type(item) != type(''):
|
||||
item.reparentTo(hidden)
|
||||
item.reparentTo(ShowBaseGlobal.hidden)
|
||||
self.refresh()
|
||||
return 1
|
||||
else:
|
||||
@ -387,7 +388,7 @@ class DirectScrolledList(DirectFrame):
|
||||
item.destroy()
|
||||
self["items"].remove(item)
|
||||
if type(item) != type(''):
|
||||
item.reparentTo(hidden)
|
||||
item.reparentTo(ShowBaseGlobal.hidden)
|
||||
self.refresh()
|
||||
return 1
|
||||
else:
|
||||
@ -410,7 +411,7 @@ class DirectScrolledList(DirectFrame):
|
||||
self["items"].remove(item)
|
||||
if type(item) != type(''):
|
||||
#RAU possible leak here, let's try to do the right thing
|
||||
#item.reparentTo(hidden)
|
||||
#item.reparentTo(ShowBaseGlobal.hidden)
|
||||
item.removeNode()
|
||||
retval = 1
|
||||
|
||||
@ -435,7 +436,7 @@ class DirectScrolledList(DirectFrame):
|
||||
self["items"].remove(item)
|
||||
if type(item) != type(''):
|
||||
#RAU possible leak here, let's try to do the right thing
|
||||
#item.reparentTo(hidden)
|
||||
#item.reparentTo(ShowBaseGlobal.hidden)
|
||||
item.removeNode()
|
||||
retval = 1
|
||||
if (refresh):
|
||||
|
@ -207,7 +207,10 @@ class ShowBase(DirectObject.DirectObject):
|
||||
# Has the clusterSyncFlag been set via a config variable
|
||||
self.clusterSyncFlag = self.config.GetBool('cluster-sync', 0)
|
||||
|
||||
self.hidden = NodePath('hidden')
|
||||
# We've already created aspect2d in ShowBaseGlobal, for the
|
||||
# benefit of creating DirectGui elements before ShowBase.
|
||||
from . import ShowBaseGlobal
|
||||
self.hidden = ShowBaseGlobal.hidden
|
||||
|
||||
## The global graphics engine, ie. GraphicsEngine.getGlobalPtr()
|
||||
self.graphicsEngine = GraphicsEngine.getGlobalPtr()
|
||||
|
@ -25,6 +25,7 @@ pandaSystem = PandaSystem.getGlobalPtr()
|
||||
|
||||
# This is defined here so GUI elements can be instantiated before ShowBase.
|
||||
aspect2d = NodePath(PGTop("aspect2d"))
|
||||
hidden = NodePath("hidden")
|
||||
|
||||
# Set direct notify categories now that we have config
|
||||
directNotify.setDconfigLevels()
|
||||
|
@ -5,6 +5,7 @@ a particular color."""
|
||||
__all__ = ['Transitions']
|
||||
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from direct.gui.DirectGui import DirectFrame
|
||||
from direct.gui import DirectGuiGlobals as DGG
|
||||
from direct.interval.LerpInterval import LerpColorScaleInterval, LerpColorInterval, LerpScaleInterval, LerpPosInterval
|
||||
@ -73,7 +74,7 @@ class Transitions:
|
||||
# so that it will also obscure mouse events for objects
|
||||
# positioned behind it.
|
||||
self.fade = DirectFrame(
|
||||
parent = hidden,
|
||||
parent = ShowBaseGlobal.hidden,
|
||||
guiId = 'fade',
|
||||
relief = None,
|
||||
image = self.fadeModel,
|
||||
|
@ -4,6 +4,7 @@ __all__ = ['MopathRecorder']
|
||||
|
||||
# Import Tkinter, Pmw, and the dial code from this directory tree.
|
||||
from panda3d.core import *
|
||||
from direct.showbase import ShowBaseGlobal
|
||||
from direct.showbase.DirectObject import DirectObject
|
||||
from direct.showbase.TkGlobal import *
|
||||
from direct.tkwidgets.AppShell import *
|
||||
@ -852,7 +853,7 @@ class MopathRecorder(AppShell, DirectObject):
|
||||
if self.getVariable('Style', 'Marker').get():
|
||||
self.playbackMarker.reparentTo(self.recorderNodePath)
|
||||
else:
|
||||
self.playbackMarker.reparentTo(hidden)
|
||||
self.playbackMarker.reparentTo(ShowBaseGlobal.hidden)
|
||||
|
||||
def setNumSegs(self, value):
|
||||
self.numSegs = int(value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user