Mercurial > MadButterfly
annotate pyink/MBScene.py @ 1178:416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
- After insert a new key scene, pyink does switch current layer to
the new scene. It is supposed to have.
- calls selectSceneObject() in doInsertKeyScene().
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 31 Dec 2010 10:43:07 +0800 |
parents | ec1ea8555911 |
children | b65df4f0d30a |
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 | 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 | 17 # Please refer to |
18 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention | |
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 | 55 self.node = node |
56 self.start = int(start) | |
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 | 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 | 97 _scenes = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes' |
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 |
1176
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
156 class MBScene_dom(object): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
157 def dumpattr(self, n): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
158 s = "" |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
159 for a,v in n.attrib.items(): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
160 s = s + ("%s=%s" % (a,v)) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
161 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
162 return s |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
163 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
164 def dump(self, node, l=0): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
165 print " " * l*2,"<", node.tag, self.dumpattr(node),">" |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
166 for n in node: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
167 self.dump(n, l+1) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
168 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
169 print " " * l * 2,"/>" |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
170 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
171 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
172 def _parse_one_scenes(self, scenes): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
173 self.scenemap = {} |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
174 try: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
175 cur = int(n.getAttribute("current")) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
176 except: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
177 cur = 1 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
178 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
179 self.current = cur |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
180 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
181 for scene in scenes.childList(): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
182 if scene.name() != 'ns0:scene': |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
183 continue |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
184 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
185 try: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
186 start = int(scene.getAttribute("start")) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
187 except: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
188 traceback.print_exc() |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
189 continue |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
190 try: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
191 end = int(scene.getAttribute("end")) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
192 except: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
193 end = start |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
194 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
195 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
196 if end > self.maxframe: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
197 self.maxframe = end |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
198 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
199 try: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
200 scene_type = scene.getAttribute('type') |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
201 if scene_type == None: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
202 scene_type = 'normal' |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
203 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
204 except: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
205 traceback.print_exc() |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
206 scene_type = 'normal' |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
207 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
208 link = scene.getAttribute("ref") |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
209 self.scenemap[link] = [int(start), int(end), scene_type] |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
210 if cur >= start and cur <= end: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
211 self.currentscene = link |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
212 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
213 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
214 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
215 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
216 def parseMetadata(self, node): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
217 for n in node.childList(): |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
218 if n.name() == 'ns0:scenes': |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
219 self._parse_one_scenes(n) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
220 break |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
221 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
222 else: |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
223 ns = "http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
224 self.root.setAttribute("xmlns:ns0", ns) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
225 scenes = self.document.createElement("ns0:scenes") |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
226 node.appendChild(scenes) |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
227 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
228 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
229 pass |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
230 |
0c1ceecb8ddb
Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
231 class MBScene(MBScene_dom): |
1151
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
232 _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
|
233 frameline.TWEEN_TYPE_SHAPE) |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
234 _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
|
235 TweenObject.TWEEN_TYPE_SCALE) |
1157
3a891dccabd8
Remove the locate tween. It is a special case for the scale tween
wycc
parents:
1155
diff
changeset
|
236 _tween_type_names = ('normal', 'scale') |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
237 |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
238 def __init__(self, desktop, win, root=None): |
956 | 239 self.desktop = desktop |
240 self.window = win | |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
241 self.layers = [] |
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
242 self.layers.append(Layer(None)) |
956 | 243 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
|
244 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
|
245 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
|
246 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
|
247 self.last_select = None |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
248 self.lockui=False |
1140 | 249 self.tween=None |
250 self.document = None | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
251 self.root = root |
1147 | 252 self.framerate=12 |
253 self.maxframe=0 | |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
254 self._disable_tween_type_selector = False |
956 | 255 pass |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
256 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
257 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
|
258 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
|
259 try: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 return |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
264 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
265 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
|
266 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
|
267 return |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
268 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
|
269 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
270 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
|
271 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
272 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
|
273 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
274 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
|
275 |
956 | 276 def confirm(self,msg): |
277 vbox = gtk.VBox() | |
278 vbox.pack_start(gtk.Label(msg)) | |
279 self.button = gtk.Button('OK') | |
280 vbox.pack_start(self.button) | |
281 self.button.connect("clicked", self.onQuit) | |
282 self.window.add(vbox) | |
283 pass | |
284 | |
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
|
285 def update(self): |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 lobj = self._framelines[layer] |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
297 self.addScenes(lobj, ns) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
298 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
299 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
300 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
301 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
302 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
303 pass |
956 | 304 |
305 def parseScene(self): | |
306 """ | |
957 | 307 In this function, we will collect all items for the current |
308 scene and then relocate them back to the appropriate scene | |
309 object. | |
956 | 310 """ |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
311 self.layers = [] |
956 | 312 self.scenemap = None |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
313 doc = self.root |
956 | 314 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
315 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
|
316 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
|
317 doc.childList() |
1131 | 318 try: |
1141 | 319 self.width = float(doc.getAttribute("width")) |
320 self.height= float(doc.getAttribute("height")) | |
1131 | 321 except: |
322 self.width = 640 | |
323 self.height=480 | |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
324 pass |
1131 | 325 |
956 | 326 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
|
327 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
|
328 if node.name() == 'svg:metadata': |
956 | 329 self.parseMetadata(node) |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
330 pass |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
331 elif node.name() == 'svg:g': |
956 | 332 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
|
333 #obs = LayerAttributeWatcher(self) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
334 #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
|
335 #node.addObserver(obs) |
956 | 336 lyobj = Layer(node) |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
337 self.layers.append(lyobj) |
956 | 338 lyobj.current_scene = [] |
339 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
|
340 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
|
341 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
|
342 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
343 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
|
344 if label == 'dup': |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
345 # XXX: This would stop animation. |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
346 # 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
|
347 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
|
348 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
349 pass |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
350 |
956 | 351 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
352 scmap = self.scenemap[scene.getAttribute('id')] |
956 | 353 if scmap == None: |
354 lyobj.current_scene.append(scene) | |
355 continue | |
356 except: | |
357 lyobj.current_scene.append(scene) | |
358 continue | |
359 | |
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
|
360 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
|
361 pass |
956 | 362 else: |
363 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
|
364 pass |
956 | 365 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
366 pass |
956 | 367 pass |
368 | |
981 | 369 |
956 | 370 self.collectID() |
371 self.dumpID() | |
372 pass | |
373 | |
374 def collectID(self): | |
375 self.ID = {} | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
376 root = self.root |
956 | 377 for n in root.childList(): |
378 self.collectID_recursive(n) | |
379 pass | |
380 pass | |
381 | |
382 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
|
383 try: |
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
384 self.ID[node.getAttribute('id')] = 1 |
1141 | 385 except: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
386 pass |
956 | 387 for n in node.childList(): |
388 self.collectID_recursive(n) | |
389 pass | |
390 pass | |
391 | |
392 def newID(self): | |
393 while True: | |
394 n = 's%d' % int(random.random()*10000) | |
395 #print "try %s" % n | |
396 if self.ID.has_key(n) == False: | |
397 return n | |
398 pass | |
399 pass | |
400 | |
401 def dumpID(self): | |
402 for a,v in self.ID.items(): | |
403 pass | |
404 pass | |
405 | |
406 def getLayer(self, layer): | |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
407 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
|
408 if l.node.getAttribute('id') == layer: |
956 | 409 return l |
410 pass | |
411 return None | |
412 | |
413 | |
414 def insertKeyScene(self): | |
415 """ | |
957 | 416 Insert a new key scene into the stage. If the nth is always a |
417 key scene, we will return without changing anything. If the | |
418 nth is a filled scene, we will break the original scene into | |
419 two parts. If the nth is out of any scene, we will append a | |
420 new scene. | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
421 |
956 | 422 """ |
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
|
423 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
|
424 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
|
425 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
|
426 ns = rdoc.createElement("svg:g") |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
427 found = False |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
428 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
|
429 try: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
430 label = node.getAttribute("inkscape:label") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
431 except: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
432 continue |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
433 if label == "dup": |
1171 | 434 #FIXME: The duplication here is not perfect. We should |
435 # get the element inside the group and apply the | |
436 # transformation matrix to it directly. | |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
437 for n in node.childList(): |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
438 ns.appendChild(n.duplicate(self.document)) |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
439 found = True |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
440 node.setAttribute("style","display:none") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
441 break |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
442 pass |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
443 pass |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
444 |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
445 if found == False: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
446 txt = rdoc.createElement("svg:rect") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
447 txt.setAttribute("x","0") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
448 txt.setAttribute("y","0") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
449 txt.setAttribute("width","100") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
450 txt.setAttribute("height","100") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
451 txt.setAttribute("style","fill:#ff00") |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
452 ns.appendChild(txt) |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
453 |
1142
dd6c60c6f41e
Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents:
1141
diff
changeset
|
454 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID() |
975 | 455 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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 self.update() |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
461 pass |
956 | 462 |
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 # 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
|
478 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
|
479 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
|
480 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
|
481 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
|
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 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 |
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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 i = i + 1 |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
497 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
498 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
499 |
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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 # 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
|
520 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
|
521 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
|
522 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
|
523 # 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
|
524 # 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
|
525 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
|
526 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
|
527 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
|
528 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
|
529 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
|
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 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
|
532 # 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
|
533 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
|
534 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
|
535 # 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 # 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
|
543 # 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 return |
956 | 552 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
|
553 # 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
|
554 i = i + 1 |
956 | 555 pass |
556 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
|
557 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
|
558 # 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 pass |
956 | 568 pass |
569 pass | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
570 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
571 |
956 | 572 |
573 def setCurrentScene(self,nth): | |
1123 | 574 """ |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
575 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
|
576 data. There are a couple of cases. |
1148 | 577 1. If the type of the scene is normal, we display it when |
578 it contains the current frame. Otherwise hide it. | |
579 2. If the type of the scene is relocate or scale, we need | |
580 to duplicate the scene group and then modify its | |
581 transform matrix according to the definition of the | |
582 scene. Then, hide the original scenr group and display | |
583 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
|
584 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
|
585 |
1148 | 586 For each layer, we will always use the duplicated scene |
587 group whose name as dup. | |
588 We will put the duplicated scene group inside it. We will | |
589 create this group if it is not | |
1123 | 590 available. |
591 """ | |
956 | 592 self.current = nth |
1140 | 593 self.tween.updateMapping() |
1151
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
594 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
|
595 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
|
596 i=0 |
1123 | 597 |
598 # Check the duplicated scene group and create it if it is not available | |
599 try: | |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
600 layer.duplicateGroup.setAttribute("style","display:none") |
1123 | 601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 layer.layer.node.appendChild(layer.duplicateGroup) |
1123 | 608 pass |
609 # 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
|
610 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
|
611 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
|
612 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
|
613 if idx == start_idx: |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
614 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
|
615 else: |
1151
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 layer.duplicateGroup.setAttribute("style","") |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
626 tween_type_idx = \ |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
627 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
|
628 tween_obj_tween_type = \ |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
629 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
|
630 |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
631 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
|
632 layer.get_frame_block(stop_idx + 1) |
1163 | 633 if next_idx == -1: |
634 next_scene_group = scene_group | |
635 else: | |
636 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
|
637 |
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
|
638 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
|
639 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
|
640 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
|
641 tween_obj_tween_type, |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
642 scene_group, |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
643 next_scene_group, |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
644 percent) |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
645 else: |
1151
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
646 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
|
647 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
|
648 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
649 pass |
956 | 650 pass |
651 pass | |
1125 | 652 |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
653 def enterGroup(self,obj): |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
654 for l in self.layers: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
655 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
|
656 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
|
657 self.desktop.setCurrentLayer(s.spitem) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
658 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
659 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
660 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
661 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
662 |
1178
416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1177
diff
changeset
|
663 def selectSceneObject(self, frameline, frame_idx): |
1177
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
664 try: |
1178
416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1177
diff
changeset
|
665 start, stop, tween_type = frameline.get_frame_block(frame_idx) |
1177
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
666 except: |
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
667 return |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
668 |
1177
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
669 scene_group = frameline.get_frame_data(start) |
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
670 self.enterGroup(scene_group) |
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
671 self.setTweenType(tween_type) |
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
672 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
673 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
674 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
|
675 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
|
676 self._disable_tween_type_selector = True |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
677 self.tweenTypeSelector.set_active(sel_type) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
678 self._disable_tween_type_selector = False |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
679 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
680 |
956 | 681 def newCell(self,file): |
682 img = gtk.Image() | |
683 img.set_from_file(file) | |
684 btn = gtk.EventBox() | |
685 btn.add(img) | |
686 btn.connect("button_press_event", self.cellSelect) | |
687 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) | |
688 return btn | |
689 | |
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
|
690 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
|
691 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
|
692 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
|
693 self.last_line.active_frame(frame) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
694 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
|
695 self.doEditScene(frame) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
696 self.lockui = False |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
697 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
|
698 |
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 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
|
700 """ |
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
701 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
|
702 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
|
703 """ |
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
704 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
|
705 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
|
706 f.hide_hover() |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
707 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
708 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
709 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
|
710 |
963
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
711 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
|
712 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
|
713 self.scrollwin = gtk.ScrolledWindow() |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
714 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
|
715 gtk.POLICY_AUTOMATIC) |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
716 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
|
717 vbox = gtk.VBox() |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
718 vbox.show() |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
719 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
|
720 self.scrollwin_vbox = vbox |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
721 else: |
1174 | 722 for c in self.scrollwin_vbox.get_children(): |
723 self.scrollwin_vbox.remove(c) | |
724 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
|
725 pass |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
726 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
727 nframes = 100 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
728 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
729 ruler = frameruler(nframes) |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
730 ruler.set_size_request(nframes * 10, 20) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
731 ruler.show() |
1032 | 732 hbox = gtk.HBox() |
733 label=gtk.Label('') | |
734 label.set_size_request(100,0) | |
735 hbox.pack_start(label,expand=False,fill=True) | |
736 hbox.pack_start(ruler) | |
737 vbox.pack_start(hbox, False) | |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
738 |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
739 # |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
740 # Add a frameline for each layer |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
741 # |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 hbox = gtk.HBox() |
1141 | 746 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
|
747 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
|
748 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
|
749 hbox.pack_start(line) |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
750 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
|
751 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
|
752 line.label = label |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 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
|
757 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
|
758 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
|
759 pass |
1174 | 760 vbox.show_all() |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
761 pass |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
762 |
963
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
763 ## \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
|
764 # |
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
765 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
|
766 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
|
767 layer = frameline.layer |
1141 | 768 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
|
769 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
|
770 else: |
1141 | 771 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
|
772 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
|
773 for scene in layer.scenes: |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
774 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
|
775 frameline.setRightTween(last_scene.end) |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
776 else: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
777 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
|
778 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
|
779 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
|
780 frameline.add_keyframe(scene.end-1,scene.node) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 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
|
785 pass |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
786 pass |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
787 |
956 | 788 def cellSelect(self, cell, data): |
789 if self.last_cell: | |
957 | 790 color = self.last_cell.get_colormap().alloc_color("gray") |
791 self.last_cell.modify_bg(gtk.STATE_NORMAL, color) | |
956 | 792 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
793 |
956 | 794 self.last_cell = cell |
957 | 795 color = cell.get_colormap().alloc_color("green") |
796 cell.modify_bg(gtk.STATE_NORMAL, color) | |
956 | 797 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
798 |
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
|
799 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
|
800 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
|
801 # 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
|
802 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
|
803 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
|
804 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
|
805 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
|
806 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
|
807 # 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
|
808 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
|
809 return |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
810 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
|
811 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
|
812 self.update() |
1166
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
813 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
|
814 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
|
815 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
|
816 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
|
817 i = i + 1 |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
818 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
819 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
820 |
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
|
821 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
|
822 # Search for the duplicated group |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
823 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
|
824 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
|
825 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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 break |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
833 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
834 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
835 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
836 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
|
837 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
|
838 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
|
839 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
|
840 |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
841 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
|
842 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
|
843 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
|
844 print old_node |
1151
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
845 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
|
846 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
|
847 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
|
848 pass |
71c72e8d6755
Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
849 |
1142
dd6c60c6f41e
Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents:
1141
diff
changeset
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 return ns |
956 | 856 |
1178
416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1177
diff
changeset
|
857 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
|
858 self.setCurrentScene(self.last_frame+1) |
1178
416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1177
diff
changeset
|
859 self.selectSceneObject(self.last_line,self.last_frame) |
956 | 860 pass |
861 | |
862 def doInsertKeyScene(self,w): | |
1131 | 863 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
|
864 self.insertKeyScene() |
1178
416e41952b76
Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1177
diff
changeset
|
865 self.selectSceneObject(self.last_line, self.last_frame) |
1131 | 866 self.lockui=False |
956 | 867 # self.grid.show_all() |
868 return | |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
869 |
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
|
870 def doDuplicateKeyScene(self,w): |
1131 | 871 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
|
872 self.duplicateKeyScene() |
1131 | 873 self.lockui = False |
956 | 874 |
875 def doRemoveScene(self,w): | |
1131 | 876 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
|
877 self.removeKeyScene() |
1131 | 878 self.lockui = False |
956 | 879 return |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
880 |
956 | 881 |
882 def doExtendScene(self,w): | |
1131 | 883 self.lockui = True |
956 | 884 self.extendScene() |
1131 | 885 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
|
886 #self.grid.show_all() |
956 | 887 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
|
888 |
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
|
889 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
|
890 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
|
891 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
|
892 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
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 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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 self.editDone.connect('clicked', self.changeObjectLabel) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
900 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
901 |
1147 | 902 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
|
903 """ |
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
|
904 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
|
905 """ |
1147 | 906 if self.btnRun.get_label() == "Run": |
907 self.btnRun.set_label("Stop") | |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
908 self.lockui = True |
1147 | 909 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) |
910 else: | |
911 self.btnRun.set_label("Run") | |
912 glib.source_remove(self.last_update) | |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
913 self.lockui = False |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
914 pass |
1147 | 915 |
916 def doRunNext(self): | |
917 if self.current >= self.maxframe: | |
918 self.current = 0 | |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
919 try: |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
920 self.setCurrentScene(self.current+1) |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
921 except: |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
922 traceback.print_exc() |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
923 raise |
1147 | 924 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) |
1174 | 925 |
926 def doInsertScene(self,w): | |
927 self.lockui=True | |
928 self.last_line.insert_frame(self.last_frame) | |
929 self.update() | |
930 self.lockui=False | |
931 | |
932 def doRemoveScene(self,w): | |
933 self.lockui=True | |
934 self.last_line.remove_frame(self.last_frame) | |
935 self.update() | |
936 self.lockui=False | |
956 | 937 |
938 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
|
939 #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
|
940 #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
|
941 #hbox.pack_start(btn,expand=False,fill=False) |
1174 | 942 |
956 | 943 btn = gtk.Button('Insert Key') |
944 btn.connect('clicked',self.doInsertKeyScene) | |
945 hbox.pack_start(btn,expand=False,fill=False) | |
1174 | 946 |
956 | 947 btn=gtk.Button('Remove Key') |
948 btn.connect('clicked', self.doRemoveScene) | |
949 hbox.pack_start(btn,expand=False,fill=False) | |
1174 | 950 |
956 | 951 btn=gtk.Button('Extend scene') |
952 btn.connect('clicked', self.doExtendScene) | |
953 hbox.pack_start(btn,expand=False,fill=False) | |
1174 | 954 |
955 btn=gtk.Button('Duplicate Key') | |
956 btn.connect('clicked', self.doDuplicateKeyScene) | |
957 hbox.pack_start(btn,expand=False,fill=False) | |
958 | |
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
|
959 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
|
960 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
|
961 hbox.pack_start(btn,expand=False,fill=False) |
1174 | 962 |
963 btn=gtk.Button('Insert') | |
964 btn.connect('clicked', self.doInsertScene) | |
965 hbox.pack_start(btn,expand=False,fill=False) | |
966 | |
967 btn=gtk.Button('Remove') | |
968 btn.connect('clicked', self.doRemoveScene) | |
969 hbox.pack_start(btn,expand=False,fill=False) | |
970 | |
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
|
971 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
|
972 btn.connect('clicked', self.doRun) |
1147 | 973 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
|
974 hbox.pack_start(btn,expand=False,fill=False) |
1174 | 975 |
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
|
976 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
|
977 self.addTweenTypeSelector(hbox) |
956 | 978 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
979 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
980 def onTweenTypeChange(self, w): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
981 if self._disable_tween_type_selector: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
982 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
983 |
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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 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
|
989 found = -1 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
990 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
|
991 if start_idx <= idx and stop_idx >= idx: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
992 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
|
993 new_tween_type = MBScene._frameline_tween_types[n] |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
994 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
|
995 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
|
996 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
|
997 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
998 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
|
999 |
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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
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 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
|
1006 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
|
1007 #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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
1013 pass |
956 | 1014 |
1015 def onQuit(self, event): | |
1016 self.OK = False | |
1017 gtk.main_quit() | |
1018 pass | |
1019 | |
1020 def onOK(self,event): | |
1021 self.OK = True | |
1022 gtk.main_quit() | |
1023 pass | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
1024 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1025 def addScenes(self, frameline, scenes_node): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1026 doc = self.document |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1032 scene_node = doc.createElement("ns0:scene") |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1033 scenes_node.appendChild(scene_node) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1034 scene_node.setAttribute("start", str(start_idx + 1)) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1035 if start_idx != stop_idx: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1036 scene_node.setAttribute("end", str(stop_idx + 1)) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1037 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1038 scene_node.setAttribute("ref", ref.attribute("id")) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1039 scene_node.setAttribute("type", tween_type_name) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1040 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1041 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1042 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
1043 def updateUI(self,node=None,arg=None): |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
1044 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
|
1045 |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
1046 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
|
1047 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
|
1048 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
|
1049 |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
1050 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
1051 |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
1052 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
|
1053 self.parseScene() |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
1054 self._create_framelines() |
d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents:
1164
diff
changeset
|
1055 self._update_framelines() |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
1056 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
1057 |
956 | 1058 def show(self): |
1059 self.OK = True | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
1060 if not self.root: |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
1061 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
|
1062 pass |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
1063 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 else: |
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
1071 self.top.remove(self.startWindow) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1072 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
1073 |
981 | 1074 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
|
1075 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
|
1076 self.top.pack_start(vbox,expand=False) |
981 | 1077 vbox.pack_start(self.scrollwin,expand=False) |
1078 hbox=gtk.HBox(False,0) | |
1079 self.addButtons(hbox) | |
1080 vbox.pack_start(hbox,expand=False) | |
1081 | |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
1082 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
|
1083 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
|
1084 return False |
956 | 1085 pass |