*** empty log message ***

This commit is contained in:
Joe Shochet 2001-05-18 02:57:55 +00:00
parent 1dc935715f
commit 3a79e9709d
9 changed files with 71 additions and 51 deletions

View File

@ -710,3 +710,5 @@ class DisplayRegionContext:
# Continue the task
return Task.cont
# Create one
__builtin__.direct = base.direct = DirectSession()

View File

@ -784,6 +784,7 @@
base.wantDIRECT = 1
base.wantTk = 1
from ShowBaseGlobal import *
from DirectSession import *
import TkGlobal
import Placer
return Placer.place(self)

View File

@ -104,6 +104,9 @@ class FSM(DirectObject):
def setFinalState(self, finalStateName):
"""setFinalState(self, string)"""
self.__finalState = self.getStateNamed(finalStateName)
def requestFinalState(self):
self.request(self.__finalState.getName())
def getCurrentState(self):
"""getCurrentState(self)"""

View File

@ -9,6 +9,9 @@ class Button(DirectObject):
def __init__(self, name,
label = None,
# If you have labels you want to use for the
# various states, pass them as a list in labels
labels = None,
scale = 0.1,
width = None,
align = None,
@ -27,7 +30,7 @@ class Button(DirectObject):
self.width = width
# if no label given, use the button name
if (label == None):
if (label == None) and (labels == None):
label = self.name
self.inactive = inactive
@ -60,7 +63,7 @@ class Button(DirectObject):
self.lUp = Label.modelLabel(label,
geomRect = geomRect,
style = upStyle,
scale = scale,
scale = (scale, scale),
drawOrder = drawOrder)
if width == None:
@ -70,23 +73,27 @@ class Button(DirectObject):
self.lLit = Label.modelLabel(label,
geomRect = geomRect,
style = litStyle,
scale = scale,
scale = (scale, scale),
drawOrder = drawOrder)
self.lDown = Label.modelLabel(label,
geomRect = geomRect,
style = downStyle,
scale = scale,
scale = (scale, scale),
drawOrder = drawOrder)
if supportInactive:
self.lInactive = Label.modelLabel(label,
geomRect = geomRect,
style = inactiveStyle,
scale = scale,
scale = (scale, scale),
drawOrder = drawOrder)
else:
# label provided, use it for all labels
self.lUp = self.lLit = self.lDown = self.lInactive = label
if labels:
# label provided, use it for all labels
self.lUp, self.lLit, self.lDown, self.lInactive = labels
else:
# label provided, use it for all labels
self.lUp = self.lLit = self.lDown = self.lInactive = label
if width == None:
width = self.lUp.getWidth()

View File

@ -157,56 +157,47 @@ def textLabelAndText(string, style,
def modelLabel(model,
geomRect = None,
style = None,
scale = 0.1,
scale = (0.1, 0.1),
drawOrder = getDefaultDrawOrder()):
# Preserve transitions on the arc by creating an intervening node.
topnode = NamedNode('model')
topnp = NodePath(topnode)
mi = model.instanceTo(topnp)
mi.setScale(scale)
mi.setScale(scale[0], scale[0], scale[1])
mi.setBin('fixed', drawOrder)
if style != None:
# For a modelLabel, the style determines the color that may be
# applied.
color = None
color = None
# The style might *itself* be a four-component color.
if (isinstance(style, types.TupleType) or
isinstance(style, VBase4)):
color = style
# Otherwise, there might be a predefined default color for one
# of the canned styles. Most don't have a default color,
# though.
elif style == ButtonInactive:
color = (0.5, 0.5, 0.5, 1.0)
color = (0.5, 0.5, 0.5, 1.0)
if color != None:
mi.setColor(color[0], color[1], color[2], color[3])
if color[3] != 1.0:
mi.setTransparency(1)
mi.setTransparency(1)
if geomRect == None:
geomRect = (1, 1)
if len(geomRect) == 2:
# If we got only two parameters, it's height and width.
label = GuiLabel.makeModelLabel(topnode,
geomRect[0] * scale,
geomRect[1] * scale)
geomRect[0] * scale[0],
geomRect[1] * scale[1])
elif len(geomRect) == 4:
# If we got four, they're left, right, bottom, top.
label = GuiLabel.makeModelLabel(topnode,
geomRect[0] * scale,
geomRect[1] * scale,
geomRect[2] * scale,
geomRect[3] * scale)
geomRect[0] * scale[0],
geomRect[1] * scale[0],
geomRect[2] * scale[1],
geomRect[3] * scale[1])
else:
raise ValueError
raise ValueError
label.setDrawOrder(drawOrder)
return label

