annotate pyink/MBScene.py @ 1244:b241f9768833

Remove MBScene_ from the prefix of class names.
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 16:48:11 +0800
parents d5f70928e9f1
children ccbf0c5d01d1
rev   line source
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1 #!/usr/bin/python
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
2 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; fill-column: 79 -*-
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
3 # vim: sw=4:ts=8:sts=4:textwidth=79
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
4 import pygtk
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
5 import gtk
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
6 import glib
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
7 import traceback
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
8 import pybInkscape
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
9 from tween import TweenObject
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
10 from domview_ui import domview_ui
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
11
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
12 # Please refer to
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
13 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
14 # 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
15
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
16
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
17 # Algorithm:
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
18 #
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
19 # 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
20 # layer and scene.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
21 # - 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
22 # column of the grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
23 # - 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
24 # grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
25 # - 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
26 # 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
27 # 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
28 # 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
29 # for this purpose.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
30 # - 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
31 # 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
32 # 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
33 # 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
34 # 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
35 # 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
36 # - 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
37 # 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
38 #
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
39
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
40 ## \brief Iterator to travel a sub-tree of DOM.
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
41 #
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
42 def _DOM_iterator(node):
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
43 nodes = [node]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
44 while nodes:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
45 node = nodes.pop(0)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
46 child = node.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
47 while child:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
48 nodes.append(child)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
49 child = child.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
50 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
51 yield node
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
52 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
53 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
54
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
55
1209
41d13feeecc4 Doc MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1208
diff changeset
56 ## \brief MBScene connect GUI and DOM-tree
41d13feeecc4 Doc MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1208
diff changeset
57 #
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
58 # This method accepts user actions and involves domview_ui to update
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
59 # data on the document.
1209
41d13feeecc4 Doc MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1208
diff changeset
60 #
1234
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
61 class MBScene(object):
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
62 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
63 TweenObject.TWEEN_TYPE_SCALE)
1157
3a891dccabd8 Remove the locate tween. It is a special case for the scale tween
wycc
parents: 1155
diff changeset
64 _tween_type_names = ('normal', 'scale')
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
65
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
66 _num_frames_of_line = 100
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
67
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
68 def __init__(self, desktop, win, root=None):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
69 super(MBScene, self).__init__()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
70
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
71 self.desktop = desktop
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
72 self.window = win
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
73 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
74 self.last_update = None
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
75 pybInkscape.inkscape.connect('change_selection', self.on_selection)
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
76 self.last_select = None
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
77 self._lockui = False
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
78 self.tween = None
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
79 self.document = None
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
80 self._root = root
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
81 self.framerate = 12
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
82 self._disable_tween_type_selector = False
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
83 self.current = 0
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
84
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
85 self._domview = domview_ui()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
86 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
87
1224
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
88 def change_active_frame(self, node):
1221
33aa2d63e240 When we select a new object, search the scene group which contain it and make it as the active frame.
wycc
parents: 1220
diff changeset
89 """
1224
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
90 Change the active frame to the current selected node. This will
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
91 tell users where the current node is.
1221
33aa2d63e240 When we select a new object, search the scene group which contain it and make it as the active frame.
wycc
parents: 1220
diff changeset
92 """
1224
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
93 while node:
1221
33aa2d63e240 When we select a new object, search the scene group which contain it and make it as the active frame.
wycc
parents: 1220
diff changeset
94 try:
1224
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
95 node_id = node.getAttribute('id')
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
96 except:
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
97 node = node.parent()
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
98 continue
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
99
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
100 try:
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
101 layer_idx, (start, end, tween_type) = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
102 self._domview.find_key_from_group(node_id)
1221
33aa2d63e240 When we select a new object, search the scene group which contain it and make it as the active frame.
wycc
parents: 1220
diff changeset
103 except:
1223
Thinker K.F. Li <thinker@codemud.net>
parents: 1222 1221
diff changeset
104 pass
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
105 else:
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
106 self._domview.set_active_layer_frame(layer_idx, start)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
107 break
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
108
1224
5d731460b32c Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1223
diff changeset
109 node = node.parent()
1223
Thinker K.F. Li <thinker@codemud.net>
parents: 1222 1221
diff changeset
110 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
111 pass
1221
33aa2d63e240 When we select a new object, search the scene group which contain it and make it as the active frame.
wycc
parents: 1220
diff changeset
112
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
113 def insertKeyScene(self, layer_idx, frame_idx):
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
114 """
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
115 Insert a new key scene into the stage. If the nth is always a
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
116 key scene, we will return without changing anything. If the
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
117 nth is a filled scene, we will break the original scene into
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
118 two parts. If the nth is out of any scene, we will append a
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
119 new scene.
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
120
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
121 """
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
122 try:
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
123 self._domview.mark_key(layer_idx, frame_idx)
1234
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
124 except ValueError: # existed key frame
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
125 pass
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
126 pass
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
127
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
128 def removeKeyScene(self, layer_idx, frame_idx):
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
129 self._domview.unmark_key(layer_idx, frame_idx)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
130 self.setCurrentScene(frame_idx)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
131 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
132
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
133 def extendScene(self):
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
134 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
135 start, end, tween_type = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
136 self._domview.get_left_key(layer_idx, frame_idx)
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
137 tween_len = frame_idx - start + 1
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
138 self._domview.tween(layer_idx, start, tween_len, tween_type)
1234
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
139
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
140 scene_group = self._domview.get_key_group(layer_idx, start)
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
141 self._enterGroup(scene_group)
956
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
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
144 def setCurrentScene(self, idx):
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
145 """
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
146 Update the scene group according to the curretn scene
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
147 data. There are a couple of cases.
1148
wycc
parents: 1147 1145
diff changeset
148 1. If the type of the scene is normal, we display it when
wycc
parents: 1147 1145
diff changeset
149 it contains the current frame. Otherwise hide it.
wycc
parents: 1147 1145
diff changeset
150 2. If the type of the scene is relocate or scale, we need
wycc
parents: 1147 1145
diff changeset
151 to duplicate the scene group and then modify its
wycc
parents: 1147 1145
diff changeset
152 transform matrix according to the definition of the
wycc
parents: 1147 1145
diff changeset
153 scene. Then, hide the original scenr group and display
wycc
parents: 1147 1145
diff changeset
154 the duplciate scene group. In addition, we may need to
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
155 delete the old duplicated scene group as well.
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
156
1148
wycc
parents: 1147 1145
diff changeset
157 For each layer, we will always use the duplicated scene
wycc
parents: 1147 1145
diff changeset
158 group whose name as dup.
wycc
parents: 1147 1145
diff changeset
159 We will put the duplicated scene group inside it. We will
wycc
parents: 1147 1145
diff changeset
160 create this group if it is not
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
161 available.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
162 """
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
163 self.current = idx
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
164 self.tween.updateMapping()
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
165 for layer_idx in range(self._domview.get_layer_num()):
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
166 dup_group = self._domview.get_layer_dup_group(layer_idx)
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
167 dup_group.setAttribute('style', 'display: none')
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
168
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
169 all_key_tweens = self._domview.get_layer_keys(layer_idx)
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
170 for start, end, tween_type in all_key_tweens:
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
171 if start == idx: # at key frame
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
172 scene_group = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
173 self._domview.get_key_group(layer_idx, start)
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
174 scene_group.setAttribute('style', '')
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
175 elif start < idx and end >= idx: # in Tween
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
176 dup_group.setAttribute('style', '')
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
177 scene_group = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
178 self._domview.get_key_group(layer_idx, start)
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
179 scene_group.setAttribute('style', 'display: none')
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
180
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
181 try:
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
182 next_scene_group = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
183 self._domview.get_key_group(layer_idx, end + 1)
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
184 except: # no next key frame
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
185 next_scene_group = scene_group
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
186 pass
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
187
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
188 tween_obj_type = self._tween_obj_tween_types[tween_type]
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
189 nframes = end - start + 1
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
190 percent = float(idx - start) / nframes
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
191 self.tween.updateTweenContent(dup_group,
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
192 tween_obj_type,
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
193 scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
194 next_scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
195 percent)
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
196 pass
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
197 else: # this scene should not be showed.
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
198 scene_group = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
199 self._domview.get_key_group(layer_idx, start)
1236
2eeac97853eb Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents: 1235
diff changeset
200 scene_group.setAttribute('style', 'display: none')
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
201 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
202 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
203 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
204 pass
1232
6d4de488389e Change setCurrentScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1231
diff changeset
205
1234
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
206 def _enterGroup(self, scene_group):
1233
7f17a7e70d82 Integrate MBScene.entrGroup()
Thinker K.F. Li <thinker@codemud.net>
parents: 1232
diff changeset
207 self.desktop.setCurrentLayer(scene_group.spitem)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
208 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
209
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
210 def setTweenType(self, tween_type):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
211 self._disable_tween_type_selector = True
1240
84bcd398cccc Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1239
diff changeset
212 self.tweenTypeSelector.set_active(tween_type)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
213 self._disable_tween_type_selector = False
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
214 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
215
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
216 def selectSceneObject(self, layer_idx, frame_idx):
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
217 try:
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
218 start, stop, tween_type = \
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
219 self._domview.get_key(layer_idx, frame_idx)
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
220 except:
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
221 return
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
222
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
223 scene_group = self._domview.get_key_group(layer_idx, start)
1234
0f597a2073eb Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents: 1233
diff changeset
224 self._enterGroup(scene_group)
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
225 self.setTweenType(tween_type)
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
226 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
227
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
228 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
229 # Search for the current scene
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
230 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
231
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
232 try:
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
233 left_start, left_end, left_tween_type = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
234 self._domview.get_left_key(layer_idx, frame_idx)
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
235 except:
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
236 return
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
237 if left_end >= frame_idx:
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
238 return
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
239
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
240 self._domview.mark_key(layer_idx, frame_idx)
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
241
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
242 scene_group = self._domview.get_key_group(layer_idx, frame_idx)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
243 left_scene_group = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
244 self._domview.get_key_group(layer_idx, left_start)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
245
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
246 dup_group = self._duplicate_group(left_scene_group, scene_group)
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
247
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
248 self.setCurrentScene(frame_idx)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
249 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
250
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
251 ## \brief Duplicate children of a group.
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
252 #
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
253 # Duplicate children of a group, and append them to another group.
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
254 #
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
255 def _duplicate_group(self, src_group, dst_group):
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
256 # Search for the duplicated group
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
257 root = self._root
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
258 doc = self.document
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
259
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
260 dup_group = src_group.duplicate(doc)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
261 for child in dup_group.childList():
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
262 dup_group.removeChild(child) # prvent from crash
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
263 dst_group.appendChild(child)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
264 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
265
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
266 old_nodes = _DOM_iterator(src_group)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
267 new_nodes = _DOM_iterator(dst_group)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
268 for old_node in old_nodes:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
269 old_node_id = old_node.getAttribute('id')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
270 new_node = new_nodes.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
271 new_node.setAttribute('ns0:duplicate-src', old_node_id)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
272 pass
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
273 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
274
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
275 def changeObjectLabel(self,w):
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
276 o = self.desktop.selection.list()[0]
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
277 o.setAttribute("inkscape:label", self.nameEditor.get_text())
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
278 pass
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
279
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
280 def addNameEditor(self,hbox):
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
281 self.nameEditor = gtk.Entry(max=40)
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
282 hbox.pack_start(self.nameEditor,expand=False,fill=False)
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
283 self.editDone = gtk.Button('Set')
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
284 hbox.pack_start(self.editDone,expand=False,fill=False)
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
285 self.editDone.connect('clicked', self.changeObjectLabel)
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
286 pass
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
287
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
288 def addTweenTypeSelector(self, hbox):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
289 tweenbox = gtk.HBox()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
290 label = gtk.Label('Tween Type')
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
291 tweenbox.pack_start(label)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
292
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
293 self.tweenTypeSelector = gtk.combo_box_new_text()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
294 self.tweenTypeSelector.append_text('normal')
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
295 self.tweenTypeSelector.append_text('scale')
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
296 self.tweenTypeSelector.set_active(0)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
297 tweenbox.pack_start(self.tweenTypeSelector, expand=False, fill=False)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
298 hbox.pack_start(tweenbox, expand=False, fill=False)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
299 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
300 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
301
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
302 def on_selection(self,w,obj):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
303 objs = self.desktop.selection.list()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
304 try:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
305 o = objs[0]
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
306 print o.getCenter()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
307 if o == self.last_select:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
308 return
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
309 except:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
310 self.nameEditor.set_text('')
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
311 self.last_select = None
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
312 return
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
313 self.last_select = o
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
314 try:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
315 self.nameEditor.set_text(o.getAttribute("inkscape:label"))
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
316 except:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
317 self.nameEditor.set_text('')
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
318 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
319
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
320 # The selection is a PYSPObject. Convert it to be PYNode
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
321 self.change_active_frame(self.last_select.repr.parent())
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
322 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
323
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
324 def onCellClick(self, layer_idx, frame_idx):
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
325 self._lockui = True
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
326
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
327 self.setCurrentScene(frame_idx)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
328 self.selectSceneObject(layer_idx, frame_idx)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
329
1207
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
330 self._lockui = False
489e6e474fdf Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1206
diff changeset
331 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
332
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
333 def doInsertKeyScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
334 self._lockui=True
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
335 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
336 self.insertKeyScene(layer_idx, frame_idx)
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
337 self.selectSceneObject(layer_idx, frame_idx)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
338 self._lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
339 return
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
340
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
341 def doDuplicateKeyScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
342 self._lockui = True
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
343 self.duplicateKeyScene()
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
344 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
345
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
346 def doRemoveScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
347 self._lockui = True
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
348 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
349 self.removeKeyScene(layer_idx, frame_idx)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
350 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
351 return
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
352
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
353
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
354 def doExtendScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
355 self._lockui = True
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
356 self.extendScene()
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
357 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
358 pass
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
359
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
360 def doRun(self,arg):
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
361 """
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
362 Execute the current animation till the last frame.
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
363 """
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
364 if self.btnRun.get_label() == "Run":
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
365 self.btnRun.set_label("Stop")
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
366 self._lockui = True
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
367 tmout = 1000 / self.framerate
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
368 self.last_update = glib.timeout_add(tmout, self.doRunNext)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
369 else:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
370 self.btnRun.set_label("Run")
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
371 glib.source_remove(self.last_update)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
372 self._lockui = False
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
373 pass
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
374 pass
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
375
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
376 def doRunNext(self):
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
377 if self.current > self._domview.get_max_frame():
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
378 self.current = 0
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
379 pass
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
380 try:
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
381 self.setCurrentScene(self.current)
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
382 except:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
383 traceback.print_exc()
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
384 raise
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
385 self.current = self.current + 1
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
386 tmout = 1000 / self.framerate
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
387 self.last_update = glib.timeout_add(tmout, self.doRunNext)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
388 pass
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
389
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
390 def doInsertFrame(self, w):
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
391 self.lockui=True
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
392 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
393 self._domview.insert_frames(layer_idx, frame_idx, 1)
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
394 self.lockui=False
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
395
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
396 def doRemoveFrame(self, w):
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
397 self.lockui=True
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
398 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
399 self._domview.rm_frames(layer_idx, frame_idx, 1)
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
400 self.lockui=False
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
401
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
402 def onTweenTypeChange(self, w):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
403 if self._disable_tween_type_selector:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
404 return
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
405
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
406 layer_idx, frame_idx = self._domview.get_active_layer_frame()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
407 tween_type = self.tweenTypeSelector.get_active()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
408
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
409 start, end, old_tween_type = \
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
410 self._domview.get_left_key(layer_idx, frame_idx)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
411 if end >= frame_idx and start != end:
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
412 # Length of tween > 1 and cover this frame
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
413 self._domview.chg_tween(layer_idx, start, tween_type=tween_type)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
414 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
415 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
416
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
417 def onQuit(self, event):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
418 self.OK = False
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
419 gtk.main_quit()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
420 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
421
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
422 def onOK(self, event):
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
423 self.OK = True
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
424 gtk.main_quit()
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
425 pass
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
426
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
427 def _add_buttons(self, hbox):
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
428 btn = gtk.Button('Insert Key')
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
429 btn.connect('clicked', self.doInsertKeyScene)
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
430 hbox.pack_start(btn, expand=False, fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
431
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
432 btn=gtk.Button('Remove Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
433 btn.connect('clicked', self.doRemoveScene)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
434 hbox.pack_start(btn, expand=False, fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
435
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
436 btn=gtk.Button('Extend scene')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
437 btn.connect('clicked', self.doExtendScene)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
438 hbox.pack_start(btn, expand=False, fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
439
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
440 btn=gtk.Button('Duplicate Key')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
441 btn.connect('clicked', self.doDuplicateKeyScene)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
442 hbox.pack_start(btn, expand=False, fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
443
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
444 btn=gtk.Button('insert')
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
445 btn.connect('clicked', self.doInsertFrame)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
446 hbox.pack_start(btn, expand=False, fill=False)
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
447
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
448 btn=gtk.Button('remove')
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
449 btn.connect('clicked', self.doRemoveFrame)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
450 hbox.pack_start(btn, expand=False, fill=False)
1219
b5e648a317eb Add insert and remove frame function.
wycc
parents: 1217
diff changeset
451
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
452 btn=gtk.Button('Run')
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
453 btn.connect('clicked', self.doRun)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
454 self.btnRun = btn
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
455 hbox.pack_start(btn, expand=False, fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
456
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
457 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
458 self.addTweenTypeSelector(hbox)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
459 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
460
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
461 def show(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
462 self.OK = True
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
463 if not self._root:
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
464 self._root = self.desktop.doc().root().repr
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
465 pass
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
466
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
467 self.document = self.desktop.doc().rdoc
1240
84bcd398cccc Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1239
diff changeset
468
1237
b5cceb2b87bb Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents: 1236
diff changeset
469 self.tween = TweenObject(self.document, self._root)
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
470 self._domview.handle_doc_root(self.document, self._root)
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
471 self._domview.register_active_frame_callback(self.onCellClick)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
472
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
473 if self.top == None:
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
474 self.top = gtk.VBox(False, 0)
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
475 toplevel = self.desktop.getToplevel()
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
476 toplevel.child.child.pack_end(self.top, expand=False)
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
477 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
478 self.top.remove(self.startWindow)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
479 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
480
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
481 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
482 self.startWindow = vbox
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
483 self.top.pack_start(vbox, expand=False)
1242
1b1eb8f9a866 Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1241
diff changeset
484 frame_ui = self._domview.get_frame_ui_widget()
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
485 vbox.pack_start(frame_ui, expand=False)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
486 hbox=gtk.HBox(False, 0)
1231
d28b1b840bfc Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 1230
diff changeset
487 self._add_buttons(hbox)
1222
03daff2d939c Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents: 1220
diff changeset
488 vbox.pack_start(hbox, expand=False)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
489
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
490 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
491 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
492 return False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
493 pass