Mercurial > MadButterfly
annotate pyink/MBScene.py @ 1428:43369f3314d8
Fix the issue of loading components from SVG.
- Users can not switch to components in the document that was loaded
from previously saved SVG file.
- Scribboo can not find components with names listed in the component
list.
- It is because that Scribboo is fault to use node name of
ns0:component instead of 'name' attribute as component name.
- It is fixed by using 'name' attribute of ns0:component node.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 10 Apr 2011 15:28:33 +0800 |
parents | d0e6f350b3fd |
children | 60f2c9a24cdb |
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 |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
9 from tween import scenes_director |
1258
2609b219703d
Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents:
1255
diff
changeset
|
10 from domview_ui import create_domview_ui |
1253
07e0cb1e051d
Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1251
diff
changeset
|
11 from data_monitor import data_monitor |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
12 |
957 | 13 # Please refer to |
14 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention | |
15 # 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
|
16 |
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 # Algorithm: |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
19 # |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
20 # 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
|
21 # layer and scene. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
22 # - 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
|
23 # column of the grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
24 # - 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
|
25 # grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
26 # - 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
|
27 # 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
|
28 # 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
|
29 # 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
|
30 # for this purpose. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
31 # - 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
|
32 # 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
|
33 # 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
|
34 # 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
|
35 # 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
|
36 # 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
|
37 # - 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
|
38 # 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
|
39 # |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
40 |
1209 | 41 ## \brief MBScene connect GUI and DOM-tree |
42 # | |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
43 # 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
|
44 # data on the document. |
1209 | 45 # |
1255
a8e01435e84e
Add more doc for MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1253
diff
changeset
|
46 # This class is protected by \ref data_monitor, meta-class. |
a8e01435e84e
Add more doc for MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1253
diff
changeset
|
47 # |
1234
0f597a2073eb
Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents:
1233
diff
changeset
|
48 class MBScene(object): |
1248
2f9fa5d59e67
Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1246
diff
changeset
|
49 __metaclass__ = data_monitor |
2f9fa5d59e67
Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1246
diff
changeset
|
50 |
1157
3a891dccabd8
Remove the locate tween. It is a special case for the scale tween
wycc
parents:
1155
diff
changeset
|
51 _tween_type_names = ('normal', 'scale') |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
52 |
1204
78925515836f
Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1203
diff
changeset
|
53 _num_frames_of_line = 100 |
78925515836f
Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1203
diff
changeset
|
54 |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
55 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
|
56 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
|
57 |
956 | 58 self.desktop = desktop |
59 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
|
60 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
|
61 self.last_update = None |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
62 pybInkscape.inkscape.connect('change_selection', self.do_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
|
63 self.last_select = None |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
64 self._director = None |
1140 | 65 self.document = None |
1237
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
66 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>
diff
changeset
|
67 self.framerate = 12 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
68 self._disable_tween_type_selector = False |
1236
2eeac97853eb
Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents:
1235
diff
changeset
|
69 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
|
70 |
1264 | 71 self._domviewui = create_domview_ui() |
1265
ca301f6abef7
Support undo for insert key frame/rm keyframe. We will refresh all layers and scenes since it is not feasible to collect these changes and update the layers and scenes. We may scan two level only in the future to improve the performance.
wycc
parents:
1264
diff
changeset
|
72 self._locker = self._domviewui |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
73 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
|
74 |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
75 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
|
76 """ |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
77 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
|
78 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
|
79 """ |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
80 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
|
81 try: |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
82 node_id = node.getAttribute('id') |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
83 except: |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
84 node = node.parent() |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
85 continue |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
86 |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
87 try: |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
88 layer_idx, (start, end, tween_type) = \ |
1264 | 89 self._domviewui.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
|
90 except: |
1223 | 91 pass |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
92 else: |
1264 | 93 self._domviewui.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
|
94 break |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
95 |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
96 node = node.parent() |
1223 | 97 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
98 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
|
99 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
100 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
|
101 """ |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 new scene. |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
107 |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
108 """ |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
109 try: |
1264 | 110 self._domviewui.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
|
111 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
|
112 pass |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
113 pass |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
114 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
115 def removeKeyScene(self, layer_idx, frame_idx): |
1264 | 116 self._domviewui.unmark_key(layer_idx, frame_idx) |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
117 self._director.show_scene(frame_idx) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
118 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
119 |
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
|
120 def extendScene(self): |
1334
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
121 # Create a tween |
1264 | 122 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
123 start, end, tween_type = \ |
1264 | 124 self._domviewui.get_left_key(layer_idx, frame_idx) |
1334
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
125 tween_len = frame_idx - start |
1264 | 126 self._domviewui.tween(layer_idx, start, tween_len, tween_type) |
1287
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
127 |
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
128 # Create a key frame which link to the previous key frame |
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
129 self._domviewui.mark_key(layer_idx, frame_idx) |
1294 | 130 self._domviewui.clone_key_group(layer_idx, start, frame_idx) |
1287
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
131 self._director.show_scene(frame_idx) |
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
132 self.selectSceneObject(layer_idx, frame_idx) |
956 | 133 pass |
134 | |
1234
0f597a2073eb
Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents:
1233
diff
changeset
|
135 def _enterGroup(self, scene_group): |
1233
7f17a7e70d82
Integrate MBScene.entrGroup()
Thinker K.F. Li <thinker@codemud.net>
parents:
1232
diff
changeset
|
136 self.desktop.setCurrentLayer(scene_group.spitem) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
137 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
138 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
139 def setTweenType(self, tween_type): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
140 self._disable_tween_type_selector = True |
1240
84bcd398cccc
Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1239
diff
changeset
|
141 self.tweenTypeSelector.set_active(tween_type) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
142 self._disable_tween_type_selector = False |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
143 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
144 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
145 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
|
146 try: |
1242
1b1eb8f9a866
Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents:
1241
diff
changeset
|
147 start, stop, tween_type = \ |
1264 | 148 self._domviewui.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
|
149 except: |
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
150 return |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
151 |
1264 | 152 scene_group = self._domviewui.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
|
153 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
|
154 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
|
155 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
156 |
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
|
157 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
|
158 # Search for the current scene |
1264 | 159 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
1334
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
160 try: |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
161 self.removeKeyScene(layer_idx, frame_idx) |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
162 except: # no key and tween |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
163 pass |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
164 |
1195
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
165 try: |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
166 left_start, left_end, left_tween_type = \ |
1264 | 167 self._domviewui.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
|
168 except: |
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
169 return |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
170 if left_end >= frame_idx: |
1195
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
171 return |
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
172 |
1264 | 173 self._domviewui.mark_key(layer_idx, frame_idx) |
174 self._domviewui.copy_key_group(layer_idx, left_start, frame_idx) | |
1195
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
175 |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
176 self._director.show_scene(frame_idx) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
177 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
178 |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
179 def _drop_undo(self): |
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
180 self.document.commit() # commit the transation and drop change log. |
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
181 self.document.beginTransaction() |
1267
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
182 |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
183 def addNameEditor(self,hbox): |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
184 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
|
185 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
|
186 self.editDone = gtk.Button('Set') |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
187 hbox.pack_start(self.editDone,expand=False,fill=False) |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
188 self.editDone.connect('clicked', self.do_changeObjectLabel) |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
189 pass |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
190 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
191 def addTweenTypeSelector(self, hbox): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
192 tweenbox = gtk.HBox() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
193 label = gtk.Label('Tween Type') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
194 tweenbox.pack_start(label) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
195 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
196 self.tweenTypeSelector = gtk.combo_box_new_text() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
197 self.tweenTypeSelector.append_text('normal') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
198 self.tweenTypeSelector.append_text('scale') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
199 self.tweenTypeSelector.set_active(0) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
200 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
|
201 hbox.pack_start(tweenbox, expand=False, fill=False) |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
202 self.tweenTypeSelector.connect('changed', self.do_TweenTypeChange) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
203 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
204 |
1267
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
205 def do_changeObjectLabel(self,w): |
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
206 o = self.desktop.selection.list()[0] |
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
207 o.setAttribute("inkscape:label", self.nameEditor.get_text()) |
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
208 pass |
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
209 |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
210 def do_selection(self,w,obj): |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
211 objs = self.desktop.selection.list() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
212 try: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
213 o = objs[0] |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
214 print o.getCenter() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
215 if o == self.last_select: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
216 return |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
217 except: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
218 self.nameEditor.set_text('') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
219 self.last_select = None |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
220 return |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
221 self.last_select = o |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
222 try: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
223 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
|
224 except: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
225 self.nameEditor.set_text('') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
226 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
227 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
228 # 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
|
229 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
|
230 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
231 |
1251
fb5ad43c13eb
Rename onCellClick to do_CellClick
Thinker K.F. Li <thinker@codemud.net>
parents:
1250
diff
changeset
|
232 def do_CellClick(self, layer_idx, frame_idx): |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
233 self._director.show_scene(frame_idx) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
234 self.selectSceneObject(layer_idx, frame_idx) |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
235 pass |
1263 | 236 |
956 | 237 def doInsertKeyScene(self,w): |
1264 | 238 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
239 self.insertKeyScene(layer_idx, frame_idx) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
240 self.selectSceneObject(layer_idx, frame_idx) |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
241 self._drop_undo() |
956 | 242 return |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
243 |
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
|
244 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
|
245 self.duplicateKeyScene() |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
246 self._drop_undo() |
1266 | 247 pass |
956 | 248 |
249 def doRemoveScene(self,w): | |
1264 | 250 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
251 self.removeKeyScene(layer_idx, frame_idx) |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
252 self._drop_undo() |
956 | 253 return |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
254 |
956 | 255 def doExtendScene(self,w): |
256 self.extendScene() | |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
257 self._drop_undo() |
956 | 258 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
|
259 |
1147 | 260 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
|
261 """ |
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
|
262 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
|
263 """ |
1147 | 264 if self.btnRun.get_label() == "Run": |
1324
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
265 # |
1325 | 266 # Make dup groups empty. |
267 # It forces TweenObject to re-generate content from scratch. | |
1324
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
268 # |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
269 nlayers = self._domviewui.get_layer_num() |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
270 for layer_idx in range(nlayers): |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
271 layer_dup = self._domviewui.get_layer_dup_group(layer_idx) |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
272 for child in layer_dup.childList(): |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
273 layer_dup.removeChild(child) |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
274 pass |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
275 pass |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
276 |
1147 | 277 self.btnRun.set_label("Stop") |
1206
1d476b35dc79
Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
diff
changeset
|
278 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>
diff
changeset
|
279 self.last_update = glib.timeout_add(tmout, self.doRunNext) |
1147 | 280 else: |
281 self.btnRun.set_label("Run") | |
282 glib.source_remove(self.last_update) | |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
283 pass |
1206
1d476b35dc79
Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
diff
changeset
|
284 pass |
1147 | 285 |
286 def doRunNext(self): | |
1264 | 287 if self.current > self._domviewui.get_max_frame(): |
1147 | 288 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>
diff
changeset
|
289 pass |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
290 try: |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
291 self._director.show_scene(self.current) |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
292 except: |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
293 traceback.print_exc() |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
294 raise |
1199
25e1579ed3d1
Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1198
diff
changeset
|
295 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>
diff
changeset
|
296 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>
diff
changeset
|
297 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>
diff
changeset
|
298 pass |
1174 | 299 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
300 def doInsertFrame(self, w): |
1264 | 301 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
302 self._domviewui.insert_frames(layer_idx, frame_idx, 1) | |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
303 self._drop_undo() |
1219 | 304 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
305 def doRemoveFrame(self, w): |
1264 | 306 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
307 self._domviewui.rm_frames(layer_idx, frame_idx, 1) | |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
308 self._drop_undo() |
1219 | 309 |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
310 def do_TweenTypeChange(self, w): |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
311 if self._disable_tween_type_selector: |
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 |
1264 | 314 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
315 tween_type = self.tweenTypeSelector.get_active() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
316 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
317 start, end, old_tween_type = \ |
1264 | 318 self._domviewui.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
|
319 if end >= frame_idx and start != end: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
320 # Length of tween > 1 and cover this frame |
1264 | 321 self._domviewui.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
|
322 pass |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
323 self._drop_undo() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
324 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
325 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
326 def onQuit(self, event): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
327 self.OK = False |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
328 gtk.main_quit() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
329 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
330 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
331 def onOK(self, event): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
332 self.OK = True |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
333 gtk.main_quit() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
334 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
335 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
336 def _add_buttons(self, hbox): |
956 | 337 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
|
338 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
|
339 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 340 |
956 | 341 btn=gtk.Button('Remove Key') |
342 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
|
343 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 344 |
956 | 345 btn=gtk.Button('Extend scene') |
346 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
|
347 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 348 |
349 btn=gtk.Button('Duplicate Key') | |
350 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
|
351 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 352 |
1219 | 353 btn=gtk.Button('insert') |
354 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
|
355 hbox.pack_start(btn, expand=False, fill=False) |
1219 | 356 |
357 btn=gtk.Button('remove') | |
358 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
|
359 hbox.pack_start(btn, expand=False, fill=False) |
1219 | 360 |
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 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
|
362 btn.connect('clicked', self.doRun) |
1147 | 363 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
|
364 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 365 |
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
|
366 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
|
367 self.addTweenTypeSelector(hbox) |
956 | 368 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
369 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
370 def do_show(self): |
956 | 371 self.OK = True |
1237
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
372 if not self._root: |
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
373 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
|
374 pass |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
375 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
376 self.document = self.desktop.doc().rdoc |
1240
84bcd398cccc
Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1239
diff
changeset
|
377 |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
378 self._domviewui.set_desktop(self.desktop) |
1264 | 379 self._domviewui.handle_doc_root(self.document, self._root) |
380 self._domviewui.register_active_frame_callback(self.do_CellClick) | |
381 self._director = scenes_director(self._domviewui) | |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
382 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
383 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
|
384 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>
diff
changeset
|
385 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
|
386 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
|
387 else: |
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
388 self.top.remove(self.startWindow) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
389 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
390 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
391 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
|
392 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
|
393 self.top.pack_start(vbox, expand=False) |
1264 | 394 frame_ui = self._domviewui.get_frame_ui_widget() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
395 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
|
396 hbox=gtk.HBox(False, 0) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
397 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
|
398 vbox.pack_start(hbox, expand=False) |
981 | 399 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
400 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
|
401 self.last_update = None |
1337
05ced4a389bf
Fix issue of mixing actions for initialiaztion with user actions
Thinker K.F. Li <thinker@codemud.net>
parents:
1334
diff
changeset
|
402 |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
403 self._drop_undo() |
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
404 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
405 return False |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
406 |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
407 ## \brief To handle context menu event. |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
408 # |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
409 def do_make_component_from_group(self, node): |
1328
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
410 node_parent_group = node.parent() |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
411 |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
412 comp_name = 'Component ' + node.getAttribute('id') |
1329
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
413 i = 0 |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
414 while comp_name in self._domviewui.all_comp_names(): |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
415 comp_name = 'Component %s - %d' % (comp_name, i) |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
416 i = i + 1 |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
417 pass |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
418 self._domviewui.add_component_from_group(comp_name, node) |
1328
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
419 |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
420 self._domviewui.link_to_component(comp_name, node_parent_group) |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
421 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
422 |
1328
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
423 ## \brief Add menu item to context menu. |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
424 # |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
425 # This method is called by pyink.pyink_context_menu() to notify the |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
426 # creation of context menu for a node. |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
427 # |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
428 def context_menu(self, spitem, menu_factory): |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
429 node = spitem.repr |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
430 if node.name() != 'svg:g': |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
431 return # not a group |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
432 |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
433 if self._domviewui.is_graph_node(node): |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
434 menu_item_handler = \ |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
435 lambda *args: self.do_make_component_from_group(node) |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
436 menu_factory.add_item_label('Make a component', |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
437 menu_item_handler) |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
438 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
439 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
440 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
441 def show(self): |
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
442 self.do_show() |
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
443 pass |
956 | 444 pass |