mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
support CInterval.popupControls()
This commit is contained in:
parent
5318552bcd
commit
045688d305
@ -28,11 +28,22 @@
|
|||||||
taskMgr.remove(self.getName() + '-play')
|
taskMgr.remove(self.getName() + '-play')
|
||||||
return self.getT()
|
return self.getT()
|
||||||
|
|
||||||
|
def setT(self, t, event = ETStep):
|
||||||
|
# Overridden from the C++ layer. We rename the C++ function
|
||||||
|
# in FFIRename to make this possible.
|
||||||
|
self.__cSetT(t, event)
|
||||||
|
if hasattr(self, "setTHooks"):
|
||||||
|
for func in self.setTHooks:
|
||||||
|
func(t)
|
||||||
|
|
||||||
def setFinalT(self):
|
def setFinalT(self):
|
||||||
# We have to define this at the Python level so we can
|
# We have to define this at the Python level so we can
|
||||||
# implicitly call stop().
|
# implicitly call stop().
|
||||||
self.stop()
|
self.stop()
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
if hasattr(self, "setTHooks"):
|
||||||
|
for func in self.setTHooks:
|
||||||
|
func(self.getT())
|
||||||
|
|
||||||
def isPlaying(self):
|
def isPlaying(self):
|
||||||
return taskMgr.hasTaskNamed(self.getName() + '-play')
|
return taskMgr.hasTaskNamed(self.getName() + '-play')
|
||||||
@ -40,7 +51,81 @@
|
|||||||
def __playTask(self, task):
|
def __playTask(self, task):
|
||||||
import Task
|
import Task
|
||||||
loopCount = self.stepPlay()
|
loopCount = self.stepPlay()
|
||||||
|
if hasattr(self, "setTHooks"):
|
||||||
|
for func in self.setTHooks:
|
||||||
|
func(self.getT())
|
||||||
if loopCount == 0 or self.__loop:
|
if loopCount == 0 or self.__loop:
|
||||||
return Task.cont
|
return Task.cont
|
||||||
else:
|
else:
|
||||||
return Task.done
|
return Task.done
|
||||||
|
|
||||||
|
def popupControls(self, tl = None):
|
||||||
|
""" popupControls()
|
||||||
|
Popup control panel for interval.
|
||||||
|
"""
|
||||||
|
import TkGlobal
|
||||||
|
import fpformat
|
||||||
|
import string
|
||||||
|
# I moved this here because Toontown does not ship Tk
|
||||||
|
from Tkinter import Toplevel, Frame, Button, LEFT, X
|
||||||
|
import Pmw
|
||||||
|
import EntryScale
|
||||||
|
if tl == None:
|
||||||
|
tl = Toplevel()
|
||||||
|
tl.title('Interval Controls')
|
||||||
|
outerFrame = Frame(tl)
|
||||||
|
self.es = es = EntryScale.EntryScale(
|
||||||
|
outerFrame, text = self.getName(),
|
||||||
|
min = 0, max = string.atof(fpformat.fix(self.getDuration(), 2)),
|
||||||
|
command = lambda t, s = self: s.setT(t))
|
||||||
|
# So when you drag scale with mouse its like you started a playback
|
||||||
|
def onPress(s=self,es=es):
|
||||||
|
# Kill playback task
|
||||||
|
s.stop()
|
||||||
|
# INIT interval
|
||||||
|
s.setT(es.get(), CInterval.ETInitialize)
|
||||||
|
es.onPress = onPress
|
||||||
|
# To make sure you stop free running intervals
|
||||||
|
es.onRelease = lambda s=self: s.stop()
|
||||||
|
# To update scale and execute intervals with ETInitialize
|
||||||
|
def onReturn(s = self, es = es):
|
||||||
|
s.setT(es.get(), CInterval.ETInitialize)
|
||||||
|
s.stop()
|
||||||
|
es.onReturnRelease = onReturn
|
||||||
|
es.pack(expand = 1, fill = X)
|
||||||
|
bf = Frame(outerFrame)
|
||||||
|
# Jump to start and end
|
||||||
|
def toStart(s=self, es=es):
|
||||||
|
s.setT(0.0, CInterval.ETInitialize)
|
||||||
|
s.stop()
|
||||||
|
def toEnd(s=self):
|
||||||
|
s.setT(s.getDuration(), CInterval.ETInitialize)
|
||||||
|
s.stop()
|
||||||
|
jumpToStart = Button(bf, text = '<<', command = toStart)
|
||||||
|
# Stop/play buttons
|
||||||
|
stop = Button(bf, text = 'Stop',
|
||||||
|
command = lambda s=self: s.stop())
|
||||||
|
play = Button(
|
||||||
|
bf, text = 'Play',
|
||||||
|
command = lambda s=self, es=es: s.play(es.get()))
|
||||||
|
jumpToEnd = Button(bf, text = '>>', command = toEnd)
|
||||||
|
jumpToStart.pack(side = LEFT, expand = 1, fill = X)
|
||||||
|
play.pack(side = LEFT, expand = 1, fill = X)
|
||||||
|
stop.pack(side = LEFT, expand = 1, fill = X)
|
||||||
|
jumpToEnd.pack(side = LEFT, expand = 1, fill = X)
|
||||||
|
bf.pack(expand = 1, fill = X)
|
||||||
|
outerFrame.pack(expand = 1, fill = X)
|
||||||
|
# Add function to update slider during setT calls
|
||||||
|
def update(t,es=es):
|
||||||
|
es.set(t, fCommand = 0)
|
||||||
|
if not hasattr(self, "setTHooks"):
|
||||||
|
self.setTHooks = []
|
||||||
|
self.setTHooks.append(update)
|
||||||
|
# Clear out function on destroy
|
||||||
|
def onDestroy(e, s=self, u=update):
|
||||||
|
if u in s.setTHooks:
|
||||||
|
s.setTHooks.remove(u)
|
||||||
|
tl.bind('<Destroy>', onDestroy)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,7 +479,8 @@ class FFIInterrogateDatabase:
|
|||||||
for typeDesc in typeDescs:
|
for typeDesc in typeDescs:
|
||||||
funcSpec = FFISpecs.MethodSpecification()
|
funcSpec = FFISpecs.MethodSpecification()
|
||||||
funcSpec.name = FFIRename.methodNameFromCppName(
|
funcSpec.name = FFIRename.methodNameFromCppName(
|
||||||
interrogate_function_name(funcIndex))
|
interrogate_function_name(funcIndex),
|
||||||
|
getTypeName(typeIndex))
|
||||||
funcSpec.typeDescriptor = typeDesc
|
funcSpec.typeDescriptor = typeDesc
|
||||||
funcSpec.index = funcIndex
|
funcSpec.index = funcIndex
|
||||||
funcSpecs.append(funcSpec)
|
funcSpecs.append(funcSpec)
|
||||||
@ -528,7 +529,8 @@ class FFIInterrogateDatabase:
|
|||||||
for typeDesc in typeDescs:
|
for typeDesc in typeDescs:
|
||||||
funcSpec = FFISpecs.GlobalFunctionSpecification()
|
funcSpec = FFISpecs.GlobalFunctionSpecification()
|
||||||
funcSpec.name = FFIRename.methodNameFromCppName(
|
funcSpec.name = FFIRename.methodNameFromCppName(
|
||||||
interrogate_function_name(funcIndex))
|
interrogate_function_name(funcIndex),
|
||||||
|
getTypeName(typeIndex))
|
||||||
funcSpec.typeDescriptor = typeDesc
|
funcSpec.typeDescriptor = typeDesc
|
||||||
funcSpec.index = funcIndex
|
funcSpec.index = funcIndex
|
||||||
# Here we look for the class in the first argument
|
# Here we look for the class in the first argument
|
||||||
|
@ -43,7 +43,8 @@ methodRenameDictionary = {
|
|||||||
'operator->' : 'dereference',
|
'operator->' : 'dereference',
|
||||||
'operator<<=' : '__ilshift__',
|
'operator<<=' : '__ilshift__',
|
||||||
'operator>>=' : '__irshift__',
|
'operator>>=' : '__irshift__',
|
||||||
'print' : 'Cprint'
|
'print' : 'Cprint',
|
||||||
|
'CInterval.setT' : '__cSetT',
|
||||||
}
|
}
|
||||||
|
|
||||||
classRenameDictionary = {
|
classRenameDictionary = {
|
||||||
@ -124,7 +125,7 @@ def nonClassNameFromCppName(cppName):
|
|||||||
newName = checkKeyword(newName)
|
newName = checkKeyword(newName)
|
||||||
return newName
|
return newName
|
||||||
|
|
||||||
def methodNameFromCppName(cppName):
|
def methodNameFromCppName(cppName, className = None):
|
||||||
methodName = ''
|
methodName = ''
|
||||||
badChars = ' '
|
badChars = ' '
|
||||||
nextCap = 0
|
nextCap = 0
|
||||||
@ -139,8 +140,11 @@ def methodNameFromCppName(cppName):
|
|||||||
nextCap = 0
|
nextCap = 0
|
||||||
else:
|
else:
|
||||||
methodName = methodName + char
|
methodName = methodName + char
|
||||||
if methodRenameDictionary.has_key(methodName):
|
|
||||||
methodName = methodRenameDictionary[methodName]
|
if className != None:
|
||||||
|
methodName = methodRenameDictionary.get(className + '.' + methodName, methodName)
|
||||||
|
methodName = methodRenameDictionary.get(methodName, methodName)
|
||||||
|
|
||||||
# Mangle names that happen to be python keywords so they are not anymore
|
# Mangle names that happen to be python keywords so they are not anymore
|
||||||
methodName = checkKeyword(methodName)
|
methodName = checkKeyword(methodName)
|
||||||
return methodName
|
return methodName
|
||||||
|
@ -71,7 +71,8 @@ class LerpPosInterval(LerpNodePathInterval):
|
|||||||
node, other)
|
node, other)
|
||||||
|
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(pos, startPos):
|
self.paramSetup = self.anyCallable(pos, startPos)
|
||||||
|
if self.paramSetup:
|
||||||
self.endPos = pos
|
self.endPos = pos
|
||||||
self.startPos = startPos
|
self.startPos = startPos
|
||||||
self.inPython = 1
|
self.inPython = 1
|
||||||
@ -80,10 +81,10 @@ class LerpPosInterval(LerpNodePathInterval):
|
|||||||
if startPos != None:
|
if startPos != None:
|
||||||
self.setStartPos(startPos)
|
self.setStartPos(startPos)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndPos, self.endPos)
|
self.setupParam(self.setEndPos, self.endPos)
|
||||||
self.setupParam(self.setStartPos, self.startPos)
|
self.setupParam(self.setStartPos, self.startPos)
|
||||||
LerpNodePathInterval.setT(self, t, event)
|
LerpNodePathInterval.setT(self, t, event)
|
||||||
@ -96,7 +97,8 @@ class LerpHprInterval(LerpNodePathInterval):
|
|||||||
node, other)
|
node, other)
|
||||||
|
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(hpr, startHpr):
|
self.paramSetup = self.anyCallable(hpr, startHpr)
|
||||||
|
if self.paramSetup:
|
||||||
self.endHpr = hpr
|
self.endHpr = hpr
|
||||||
self.startHpr = startHpr
|
self.startHpr = startHpr
|
||||||
self.inPython = 1
|
self.inPython = 1
|
||||||
@ -105,10 +107,10 @@ class LerpHprInterval(LerpNodePathInterval):
|
|||||||
if startHpr != None:
|
if startHpr != None:
|
||||||
self.setStartHpr(startHpr)
|
self.setStartHpr(startHpr)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndHpr, self.endHpr)
|
self.setupParam(self.setEndHpr, self.endHpr)
|
||||||
self.setupParam(self.setStartHpr, self.startHpr)
|
self.setupParam(self.setStartHpr, self.startHpr)
|
||||||
LerpNodePathInterval.setT(self, t, event)
|
LerpNodePathInterval.setT(self, t, event)
|
||||||
@ -119,7 +121,8 @@ class LerpScaleInterval(LerpNodePathInterval):
|
|||||||
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
||||||
node, other)
|
node, other)
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(scale, startScale):
|
self.paramSetup = self.anyCallable(scale, startScale)
|
||||||
|
if self.paramSetup:
|
||||||
self.endScale = scale
|
self.endScale = scale
|
||||||
self.startScale = startScale
|
self.startScale = startScale
|
||||||
self.inPython = 1
|
self.inPython = 1
|
||||||
@ -128,10 +131,10 @@ class LerpScaleInterval(LerpNodePathInterval):
|
|||||||
if startScale != None:
|
if startScale != None:
|
||||||
self.setStartScale(startScale)
|
self.setStartScale(startScale)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndScale, self.endScale)
|
self.setupParam(self.setEndScale, self.endScale)
|
||||||
self.setupParam(self.setStartScale, self.startScale)
|
self.setupParam(self.setStartScale, self.startScale)
|
||||||
LerpNodePathInterval.setT(self, t, event)
|
LerpNodePathInterval.setT(self, t, event)
|
||||||
@ -143,7 +146,8 @@ class LerpPosHprInterval(LerpNodePathInterval):
|
|||||||
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
||||||
node, other)
|
node, other)
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(pos, startPos, hpr, startHpr):
|
self.paramSetup = self.anyCallable(pos, startPos, hpr, startHpr)
|
||||||
|
if self.paramSetup:
|
||||||
self.endPos = pos
|
self.endPos = pos
|
||||||
self.startPos = startPos
|
self.startPos = startPos
|
||||||
self.endHpr = hpr
|
self.endHpr = hpr
|
||||||
@ -157,10 +161,10 @@ class LerpPosHprInterval(LerpNodePathInterval):
|
|||||||
if startHpr != None:
|
if startHpr != None:
|
||||||
self.setStartHpr(startHpr)
|
self.setStartHpr(startHpr)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndPos, self.endPos)
|
self.setupParam(self.setEndPos, self.endPos)
|
||||||
self.setupParam(self.setStartPos, self.startPos)
|
self.setupParam(self.setStartPos, self.startPos)
|
||||||
self.setupParam(self.setEndHpr, self.endHpr)
|
self.setupParam(self.setEndHpr, self.endHpr)
|
||||||
@ -175,7 +179,8 @@ class LerpHprScaleInterval(LerpNodePathInterval):
|
|||||||
node, other)
|
node, other)
|
||||||
|
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(hpr, startHpr, scale, startScale):
|
self.paramSetup = self.anyCallable(hpr, startHpr, scale, startScale)
|
||||||
|
if self.paramSetup:
|
||||||
self.endHpr = hpr
|
self.endHpr = hpr
|
||||||
self.startHpr = startHpr
|
self.startHpr = startHpr
|
||||||
self.endScale = scale
|
self.endScale = scale
|
||||||
@ -189,10 +194,10 @@ class LerpHprScaleInterval(LerpNodePathInterval):
|
|||||||
if startScale != None:
|
if startScale != None:
|
||||||
self.setStartScale(startScale)
|
self.setStartScale(startScale)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndHpr, self.endHpr)
|
self.setupParam(self.setEndHpr, self.endHpr)
|
||||||
self.setupParam(self.setStartHpr, self.startHpr)
|
self.setupParam(self.setStartHpr, self.startHpr)
|
||||||
self.setupParam(self.setEndScale, self.endScale)
|
self.setupParam(self.setEndScale, self.endScale)
|
||||||
@ -206,7 +211,8 @@ class LerpPosHprScaleInterval(LerpNodePathInterval):
|
|||||||
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
LerpNodePathInterval.__init__(self, name, duration, blendType,
|
||||||
node, other)
|
node, other)
|
||||||
# Check for functors in the input parameters.
|
# Check for functors in the input parameters.
|
||||||
if self.anyCallable(pos, startPos, hpr, startHpr, scale, startScale):
|
self.paramSetup = self.anyCallable(pos, startPos, hpr, startHpr, scale, startScale)
|
||||||
|
if self.paramSetup:
|
||||||
self.endPos = pos
|
self.endPos = pos
|
||||||
self.startPos = startPos
|
self.startPos = startPos
|
||||||
self.endHpr = hpr
|
self.endHpr = hpr
|
||||||
@ -225,10 +231,10 @@ class LerpPosHprScaleInterval(LerpNodePathInterval):
|
|||||||
if startScale != None:
|
if startScale != None:
|
||||||
self.setStartScale(startScale)
|
self.setStartScale(startScale)
|
||||||
|
|
||||||
def setT(self, t, event):
|
def setT(self, t, event = Interval.IVAL_NONE):
|
||||||
# This function is only used if Python functors were passed in
|
# This function is only used if Python functors were passed in
|
||||||
# for some of the input parameters.
|
# for some of the input parameters.
|
||||||
if event == Interval.IVAL_INIT:
|
if self.paramSetup and event == Interval.IVAL_INIT:
|
||||||
self.setupParam(self.setEndPos, self.endPos)
|
self.setupParam(self.setEndPos, self.endPos)
|
||||||
self.setupParam(self.setStartPos, self.startPos)
|
self.setupParam(self.setStartPos, self.startPos)
|
||||||
self.setupParam(self.setEndHpr, self.endHpr)
|
self.setupParam(self.setEndHpr, self.endHpr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user