# HG changeset patch # User wycc # Date 1293546371 -28800 # Node ID c23593881507e2de86dc6c0024eb49a847a5b5fd # Parent 64c54ef394803485cc43b28c04406fbdee722738# Parent a7faab54e8f826cf20a4bb87ac5cc28225825247 Merge. Fix a bug to select the tween without key frame after it. diff -r 64c54ef39480 -r c23593881507 pyink/MBScene.py --- a/pyink/MBScene.py Mon Dec 27 23:20:13 2010 +0800 +++ b/pyink/MBScene.py Tue Dec 28 22:26:11 2010 +0800 @@ -86,7 +86,7 @@ if self.type == 'DOMSubtreeModified': self.func(node) def notifyAttributeChanged(self,node, name, old_value, new_value): - print 'attr',node,name,old_value,new_value + # print 'attr',node,name,old_value,new_value if self.type == 'DOMAttrModified': self.func(node,name) @@ -336,6 +336,8 @@ try: label = scene.getAttribute('inkscape:label') if label == 'dup': + # XXX: This would stop animation. + # This function is called by updateUI() node.removeChild(scene) except: pass @@ -603,9 +605,12 @@ next_idx, next_stop_idx, next_tween_type = \ layer.get_frame_block(stop_idx + 1) - next_scene_group = layer.get_frame_data(next_idx) + if next_idx == -1: + next_scene_group = scene_group + else: + next_scene_group = layer.get_frame_data(next_idx) - nframes = next_idx - start_idx + 1 + nframes = stop_idx - start_idx + 1 percent = float(idx - start_idx) / nframes self.tween.updateTweenContent(layer.duplicateGroup, tween_obj_tween_type, @@ -873,16 +878,22 @@ """ if self.btnRun.get_label() == "Run": self.btnRun.set_label("Stop") + self.lockui = True self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) else: self.btnRun.set_label("Run") glib.source_remove(self.last_update) + self.lockui = False + pass def doRunNext(self): if self.current >= self.maxframe: self.current = 0 - print self.current,self.maxframe - self.setCurrentScene(self.current+1) + try: + self.setCurrentScene(self.current+1) + except: + traceback.print_exc() + raise self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) @@ -917,10 +928,11 @@ if self.last_line == None: return frameline = self.last_line + idx = self.last_frame i = 0 found = -1 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks(): - if start_idx < stop_idx: + if start_idx <= idx and stop_idx >= idx: n = self.tweenTypeSelector.get_active() new_tween_type = MBScene._frameline_tween_types[n] self.last_line.set_tween_type(start_idx, new_tween_type) diff -r 64c54ef39480 -r c23593881507 pyink/frameline.py --- a/pyink/frameline.py Mon Dec 27 23:20:13 2010 +0800 +++ b/pyink/frameline.py Tue Dec 28 22:26:11 2010 +0800 @@ -370,6 +370,12 @@ self._draw_tween(first_tween_key.idx, last_tween_key.idx, first_tween_key.right_tween_type) last_tween_key = self._keys[last_tween_pos] + key_pos = last_tween_pos + 1 + try: + key = self._keys[key_pos] + except: + key = keyframe(self._num_frames) + pass i = last_tween_key.idx + 1 else: self._draw_normal_frame(i) @@ -704,7 +710,8 @@ block = (key.idx, next_key.idx, key.right_tween_type) elif not key.left_tween: block = (key.idx, key.idx, 0) - pass + else: + continue blocks.append(block) pass return blocks @@ -713,11 +720,14 @@ pos = self._find_keyframe_floor(idx) if pos != -1: key = self._keys[pos] + print key.right_tween, key.left_tween if key.idx == idx: return key.idx, key.idx, 0 elif key.right_tween: next_key = self._keys[pos + 1] return key.idx, next_key.idx, key.right_tween_type + else: + return -1,-1,-1 pass raise ValueError, \ 'the frame specified by idx is not in any tween or a key frame' diff -r 64c54ef39480 -r c23593881507 pyink/primitive_test.svg --- a/pyink/primitive_test.svg Mon Dec 27 23:20:13 2010 +0800 +++ b/pyink/primitive_test.svg Tue Dec 28 22:26:11 2010 +0800 @@ -55,26 +55,17 @@ ref="icon3s1983" type="scale" /> - - + type="scale" /> - - + type="scale" /> - + style="display:none" + id="g3701" /> - - - - - - + id="g3695"> - - - - - - + ref="path3112" + id="g3723" + transform="matrix(1,0,0,1,0,0)"> - - - - - - - - - - - - + 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" /> @@ -336,7 +194,7 @@ - - - - - - - - - - - - - - - - - - + id="g3683"> - - - - - - - - - - - - - - - - - - + ref="path3196" + id="g3685" + transform="matrix(1,0,0,1,0,51.4286)"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 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" /> diff -r 64c54ef39480 -r c23593881507 pyink/tween.py --- a/pyink/tween.py Mon Dec 27 23:20:13 2010 +0800 +++ b/pyink/tween.py Tue Dec 28 22:26:11 2010 +0800 @@ -62,6 +62,14 @@ node = node.next() pass + # Remove duplicate nodes that is not in the set of stop nodes + for node_ref in dup_nodes: + if node_ref not in stop_nodes: + node = dup_nodes[node_ref] + duplicate_group.removeChild(node) + pass + pass + # # Node ID of a node of start scene must be mapped to # 'ns0:duplicate-src' attribute of a node of stop scene. The @@ -75,6 +83,7 @@ start_node = start_scene_group.firstChild() while start_node: start_node_id = start_node.getAttribute('id') + dup_node = dup_nodes.setdefault(start_node_id, None) try: stop_node = stop_nodes[start_node_id] except KeyError: @@ -84,7 +93,6 @@ start_node = start_node.next() continue - dup_node = dup_nodes.setdefault(start_node_id, None) self.updateTweenObject(duplicate_group, tween_type, start_node, stop_node,