Mercurial > MadButterfly
annotate pyink/MBScene.py @ 1149:0ffef2df6201
Rename MBScene.dom to MBScene.root
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 24 Dec 2010 15:40:16 +0800 |
parents | 153a87b4edb7 |
children | 6586cd10c92f |
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 |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
2 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; -*- |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
3 # vim: sw=4:ts=8:sts=4 |
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 |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
15 |
957 | 16 # Please refer to |
17 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention | |
18 # 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
|
19 |
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 # Algorithm: |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
22 # |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
23 # 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
|
24 # layer and scene. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
25 # - 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
|
26 # column of the grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
27 # - 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
|
28 # grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
29 # - 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
|
30 # 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
|
31 # 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
|
32 # 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
|
33 # for this purpose. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
34 # - 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
|
35 # 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
|
36 # 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
|
37 # 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
|
38 # 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
|
39 # 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
|
40 # - 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
|
41 # 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
|
42 # |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
43 |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
44 class Layer: |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
45 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
|
46 self.scenes = [] |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
47 self.node = node |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
48 self.nodes=[] |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
49 pass |
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 |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
52 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
|
53 def __init__(self, node, start,end,typ): |
956 | 54 self.node = node |
55 self.start = int(start) | |
56 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
|
57 self.type = typ |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
58 pass |
956 | 59 pass |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 pass |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
64 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
65 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
|
66 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
|
67 |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 pass |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
83 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
|
84 print 'cont' |
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): |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
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 |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
143 class MBScene(): |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
144 def __init__(self, desktop, win, root=None): |
956 | 145 self.desktop = desktop |
146 self.window = win | |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
147 self.layers = [] |
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
148 self.layers.append(Layer(None)) |
956 | 149 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
|
150 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
|
151 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
|
152 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
|
153 self.last_select = None |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
154 self.lockui=False |
1140 | 155 self.tween=None |
156 self.document = None | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
157 self.root = root |
1147 | 158 self.framerate=12 |
159 self.maxframe=0 | |
956 | 160 pass |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
161 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
162 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
|
163 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
|
164 try: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 return |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
169 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
170 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
|
171 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
|
172 return |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
173 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
|
174 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
175 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
|
176 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
177 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
|
178 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
179 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
|
180 |
956 | 181 def confirm(self,msg): |
182 vbox = gtk.VBox() | |
183 vbox.pack_start(gtk.Label(msg)) | |
184 self.button = gtk.Button('OK') | |
185 vbox.pack_start(self.button) | |
186 self.button.connect("clicked", self.onQuit) | |
187 self.window.add(vbox) | |
188 pass | |
189 | |
190 def dumpattr(self,n): | |
191 s = "" | |
192 for a,v in n.attrib.items(): | |
193 s = s + ("%s=%s" % (a,v)) | |
194 pass | |
195 return s | |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
196 |
956 | 197 def dump(self,node,l=0): |
198 print " " * l*2,"<", node.tag, self.dumpattr(node),">" | |
199 for n in node: | |
200 self.dump(n,l+1) | |
201 pass | |
202 print " " * l * 2,"/>" | |
203 pass | |
204 | |
205 def parseMetadata(self,node): | |
206 self.current = 1 | |
207 for n in node.childList(): | |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
208 if n.name() == 'ns0:scenes': |
956 | 209 self.scenemap={} |
976
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
210 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
211 cur = int(n.getAttribute("current")) |
976
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
212 except: |
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
213 cur = 1 |
956 | 214 self.current = cur |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
215 |
956 | 216 for s in n.childList(): |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
217 if s.name() == 'ns0:scene': |
956 | 218 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
219 start = int(s.getAttribute("start")) |
956 | 220 except: |
221 traceback.print_exc() | |
222 continue | |
223 try: | |
1147 | 224 end = int(s.getAttribute("end")) |
956 | 225 if end == None: |
226 end = start | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
227 pass |
956 | 228 except: |
229 end = start | |
230 pass | |
1147 | 231 if end > self.maxframe: |
232 self.maxframe = end | |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
233 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
234 typ = s.getAttribute('type') |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
235 if typ == None: |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
236 typ = 'normal' |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
237 except: |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
238 traceback.print_exc() |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
239 typ = 'normal' |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
240 link = s.getAttribute("ref") |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
241 self.scenemap[link] = [int(start),int(end),typ] |
956 | 242 if cur >= start and cur <= end: |
243 self.currentscene = link | |
244 pass | |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
245 pass |
956 | 246 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
247 pass |
956 | 248 pass |
249 pass | |
981 | 250 if self.scenemap==None: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
251 #self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
252 self.root.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
253 scenes = self.document.createElement("ns0:scenes") |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
254 node.appendChild(scenes) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
255 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
256 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
257 |
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
|
258 def update(self): |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 lobj = self._framelines[layer] |
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
|
270 lobj.addScenes(rdoc,ns) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
271 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
272 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
273 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
274 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
275 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
276 pass |
956 | 277 |
278 def parseScene(self): | |
279 """ | |
957 | 280 In this function, we will collect all items for the current |
281 scene and then relocate them back to the appropriate scene | |
282 object. | |
956 | 283 """ |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
284 self.layers = [] |
956 | 285 self.scenemap = None |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
286 doc = self.root |
956 | 287 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
288 #obs = pybInkscape.PYNodeObserver() |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
289 #obs = LayerAddRemoveWatcher(self) |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
290 #doc.addObserver(obs) |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
291 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
|
292 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
|
293 doc.childList() |
1131 | 294 try: |
1141 | 295 self.width = float(doc.getAttribute("width")) |
296 self.height= float(doc.getAttribute("height")) | |
1131 | 297 except: |
298 self.width = 640 | |
299 self.height=480 | |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
300 pass |
1131 | 301 |
956 | 302 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
|
303 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
|
304 if node.name() == 'svg:metadata': |
956 | 305 self.parseMetadata(node) |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
306 pass |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
307 elif node.name() == 'svg:g': |
956 | 308 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
|
309 #obs = LayerAttributeWatcher(self) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
310 #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
|
311 #node.addObserver(obs) |
956 | 312 lyobj = Layer(node) |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
313 self.layers.append(lyobj) |
956 | 314 lyobj.current_scene = [] |
315 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
|
316 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
|
317 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
|
318 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
319 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
|
320 if label == 'dup': |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
321 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
|
322 except: |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
323 pass |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
324 |
956 | 325 try: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
326 scmap = self.scenemap[scene.getAttribute('id')] |
956 | 327 if scmap == None: |
328 lyobj.current_scene.append(scene) | |
329 continue | |
330 except: | |
331 lyobj.current_scene.append(scene) | |
332 continue | |
333 | |
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
|
334 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
|
335 pass |
956 | 336 else: |
337 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
|
338 pass |
956 | 339 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
340 pass |
956 | 341 pass |
342 | |
981 | 343 |
956 | 344 self.collectID() |
345 self.dumpID() | |
346 pass | |
347 | |
348 def collectID(self): | |
349 self.ID = {} | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
350 root = self.root |
956 | 351 for n in root.childList(): |
352 self.collectID_recursive(n) | |
353 pass | |
354 pass | |
355 | |
356 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
|
357 try: |
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
358 self.ID[node.getAttribute('id')] = 1 |
1141 | 359 except: |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
360 pass |
956 | 361 for n in node.childList(): |
362 self.collectID_recursive(n) | |
363 pass | |
364 pass | |
365 | |
366 def newID(self): | |
367 while True: | |
368 n = 's%d' % int(random.random()*10000) | |
369 #print "try %s" % n | |
370 if self.ID.has_key(n) == False: | |
371 return n | |
372 pass | |
373 pass | |
374 | |
375 def dumpID(self): | |
376 for a,v in self.ID.items(): | |
377 pass | |
378 pass | |
379 | |
380 def getLayer(self, layer): | |
961
b6375e74c69e
Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents:
960
diff
changeset
|
381 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
|
382 if l.node.getAttribute('id') == layer: |
956 | 383 return l |
384 pass | |
385 return None | |
386 | |
387 | |
388 def insertKeyScene(self): | |
389 """ | |
957 | 390 Insert a new key scene into the stage. If the nth is always a |
391 key scene, we will return without changing anything. If the | |
392 nth is a filled scene, we will break the original scene into | |
393 two parts. If the nth is out of any scene, we will append a | |
394 new scene. | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
395 |
956 | 396 """ |
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
|
397 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
|
398 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
|
399 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
|
400 ns = rdoc.createElement("svg:g") |
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
|
401 txt = rdoc.createElement("svg:rect") |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
402 txt.setAttribute("x","0") |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
403 txt.setAttribute("y","0") |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
404 txt.setAttribute("width","100") |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
405 txt.setAttribute("height","100") |
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
406 txt.setAttribute("style","fill:#ff00") |
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
|
407 ns.appendChild(txt) |
1142
dd6c60c6f41e
Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents:
1141
diff
changeset
|
408 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID() |
975 | 409 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
|
410 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
|
411 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
|
412 self.last_line.node.appendChild(ns) |
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
|
413 print 'Add key ', x |
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
|
414 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
|
415 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
|
416 self.last_line.update() |
956 | 417 |
418 | |
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 # 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 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
|
446 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
|
447 |
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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 i = i + 1 |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
453 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
454 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
455 |
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
|
456 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
|
457 nth = self.last_frame |
84f502fb3e40
Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents:
964
diff
changeset
|
458 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 # 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
|
476 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
|
477 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
|
478 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
|
479 # 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
|
480 # 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 # 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
|
489 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
|
490 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
|
491 # 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
|
492 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
|
493 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
|
494 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
|
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 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
|
497 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
|
498 # 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
|
499 # 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 return |
956 | 508 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
|
509 # 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
|
510 i = i + 1 |
956 | 511 pass |
512 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
|
513 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
|
514 # 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 self.last_line.update() |
973
84f502fb3e40
Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents:
964
diff
changeset
|
522 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
|
523 pass |
956 | 524 pass |
525 pass | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
526 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
527 |
956 | 528 |
529 def setCurrentScene(self,nth): | |
1123 | 530 """ |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
531 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
|
532 data. There are a couple of cases. |
1148 | 533 1. If the type of the scene is normal, we display it when |
534 it contains the current frame. Otherwise hide it. | |
535 2. If the type of the scene is relocate or scale, we need | |
536 to duplicate the scene group and then modify its | |
537 transform matrix according to the definition of the | |
538 scene. Then, hide the original scenr group and display | |
539 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
|
540 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
|
541 |
1148 | 542 For each layer, we will always use the duplicated scene |
543 group whose name as dup. | |
544 We will put the duplicated scene group inside it. We will | |
545 create this group if it is not | |
1123 | 546 available. |
547 """ | |
956 | 548 self.current = nth |
1140 | 549 self.tween.updateMapping() |
973
84f502fb3e40
Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents:
964
diff
changeset
|
550 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
|
551 i=0 |
1123 | 552 |
553 # Check the duplicated scene group and create it if it is not available | |
554 try: | |
555 if layer.duplicateGroup: | |
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
|
556 layer.duplicateGroup.setAttribute("style","display:none") |
1123 | 557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 layer.layer.node.appendChild(layer.duplicateGroup) |
1123 | 564 pass |
565 # Create a new group | |
1148 | 566 #layer.duplicateGroup = None |
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
|
567 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
|
568 s = layer._keys[i] |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
569 print s.ref.getAttribute("id"),s.idx,s.left_tween,s.right_tween |
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
|
570 if s.right_tween is False: |
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
|
571 if nth == s.idx+1: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
572 s.ref.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
|
573 else: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
574 s.ref.setAttribute("style","display:none") |
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
|
575 i = i + 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
|
576 continue |
1123 | 577 if nth == s.idx + 1: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
578 s.ref.setAttribute("style","") |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
579 else: |
1123 | 580 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1): |
581 if i+2 < len(layer._keys): | |
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
|
582 #s.ref.parent().appendChild(layer.duplicateGroup) |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
583 s.ref.setAttribute("style","display:none") |
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
|
584 layer.duplicateGroup.setAttribute("style","") |
1140 | 585 self.tween.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth) |
586 else: | |
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
|
587 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
|
588 #layer.duplicateGroup = s.ref.duplicate(self.document) |
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
|
589 #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
|
590 #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
|
591 #layer.duplicateGroup.setAttribute("sodipodi:insensitive","1") |
1140 | 592 s.ref.setAttribute("style","display:none") |
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
|
593 #s.ref.parent().appendChild(layer.duplicateGroup) |
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
|
594 pass |
1123 | 595 else: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
596 s.ref.setAttribute("style","display:none") |
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
|
597 i = i + 2 |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
598 pass |
956 | 599 pass |
600 pass | |
1125 | 601 |
1141 | 602 def DOMtoItem(self,obj): |
1123 | 603 """ |
1141 | 604 Find the corresponding PYSPObject object for a DOM object. |
1133 | 605 """ |
1141 | 606 return self.DOMtoItem_recursive(self.desktop.doc().root(),obj) |
1123 | 607 |
1141 | 608 def DOMtoItem_recursive(self,tree,obj): |
609 nodes = tree.childList() | |
610 for s in nodes: | |
611 if s.getId() == obj.getAttribute('id'): | |
612 return s | |
613 d = self.DOMtoItem_recursive(s,obj) | |
614 if d != None: return d | |
615 | |
1131 | 616 |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
617 def enterGroup(self,obj): |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
618 for l in self.layers: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
619 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
|
620 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
|
621 self.desktop.setCurrentLayer(s.spitem) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
622 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
623 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
624 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
625 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
626 |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
627 def selectSceneObject(self,frameline, nth): |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
628 i = 0 |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
629 while i < len(frameline._keys): |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
630 s = frameline._keys[i] |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
631 if s.right_tween is False: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
632 if nth == s.idx+1: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
633 self.enterGroup(s.ref) |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
634 self.setTweenType(frameline.get_tween_type(s.idx)) |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
635 return |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
636 else: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
637 pass |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
638 i = i + 1 |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
639 continue |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
640 |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
641 if nth >= (s.idx+1) and nth <= (frameline._keys[i+1].idx+1): |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
642 self.enterGroup(s.ref) |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
643 self.setTweenType(frameline.get_tween_type(s.idx)) |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
644 return |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
645 else: |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
646 pass |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
647 i = i + 2 |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
648 pass |
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
649 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
650 |
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
|
651 def setTweenType(self,typ): |
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
|
652 if typ == 'normal': |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
653 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
|
654 elif typ == 'relocate': |
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
|
655 self.tweenTypeSelector.set_active(1) |
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
|
656 elif typ == '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
|
657 self.tweenTypeSelector.set_active(2) |
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 |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
660 |
956 | 661 def newCell(self,file): |
662 img = gtk.Image() | |
663 img.set_from_file(file) | |
664 btn = gtk.EventBox() | |
665 btn.add(img) | |
666 btn.connect("button_press_event", self.cellSelect) | |
667 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) | |
668 return btn | |
669 | |
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
|
670 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
|
671 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
|
672 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
|
673 self.last_line.active_frame(frame) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
674 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
|
675 self.doEditScene(frame) |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
676 self.lockui = False |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
677 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
|
678 |
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
|
679 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
|
680 """ |
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
681 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
|
682 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
|
683 """ |
ab09c536a137
Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents:
975
diff
changeset
|
684 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
|
685 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
|
686 f.hide_hover() |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
687 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
688 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
689 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
|
690 |
963
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
691 def _create_framelines(self): |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
692 import frameline |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
693 self.scrollwin = gtk.ScrolledWindow() |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
694 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
695 self.scrollwin.set_size_request(-1,150) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
696 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
697 nframes = 100 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
698 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
699 vbox = gtk.VBox() |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
700 vbox.show() |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
701 self.scrollwin.add_with_viewport(vbox) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
702 |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
703 ruler = frameline.frameruler(nframes) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
704 ruler.set_size_request(nframes * 10, 20) |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
705 ruler.show() |
1032 | 706 hbox = gtk.HBox() |
707 label=gtk.Label('') | |
708 label.set_size_request(100,0) | |
709 hbox.pack_start(label,expand=False,fill=True) | |
710 hbox.pack_start(ruler) | |
711 vbox.pack_start(hbox, False) | |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
712 |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
713 # |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
714 # Add a frameline for each layer |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
715 # |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
716 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
|
717 for i in range(len(self.layers)-1,-1,-1): |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
718 line = frameline.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
|
719 hbox = gtk.HBox() |
1141 | 720 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
|
721 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
|
722 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
|
723 hbox.pack_start(line) |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
724 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
|
725 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
|
726 line.label = label |
960
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
727 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 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
|
733 pass |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
734 pass |
8fd97e0becb3
Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents:
959
diff
changeset
|
735 |
963
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
736 ## \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
|
737 # |
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
738 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
|
739 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
|
740 layer = frameline.layer |
1141 | 741 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
|
742 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
|
743 else: |
1141 | 744 frameline.label.set_text(frameline.node.getAttribute("inkscape:label")) |
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
|
745 for scene in layer.scenes: |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
746 frameline.add_keyframe(scene.start-1,scene.node) |
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
|
747 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
|
748 frameline.add_keyframe(scene.end-1,scene.node) |
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
|
749 frameline.tween(scene.start-1,scene.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
|
750 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
|
751 pass |
959
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
752 pass |
67823f7a0a17
Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
957
diff
changeset
|
753 |
956 | 754 def cellSelect(self, cell, data): |
755 if self.last_cell: | |
957 | 756 color = self.last_cell.get_colormap().alloc_color("gray") |
757 self.last_cell.modify_bg(gtk.STATE_NORMAL, color) | |
956 | 758 pass |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
759 |
956 | 760 self.last_cell = cell |
957 | 761 color = cell.get_colormap().alloc_color("green") |
762 cell.modify_bg(gtk.STATE_NORMAL, color) | |
956 | 763 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
764 |
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
|
765 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
|
766 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
|
767 # 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 # 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
|
774 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
|
775 return |
1139
a2b068594412
Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents:
1136
diff
changeset
|
776 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
|
777 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
|
778 self.update() |
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
|
779 self.show() |
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
|
780 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
|
781 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
|
782 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
|
783 i = i + 1 |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
784 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
785 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
786 |
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
|
787 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
|
788 # Search for the duplicated group |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
789 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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 break |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
799 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
800 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
801 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
802 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
|
803 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
|
804 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
|
805 ns = orig.duplicate(rdoc) |
1142
dd6c60c6f41e
Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents:
1141
diff
changeset
|
806 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
|
807 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
|
808 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
|
809 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
|
810 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
|
811 return ns |
956 | 812 |
813 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
|
814 self.setCurrentScene(self.last_frame+1) |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
815 self.selectSceneObject(self.last_line,self.last_frame+1) |
956 | 816 pass |
817 | |
818 def doInsertKeyScene(self,w): | |
1131 | 819 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
|
820 self.insertKeyScene() |
1131 | 821 self.lockui=False |
956 | 822 # self.grid.show_all() |
823 return | |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
824 |
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 def doDuplicateKeyScene(self,w): |
1131 | 826 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
|
827 self.duplicateKeyScene() |
1131 | 828 self.lockui = False |
956 | 829 |
830 def doRemoveScene(self,w): | |
1131 | 831 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
|
832 self.removeKeyScene() |
1131 | 833 self.lockui = False |
956 | 834 return |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
835 |
956 | 836 |
837 def doExtendScene(self,w): | |
1131 | 838 self.lockui = True |
956 | 839 self.extendScene() |
1131 | 840 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
|
841 #self.grid.show_all() |
956 | 842 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
|
843 |
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
|
844 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
|
845 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
|
846 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
|
847 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
848 |
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
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 self.editDone.connect('clicked', self.changeObjectLabel) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
855 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
856 |
1147 | 857 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
|
858 """ |
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
|
859 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
|
860 """ |
1147 | 861 if self.btnRun.get_label() == "Run": |
862 self.btnRun.set_label("Stop") | |
863 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) | |
864 else: | |
865 self.btnRun.set_label("Run") | |
866 glib.source_remove(self.last_update) | |
867 | |
868 def doRunNext(self): | |
869 if self.current >= self.maxframe: | |
870 self.current = 0 | |
871 print self.current,self.maxframe | |
872 self.setCurrentScene(self.current+1) | |
873 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) | |
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
|
874 |
956 | 875 |
876 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
|
877 #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
|
878 #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
|
879 #hbox.pack_start(btn,expand=False,fill=False) |
956 | 880 btn = gtk.Button('Insert Key') |
881 btn.connect('clicked',self.doInsertKeyScene) | |
882 hbox.pack_start(btn,expand=False,fill=False) | |
883 btn=gtk.Button('Remove Key') | |
884 btn.connect('clicked', self.doRemoveScene) | |
885 hbox.pack_start(btn,expand=False,fill=False) | |
886 btn=gtk.Button('Extend scene') | |
887 btn.connect('clicked', self.doExtendScene) | |
888 hbox.pack_start(btn,expand=False,fill=False) | |
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
|
889 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
|
890 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
|
891 hbox.pack_start(btn,expand=False,fill=False) |
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
|
892 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
|
893 btn.connect('clicked', self.doRun) |
1147 | 894 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
|
895 hbox.pack_start(btn,expand=False,fill=False) |
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
|
896 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
|
897 self.addTweenTypeSelector(hbox) |
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
|
898 |
956 | 899 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
900 |
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
|
901 def onTweenTypeChange(self,w): |
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
|
902 n = self.tweenTypeSelector.get_active() |
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
|
903 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
|
904 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
|
905 frameline = self.last_line |
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
|
906 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
|
907 found = -1 |
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
|
908 while i < len(frameline._keys): |
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
|
909 s = frameline._keys[i] |
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
|
910 if s.right_tween is 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
|
911 if self.last_frame == s.idx: |
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
|
912 found = s.idx |
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
|
913 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
|
914 else: |
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
|
915 pass |
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
|
916 i = i + 1 |
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
|
917 continue |
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
|
918 |
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
|
919 if self.last_frame >= s.idx and self.last_frame <= frameline._keys[i+1].idx: |
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
|
920 found = s.idx |
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
|
921 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
|
922 else: |
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
|
923 pass |
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
|
924 i = i + 2 |
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
|
925 pass |
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
|
926 pass |
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
|
927 if found == -1: 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
|
928 self.last_line.set_tween_type(found,self.tweenTypeSelector.get_active_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
|
929 self.last_line.update() |
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
|
930 self.update() |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
931 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
|
932 |
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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 |
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
|
938 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
|
939 self.tweenTypeSelector.append_text('normal') |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
1099
diff
changeset
|
940 self.tweenTypeSelector.append_text('relocate') |
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
|
941 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
|
942 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
|
943 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
|
944 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
|
945 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
946 pass |
956 | 947 |
948 def onQuit(self, event): | |
949 self.OK = False | |
950 gtk.main_quit() | |
951 pass | |
952 | |
953 def onOK(self,event): | |
954 self.OK = True | |
955 gtk.main_quit() | |
956 pass | |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
957 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
958 def updateUI(self,node=None,arg=None): |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
959 if self.lockui: return |
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
960 self.lockui = True |
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
961 self._updateUI() |
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
962 self.lockui = False |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
963 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
964 |
1130
37a0f6ab2f91
Lock the UI from refreshing during the update procedure
wycc
parents:
1128
diff
changeset
|
965 def _updateUI(self,node=None,arg=None): |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
966 if 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
|
967 glib.source_remove(self.last_update) |
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
968 self.last_update = glib.timeout_add(300,self.show) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
969 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
970 |
956 | 971 def show(self): |
972 self.OK = True | |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
973 if not self.root: |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
974 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
|
975 pass |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
976 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
977 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
|
978 self.tween = TweenObject(self.document, self.root) |
956 | 979 self.parseScene() |
963
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
980 self._create_framelines() |
a05ec4fb1c20
update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents:
962
diff
changeset
|
981 self._update_framelines() |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
982 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
|
983 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
|
984 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
|
985 else: |
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
986 self.top.remove(self.startWindow) |
981 | 987 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
|
988 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
|
989 self.top.pack_start(vbox,expand=False) |
981 | 990 vbox.pack_start(self.scrollwin,expand=False) |
991 hbox=gtk.HBox(False,0) | |
992 self.addButtons(hbox) | |
993 vbox.pack_start(hbox,expand=False) | |
994 | |
956 | 995 # self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) |
996 # self.window.connect("destroy", gtk.main_quit) | |
997 # self.window.set_position(gtk.WIN_POS_MOUSE) | |
998 | |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
999 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
|
1000 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
|
1001 return False |
956 | 1002 pass |