comparison pyink/MBScene.py @ 1164:2cb5047d8f2b

Add support to insert key frame in the middle of the tween.
author wycc
date Wed, 29 Dec 2010 00:33:48 +0800
parents c23593881507
children d73ef03c96de
comparison
equal deleted inserted replaced
1163:c23593881507 1164:2cb5047d8f2b
416 """ 416 """
417 x = self.last_frame 417 x = self.last_frame
418 y = self.last_line 418 y = self.last_line
419 rdoc = self.document 419 rdoc = self.document
420 ns = rdoc.createElement("svg:g") 420 ns = rdoc.createElement("svg:g")
421 txt = rdoc.createElement("svg:rect") 421 found = False
422 txt.setAttribute("x","0") 422 for node in self.last_line.node.childList():
423 txt.setAttribute("y","0") 423 try:
424 txt.setAttribute("width","100") 424 label = node.getAttribute("inkscape:label")
425 txt.setAttribute("height","100") 425 except:
426 txt.setAttribute("style","fill:#ff00") 426 continue
427 ns.appendChild(txt) 427 if label == "dup":
428 for n in node.childList():
429 ns.appendChild(n.duplicate(self.document))
430 found = True
431 node.setAttribute("style","display:none")
432 break
433 pass
434 pass
435
436 if found == False:
437 txt = rdoc.createElement("svg:rect")
438 txt.setAttribute("x","0")
439 txt.setAttribute("y","0")
440 txt.setAttribute("width","100")
441 txt.setAttribute("height","100")
442 txt.setAttribute("style","fill:#ff00")
443 ns.appendChild(txt)
444
428 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID() 445 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID()
429 self.ID[gid]=1 446 self.ID[gid]=1
430 ns.setAttribute("id",gid) 447 ns.setAttribute("id",gid)
431 ns.setAttribute("inkscape:groupmode","layer") 448 ns.setAttribute("inkscape:groupmode","layer")
432 self.last_line.node.appendChild(ns) 449 self.last_line.node.appendChild(ns)
747 layer = frameline.layer 764 layer = frameline.layer
748 if frameline.node.getAttribute("inkscape:label")==None: 765 if frameline.node.getAttribute("inkscape:label")==None:
749 frameline.label.set_text('???') 766 frameline.label.set_text('???')
750 else: 767 else:
751 frameline.label.set_text(frameline.node.getAttribute("inkscape:label")) 768 frameline.label.set_text(frameline.node.getAttribute("inkscape:label"))
769 last_scene = None
752 for scene in layer.scenes: 770 for scene in layer.scenes:
753 frameline.add_keyframe(scene.start-1,scene.node) 771 if last_scene and last_scene.end == scene.start:
772 frameline.setRightTween(last_scene.end)
773 else:
774 frameline.add_keyframe(scene.start-1,scene.node)
775 last_scene = scene
754 if scene.start != scene.end: 776 if scene.start != scene.end:
755 frameline.add_keyframe(scene.end-1,scene.node) 777 frameline.add_keyframe(scene.end-1,scene.node)
756 tween_type_idx = self._tween_type_names.index(scene.type) 778 tween_type_idx = self._tween_type_names.index(scene.type)
757 tween_type = self._frameline_tween_types[tween_type_idx] 779 tween_type = self._frameline_tween_types[tween_type_idx]
758 frameline.tween(scene.start-1, tween_type) 780 frameline.tween(scene.start-1, tween_type)
814 ns = orig.duplicate(rdoc) 836 ns = orig.duplicate(rdoc)
815 837
816 old_nodes = _travel_DOM(orig) 838 old_nodes = _travel_DOM(orig)
817 new_nodes = _travel_DOM(ns) 839 new_nodes = _travel_DOM(ns)
818 for old_node in old_nodes: 840 for old_node in old_nodes:
841 print old_node
819 old_node_id = old_node.getAttribute('id') 842 old_node_id = old_node.getAttribute('id')
820 new_node = new_nodes.next() 843 new_node = new_nodes.next()
821 new_node.setAttribute('ns0:duplicate-src', old_node_id) 844 new_node.setAttribute('ns0:duplicate-src', old_node_id)
822 pass 845 pass
823 846