Can now move keyframes.
This commit is contained in:
parent
58b3abe5dd
commit
b2e6b88f5e
|
|
@ -82,6 +82,7 @@ def onLoadFrames(self):
|
|||
j = box(i*16,0,16,32,svlgui.Color([1,1,1]))
|
||||
self.add(j)'''
|
||||
def onClickFrame(self, x, y,button=1,clicks=1):
|
||||
self.clicks = clicks
|
||||
root.descendItem().activelayer.frames[root.descendItem().activelayer.currentframe].actions = MainWindow.scriptwindow.text
|
||||
root.descendItem().activeframe = int(x/16)
|
||||
print ">>>>>> ", x, y
|
||||
|
|
@ -164,6 +165,8 @@ def onMouseDownText(self,x,y,button=1,clicks=1):
|
|||
self.obj.editing = True
|
||||
def onMouseDownFrame(self, x, y,button=1,clicks=1):
|
||||
pass
|
||||
def onMouseDownMC(self, x, y, button=1, clicks=1):
|
||||
print clicks
|
||||
def onMouseUpGroup(self, x, y,button=1,clicks=1):
|
||||
self.clicked = False
|
||||
if svlgui.MODE in ["r", "e"]:
|
||||
|
|
@ -199,6 +202,22 @@ def onMouseUpObj(self, x, y,button=1,clicks=1):
|
|||
del undo_stack[-1]
|
||||
def onMouseUpText(self, x, y,button=1,clicks=1):
|
||||
self.clicked = False
|
||||
def onMouseUpFrame(self, x, y, button=1, clicks=1):
|
||||
self.x = None
|
||||
if root.descendItem().activeframe==root.descendItem().activelayer.currentframe:
|
||||
index = int(x/16)
|
||||
if index>len(root.descendItem().activelayer.frames):
|
||||
[root.descendItem().activelayer.frames.append(None) for i in xrange(len(root.descendItem().activelayer.frames),index+1)]
|
||||
if index>root.descendItem().activeframe:
|
||||
print "bigger"
|
||||
root.descendItem().activelayer.frames.insert(index, root.descendItem().activelayer.frames.pop(root.descendItem().activeframe))
|
||||
else:
|
||||
root.descendItem().activelayer.frames.insert(index, root.descendItem().activelayer.frames.pop(root.descendItem().activeframe))
|
||||
if not any(root.activelayer.frames[index+1:]):
|
||||
root.descendItem().activelayer.frames = root.descendItem().activelayer.frames[:index+1]
|
||||
root.descendItem().currentframe = index
|
||||
print root.descendItem().activelayer.frames
|
||||
|
||||
def onMouseMoveGroup(self, x, y,button=1):
|
||||
pass
|
||||
#This is for testing rotation. Comment out before any commit!
|
||||
|
|
@ -251,7 +270,9 @@ def onMouseDragObj(self, x, y,button=1,clicks=1):
|
|||
def onMouseDragText(self, x, y,button=1,clicks=1):
|
||||
self.x = x-self.initx
|
||||
self.y = y-self.inity
|
||||
|
||||
def onMouseDragFrame(self, x, y, button=1, clicks=1):
|
||||
if root.descendItem().activeframe==root.descendItem().activelayer.currentframe:
|
||||
self.x = x
|
||||
def onKeyDownGroup(self, key):
|
||||
if not svlgui.EDITING:
|
||||
if key in [" ", "s", "r", "e", "b", "p"]:
|
||||
|
|
@ -482,6 +503,8 @@ MainWindow.layerbox.add(layers,0,0)
|
|||
#MainWindow.timelinebox.add(frames,0,0)
|
||||
MainWindow.timelinebox.root = root
|
||||
MainWindow.timelinebox.onMouseDown = onClickFrame
|
||||
MainWindow.timelinebox.onMouseDrag = onMouseDragFrame
|
||||
MainWindow.timelinebox.onMouseUp = onMouseUpFrame
|
||||
|
||||
|
||||
def new_file(widget=None):
|
||||
|
|
@ -764,7 +787,7 @@ def convert_to_symbol(widget=None):
|
|||
svlgui.alert("No object selected!")
|
||||
return
|
||||
else:
|
||||
svlgui.ConvertToSymbolWindow(root)
|
||||
svlgui.ConvertToSymbolWindow(root, onMouseDownMC)
|
||||
MainWindow.stage.draw()
|
||||
|
||||
def about(widget=None):
|
||||
|
|
|
|||
34
svlgui.py
34
svlgui.py
|
|
@ -3121,8 +3121,9 @@ class PublishSettingsWindow:
|
|||
self.win.ok()
|
||||
|
||||
class ConvertToSymbolWindow:
|
||||
def __init__(self,root):
|
||||
def __init__(self,root,onMouseDown):
|
||||
self.root = root
|
||||
self.onMouseDown = onMouseDown
|
||||
if SYSTEM=="osx":
|
||||
self.win = ModalDialog(closable=True,width=400,height=150)
|
||||
self.win.title = "Convert to symbol"
|
||||
|
|
@ -3154,20 +3155,25 @@ class ConvertToSymbolWindow:
|
|||
self.root.descendItem().activelayer.delete(self.root.descendItem().activelayer.currentselect)
|
||||
print self.root.descendItem().activelayer.currentFrame()
|
||||
self.root.descendItem().activelayer.add(symbol)
|
||||
symbol.onMouseDown = self.onMouseDown
|
||||
self.win.ok()
|
||||
|
||||
class FramesCanvas(Canvas):
|
||||
def __init__(self,w,h):
|
||||
Canvas.__init__(self,w,h)
|
||||
self.pointer = 1
|
||||
self.x = None
|
||||
if SYSTEM == 'osx':
|
||||
self.canvas.draw = self._draw
|
||||
self.canvas.mouse_down = self.mouse_down
|
||||
self.canvas.mouse_drag = self.mouse_drag
|
||||
self.canvas.mouse_up = self.mouse_up
|
||||
self.ackfr = GUI.Image(file = media_path+"media/keyframe_active.png")
|
||||
self.inackfr = GUI.Image(file = media_path+"media/keyframe_inactive.png")
|
||||
self.acfr = GUI.Image(file = media_path+"media/frame_active_tween.png")
|
||||
self.inacfr = GUI.Image(file = media_path+"media/frame_inactive_tween.png")
|
||||
def _draw(self,cr,update_rect):
|
||||
try:
|
||||
for k in xrange(len(self.root.descendItem().layers)):
|
||||
FRAMES = self.root.descendItem().layers[k].frames
|
||||
for i in xrange(len(FRAMES)):
|
||||
|
|
@ -3222,13 +3228,31 @@ class FramesCanvas(Canvas):
|
|||
cr.fillcolor = Color([0.1,0.1,0.1]).pygui
|
||||
cr.rect([i*16+15,k*32,i*16+16,k*32+32])
|
||||
cr.fill()
|
||||
|
||||
if self.x:
|
||||
src_rect = [0,0,16,32]
|
||||
dst_rect = [self.x-8, 0, self.x+8, 32]
|
||||
self.ackfr.draw(cr,src_rect,dst_rect)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
def mouse_down(self, event):
|
||||
x, y = event.position
|
||||
self.onMouseDown(self,x, y)
|
||||
clicks = event.num_clicks
|
||||
self.onMouseDown(self,x, y, clicks)
|
||||
self.canvas.invalidate_rect([0,0,self.canvas.extent[0],self.canvas.extent[1]])
|
||||
def onMouseDown(self,self1,x, y):
|
||||
print "Nananana"
|
||||
def mouse_drag(self, event):
|
||||
x, y = event.position
|
||||
self.onMouseDrag(self,x, y)
|
||||
self.canvas.invalidate_rect([0,0,self.canvas.extent[0],self.canvas.extent[1]])
|
||||
def mouse_up(self, event):
|
||||
x, y = event.position
|
||||
self.onMouseUp(self,x, y)
|
||||
self.canvas.invalidate_rect([0,0,self.canvas.extent[0],self.canvas.extent[1]])
|
||||
def onMouseDown(self,self1,x, y, button=1, clicks=1):
|
||||
pass
|
||||
def onMouseDrag(self, self1, x, y, button=1, clicks=1):
|
||||
pass
|
||||
def onMouseUp(self, self1, x, y, button=1, clicks=1):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
Loading…
Reference in New Issue