annotate pyink/MBScene.py @ 1125:5b2394f67ad0

Add shape tween support.
author wycc
date Sat, 11 Dec 2010 21:08:51 +0800
parents aad659b6b625
children b65ac686a7c5
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
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
13
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
14 # Please refer to
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
15 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
16 # 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
17
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
18
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
19 # Algorithm:
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
20 #
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
21 # 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
22 # layer and scene.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
23 # - 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
24 # column of the grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
25 # - 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
26 # grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
27 # - 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
28 # 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
29 # 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
30 # 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
31 # for this purpose.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
32 # - 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
33 # 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
34 # 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
35 # 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
36 # 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
37 # 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
38 # - 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
39 # 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
40 #
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
41
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
42 class Layer:
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
43 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
44 self.scenes = []
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
45 self.node = node
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
46 self.nodes=[]
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
47 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
48 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
49
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
50 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
51 def __init__(self, node, start,end,typ):
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
52 self.node = node
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
53 self.start = int(start)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
54 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
55 self.type = typ
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
56 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
57 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
58
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
59 _scenes = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes'
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
60 _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
61 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
62 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
63 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
64 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
65 pass
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
66 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
67 pass
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
68 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
69 pass
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
70 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
71 pass
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
72 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
73 self.ui.updateUI()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
74 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
75 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
76 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
77 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
78 self.ui.updateUI()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
79 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
80 self.ui.updateUI()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
81 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
82 self.ui.updateUI()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
83 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
84 self.ui.updateUI()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
85 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
86 self.ui.updateUI()
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
87 class MBScene():
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
88 def __init__(self,desktop,win):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
89 self.desktop = desktop
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
90 self.window = win
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
91 self.layers = []
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
92 self.layers.append(Layer(None))
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
93 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
94 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
95 self.last_update = None
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
96 self.startPolling()
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
97 self.last_select = None
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
98 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
99
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
100 def startPolling(self):
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
101 objs = self.desktop.selection.list()
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
102 if len(objs) != 1:
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
103 glib.timeout_add(500,self.startPolling)
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
104 try:
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
105 self.nameEditor.set_text('')
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
106 except:
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
107 traceback.print_exc()
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
108 pass
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
109 return
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
110 o = objs[0]
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
111 if o == self.last_select:
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
112 glib.timeout_add(500,self.startPolling)
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
113 return
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
114 self.last_select = o
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
115 try:
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
116 self.nameEditor.set_text(o.repr.attribute("inkscape:label"))
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
117 except:
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
118 self.nameEditor.set_text('')
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
119 pass
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
120 glib.timeout_add(500,self.startPolling)
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
121
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
122 def confirm(self,msg):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
123 vbox = gtk.VBox()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
124 vbox.pack_start(gtk.Label(msg))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
125 self.button = gtk.Button('OK')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
126 vbox.pack_start(self.button)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
127 self.button.connect("clicked", self.onQuit)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
128 self.window.add(vbox)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
129 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
130
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
131 def dumpattr(self,n):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
132 s = ""
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
133 for a,v in n.attrib.items():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
134 s = s + ("%s=%s" % (a,v))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
135 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
136 return s
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
137
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
138 def dump(self,node,l=0):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
139 print " " * l*2,"<", node.tag, self.dumpattr(node),">"
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
140 for n in node:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
141 self.dump(n,l+1)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
142 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
143 print " " * l * 2,"/>"
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
144 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
145
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
146 def parseMetadata(self,node):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
147 self.current = 1
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
148 for n in node.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
149 if n.repr.name() == 'ns0:scenes':
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
150 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
151 try:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
152 cur = int(n.repr.attribute("current"))
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
153 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
154 cur = 1
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
155 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
156
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
157 for s in n.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
158 if s.repr.name() == 'ns0:scene':
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
159 try:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
160 start = int(s.repr.attribute("start"))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
161 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
162 traceback.print_exc()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
163 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
164 try:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
165 end = s.repr.attribute("end")
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
166 if end == None:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
167 end = start
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
168 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
169 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
170 end = start
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
171 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
172 try:
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
173 typ = s.repr.attribute('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
174 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
175 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
176 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
177 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
178 typ = 'normal'
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
179 link = s.repr.attribute("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
180 self.scenemap[link] = [int(start),int(end),typ]
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
181 if cur >= start and cur <= end:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
182 self.currentscene = link
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
183 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
184 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
185 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
186 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
187 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
188 pass
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
189 if self.scenemap==None:
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
190 self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd",True)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
191 scenes = self.desktop.doc().rdoc.createElement("ns0:scenes")
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
192 node.repr.appendChild(scenes)
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
193 def update(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
194 doc = self.desktop.doc().root()
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
195 rdoc = self.desktop.doc().rdoc
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
196 for node in doc.childList():
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
197 if node.repr.name() == 'svg:metadata':
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
198 for t in node.childList():
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
199 if t.repr.name() == "ns0:scenes":
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
200 node.repr.removeChild(t.repr)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
201 ns = rdoc.createElement("ns0:scenes")
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
202 node.repr.appendChild(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
203 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
204 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
205 lobj.addScenes(rdoc,ns)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
206
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
207
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
208 def parseScene(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
209 """
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
210 In this function, we will collect all items for the current
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
211 scene and then relocate them back to the appropriate scene
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
212 object.
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
213 """
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
214 self.layers = []
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
215 self.scenemap = None
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
216 doc = self.desktop.doc().root()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
217
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
218 #obs = pybInkscape.PYNodeObserver()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
219 obs = LayerAddRemoveWatcher(self)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
220 doc.repr.addObserver(obs)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
221 for node in doc.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
222 if node.repr.name() == 'svg:metadata':
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
223 self.parseMetadata(node)
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
224 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
225 elif node.repr.name() == 'svg:g':
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
226 oldscene = None
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
227 obs = LayerAttributeWatcher(self)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
228 node.repr.addObserver(obs)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
229 lyobj = Layer(node)
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
230 self.layers.append(lyobj)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
231 lyobj.current_scene = []
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
232 for scene in node.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
233 if scene.repr.name() == 'svg:g':
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
234 try:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
235 scmap = self.scenemap[scene.getId()]
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
236 if scmap == None:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
237 lyobj.current_scene.append(scene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
238 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
239 except:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
240 lyobj.current_scene.append(scene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
241 continue
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
242
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
243 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
244 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
245 else:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
246 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
247 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
248 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
249 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
250 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
251
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
252
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
253 self.collectID()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
254 self.dumpID()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
255 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
256
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
257 def collectID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
258 self.ID = {}
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
259 root = self.desktop.doc().root()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
260 for n in root.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
261 self.collectID_recursive(n)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
262 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
263 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
264
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
265 def collectID_recursive(self,node):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
266 self.ID[node.getId()] = 1
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
267 for n in node.childList():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
268 self.collectID_recursive(n)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
269 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
270 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
271
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
272 def newID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
273 while True:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
274 n = 's%d' % int(random.random()*10000)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
275 #print "try %s" % n
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
276 if self.ID.has_key(n) == False:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
277 return n
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
278 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
279 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
280
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
281 def dumpID(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
282 for a,v in self.ID.items():
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
283 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
284 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
285
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
286 def getLayer(self, layer):
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
287 for l in self.layers:
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
288 if l.node.getId() == layer:
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
289 return l
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
290 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
291 return None
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
292
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
293
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
294 def insertKeyScene(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
295 """
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
296 Insert a new key scene into the stage. If the nth is always a
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
297 key scene, we will return without changing anything. If the
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
298 nth is a filled scene, we will break the original scene into
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
299 two parts. If the nth is out of any scene, we will append a
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
300 new scene.
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
301
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
302 """
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
303 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
304 y = 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
305 rdoc = self.desktop.doc().rdoc
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
306 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
307 txt = rdoc.createElement("svg:rect")
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
308 txt.setAttribute("x","0",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
309 txt.setAttribute("y","0",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
310 txt.setAttribute("width","100",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
311 txt.setAttribute("height","100",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
312 txt.setAttribute("style","fill:#ff00",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
313 ns.appendChild(txt)
982
1bda9f9e00ea Set the inkscape:groupmode attribute so that the inkscape will put the scene groups in the layer manager and protect it from detection.
wycc
parents: 981
diff changeset
314 gid = self.last_line.node.label()+self.newID()
975
ed7e8e309d55 Remove generate function
wycc
parents: 973
diff changeset
315 self.ID[gid]=1
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
316 ns.setAttribute("id",gid,True)
982
1bda9f9e00ea Set the inkscape:groupmode attribute so that the inkscape will put the scene groups in the layer manager and protect it from detection.
wycc
parents: 981
diff changeset
317 ns.setAttribute("inkscape:groupmode","layer",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
318 self.last_line.node.repr.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
319 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
320 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
321 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
322 self.last_line.update()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
323
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
324
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
325 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
326 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
327 y = 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
328 rdoc = self.desktop.doc().rdoc
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 # 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353
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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 # 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
379 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
380 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
381 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
382 # 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
383 # 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391 # 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
392 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
393 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
394 # 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
395 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
396 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
397 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
398 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
399 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
400 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
401 # 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
402 # 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
403 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
404 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
405 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
406 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
407 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
408 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
409 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
410 return
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
411 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
412 # 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
413 i = i + 1
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
414 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
415 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
416 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
417 # 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 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
426 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
427 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
428 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
429
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
430
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
431 def setCurrentScene(self,nth):
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
432 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
433 Update the scene group according to the curretn scene data. There are a couple of cases.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
434 1. If the type of the scene is normal, we display it when it contains the current
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
435 frame. Otherwise hide it.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
436 2. If the type of the scene is relocate or scale, we need to duplicate the scene group
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
437 and then modify its transform matrix according to the definition of the scene. Then,
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
438 hide the original scenr group and display the duplciate scene group. In addition,
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
439 we may need to delete the old duplicated scene group as well.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
440
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
441 For each layer, we will always use the duplicated scene group whose name as dup.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
442 We will put the duplicated scene group inside it. We will create this group if it is not
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
443 available.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
444 """
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
445 self.current = nth
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
446 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
447 i=0
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
448
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
449 # Check the duplicated scene group and create it if it is not available
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
450 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
451 if layer.duplicateGroup:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
452 layer.duplicateGroup.parent().removeChild(layer.duplicateGroup)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
453 layer.duplicateGroup = None
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
454 except:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
455 traceback.print_exc()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
456 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
457 # Create a new group
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
458 layer.duplicateGroup = None
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
459
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
460
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
461 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
462 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
463 print s.ref.attribute("id"),s.idx,s.left_tween,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
464 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
465 if nth == s.idx+1:
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
466 s.ref.setAttribute("style","",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old 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 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
468 s.ref.setAttribute("style","display:none",True)
84f502fb3e40 Rewrite the MBScene to use framelines. The old 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 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
470 continue
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
471 if nth == s.idx + 1:
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
472 s.ref.setAttribute("style","",True)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
473 else:
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
474 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
475 if i+2 < len(layer._keys):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
476 layer.duplicateGroup = self.desktop.doc().rdoc.createElement("svg:g")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
477 layer.duplicateGroup.setAttribute("inkscape:label","dup",True)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
478 s.ref.setAttribute("style","display:none",True)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
479 s.ref.parent().appendChild(layer.duplicateGroup)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
480 self.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
481 else:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
482 s.ref.setAttribute("style","display:none",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
483 i = i + 2
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
484 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
485 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
486 pass
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
487 def updateTweenContent(self,obj, typ, source,dest,cur):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
488 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
489 Update the content of the duplicate scene group. We will use the (start,end) and cur to calculate the percentage of
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
490 the tween motion effect and then use it to update the transform matrix of the duplicated scene group.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
491 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
492 start = source.idx
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
493 end = dest.idx
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
494 print cur,start,end
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
495 percent = (cur-start)*1.0/(end-start)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
496 i = 0
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
497 s = source.ref.firstChild()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
498 d = dest.ref.firstChild()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
499 sources={}
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
500 dests={}
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
501 # Collect all objects
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
502 while d:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
503 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
504 label = d.attribute("inkscape:label")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
505 except:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
506 d = d.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
507 continue
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
508 dests[label.value()] = d
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
509 d = d.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
510 # Check if the object in the source exists in the destination
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
511 s = source.ref.firstChild()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
512 d = dest.ref.firstChild()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
513 while s:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
514 print s,d
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
515 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
516 label = s.attribute("inkscape:label")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
517 # Use i8nkscape:label to identidy the equipvalent objects
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
518 if label:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
519 if dests.hasattr(label.value()):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
520 self.updateTweenObject(obj,typ,s,dests[label.value()],percent)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
521 s = s.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
522 continue
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
523 except:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
524 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
525 # Search obejcts in the destination
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
526 while d:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
527 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
528 d.attribute("inkscape:label")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
529 d = d.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
530 continue
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
531 except:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
532 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
533 if s.name() == d.name():
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
534 self.updateTweenObject(obj,typ,s,d,percent)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
535 d = d.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
536 break
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
537 d = d.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
538 s = s.next()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
539 def parseTransform(self,obj):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
540 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
541 Return the transform matrix of an object
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
542 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
543 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
544 t = obj.attribute("transform")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
545 print t
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
546 if t[0:9] == 'translate':
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
547 print "translate"
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
548 fields = t[10:].split(',')
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
549 x = float(fields[0])
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
550 fields = fields[1].split(')')
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
551 y = float(fields[0])
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
552 return [1,0,0,1,x,y]
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
553 elif t[0:6] == 'matrix':
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
554 print "matrix"
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
555 fields=t[7:].split(')')
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
556 fields = fields[0].split(',')
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
557 return [float(fields[0]),float(fields[1]),float(fields[2]),float(fields[3]),float(fields[4]),float(fields[5])]
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
558 except:
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
559 #traceback.print_exc()
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
560 return [1,0,0,1,0,0]
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
561
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
562 def invA(self,m):
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
563 d = m[0]*m[3]-m[2]*m[1]
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
564 return [m[3]/d, m[1]/d, -m[2]/d, m[0]/d, (m[1]*m[5]-m[4]*m[3])/d, (m[4]*m[2]-m[0]*m[5])/d]
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
565 def mulA(self,a,b):
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
566 return [a[0]*b[0]+a[1]*b[2],
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
567 a[0]*b[1]+a[1]*b[3],
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
568 a[2]*b[0]+a[3]*b[2],
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
569 a[2]*b[1]+a[3]*b[3],
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
570 a[0]*b[4]+a[1]*b[5]+a[4],
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
571 a[2]*b[4]+a[3]*b[5]+a[5]]
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
572
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
573
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
574 def updateTweenObject(self,obj,typ,s,d,p):
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
575 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
576 Generate tweened object in the @obj by using s and d in the @p percent
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
577 """
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
578 print 'compare',s,d
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
579 if typ == 'relocate':
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
580 print "percent",p
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
581 newobj = s.duplicate(self.desktop.doc().rdoc)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
582 top = self.desktop.doc().rdoc.createElement("svg:g")
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
583 top.appendChild(newobj)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
584 obj.appendChild(top)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
585 print s.name()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
586 if s.name() == 'svg:g':
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
587 # Parse the translate or matrix
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
588 sm = self.parseTransform(s)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
589 dm = self.parseTransform(d)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
590 print "g", (dm[2]-sm[2])*p,(dm[5]-sm[5])*p
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
591 top.setAttribute("transform","translate(%g,%g)" % ((dm[2]-sm[2])*p,(dm[5]-sm[5])*p),True)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
592 else:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
593 try:
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
594 sx = float(s.attribute("x"))
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
595 sy = float(s.attribute("y"))
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
596 dx = float(d.attribute("x"))
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
597 dy = float(d.attribute("y"))
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
598 tx = (dx-sx)*p
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
599 ty = (dy-sy)*p
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
600 print tx,ty
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
601 top.setAttribute("transform","translate(%g,%g)" % (tx,ty),True)
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
602 except:
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
603 #traceback.print_exc()
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
604 pass
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
605 pass
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
606 elif typ == 'scale':
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
607 newobj = s.duplicate(self.desktop.doc().rdoc)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
608 top = self.desktop.doc().rdoc.createElement("svg:g")
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
609 top.appendChild(newobj)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
610 obj.appendChild(top)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
611 if s.name() == 'svg:g':
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
612 # Parse the translate or matrix
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
613 sm = self.parseTransform(s)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
614 dm = self.parseTransform(d)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
615 # r(1)*A = B
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
616 # ==> r(1) = B * inv(A)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
617 r1 = self.mulA(dm,self.invA(sm))
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
618 t0 = 1+ (r1[0]-1)*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
619 t1 = r1[1]*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
620 t2 = r1[2]*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
621 t3 = 1+(r1[3]-1)*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
622 t4 = r1[4]*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
623 t5 = r1[5]*p
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
624
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
625 print "scale: %g %g %g %g %g %g" % (t0,t1,t2,t3,t4,t5)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
626 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (t0,t1,t2,t3,t4,t5),True)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
627 else:
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
628 try:
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
629 sw = float(s.attribute("width"))
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
630 sh = float(s.attribute("height"))
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
631 dw = float(d.attribute("width"))
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
632 dh = float(d.attribute("height"))
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
633 tx = (dw-sw)*p+sw
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
634 ty = (dh-sh)*p+sh
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
635 print tx,ty
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
636 top.setAttribute("transform","matrix(%g,0,0,%g,0,0)" % (tx,ty),True)
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
637 except:
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
638 traceback.print_exc()
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
639 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
640 pass
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
641
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
642 pass
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
643 def enterGroup(self,obj):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
644 for l in self.layers:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
645 for s in l.node.childList():
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
646 if s.getId() == obj.attribute("id"):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
647 self.desktop.setCurrentLayer(s)
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
648
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
649 def selectSceneObject(self,frameline, nth):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
650 i = 0
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
651 while i < len(frameline._keys):
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
652 s = frameline._keys[i]
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
653 if s.right_tween is False:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
654 if nth == s.idx+1:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
655 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
656 self.setTweenType(frameline.get_tween_type(s.idx))
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
657 return
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
658 else:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
659 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
660 i = i + 1
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
661 continue
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
662
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
663 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
664 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
665 self.setTweenType(frameline.get_tween_type(s.idx))
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
666 return
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
667 else:
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
668 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
669 i = i + 2
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
670 pass
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
671 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
672 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
673 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
674 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
675 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
676 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
677 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
678 self.tweenTypeSelector.set_active(2)
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
679
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
680
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
681
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
682 def newCell(self,file):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
683 img = gtk.Image()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
684 img.set_from_file(file)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
685 btn = gtk.EventBox()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
686 btn.add(img)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
687 btn.connect("button_press_event", self.cellSelect)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
688 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray"))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
689 return btn
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
690
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
691 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
692 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
693 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
694 self.last_line.active_frame(frame)
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
695 self.doEditScene(frame)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
696
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
697
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
698 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
699 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
700 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
701 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
702 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
703 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
704 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
705 f.hide_hover()
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
706
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
707 def _create_framelines(self):
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
708 import frameline
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
709 self.scrollwin = gtk.ScrolledWindow()
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
710 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
711 self.scrollwin.set_size_request(-1,150)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
712
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
713 nframes = 100
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
714
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
715 vbox = gtk.VBox()
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
716 vbox.show()
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
717 self.scrollwin.add_with_viewport(vbox)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
718
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
719 ruler = frameline.frameruler(nframes)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
720 ruler.set_size_request(nframes * 10, 20)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
721 ruler.show()
1032
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
722 hbox = gtk.HBox()
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
723 label=gtk.Label('')
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
724 label.set_size_request(100,0)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
725 hbox.pack_start(label,expand=False,fill=True)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
726 hbox.pack_start(ruler)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
727 vbox.pack_start(hbox, False)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
728
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
729 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
730 # Add a frameline for each layer
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
731 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
732 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
733 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
734 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
735 hbox = gtk.HBox()
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
736 label = gtk.Label(self.layers[i].node.label())
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
737 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
738 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
739 hbox.pack_start(line)
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
740 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
741 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
742 line.label = label
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
743 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
744 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
745 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
746 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
747 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
748 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
749 pass
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
750 pass
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
751
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
752 ## \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
753 #
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
754 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
755 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
756 layer = frameline.layer
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
757 if frameline.node.label()==None:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
758 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
759 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
760 frameline.label.set_text(frameline.node.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
761 for scene in layer.scenes:
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
762 frameline.add_keyframe(scene.start-1,scene.node.repr)
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
763 if scene.start != scene.end:
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
764 frameline.add_keyframe(scene.end-1,scene.node.repr)
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
765 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
766 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
767 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
768 pass
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
769
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
770 def cellSelect(self, cell, data):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
771 if self.last_cell:
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
772 color = self.last_cell.get_colormap().alloc_color("gray")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
773 self.last_cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
774 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
775
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
776 self.last_cell = cell
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
777 color = cell.get_colormap().alloc_color("green")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
778 cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
779 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
780 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
781 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
782 # 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
783 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
784 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
785 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
786 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
787 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
788 # 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
789 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
790 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
791 node = self.duplicateSceneGroup(last_key.ref.attribute("id"))
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 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
793 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
794 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
795 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
796 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
797 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
798 i = i + 1
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
799 def 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
800 # Search for the duplicated group
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
801 doc = self.desktop.doc().root()
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
802 rdoc = self.desktop.doc().rdoc
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 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 for node in doc.childList():
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
805 if node.repr.name() == 'svg:g':
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
806 for t in node.childList():
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 if t.repr.name() == "svg:g":
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
808 if t.repr.attribute("id") == 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
809 orig = t.repr
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
810 break
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
811 if 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
812 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
813 ns = orig.duplicate(rdoc)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
814 gid = self.last_line.node.label()+self.newID()
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
815 self.ID[gid]=1
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
816 ns.setAttribute("id",gid,True)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
817 ns.setAttribute("inkscape:groupmode","layer",True)
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
818 self.last_line.node.repr.appendChild(ns)
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
819 return ns
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
820
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
821 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
822 self.setCurrentScene(self.last_frame+1)
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
823 self.selectSceneObject(self.last_line,self.last_frame+1)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
824 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
825
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
826 def doInsertKeyScene(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
827 self.insertKeyScene()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
828 # self.grid.show_all()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
829 return
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
830 def doDuplicateKeyScene(self,w):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
831 self.duplicateKeyScene()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
832
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
833 def doRemoveScene(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
834 self.removeKeyScene()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
835 return
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
836
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
837
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
838 def doExtendScene(self,w):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
839 self.extendScene()
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
840 #self.grid.show_all()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
841 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
842 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
843 o = self.desktop.selection.list()[0]
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 o.repr.setAttribute("inkscape:label", self.nameEditor.get_text(), True)
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 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
846 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
847 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
848 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
849 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
850 self.editDone.connect('clicked', self.changeObjectLabel)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
851
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
852 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
853 #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
854 #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
855 #hbox.pack_start(btn,expand=False,fill=False)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
856 btn = gtk.Button('Insert Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
857 btn.connect('clicked',self.doInsertKeyScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
858 hbox.pack_start(btn,expand=False,fill=False)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
859 btn=gtk.Button('Remove Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
860 btn.connect('clicked', self.doRemoveScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
861 hbox.pack_start(btn,expand=False,fill=False)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
862 btn=gtk.Button('Extend scene')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
863 btn.connect('clicked', self.doExtendScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
864 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
865 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
866 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
867 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
868 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
869 self.addTweenTypeSelector(hbox)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
870 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
871 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
872 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
873 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
874 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
875 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
876 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
877 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
878 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
879 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
880 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
881 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
882 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
883 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
884 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
885 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
886 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
887 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
888
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
889 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
890 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
891 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
892 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
893 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
894 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
895 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
896 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
897 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
898 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
899 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
900 self.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
901
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 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
903 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
904 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
905 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
906
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 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
908 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
909 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
910 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
911 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
912 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
913 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
914 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
915
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
916 def onQuit(self, event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
917 self.OK = False
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
918 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
919 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
920
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
921 def onOK(self,event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
922 self.OK = True
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
923 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
924 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
925
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
926 def updateUI(self):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
927 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
928 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
929 self.last_update = glib.timeout_add(300,self.show)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
930 def show(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
931 self.OK = True
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
932 self.parseScene()
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
933 self._create_framelines()
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
934 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
935 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
936 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
937 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
938 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
939 self.top.remove(self.startWindow)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
940 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
941 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
942 self.top.pack_start(vbox,expand=False)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
943 vbox.pack_start(self.scrollwin,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
944 hbox=gtk.HBox(False,0)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
945 self.addButtons(hbox)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
946 vbox.pack_start(hbox,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
947
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
948 # self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
949 # self.window.connect("destroy", gtk.main_quit)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
950 # self.window.set_position(gtk.WIN_POS_MOUSE)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
951
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
952 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
953 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
954 return False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
955 pass