# HG changeset patch # User wycc # Date 1293727798 -28800 # Node ID 96a7abce774a6fdf7cdfff6bda6d8c5832ff973b # Parent 178b126edd2cdc25209c655a43c75f067bb615f0 Add functions to insert and remove frame. diff -r 178b126edd2c -r 96a7abce774a pyink/MBScene.py --- a/pyink/MBScene.py Thu Dec 30 11:50:02 2010 +0800 +++ b/pyink/MBScene.py Fri Dec 31 00:49:58 2010 +0800 @@ -82,7 +82,6 @@ def notifyChildOrderChanged(self,node,child,prev): pass def notifyContentChanged(self,node,old_content,new_content): - print 'cont' if self.type == 'DOMSubtreeModified': self.func(node) def notifyAttributeChanged(self,node, name, old_value, new_value): @@ -450,7 +449,6 @@ ns.setAttribute("id",gid) ns.setAttribute("inkscape:groupmode","layer") self.last_line.node.appendChild(ns) - print 'Add key ', x self.last_line.add_keyframe(x,ns) self.update() pass @@ -727,11 +725,9 @@ self.scrollwin.add_with_viewport(vbox) self.scrollwin_vbox = vbox else: - self.scrollwin.remove(self.scrollwin_vbox) - vbox = gtk.VBox() - vbox.show() - self.scrollwin.add_with_viewport(vbox) - self.scrollwin_vbox = vbox + for c in self.scrollwin_vbox.get_children(): + self.scrollwin_vbox.remove(c) + vbox = self.scrollwin_vbox pass nframes = 100 @@ -767,6 +763,7 @@ line.layer = self.layers[i] line.connect('motion-notify-event', self._remove_active_frame) pass + vbox.show_all() pass ## \brief Update conetent of frameliens according layers. @@ -930,28 +927,57 @@ traceback.print_exc() raise self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) - + + def doInsertScene(self,w): + self.lockui=True + self.last_line.insert_frame(self.last_frame) + self.update() + self.lockui=False + + def doRemoveScene(self,w): + self.lockui=True + self.last_line.remove_frame(self.last_frame) + self.update() + self.lockui=False def addButtons(self,hbox): #btn = gtk.Button('Edit') #btn.connect('clicked', self.doEditScene) #hbox.pack_start(btn,expand=False,fill=False) + btn = gtk.Button('Insert Key') btn.connect('clicked',self.doInsertKeyScene) hbox.pack_start(btn,expand=False,fill=False) + btn=gtk.Button('Remove Key') btn.connect('clicked', self.doRemoveScene) hbox.pack_start(btn,expand=False,fill=False) + btn=gtk.Button('Extend scene') btn.connect('clicked', self.doExtendScene) hbox.pack_start(btn,expand=False,fill=False) + + btn=gtk.Button('Duplicate Key') + btn.connect('clicked', self.doDuplicateKeyScene) + hbox.pack_start(btn,expand=False,fill=False) + btn=gtk.Button('Duplicate Key') btn.connect('clicked', self.doDuplicateKeyScene) hbox.pack_start(btn,expand=False,fill=False) + + btn=gtk.Button('Insert') + btn.connect('clicked', self.doInsertScene) + hbox.pack_start(btn,expand=False,fill=False) + + btn=gtk.Button('Remove') + btn.connect('clicked', self.doRemoveScene) + hbox.pack_start(btn,expand=False,fill=False) + btn=gtk.Button('Run') btn.connect('clicked', self.doRun) self.btnRun = btn hbox.pack_start(btn,expand=False,fill=False) + self.addNameEditor(hbox) self.addTweenTypeSelector(hbox) pass diff -r 178b126edd2c -r 96a7abce774a pyink/frameline.py --- a/pyink/frameline.py Thu Dec 30 11:50:02 2010 +0800 +++ b/pyink/frameline.py Fri Dec 31 00:49:58 2010 +0800 @@ -660,6 +660,55 @@ pos = self._find_keyframe(idx) self._keys[pos].right_tween = TRue + def remove_frame(self, idx): + pos = self._find_keyframe_floor(idx) + if pos != -1: + key = self._keys[pos] + if key.idx == idx: + if key.left_tween: + self._keys[pos-1].right_tween = False + del self._keys[pos] + while pos < len(self._keys): + self._keys[pos].idx = self._keys[pos].idx - 1 + pos = pos+1 + self.update() + # Use remove key frame to remove the key frame + return + elif key.right_tween: + pos = pos + 1 + while pos < len(self._keys): + self._keys[pos].idx = self._keys[pos].idx - 1 + pos = pos + 1 + if self._drawing: + self.update() + else: + return + pass + pass + + def insert_frame(self,idx): + pos = self._find_keyframe_floor(idx) + if pos != -1: + key = self._keys[pos] + if key.idx == idx: + while pos < len(self._keys): + self._keys[pos].idx = self._keys[pos].idx + 1 + pos = pos + 1 + if self._drawing: + self.update() + return + elif key.right_tween: + pos = pos + 1 + while pos < len(self._keys): + self._keys[pos].idx = self._keys[pos].idx + 1 + pos = pos + 1 + if self._drawing: + self.update() + else: + return + pass + pass + pass def rm_keyframe(self, idx): key_pos = self._find_keyframe(idx) key = self._keys[key_pos] @@ -678,7 +727,6 @@ left_key.right_tween = False redraw_range = (idx, left_key.idx + 1) pass - for i in range(*redraw_range): self._draw_frame(i) pass else: diff -r 178b126edd2c -r 96a7abce774a pyink/primitive_test.svg --- a/pyink/primitive_test.svg Thu Dec 30 11:50:02 2010 +0800 +++ b/pyink/primitive_test.svg Fri Dec 31 00:49:58 2010 +0800 @@ -30,12 +30,12 @@ inkscape:cx="174.98236" inkscape:cy="910.80426" inkscape:document-units="px" - inkscape:current-layer="layer3" + inkscape:current-layer="icon3s9194" showgrid="false" - inkscape:window-width="777" + inkscape:window-width="1222" inkscape:window-height="639" - inkscape:window-x="594" - inkscape:window-y="229" + inkscape:window-x="199" + inkscape:window-y="151" inkscape:window-maximized="0" /> @@ -119,8 +119,8 @@ + style="display:none" + id="g3178" /> + id="g3172"> + ref="path3112" + id="g3174" + transform="matrix(1,0,0,1,0,0)"> + sodipodi:rx="29.285715" + sodipodi:ry="28.571428" + d="m 102.85714,46.647896 c 0,15.779564 -13.11166,28.571428 -29.285714,28.571428 -16.174053,0 -29.285715,-12.791864 -29.285715,-28.571428 0,-15.779564 13.111662,-28.571428 29.285715,-28.571428 16.174054,0 29.285714,12.791864 29.285714,28.571428 z" /> @@ -249,1513 +251,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + sodipodi:insensitive="1" + style="" + id="g3166"> - - - - - - - - - + ref="path3105-1" + id="g3168" + transform="matrix(1,0,0,1,0.779221,49.0909)"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + transform="translate(86.428574,1.4285721)" /> + inkscape:label="icon3" + style="display:inline"> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + sodipodi:insensitive="true" + id="g3164" + style="display:none"> + +