annotate pyink/MBScene.py @ 1174:96a7abce774a

Add functions to insert and remove frame.
author wycc
date Fri, 31 Dec 2010 00:49:58 +0800
parents 16ea7b81eda8
children 0c1ceecb8ddb
rev   line source
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1 #!/usr/bin/python
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
2 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; fill-column: 79 -*-
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
3 # vim: sw=4:ts=8:sts=4:textwidth=79
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
4 import pygtk
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
5 import gtk
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
6 import glib
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
7 from copy import deepcopy
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
8 from lxml import etree
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
9 import random
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
10 import traceback
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
11 import time
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
12 import pybInkscape
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
13 import math
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
14 from tween import TweenObject
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
15 from frameline import frameline, frameruler
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
16
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
17 # Please refer to
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
18 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
19 # for the designed document.
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
20
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
21
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
22 # Algorithm:
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
23 #
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
24 # We will parse the first two level of the SVG DOM. collect a table of
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
25 # layer and scene.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
26 # - 1. Collect the layer table which will be displayed as the first
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
27 # column of the grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
28 # - 2. Get the maximum scene number. This will decide the size of the
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
29 # grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
30 # - 3. When F6 is pressed, we will check if this scene has been
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
31 # defined. This can be done by scan all second level group and
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
32 # check if the current scene number is within the range specified
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
33 # by scene field. The function IsSceneDefined(scene) can be used
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
34 # for this purpose.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
35 # - 4. If this is a new scene, we will append a new group which
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
36 # duplication the content of the last scene in the same
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
37 # group. The scene field will contain the number from the last
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
38 # scene number of the last scene to the current scenen
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
39 # number. For example, if the last scene is from 4-7 and the new
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
40 # scene is 10, we will set the scene field as "8-10".
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
41 # - 5. If this scene are filled screne, we will split the existing
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
42 # scene into two scenes with the same content.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
43 #
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
44
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
45 class Layer:
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
46 def __init__(self,node):
962
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
47 self.scenes = []
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
48 self.node = node
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
49 self.nodes=[]
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
50 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
51 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
52
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
53 class Scene:
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
54 def __init__(self, node, start,end,typ):
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
55 self.node = node
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
56 self.start = int(start)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
57 self.end = int(end)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
58 self.type = typ
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
59 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
60 pass
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
61 class DOM(pybInkscape.PYSPObject):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
62 def __init__(self,obj=None):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
63 self.proxy = obj
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
64 pass
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
65
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
66 def duplicate(self,doc):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
67 return DOM(self.repr.duplicate(doc))
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
68
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
69 class ObjectWatcher(pybInkscape.PYNodeObserver):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
70 def __init__(self,obj,type,func,arg):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
71 self.obj = obj
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
72 self.type = type
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
73 self.func = func
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
74 self.arg = arg
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
75
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
76 def notifyChildAdded(self,node,child,prev):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
77 if self.type == 'DOMNodeInserted':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
78 self.func(node)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
79 def notifyChildRemoved(self,node,child,prev):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
80 if self.type == 'DOMNodeRemoved':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
81 self.func(node)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
82 def notifyChildOrderChanged(self,node,child,prev):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
83 pass
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
84 def notifyContentChanged(self,node,old_content,new_content):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
85 if self.type == 'DOMSubtreeModified':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
86 self.func(node)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
87 def notifyAttributeChanged(self,node, name, old_value, new_value):
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
88 # print 'attr',node,name,old_value,new_value
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
89 if self.type == 'DOMAttrModified':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
90 self.func(node,name)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
91
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
92 def addEventListener(obj, type, func,arg):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
93 obs = ObjectWatcher(obj,type,func,arg)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
94 obj.addSubtreeObserver(obs)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
95
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
96
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
97 _scenes = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes'
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
98 _scene = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene'
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
99 class LayerAttributeWatcher(pybInkscape.PYNodeObserver):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
100 def __init__(self,ui):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
101 self.ui = ui
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
102 def notifyChildAdded(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
103 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
104
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
105 def notifyChildRemoved(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
106 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
107
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
108 def notifyChildOrderChanged(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
109 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
110
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
111 def notifyContentChanged(self,node,old_content,new_content):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
112 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
113
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
114 def notifyAttributeChanged(self,node, name, old_value, new_value):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
115 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
116 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
117
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
118 class LayerAddRemoveWatcher(pybInkscape.PYNodeObserver):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
119 def __init__(self,ui):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
120 self.ui = ui
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
121 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
122
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
123 def notifyChildAdded(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
124 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
125 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
126
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
127 def notifyChildRemoved(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
128 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
129 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
130
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
131 def notifyChildOrderChanged(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
132 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
133 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
134
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
135 def notifyContentChanged(self,node,old_content,new_content):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
136 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
137 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
138
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
139 def notifyAttributeChanged(self,node, name, old_value, new_value):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
140 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
141 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
142
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
143 def _travel_DOM(node):
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
144 nodes = [node]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
145 while nodes:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
146 node = nodes.pop(0)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
147 child = node.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
148 while child:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
149 nodes.append(child)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
150 child = child.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
151 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
152 yield node
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
153 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
154 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
155
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
156 class MBScene():
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
157 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
158 frameline.TWEEN_TYPE_SHAPE)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
159 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
160 TweenObject.TWEEN_TYPE_SCALE)
1157
3a891dccabd8 Remove the locate tween. It is a special case for the scale tween
wycc
parents: 1155
diff changeset
161 _tween_type_names = ('normal', 'scale')
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
162
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
163 def __init__(self, desktop, win, root=None):
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
164 self.desktop = desktop
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
165 self.window = win
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
166 self.layers = []
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
167 self.layers.append(Layer(None))
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
168 self.scenemap = None
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
169 self.top = None
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
170 self.last_update = None
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
171 pybInkscape.inkscape.connect('change_selection', self.show_selection)
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
172 self.last_select = None
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
173 self.lockui=False
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
174 self.tween=None
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
175 self.document = None
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
176 self.root = root
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
177 self.framerate=12
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
178 self.maxframe=0
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
179 self._disable_tween_type_selector = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
180 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
181
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
182 def show_selection(self,w,obj):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
183 objs = self.desktop.selection.list()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
184 try:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
185 o = objs[0]
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
186 print o.getCenter()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
187 if o == self.last_select:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
188 return
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
189 except:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
190 self.nameEditor.set_text('')
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
191 self.last_select = None
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
192 return
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
193 self.last_select = o
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
194 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
195 self.nameEditor.set_text(o.getAttribute("inkscape:label"))
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
196 except:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
197 self.nameEditor.set_text('')
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
198 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
199 pass
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
200
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
201 def confirm(self,msg):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
202 vbox = gtk.VBox()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
203 vbox.pack_start(gtk.Label(msg))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
204 self.button = gtk.Button('OK')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
205 vbox.pack_start(self.button)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
206 self.button.connect("clicked", self.onQuit)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
207 self.window.add(vbox)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
208 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
209
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
210 def dumpattr(self,n):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
211 s = ""
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
212 for a,v in n.attrib.items():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
213 s = s + ("%s=%s" % (a,v))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
214 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
215 return s
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
216
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
217 def dump(self,node,l=0):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
218 print " " * l*2,"<", node.tag, self.dumpattr(node),">"
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
219 for n in node:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
220 self.dump(n,l+1)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
221 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
222 print " " * l * 2,"/>"
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
223 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
224
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
225 def parseMetadata(self,node):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
226 self.current = 1
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
227 for n in node.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
228 if n.name() == 'ns0:scenes':
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
229 self.scenemap={}
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
230 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
231 cur = int(n.getAttribute("current"))
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
232 except:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
233 cur = 1
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
234 self.current = cur
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
235
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
236 for s in n.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
237 if s.name() == 'ns0:scene':
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
238 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
239 start = int(s.getAttribute("start"))
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
240 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
241 traceback.print_exc()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
242 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
243 try:
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
244 end = int(s.getAttribute("end"))
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
245 if end == None:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
246 end = start
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
247 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
248 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
249 end = start
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
250 pass
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
251 if end > self.maxframe:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
252 self.maxframe = end
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
253 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
254 typ = s.getAttribute('type')
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
255 if typ == None:
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
256 typ = 'normal'
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
257 except:
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
258 traceback.print_exc()
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
259 typ = 'normal'
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
260 link = s.getAttribute("ref")
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
261 self.scenemap[link] = [int(start),int(end),typ]
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
262 if cur >= start and cur <= end:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
263 self.currentscene = link
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
264 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
265 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
266 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
267 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
268 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
269 pass
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
270 if self.scenemap==None:
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
271 #self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd")
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
272 self.root.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd")
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
273 scenes = self.document.createElement("ns0:scenes")
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
274 node.appendChild(scenes)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
275 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
276 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
277
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
278 def update(self):
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
279 doc = self.root
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
280 rdoc = self.document
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
281 for node in doc.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
282 if node.name() == 'svg:metadata':
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
283 for t in node.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
284 if t.name() == "ns0:scenes":
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
285 node.removeChild(t)
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
286 ns = rdoc.createElement("ns0:scenes")
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
287 node.appendChild(ns)
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
288 for layer in range(0,len(self._framelines)):
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
289 lobj = self._framelines[layer]
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
290 self.addScenes(lobj, ns)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
291 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
292 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
293 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
294 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
295 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
296 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
297
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
298 def parseScene(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
299 """
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
300 In this function, we will collect all items for the current
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
301 scene and then relocate them back to the appropriate scene
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
302 object.
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
303 """
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
304 self.layers = []
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
305 self.scenemap = None
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
306 doc = self.root
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
307
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
308 addEventListener(doc,'DOMNodeInserted',self.updateUI,None)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
309 addEventListener(doc,'DOMNodeRemoved',self.updateUI,None)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
310 doc.childList()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
311 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
312 self.width = float(doc.getAttribute("width"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
313 self.height= float(doc.getAttribute("height"))
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
314 except:
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
315 self.width = 640
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
316 self.height=480
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
317 pass
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
318
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
319 for node in doc.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
320 print node.name()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
321 if node.name() == 'svg:metadata':
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
322 self.parseMetadata(node)
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
323 pass
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
324 elif node.name() == 'svg:g':
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
325 oldscene = None
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
326 #obs = LayerAttributeWatcher(self)
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
327 #addEventListener(doc,'DOMAttrModified',self.updateUI,None)
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
328 #node.addObserver(obs)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
329 lyobj = Layer(node)
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
330 self.layers.append(lyobj)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
331 lyobj.current_scene = []
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
332 for scene in node.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
333 print scene.getCenter()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
334 if scene.name() == 'svg:g':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
335 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
336 label = scene.getAttribute('inkscape:label')
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
337 if label == 'dup':
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
338 # XXX: This would stop animation.
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
339 # This function is called by updateUI()
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
340 node.removeChild(scene)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
341 except:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
342 pass
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
343
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
344 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
345 scmap = self.scenemap[scene.getAttribute('id')]
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
346 if scmap == None:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
347 lyobj.current_scene.append(scene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
348 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
349 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
350 lyobj.current_scene.append(scene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
351 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
352
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
353 lyobj.scenes.append(Scene(scene,scmap[0],scmap[1],scmap[2]))
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
354 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
355 else:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
356 lyobj.current_scene.append(scene)
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
357 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
358 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
359 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
360 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
361
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
362
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
363 self.collectID()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
364 self.dumpID()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
365 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
366
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
367 def collectID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
368 self.ID = {}
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
369 root = self.root
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
370 for n in root.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
371 self.collectID_recursive(n)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
372 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
373 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
374
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
375 def collectID_recursive(self,node):
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
376 try:
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
377 self.ID[node.getAttribute('id')] = 1
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
378 except:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
379 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
380 for n in node.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
381 self.collectID_recursive(n)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
382 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
383 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
384
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
385 def newID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
386 while True:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
387 n = 's%d' % int(random.random()*10000)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
388 #print "try %s" % n
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
389 if self.ID.has_key(n) == False:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
390 return n
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
391 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
392 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
393
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
394 def dumpID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
395 for a,v in self.ID.items():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
396 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
397 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
398
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
399 def getLayer(self, layer):
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
400 for l in self.layers:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
401 if l.node.getAttribute('id') == layer:
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
402 return l
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
403 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
404 return None
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
405
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
406
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
407 def insertKeyScene(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
408 """
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
409 Insert a new key scene into the stage. If the nth is always a
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
410 key scene, we will return without changing anything. If the
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
411 nth is a filled scene, we will break the original scene into
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
412 two parts. If the nth is out of any scene, we will append a
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
413 new scene.
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
414
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
415 """
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
416 x = self.last_frame
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
417 y = self.last_line
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
418 rdoc = self.document
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
419 ns = rdoc.createElement("svg:g")
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
420 found = False
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
421 for node in self.last_line.node.childList():
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
422 try:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
423 label = node.getAttribute("inkscape:label")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
424 except:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
425 continue
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
426 if label == "dup":
1171
16ea7b81eda8 Add comment to update it latter.
wycc
parents: 1166
diff changeset
427 #FIXME: The duplication here is not perfect. We should
16ea7b81eda8 Add comment to update it latter.
wycc
parents: 1166
diff changeset
428 # get the element inside the group and apply the
16ea7b81eda8 Add comment to update it latter.
wycc
parents: 1166
diff changeset
429 # transformation matrix to it directly.
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
430 for n in node.childList():
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
431 ns.appendChild(n.duplicate(self.document))
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
432 found = True
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
433 node.setAttribute("style","display:none")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
434 break
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
435 pass
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
436 pass
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
437
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
438 if found == False:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
439 txt = rdoc.createElement("svg:rect")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
440 txt.setAttribute("x","0")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
441 txt.setAttribute("y","0")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
442 txt.setAttribute("width","100")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
443 txt.setAttribute("height","100")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
444 txt.setAttribute("style","fill:#ff00")
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
445 ns.appendChild(txt)
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
446
1142
dd6c60c6f41e Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents: 1141
diff changeset
447 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID()
975
ed7e8e309d55 Remove generate function
wycc
parents: 973
diff changeset
448 self.ID[gid]=1
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
449 ns.setAttribute("id",gid)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
450 ns.setAttribute("inkscape:groupmode","layer")
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
451 self.last_line.node.appendChild(ns)
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
452 self.last_line.add_keyframe(x,ns)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
453 self.update()
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
454 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
455
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
456 def removeKeyScene(self):
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
457 nth = self.last_frame
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
458 y = self.last_line
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
459 rdoc = self.document
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
460 i = 0
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
461 layer = self.last_line
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
462 while i < len(layer._keys):
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
463 s = layer._keys[i]
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
464 print "nth:%d idx %d" % (nth,s.idx)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
465 if nth > s.idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
466 if i == len(layer._keys)-1:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
467 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
468 if nth == s.idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
469 if s.left_tween:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
470 # This is left tween, we move the keyframe one frame ahead
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
471 if s.idx == layer._keys[i-1].idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
472 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
473 self.last_line.rm_keyframe(nth)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
474 self.last_line.rm_keyframe(nth-1)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
475 else:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
476 s.idx = s.idx-1
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
477 else:
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
478 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
479 if s.right_tween:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
480 self.last_line.rm_keyframe(layer._keys[i+1].idx)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
481 self.last_line.rm_keyframe(nth)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
482 else:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
483 self.last_line.rm_keyframe(nth)
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
484
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
485 self.update()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
486 self.last_line._draw_all_frames()
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
487 self.last_line.update()
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
488 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
489 i = i + 1
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
490 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
491 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
492
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
493 def extendScene(self):
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
494 nth = self.last_frame
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
495 layer = self.last_line
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
496 i = 0
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
497 while i < len(layer._keys):
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
498 s = layer._keys[i]
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
499 if s.right_tween:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
500 if nth > s.idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
501 if nth <= layer._keys[i+1].idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
502 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
503 try:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
504 if nth <= layer._keys[i+2].idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
505 layer._keys[i+1].idx = nth
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
506 layer.draw_all_frames()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
507 self.update()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
508 self.setCurrentScene(nth)
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
509 self.last_line.update()
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
510 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
511 else:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
512 # We may in the next scene
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
513 i = i + 2
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
514 pass
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
515 except:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
516 # This is the last keyframe, extend the keyframe by
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
517 # relocate the location of the keyframe
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
518 layer._keys[i+1].idx = nth
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
519 layer._draw_all_frames()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
520 self.update()
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
521 self.last_line.update()
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
522 self.setCurrentScene(nth)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
523 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
524 else:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
525 # We are in the front of all keyframes
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
526 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
527 else:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
528 # This is a single keyframe
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
529 if nth < s.idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
530 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
531 if nth == s.idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
532 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
533 try:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
534 if nth < layer._keys[i+1].idx:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
535 # We are after a single keyframe and no scene is
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
536 # available here. Create a new tween here
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
537 idx = layer._keys[i].idx
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
538 layer.add_keyframe(nth,layer._keys[i].ref)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
539 layer.tween(idx)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
540 layer._draw_all_frames()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
541 self.update()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
542 self.setCurrentScene(nth)
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
543 self.last_line.update()
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
544 return
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
545 else:
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
546 # We may in the next scene
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
547 i = i + 1
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
548 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
549 pass
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
550 except:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
551 # This is the last scene, create a new one
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
552 idx = layer._keys[i].idx
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
553 layer.add_keyframe(nth,layer._keys[i].ref)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
554 layer.tween(idx)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
555 layer._draw_all_frames()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
556 self.update()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
557 self.setCurrentScene(nth)
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
558 self.last_line.update()
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
559 return
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
560 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
561 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
562 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
563
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
564
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
565
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
566 def setCurrentScene(self,nth):
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
567 """
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
568 Update the scene group according to the curretn scene
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
569 data. There are a couple of cases.
1148
wycc
parents: 1147 1145
diff changeset
570 1. If the type of the scene is normal, we display it when
wycc
parents: 1147 1145
diff changeset
571 it contains the current frame. Otherwise hide it.
wycc
parents: 1147 1145
diff changeset
572 2. If the type of the scene is relocate or scale, we need
wycc
parents: 1147 1145
diff changeset
573 to duplicate the scene group and then modify its
wycc
parents: 1147 1145
diff changeset
574 transform matrix according to the definition of the
wycc
parents: 1147 1145
diff changeset
575 scene. Then, hide the original scenr group and display
wycc
parents: 1147 1145
diff changeset
576 the duplciate scene group. In addition, we may need to
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
577 delete the old duplicated scene group as well.
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
578
1148
wycc
parents: 1147 1145
diff changeset
579 For each layer, we will always use the duplicated scene
wycc
parents: 1147 1145
diff changeset
580 group whose name as dup.
wycc
parents: 1147 1145
diff changeset
581 We will put the duplicated scene group inside it. We will
wycc
parents: 1147 1145
diff changeset
582 create this group if it is not
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
583 available.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
584 """
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
585 self.current = nth
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
586 self.tween.updateMapping()
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
587 idx = nth - 1
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
588 for layer in self._framelines:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
589 i=0
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
590
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
591 # Check the duplicated scene group and create it if it is not available
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
592 try:
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
593 layer.duplicateGroup.setAttribute("style","display:none")
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
594 except:
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
595 print "*"*40
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
596 layer.duplicateGroup = self.document.createElement("svg:g")
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
597 layer.duplicateGroup.setAttribute("inkscape:label","dup")
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
598 layer.duplicateGroup.setAttribute("sodipodi:insensitive","1")
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
599 layer.duplicateGroup.setAttribute("style","")
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
600 layer.layer.node.appendChild(layer.duplicateGroup)
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
601 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
602 # Create a new group
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
603 for start_idx, stop_idx, tween_type in layer.get_frame_blocks():
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
604 if start_idx == stop_idx:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
605 scene_group = layer.get_frame_data(start_idx)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
606 if idx == start_idx:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
607 scene_group.setAttribute('style', '')
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
608 else:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
609 scene_group.setAttribute('style', 'display: none')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
610 pass
1155
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
611 elif idx == start_idx:
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
612 layer.duplicateGroup.setAttribute("style","display:none")
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
613 scene_group = layer.get_frame_data(start_idx)
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
614 scene_group.setAttribute("style","")
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
615 elif start_idx <= idx and stop_idx >= idx:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
616 scene_group = layer.get_frame_data(start_idx)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
617 scene_group.setAttribute("style","display:none")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
618 layer.duplicateGroup.setAttribute("style","")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
619 tween_type_idx = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
620 self._frameline_tween_types.index(tween_type)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
621 tween_obj_tween_type = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
622 self._tween_obj_tween_types[tween_type_idx]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
623
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
624 next_idx, next_stop_idx, next_tween_type = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
625 layer.get_frame_block(stop_idx + 1)
1163
wycc
parents: 1161
diff changeset
626 if next_idx == -1:
wycc
parents: 1161
diff changeset
627 next_scene_group = scene_group
wycc
parents: 1161
diff changeset
628 else:
wycc
parents: 1161
diff changeset
629 next_scene_group = layer.get_frame_data(next_idx)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
630
1160
1a699dc00fa3 Fix the issue of not removing node in old scene when switching scenes.
Thinker K.F. Li <thinker@codemud.net>
parents: 1159
diff changeset
631 nframes = stop_idx - start_idx + 1
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
632 percent = float(idx - start_idx) / nframes
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
633 self.tween.updateTweenContent(layer.duplicateGroup,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
634 tween_obj_tween_type,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
635 scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
636 next_scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
637 percent)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
638 else:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
639 scene_group = layer.get_frame_data(start_idx)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
640 scene_group.setAttribute("style","display:none")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
641 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
642 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
643 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
644 pass
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
645
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
646 def enterGroup(self,obj):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
647 for l in self.layers:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
648 for s in l.node.childList():
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
649 if s.getAttribute('id') == obj.getAttribute("id"):
1142
dd6c60c6f41e Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents: 1141
diff changeset
650 self.desktop.setCurrentLayer(s.spitem)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
651 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
652 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
653 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
654 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
655
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
656 def selectSceneObject(self,frameline, nth):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
657 i = 0
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
658 while i < len(frameline._keys):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
659 s = frameline._keys[i]
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
660 if s.right_tween is False:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
661 if nth == s.idx+1:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
662 self.enterGroup(s.ref)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
663 self.setTweenType(frameline.get_tween_type(s.idx))
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
664 return
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
665 else:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
666 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
667 i = i + 1
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
668 continue
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
669
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
670 if nth >= (s.idx+1) and nth <= (frameline._keys[i+1].idx+1):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
671 self.enterGroup(s.ref)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
672 self.setTweenType(frameline.get_tween_type(s.idx))
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
673 return
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
674 else:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
675 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
676 i = i + 2
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
677 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
678 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
679
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
680 def setTweenType(self, tween_type):
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
681 sel_type = MBScene._frameline_tween_types.index(tween_type)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
682 self._disable_tween_type_selector = True
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
683 self.tweenTypeSelector.set_active(sel_type)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
684 self._disable_tween_type_selector = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
685 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
686
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
687 def newCell(self,file):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
688 img = gtk.Image()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
689 img.set_from_file(file)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
690 btn = gtk.EventBox()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
691 btn.add(img)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
692 btn.connect("button_press_event", self.cellSelect)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
693 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray"))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
694 return btn
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
695
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
696 def onCellClick(self,line,frame,but):
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
697 self.last_line = line
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
698 self.last_frame = frame
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
699 self.last_line.active_frame(frame)
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
700 self.lockui = True
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
701 self.doEditScene(frame)
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
702 self.lockui = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
703 pass
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
704
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
705 def _remove_active_frame(self,widget,event):
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
706 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
707 Hide all hover frames. This is a hack. We should use the lost focus event
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
708 instead in the future to reduce the overhead.
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
709 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
710 for f in self._framelines:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
711 if f != widget:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
712 f.hide_hover()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
713 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
714 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
715 pass
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
716
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
717 def _create_framelines(self):
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
718 if not hasattr(self, 'scrollwin'):
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
719 self.scrollwin = gtk.ScrolledWindow()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
720 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
721 gtk.POLICY_AUTOMATIC)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
722 self.scrollwin.set_size_request(-1,150)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
723 vbox = gtk.VBox()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
724 vbox.show()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
725 self.scrollwin.add_with_viewport(vbox)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
726 self.scrollwin_vbox = vbox
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
727 else:
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
728 for c in self.scrollwin_vbox.get_children():
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
729 self.scrollwin_vbox.remove(c)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
730 vbox = self.scrollwin_vbox
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
731 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
732
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
733 nframes = 100
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
734
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
735 ruler = frameruler(nframes)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
736 ruler.set_size_request(nframes * 10, 20)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
737 ruler.show()
1032
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
738 hbox = gtk.HBox()
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
739 label=gtk.Label('')
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
740 label.set_size_request(100,0)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
741 hbox.pack_start(label,expand=False,fill=True)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
742 hbox.pack_start(ruler)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
743 vbox.pack_start(hbox, False)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
744
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
745 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
746 # Add a frameline for each layer
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
747 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
748 self._framelines = []
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
749 for i in range(len(self.layers)-1,-1,-1):
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
750 line = frameline(nframes)
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
751 hbox = gtk.HBox()
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
752 label = gtk.Label(self.layers[i].node.getAttribute("inkscape:label"))
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
753 label.set_size_request(100,0)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
754 hbox.pack_start(label,expand=False,fill=True)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
755 hbox.pack_start(line)
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
756 line.set_size_request(nframes * 10, 20)
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
757 vbox.pack_start(hbox, False)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
758 line.label = label
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
759 self._framelines.append(line)
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
760 line.connect(line.FRAME_BUT_PRESS, self.onCellClick)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
761 line.nLayer = i
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
762 line.node = self.layers[i].node
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
763 line.layer = self.layers[i]
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
764 line.connect('motion-notify-event', self._remove_active_frame)
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
765 pass
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
766 vbox.show_all()
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
767 pass
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
768
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
769 ## \brief Update conetent of frameliens according layers.
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
770 #
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
771 def _update_framelines(self):
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
772 for frameline in self._framelines:
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
773 layer = frameline.layer
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
774 if frameline.node.getAttribute("inkscape:label")==None:
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
775 frameline.label.set_text('???')
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
776 else:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
777 frameline.label.set_text(frameline.node.getAttribute("inkscape:label"))
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
778 last_scene = None
962
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
779 for scene in layer.scenes:
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
780 if last_scene and last_scene.end == scene.start:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
781 frameline.setRightTween(last_scene.end)
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
782 else:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
783 frameline.add_keyframe(scene.start-1,scene.node)
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
784 last_scene = scene
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
785 if scene.start != scene.end:
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
786 frameline.add_keyframe(scene.end-1,scene.node)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
787 tween_type_idx = self._tween_type_names.index(scene.type)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
788 tween_type = self._frameline_tween_types[tween_type_idx]
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
789 frameline.tween(scene.start-1, tween_type)
962
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
790 pass
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
791 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
792 pass
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
793
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
794 def cellSelect(self, cell, data):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
795 if self.last_cell:
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
796 color = self.last_cell.get_colormap().alloc_color("gray")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
797 self.last_cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
798 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
799
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
800 self.last_cell = cell
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
801 color = cell.get_colormap().alloc_color("green")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
802 cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
803 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
804
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
805 def duplicateKeyScene(self):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
806 self.last_line.add_keyframe(self.last_frame)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
807 # Search for the current scene
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
808 i = 0
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
809 while i < len(self.last_line._keys):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
810 key = self.last_line._keys[i]
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
811 if key.idx == self.last_frame:
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
812 if i == 0:
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
813 # This is the first frame, we can not duplicate it
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
814 self.last_line.rm_keyframe(self.last_frame)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
815 return
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
816 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id"))
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
817 key.ref = node
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
818 self.update()
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
819 self.updateUI()
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
820 self.doEditScene(None)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
821 return
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
822 last_key = key
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
823 i = i + 1
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
824 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
825 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
826
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
827 def duplicateSceneGroup(self,gid):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
828 # Search for the duplicated group
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
829 doc = self.root
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
830 rdoc = self.document
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
831 orig = None
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
832 for node in doc.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
833 if node.name() == 'svg:g':
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
834 for t in node.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
835 if t.name() == "svg:g":
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
836 if t.getAttribute("id") == gid:
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
837 orig = t
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
838 break
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
839 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
840 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
841 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
842 pass
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
843 if orig == None:
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
844 return None
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
845 ns = orig.duplicate(rdoc)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
846
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
847 old_nodes = _travel_DOM(orig)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
848 new_nodes = _travel_DOM(ns)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
849 for old_node in old_nodes:
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
850 print old_node
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
851 old_node_id = old_node.getAttribute('id')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
852 new_node = new_nodes.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
853 new_node.setAttribute('ns0:duplicate-src', old_node_id)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
854 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
855
1142
dd6c60c6f41e Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents: 1141
diff changeset
856 gid = self.last_line.node.getAttribute("inkscape:label")+self.newID()
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
857 self.ID[gid]=1
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
858 ns.setAttribute("id",gid)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
859 ns.setAttribute("inkscape:groupmode","layer")
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
860 self.last_line.node.appendChild(ns)
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
861 return ns
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
862
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
863 def doEditScene(self,w):
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
864 self.setCurrentScene(self.last_frame+1)
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
865 self.selectSceneObject(self.last_line,self.last_frame+1)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
866 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
867
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
868 def doInsertKeyScene(self,w):
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
869 self.lockui=True
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
870 self.insertKeyScene()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
871 self.lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
872 # self.grid.show_all()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
873 return
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
874
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
875 def doDuplicateKeyScene(self,w):
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
876 self.lockui = True
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
877 self.duplicateKeyScene()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
878 self.lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
879
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
880 def doRemoveScene(self,w):
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
881 self.lockui = True
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
882 self.removeKeyScene()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
883 self.lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
884 return
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
885
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
886
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
887 def doExtendScene(self,w):
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
888 self.lockui = True
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
889 self.extendScene()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
890 self.lockui = False
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
891 #self.grid.show_all()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
892 pass
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
893
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
894 def changeObjectLabel(self,w):
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
895 o = self.desktop.selection.list()[0]
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
896 o.setAttribute("inkscape:label", self.nameEditor.get_text())
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
897 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
898
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
899 def addNameEditor(self,hbox):
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
900 self.nameEditor = gtk.Entry(max=40)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
901 hbox.pack_start(self.nameEditor,expand=False,fill=False)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
902 self.editDone = gtk.Button('Set')
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
903 hbox.pack_start(self.editDone,expand=False,fill=False)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
904 self.editDone.connect('clicked', self.changeObjectLabel)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
905 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
906
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
907 def doRun(self,arg):
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
908 """
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
909 Execute the current animation till the last frame.
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
910 """
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
911 if self.btnRun.get_label() == "Run":
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
912 self.btnRun.set_label("Stop")
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
913 self.lockui = True
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
914 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
915 else:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
916 self.btnRun.set_label("Run")
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
917 glib.source_remove(self.last_update)
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
918 self.lockui = False
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
919 pass
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
920
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
921 def doRunNext(self):
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
922 if self.current >= self.maxframe:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
923 self.current = 0
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
924 try:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
925 self.setCurrentScene(self.current+1)
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
926 except:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
927 traceback.print_exc()
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
928 raise
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
929 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
930
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
931 def doInsertScene(self,w):
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
932 self.lockui=True
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
933 self.last_line.insert_frame(self.last_frame)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
934 self.update()
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
935 self.lockui=False
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
936
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
937 def doRemoveScene(self,w):
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
938 self.lockui=True
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
939 self.last_line.remove_frame(self.last_frame)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
940 self.update()
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
941 self.lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
942
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
943 def addButtons(self,hbox):
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
944 #btn = gtk.Button('Edit')
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
945 #btn.connect('clicked', self.doEditScene)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
946 #hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
947
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
948 btn = gtk.Button('Insert Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
949 btn.connect('clicked',self.doInsertKeyScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
950 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
951
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
952 btn=gtk.Button('Remove Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
953 btn.connect('clicked', self.doRemoveScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
954 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
955
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
956 btn=gtk.Button('Extend scene')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
957 btn.connect('clicked', self.doExtendScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
958 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
959
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
960 btn=gtk.Button('Duplicate Key')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
961 btn.connect('clicked', self.doDuplicateKeyScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
962 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
963
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
964 btn=gtk.Button('Duplicate Key')
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
965 btn.connect('clicked', self.doDuplicateKeyScene)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
966 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
967
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
968 btn=gtk.Button('Insert')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
969 btn.connect('clicked', self.doInsertScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
970 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
971
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
972 btn=gtk.Button('Remove')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
973 btn.connect('clicked', self.doRemoveScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
974 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
975
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
976 btn=gtk.Button('Run')
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
977 btn.connect('clicked', self.doRun)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
978 self.btnRun = btn
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
979 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
980
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
981 self.addNameEditor(hbox)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
982 self.addTweenTypeSelector(hbox)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
983 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
984
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
985 def onTweenTypeChange(self, w):
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
986 if self._disable_tween_type_selector:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
987 return
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
988
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
989 if self.last_line == None:
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
990 return
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
991 frameline = self.last_line
1159
e731a0eaa35f Fix issue of chagne tween type when there is more than one tween block.
Thinker K.F. Li <thinker@codemud.net>
parents: 1157
diff changeset
992 idx = self.last_frame
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
993 i = 0
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
994 found = -1
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
995 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
1159
e731a0eaa35f Fix issue of chagne tween type when there is more than one tween block.
Thinker K.F. Li <thinker@codemud.net>
parents: 1157
diff changeset
996 if start_idx <= idx and stop_idx >= idx:
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
997 n = self.tweenTypeSelector.get_active()
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
998 new_tween_type = MBScene._frameline_tween_types[n]
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
999 self.last_line.set_tween_type(start_idx, new_tween_type)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1000 self.update()
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1001 break
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1002 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1003 pass
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1004
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1005 def addTweenTypeSelector(self,hbox):
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1006 tweenbox = gtk.HBox()
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1007 label = gtk.Label('Tween Type')
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1008 tweenbox.pack_start(label)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1009
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1010 self.tweenTypeSelector = gtk.combo_box_new_text()
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1011 self.tweenTypeSelector.append_text('normal')
1157
3a891dccabd8 Remove the locate tween. It is a special case for the scale tween
wycc
parents: 1155
diff changeset
1012 #self.tweenTypeSelector.append_text('relocate')
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1013 self.tweenTypeSelector.append_text('scale')
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1014 self.tweenTypeSelector.set_active(0)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1015 tweenbox.pack_start(self.tweenTypeSelector, expand=False,fill=False)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1016 hbox.pack_start(tweenbox,expand=False,fill=False)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1017 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1018 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1019
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1020 def onQuit(self, event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1021 self.OK = False
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1022 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1023 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1024
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1025 def onOK(self,event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1026 self.OK = True
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1027 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1028 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1029
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1030 def addScenes(self, frameline, scenes_node):
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1031 doc = self.document
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1032 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1033 ref = frameline.get_frame_data(start_idx)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1034 tween_type_idx = self._frameline_tween_types.index(tween_type)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1035 tween_type_name = self._tween_type_names[tween_type_idx]
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1036
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1037 scene_node = doc.createElement("ns0:scene")
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1038 scenes_node.appendChild(scene_node)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1039 scene_node.setAttribute("start", str(start_idx + 1))
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1040 if start_idx != stop_idx:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1041 scene_node.setAttribute("end", str(stop_idx + 1))
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1042 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1043 scene_node.setAttribute("ref", ref.attribute("id"))
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1044 scene_node.setAttribute("type", tween_type_name)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1045 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1046 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1047
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1048 def updateUI(self,node=None,arg=None):
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
1049 if self.lockui: return
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1050
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1051 if self.last_update!= None:
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1052 glib.source_remove(self.last_update)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1053 self.last_update = glib.timeout_add(300,self._updateUI)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1054
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1055 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1056
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
1057 def _updateUI(self,node=None,arg=None):
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1058 self.parseScene()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1059 self._create_framelines()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1060 self._update_framelines()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1061 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1062
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1063 def show(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1064 self.OK = True
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1065 if not self.root:
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1066 self.root = self.desktop.doc().root().repr
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1067 pass
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1068
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1069 self.document = self.desktop.doc().rdoc
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1070 self.tween = TweenObject(self.document, self.root)
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1071 self._updateUI()
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1072 if self.top == None:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1073 self.top = gtk.VBox(False,0)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1074 self.desktop.getToplevel().child.child.pack_end(self.top,expand=False)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1075 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1076 self.top.remove(self.startWindow)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1077 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1078
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1079 vbox = gtk.VBox(False,0)
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1080 self.startWindow = vbox
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1081 self.top.pack_start(vbox,expand=False)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1082 vbox.pack_start(self.scrollwin,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1083 hbox=gtk.HBox(False,0)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1084 self.addButtons(hbox)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1085 vbox.pack_start(hbox,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1086
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1087 self.top.show_all()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1088 self.last_update = None
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1089 return False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1090 pass