View File

@ -19,7 +19,10 @@ class ScrollingLabel(PandaObject.PandaObject):
width = None,
drawOrder = getDefaultDrawOrder(),
font = getDefaultFont(),
showLabels = 1):
showLabels = 1,
leftLabels = None,
rightLabels = None,
):
self.name = name
if (label == None):
@ -65,22 +68,37 @@ class ScrollingLabel(PandaObject.PandaObject):
self.title)
# create the scroll buttons
self.leftButton = Button.Button(self.eventName + "-left",
label = " < ",
scale = scale,
drawOrder = drawOrder,
font = font, event = "left-button")
if leftLabels:
self.leftButton = Button.Button(self.eventName + "-left",
labels = leftLabels,
scale = scale,
drawOrder = drawOrder,
font = font, event = "left-button")
else:
self.leftButton = Button.Button(self.eventName + "-left",
label = " < ",
scale = scale,
drawOrder = drawOrder,
font = font, event = "left-button")
self.leftButton.getGuiItem().setUpRolloverEvent(self.eventName + "-rollover")
self.frame.addItem(self.leftButton)
self.frame.packItem(self.leftButton, GuiFrame.GuiFrame.UNDER,
self.title)
self.frame.packItem(self.leftButton, GuiFrame.GuiFrame.LEFT,
self.title)
self.rightButton = Button.Button(self.eventName + "-right",
label = " > ",
scale = scale,
drawOrder = drawOrder,
font = font, event = "right-button")
self.title)
if rightLabels:
self.rightButton = Button.Button(self.eventName + "-right",
labels = rightLabels,
scale = scale,
drawOrder = drawOrder,
font = font, event = "right-button")
else:
self.rightButton = Button.Button(self.eventName + "-right",
label = " > ",
scale = scale,
drawOrder = drawOrder,
font = font, event = "right-button")
self.rightButton.getGuiItem().setUpRolloverEvent(self.eventName + "-rollover")
self.frame.addItem(self.rightButton)
self.frame.packItem(self.rightButton, GuiFrame.GuiFrame.UNDER,

View File

@ -6,16 +6,16 @@ class DirectObject:
"""
This is the class that all Direct/SAL classes should inherit from
"""
def __del__(self):
#def __del__(self):
# print "Destructing: ", self.__class__.__name__
# This is really old and we really should not be relying on it
# One day I'll see if anybody still needs this
try:
self.cleanup()
except AttributeError:
# No cleanup() method defined
pass
#try:
# self.cleanup()
#except AttributeError:
# # No cleanup() method defined
# pass
# Event Handling

View File

@ -122,7 +122,7 @@ class Messenger:
if self.dict.has_key(event):
acceptorDict = self.dict[event]
for object in acceptorDict.keys():
for object in self.dict[event].keys():
# We have to make this apparently redundant check, because
# it is possible that one object removes its own hooks
# in response to a handler called by a previous object.
@ -136,10 +136,9 @@ class Messenger:
# have done an ignore.
if acceptorDict.has_key(object):
del acceptorDict[object]
# If this dictionary is now empty, remove the event
# If the dictionary at this event is now empty, remove the event
# entry from the Messenger alltogether
if ((len(acceptorDict) == 0) and
(self.dict.has_key(event))):
if (self.dict.has_key(event) and (len(self.dict[event]) == 0)):
del self.dict[event]
def clear(self):

View File

@ -23,7 +23,6 @@ __builtin__.directNotify = directNotify
# Initialize DIRECT
if base.wantDIRECT:
from DirectSession import *
__builtin__.direct = base.direct = DirectSession()
direct.enable()
else:
# Otherwise set the values to None