Timeline redone
This commit is contained in:
parent
d1d1d005b6
commit
6fea123682
5
base.js
5
base.js
|
|
@ -16,6 +16,11 @@ function log(str){
|
||||||
setTimeout("appendError('"+str+"')", 1)
|
setTimeout("appendError('"+str+"')", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trace(str) {
|
||||||
|
//Placeholder
|
||||||
|
log(str);
|
||||||
|
}
|
||||||
|
|
||||||
function _timerBase () {
|
function _timerBase () {
|
||||||
/* This provides the 'tick' by which all animations are run.
|
/* This provides the 'tick' by which all animations are run.
|
||||||
Playing animations should have their ._draw() method added here;
|
Playing animations should have their ._draw() method added here;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ def onLoadFrames(self):
|
||||||
def onClickFrame(self, x, y):
|
def onClickFrame(self, x, y):
|
||||||
root.descendItem().activelayer.frames[root.descendItem().activelayer.currentframe].actions = MainWindow.scriptwindow.text
|
root.descendItem().activelayer.frames[root.descendItem().activelayer.currentframe].actions = MainWindow.scriptwindow.text
|
||||||
root.descendItem().activeframe = int(x/16)
|
root.descendItem().activeframe = int(x/16)
|
||||||
|
print ">>>>>> ", x, y
|
||||||
MainWindow.stage.draw()
|
MainWindow.stage.draw()
|
||||||
MainWindow.scriptwindow.text = str(root.descendItem().activelayer.frames[root.descendItem().activelayer.currentframe].actions)
|
MainWindow.scriptwindow.text = str(root.descendItem().activelayer.frames[root.descendItem().activelayer.currentframe].actions)
|
||||||
def onKeyDownFrame(self, key):
|
def onKeyDownFrame(self, key):
|
||||||
|
|
@ -264,12 +265,14 @@ b = svlgui.Image("media/object_active.png",0,0,True,MainWindow.layerbox,16,1,Tru
|
||||||
layers.add(b)
|
layers.add(b)
|
||||||
MainWindow.layerbox.add(layers,0,0)
|
MainWindow.layerbox.add(layers,0,0)
|
||||||
|
|
||||||
frames = svlgui.Group(onload=onLoadFrames,skipl=True)
|
#frames = svlgui.Group(onload=onLoadFrames,skipl=True)
|
||||||
b = svlgui.Image("media/keyframe_active.png",0,0,True,MainWindow.timelinebox,16,1,True)
|
#b = svlgui.Image("media/keyframe_active.png",0,0,True,MainWindow.timelinebox,16,1,True)
|
||||||
frames.add(b)
|
#frames.add(b)
|
||||||
frames.onMouseDown = onClickFrame
|
#frames.onMouseDown = onClickFrame
|
||||||
frames.onKeyDown = onKeyDownFrame
|
#frames.onKeyDown = onKeyDownFrame
|
||||||
MainWindow.timelinebox.add(frames,0,0)
|
#MainWindow.timelinebox.add(frames,0,0)
|
||||||
|
MainWindow.timelinebox.root = root
|
||||||
|
MainWindow.timelinebox.onMouseDown = onClickFrame
|
||||||
|
|
||||||
|
|
||||||
def new_file(widget=None):
|
def new_file(widget=None):
|
||||||
|
|
@ -288,6 +291,7 @@ def open_file(widget=None):
|
||||||
root = pickle.load(thefile)
|
root = pickle.load(thefile)
|
||||||
MainWindow.stage.add(root, 0, 0)
|
MainWindow.stage.add(root, 0, 0)
|
||||||
MainWindow.stage.draw()
|
MainWindow.stage.draw()
|
||||||
|
MainWindow.timelinebox.root = root
|
||||||
MainWindow.timelinebox.draw()
|
MainWindow.timelinebox.draw()
|
||||||
def open_sc_file(widget=None):
|
def open_sc_file(widget=None):
|
||||||
pass
|
pass
|
||||||
|
|
@ -315,9 +319,8 @@ def quit(widget):
|
||||||
|
|
||||||
|
|
||||||
def add_keyframe(widget=None):
|
def add_keyframe(widget=None):
|
||||||
|
print "af> ", root.descendItem().activeframe
|
||||||
root.descendItem().add_frame(True)
|
root.descendItem().add_frame(True)
|
||||||
b = svlgui.Image("media/keyframe_active.png",root.descendItem().activeframe*16,0,True,MainWindow.timelinebox,16,1,True)
|
|
||||||
frames.add(b)
|
|
||||||
MainWindow.timelinebox.draw()
|
MainWindow.timelinebox.draw()
|
||||||
def add_layer(widget=None):
|
def add_layer(widget=None):
|
||||||
root.descendItem().add_layer(root.descendItem()._al)
|
root.descendItem().add_layer(root.descendItem()._al)
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ class MainWindowOSX:
|
||||||
self.stage = svlgui.Canvas(800,600)
|
self.stage = svlgui.Canvas(800,600)
|
||||||
misc_funcs.stage = self.stage
|
misc_funcs.stage = self.stage
|
||||||
self.layerbox = svlgui.Canvas(128,320)
|
self.layerbox = svlgui.Canvas(128,320)
|
||||||
self.timelinebox = svlgui.Canvas(2000,320)
|
self.timelinebox = svlgui.FramesCanvas(2000,320)
|
||||||
self.frame = svlgui.Frame()
|
self.frame = svlgui.Frame()
|
||||||
self.toolbox = svlgui.Grid([svlgui.Button("------"),svlgui.Button("------")],
|
self.toolbox = svlgui.Grid([svlgui.Button("------"),svlgui.Button("------")],
|
||||||
[svlgui.Button("------"),svlgui.Button("------")],
|
[svlgui.Button("------"),svlgui.Button("------")],
|
||||||
|
|
|
||||||
65
svlgui.py
65
svlgui.py
|
|
@ -1957,6 +1957,71 @@ class PreferencesWindow:
|
||||||
frame.layout_self([label,0,None,0,None,"nw",""])
|
frame.layout_self([label,0,None,0,None,"nw",""])
|
||||||
win.present()
|
win.present()
|
||||||
|
|
||||||
|
class FramesCanvas(Canvas):
|
||||||
|
def __init__(self,w,h):
|
||||||
|
Canvas.__init__(self,w,h)
|
||||||
|
self.pointer = 1
|
||||||
|
if SYSTEM == 'osx':
|
||||||
|
self.canvas.draw = self._draw
|
||||||
|
self.canvas.mouse_down = self.mouse_down
|
||||||
|
self.ackfr = GUI.Image(file = "media/keyframe_active.png")
|
||||||
|
self.inackfr = GUI.Image(file = "media/keyframe_inactive.png")
|
||||||
|
self.acfr = GUI.Image(file = "media/frame_active_tween.png")
|
||||||
|
self.inacfr = GUI.Image(file = "media/frame_inactive_tween.png")
|
||||||
|
def _draw(self,cr,update_rect):
|
||||||
|
for k in xrange(len(self.root.descendItem().layers)):
|
||||||
|
FRAMES = self.root.descendItem().layers[k].frames
|
||||||
|
for i in xrange(len(FRAMES)):
|
||||||
|
cr.gsave()
|
||||||
|
#cr.translate(i*16,k*32)
|
||||||
|
if FRAMES[i]:
|
||||||
|
if self.root.descendItem().currentframe == i:
|
||||||
|
src_rect = self.ackfr.bounds
|
||||||
|
src_rect = [0,0,(16)*(self.pointer%17),32]
|
||||||
|
dst_rect = [i*16, k*32, 16+i*16, 32+k*32]
|
||||||
|
print dst_rect
|
||||||
|
self.ackfr.draw(cr, src_rect, dst_rect)
|
||||||
|
else:
|
||||||
|
src_rect = self.inackfr.bounds
|
||||||
|
dst_rect = [i*16, k*32, 16+i*16, 32+k*32]
|
||||||
|
self.inackfr.draw(cr, src_rect, dst_rect)
|
||||||
|
else:
|
||||||
|
if self.root.descendItem() == i:
|
||||||
|
src_rect = self.acfr.bounds
|
||||||
|
dst_rect = [i*16, k*32, 16+i*16, 32+k*32]
|
||||||
|
self.acfr.draw(cr, src_rect, dst_rect)
|
||||||
|
else:
|
||||||
|
src_rect = self.inacfr.bounds
|
||||||
|
dst_rect = [i*16, k*32, 16+i*16, 32+k*32]
|
||||||
|
self.inacfr.draw(cr, src_rect, dst_rect)
|
||||||
|
cr.grestore()
|
||||||
|
print max(len(FRAMES),int(update_rect[0]/16-1)),int(update_rect[2]/16+1)
|
||||||
|
for i in xrange(max(len(FRAMES),int(update_rect[0]/16-1)),int(update_rect[2]/16+1)):
|
||||||
|
cr.newpath()
|
||||||
|
cr.rect([i*16,k*32,i*16+16,k*32+32])
|
||||||
|
if self.root.descendItem().activeframe==i:
|
||||||
|
cr.fillcolor = Color([0.2,0.2,0.2]).pygui
|
||||||
|
cr.fill()
|
||||||
|
elif i%5==0:
|
||||||
|
cr.fillcolor = Color([0.5,0.5,0.5]).pygui
|
||||||
|
cr.fill()
|
||||||
|
print i
|
||||||
|
else:
|
||||||
|
cr.fillcolor = Color([1.0,1.0,1.0]).pygui
|
||||||
|
cr.fill()
|
||||||
|
cr.newpath()
|
||||||
|
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()
|
||||||
|
|
||||||
|
def mouse_down(self, event):
|
||||||
|
x, y = event.position
|
||||||
|
self.onMouseDown(self,x, y)
|
||||||
|
self.canvas.invalidate_rect([0,0,self.canvas.extent[0],self.canvas.extent[1]])
|
||||||
|
def onMouseDown(self,self1,x, y):
|
||||||
|
print "Nananana"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#Executes the main loop for whatever GUI is running
|
#Executes the main loop for whatever GUI is running
|
||||||
if SYSTEM=="gtk":
|
if SYSTEM=="gtk":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue