Mercurial > MadButterfly
annotate pyink/MBScene.py @ 1531:5a3597eba722
Switch current layer away before removing a layer.
We must switch current layer to another one before removing a layer
group node. It avoids a crash since inkscape does not know the group
node of the layer is removed, and it would emit a signal on this node
later.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 28 Sep 2011 21:54:39 +0800 |
parents | af8dd27bf450 |
children | 4a92b639a1cd |
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 |
1517
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
13 ## \page design_scribboo Designs of Scribboo |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
14 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
15 # \image html scribboo_arch.png |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
16 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
17 # The idea of Scribboo is that domview_ui is responsible for synchronizing |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
18 # domview and framelines. domview is responsible for managing data model |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
19 # provided by Inkscape for SVG documents. All access to data model use APIs |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
20 # provided by domview. domview_ui is a decorator of domview. It does not only |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
21 # delegate calls to domview, but also make sure that framelines are always up |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
22 # to date and keep consistent with data model provided by domview. |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
23 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
24 # MBScene implements most feature about editing scenes. It uses domview_ui to |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
25 # manage and control scenes. With MBScene, you can create, delete, and change |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
26 # scenes. It also provide the capability of tweening animation. |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
27 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
28 # comp_dock is responsible for managing components and actions. You can see a |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
29 # list of components and a list of actions. These two list boxes are |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
30 # implemented by comp_dock. |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
31 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
32 # FSM_window is responsible for implementation of FSM editor. All features |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
33 # provided by FSM editor is a part of FSM_window. It also use domview_ui to |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
34 # access data model. |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
35 # |
31a21656c0a8
Describe designs of Scribboo
Thinker K.F. Li <thinker@codemud.net>
parents:
1455
diff
changeset
|
36 |
957 | 37 # Please refer to |
38 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention | |
39 # 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
|
40 |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
41 |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
42 # Algorithm: |
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
43 # |
955
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
44 # 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
|
45 # layer and scene. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
46 # - 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
|
47 # column of the grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
48 # - 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
|
49 # grid. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
50 # - 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
|
51 # 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
|
52 # 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
|
53 # 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
|
54 # for this purpose. |
53b0f8dc2284
Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents:
943
diff
changeset
|
55 # - 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
|
56 # 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
|
57 # 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
|
58 # 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
|
59 # 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
|
60 # 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
|
61 # - 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
|
62 # 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
|
63 # |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
64 |
1209 | 65 ## \brief MBScene connect GUI and DOM-tree |
66 # | |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
67 # 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
|
68 # data on the document. |
1209 | 69 # |
1255
a8e01435e84e
Add more doc for MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1253
diff
changeset
|
70 # 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
|
71 # |
1234
0f597a2073eb
Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents:
1233
diff
changeset
|
72 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
|
73 __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
|
74 |
1157
3a891dccabd8
Remove the locate tween. It is a special case for the scale tween
wycc
parents:
1155
diff
changeset
|
75 _tween_type_names = ('normal', 'scale') |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
76 |
1204
78925515836f
Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1203
diff
changeset
|
77 _num_frames_of_line = 100 |
78925515836f
Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1203
diff
changeset
|
78 |
1149
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
79 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
|
80 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
|
81 |
956 | 82 self.desktop = desktop |
83 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
|
84 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
|
85 self.last_update = None |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
86 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
|
87 self.last_select = None |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
88 self._director = None |
1140 | 89 self.document = None |
1237
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
90 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
|
91 self.framerate = 12 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
92 self._disable_tween_type_selector = False |
1236
2eeac97853eb
Running animation successful
Thinker K.F. Li <thinker@codemud.net>
parents:
1235
diff
changeset
|
93 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
|
94 |
1264 | 95 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
|
96 self._locker = self._domviewui |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
97 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
|
98 |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
99 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
|
100 """ |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
101 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
|
102 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
|
103 """ |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
104 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
|
105 try: |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
106 node_id = node.getAttribute('id') |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
107 except: |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
108 node = node.parent() |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
109 continue |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
110 |
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
111 try: |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
112 layer_idx, (start, end, tween_type) = \ |
1264 | 113 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
|
114 except: |
1223 | 115 pass |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
116 else: |
1264 | 117 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
|
118 break |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
119 |
1224
5d731460b32c
Remove search_by_id() from frameline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1223
diff
changeset
|
120 node = node.parent() |
1223 | 121 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
122 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
|
123 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
124 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
|
125 """ |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 new scene. |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
131 |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
132 """ |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
133 try: |
1264 | 134 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
|
135 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
|
136 pass |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
137 pass |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
138 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
139 def removeKeyScene(self, layer_idx, frame_idx): |
1264 | 140 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
|
141 self._director.show_scene(frame_idx) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
142 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
143 |
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
|
144 def extendScene(self): |
1334
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
145 # Create a tween |
1264 | 146 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
|
147 start, end, tween_type = \ |
1264 | 148 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
|
149 tween_len = frame_idx - start |
1264 | 150 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
|
151 |
f6a28f473494
Change the exten dScene to create an key frame which link back to the previous key frame.
wycc
parents:
1268
diff
changeset
|
152 # 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
|
153 self._domviewui.mark_key(layer_idx, frame_idx) |
1294 | 154 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
|
155 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
|
156 self.selectSceneObject(layer_idx, frame_idx) |
956 | 157 pass |
158 | |
1234
0f597a2073eb
Enter the group after insert/extend a key frame
Thinker K.F. Li <thinker@codemud.net>
parents:
1233
diff
changeset
|
159 def _enterGroup(self, scene_group): |
1233
7f17a7e70d82
Integrate MBScene.entrGroup()
Thinker K.F. Li <thinker@codemud.net>
parents:
1232
diff
changeset
|
160 self.desktop.setCurrentLayer(scene_group.spitem) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
161 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
162 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
163 def setTweenType(self, tween_type): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
164 self._disable_tween_type_selector = True |
1240
84bcd398cccc
Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1239
diff
changeset
|
165 self.tweenTypeSelector.set_active(tween_type) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
166 self._disable_tween_type_selector = False |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
167 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
168 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
169 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
|
170 try: |
1242
1b1eb8f9a866
Rename *_dom to *_domview and *_framelines to *_frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents:
1241
diff
changeset
|
171 start, stop, tween_type = \ |
1264 | 172 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
|
173 except: |
1455
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
174 dup_group = self._domviewui.get_layer_dup_group(layer_idx) |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
175 self._enterGroup(dup_group) |
1177
ec1ea8555911
Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
1176
diff
changeset
|
176 return |
1070
afa42d5836cc
Call setCurrentLayer to enter the current scene group.
wycc
parents:
1064
diff
changeset
|
177 |
1264 | 178 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
|
179 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
|
180 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
|
181 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
182 |
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
|
183 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
|
184 # Search for the current scene |
1264 | 185 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
|
186 try: |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
187 self.removeKeyScene(layer_idx, frame_idx) |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
188 except: # no key and tween |
38403fdb0c6c
Fix bug of duplicateKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents:
1329
diff
changeset
|
189 pass |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
190 |
1195
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
191 try: |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
192 left_start, left_end, left_tween_type = \ |
1264 | 193 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
|
194 except: |
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
195 return |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
196 if left_end >= frame_idx: |
1195
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
197 return |
cb2c611d1656
Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1194
diff
changeset
|
198 |
1264 | 199 self._domviewui.mark_key(layer_idx, frame_idx) |
200 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
|
201 |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
202 self._director.show_scene(frame_idx) |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
203 pass |
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
204 |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
205 def _drop_undo(self): |
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
206 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
|
207 self.document.beginTransaction() |
1267
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
208 |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
209 def addNameEditor(self,hbox): |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
210 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
|
211 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
|
212 self.editDone = gtk.Button('Set') |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
213 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
|
214 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
|
215 pass |
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
216 |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
217 def addTweenTypeSelector(self, hbox): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
218 tweenbox = gtk.HBox() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
219 label = gtk.Label('Tween Type') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
220 tweenbox.pack_start(label) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
221 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
222 self.tweenTypeSelector = gtk.combo_box_new_text() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
223 self.tweenTypeSelector.append_text('normal') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
224 self.tweenTypeSelector.append_text('scale') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
225 self.tweenTypeSelector.set_active(0) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
230 |
1267
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 pass |
2318a094a277
Move function around to separate do_* from others
Thinker K.F. Li <thinker@codemud.net>
parents:
1266
diff
changeset
|
235 |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
236 def do_selection(self,w,obj): |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
237 objs = self.desktop.selection.list() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
238 try: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
239 o = objs[0] |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
240 print o.getCenter() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
241 if o == self.last_select: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
242 return |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
243 except: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
244 self.nameEditor.set_text('') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
245 self.last_select = None |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
246 return |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
247 self.last_select = o |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
248 try: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
249 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
|
250 except: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
251 self.nameEditor.set_text('') |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
252 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
253 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
254 # 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
|
255 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
|
256 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
257 |
1251
fb5ad43c13eb
Rename onCellClick to do_CellClick
Thinker K.F. Li <thinker@codemud.net>
parents:
1250
diff
changeset
|
258 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
|
259 self._director.show_scene(frame_idx) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
260 self.selectSceneObject(layer_idx, frame_idx) |
1431
60f2c9a24cdb
Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents:
1338
diff
changeset
|
261 self._domviewui.remember_current_frame(layer_idx, frame_idx) |
1207
489e6e474fdf
Change names of methods and grouping methods
Thinker K.F. Li <thinker@codemud.net>
parents:
1206
diff
changeset
|
262 pass |
1263 | 263 |
1528
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
264 def doAddLayer(self, w): |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
265 domview = self._domviewui |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
266 layer_num = domview.get_layer_num() |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
267 domview.insert_layer(layer_num) |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
268 pass |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
269 |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
270 def doRemoveLayer(self, w): |
1529
af8dd27bf450
Remove layer from button
Thinker K.F. Li <thinker@codemud.net>
parents:
1528
diff
changeset
|
271 domview = self._domviewui |
af8dd27bf450
Remove layer from button
Thinker K.F. Li <thinker@codemud.net>
parents:
1528
diff
changeset
|
272 layer_idx, frame_idx = domview.get_current_frame() |
1531
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
273 if layer_idx == 0: # never remove first layer (default) |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
274 return |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
275 |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
276 # We must switch current layer to another one before removing a layer |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
277 # group node. It avoids a crash since inkscape does not know the group |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
278 # node of the layer is removed, and it would emit a signal on this node |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
279 # later. |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
280 self.selectSceneObject(layer_idx - 1, frame_idx) |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
281 |
5a3597eba722
Switch current layer away before removing a layer.
Thinker K.F. Li <thinker@codemud.net>
parents:
1529
diff
changeset
|
282 self._domviewui.remember_current_frame(layer_idx - 1, frame_idx) |
1529
af8dd27bf450
Remove layer from button
Thinker K.F. Li <thinker@codemud.net>
parents:
1528
diff
changeset
|
283 domview.rm_layer(layer_idx) |
1528
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
284 pass |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
285 |
956 | 286 def doInsertKeyScene(self,w): |
1264 | 287 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
|
288 self.insertKeyScene(layer_idx, frame_idx) |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
289 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
|
290 self._drop_undo() |
956 | 291 return |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
292 |
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
|
293 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
|
294 self.duplicateKeyScene() |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
295 self._drop_undo() |
1266 | 296 pass |
956 | 297 |
298 def doRemoveScene(self,w): | |
1264 | 299 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
|
300 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
|
301 self._drop_undo() |
956 | 302 return |
941
9ba94c577a6f
Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff
changeset
|
303 |
956 | 304 def doExtendScene(self,w): |
305 self.extendScene() | |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
306 self._drop_undo() |
956 | 307 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
|
308 |
1147 | 309 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
|
310 """ |
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
|
311 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
|
312 """ |
1147 | 313 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
|
314 # |
1325 | 315 # Make dup groups empty. |
316 # 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
|
317 # |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
318 nlayers = self._domviewui.get_layer_num() |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
319 for layer_idx in range(nlayers): |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
320 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
|
321 for child in layer_dup.childList(): |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
322 layer_dup.removeChild(child) |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
323 pass |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
324 pass |
740b3239030e
Clear dup group before running animation.
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
325 |
1147 | 326 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
|
327 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
|
328 self.last_update = glib.timeout_add(tmout, self.doRunNext) |
1147 | 329 else: |
330 self.btnRun.set_label("Run") | |
331 glib.source_remove(self.last_update) | |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
332 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
|
333 pass |
1147 | 334 |
335 def doRunNext(self): | |
1264 | 336 if self.current > self._domviewui.get_max_frame(): |
1147 | 337 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
|
338 pass |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
339 try: |
1245
ccbf0c5d01d1
Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
340 self._director.show_scene(self.current) |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
341 except: |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
342 traceback.print_exc() |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1160
diff
changeset
|
343 raise |
1199
25e1579ed3d1
Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1198
diff
changeset
|
344 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
|
345 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
|
346 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
|
347 pass |
1174 | 348 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
349 def doInsertFrame(self, w): |
1264 | 350 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
351 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
|
352 self._drop_undo() |
1219 | 353 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
354 def doRemoveFrame(self, w): |
1264 | 355 layer_idx, frame_idx = self._domviewui.get_active_layer_frame() |
356 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
|
357 self._drop_undo() |
1219 | 358 |
1249
16a1166c3850
Add more method being monitored
Thinker K.F. Li <thinker@codemud.net>
parents:
1248
diff
changeset
|
359 def do_TweenTypeChange(self, w): |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
360 if self._disable_tween_type_selector: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
361 return |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
362 |
1264 | 363 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
|
364 tween_type = self.tweenTypeSelector.get_active() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
365 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
366 start, end, old_tween_type = \ |
1264 | 367 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
|
368 if end >= frame_idx and start != end: |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
369 # Length of tween > 1 and cover this frame |
1264 | 370 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
|
371 pass |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
372 self._drop_undo() |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
373 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
374 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
375 def onQuit(self, event): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
376 self.OK = False |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
377 gtk.main_quit() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
378 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
379 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
380 def onOK(self, event): |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
381 self.OK = True |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
382 gtk.main_quit() |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
383 pass |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
384 |
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
385 def _add_buttons(self, hbox): |
1528
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
386 btn = gtk.Button('Add a Layer') |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
387 btn.connect('clicked', self.doAddLayer) |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
388 hbox.pack_start(btn, expand=False, fill=False) |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
389 |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
390 btn = gtk.Button('Remove the Layer') |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
391 btn.connect('clicked', self.doRemoveLayer) |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
392 hbox.pack_start(btn, expand=False, fill=False) |
b7d70341ee57
Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents:
1517
diff
changeset
|
393 |
956 | 394 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
|
395 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
|
396 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 397 |
956 | 398 btn=gtk.Button('Remove Key') |
399 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
|
400 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 401 |
956 | 402 btn=gtk.Button('Extend scene') |
403 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
|
404 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 405 |
406 btn=gtk.Button('Duplicate Key') | |
407 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
|
408 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 409 |
1219 | 410 btn=gtk.Button('insert') |
411 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
|
412 hbox.pack_start(btn, expand=False, fill=False) |
1219 | 413 |
414 btn=gtk.Button('remove') | |
415 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
|
416 hbox.pack_start(btn, expand=False, fill=False) |
1219 | 417 |
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
|
418 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
|
419 btn.connect('clicked', self.doRun) |
1147 | 420 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
|
421 hbox.pack_start(btn, expand=False, fill=False) |
1174 | 422 |
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
|
423 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
|
424 self.addTweenTypeSelector(hbox) |
956 | 425 pass |
1144
257beac7c982
Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents:
1142
diff
changeset
|
426 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
427 def do_show(self): |
956 | 428 self.OK = True |
1237
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
429 if not self._root: |
b5cceb2b87bb
Sucessful extend and duplicate
Thinker K.F. Li <thinker@codemud.net>
parents:
1236
diff
changeset
|
430 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
|
431 pass |
0ffef2df6201
Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents:
1148
diff
changeset
|
432 |
1128
b65ac686a7c5
Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents:
1125
diff
changeset
|
433 self.document = self.desktop.doc().rdoc |
1240
84bcd398cccc
Fix bug of removing keyframe
Thinker K.F. Li <thinker@codemud.net>
parents:
1239
diff
changeset
|
434 |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
435 self._domviewui.set_desktop(self.desktop) |
1264 | 436 self._domviewui.handle_doc_root(self.document, self._root) |
437 self._domviewui.register_active_frame_callback(self.do_CellClick) | |
438 self._director = scenes_director(self._domviewui) | |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
439 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
440 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
|
441 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
|
442 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
|
443 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
|
444 else: |
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
445 self.top.remove(self.startWindow) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
446 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1149
diff
changeset
|
447 |
1222
03daff2d939c
Add a space after every comma in an argument list
Thinker K.F. Li <thinker@codemud.net>
parents:
1220
diff
changeset
|
448 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
|
449 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
|
450 self.top.pack_start(vbox, expand=False) |
1264 | 451 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
|
452 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
|
453 hbox=gtk.HBox(False, 0) |
1231
d28b1b840bfc
Integrate MBDOM_UI to MBScene
Thinker K.F. Li <thinker@codemud.net>
parents:
1230
diff
changeset
|
454 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
|
455 vbox.pack_start(hbox, expand=False) |
981 | 456 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
457 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
|
458 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
|
459 |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
460 self._drop_undo() |
1455
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
461 |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
462 self.desktop.connectCurrentLayerChanged(self.handle_change_layer) |
1338
d0e6f350b3fd
Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents:
1337
diff
changeset
|
463 |
1064
16c69756ef5d
Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents:
1032
diff
changeset
|
464 return False |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
465 |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
466 ## \brief To handle context menu event. |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
467 # |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
468 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
|
469 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
|
470 |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
471 comp_name = 'Component ' + node.getAttribute('id') |
1329
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
472 i = 0 |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
473 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
|
474 comp_name = 'Component %s - %d' % (comp_name, i) |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
475 i = i + 1 |
2b051e474b0f
Avoid component name confliction
Thinker K.F. Li <thinker@codemud.net>
parents:
1328
diff
changeset
|
476 pass |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
477 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
|
478 |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
479 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
|
480 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
481 |
1455
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
482 ## \brief Handle event that user change layers. |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
483 # |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
484 # This method is always being called for chaning layer event. |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
485 # So, we should do some check at beginning for re-entry condition. |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
486 # |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
487 def handle_change_layer(self, node): |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
488 layer = self.desktop.currentLayer() |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
489 node = layer.repr |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
490 |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
491 # |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
492 # Only scene group and dup group are allowed. |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
493 # |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
494 try: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
495 scene_group_attr = node.getAttribute('scene_group') |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
496 except KeyError: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
497 pass |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
498 else: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
499 if scene_group_attr == 'true': |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
500 return |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
501 pass |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
502 |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
503 try: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
504 label = node.getAttribute('inkscape:label') |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
505 except KeyError: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
506 pass |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
507 else: |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
508 if label == 'dup': |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
509 return |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
510 pass |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
511 # It is not a scene or dup group. |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
512 |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
513 layer_idx, frame_idx = self._domviewui.get_current_frame() |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
514 self.selectSceneObject(layer_idx, frame_idx) |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
515 pass |
8ea0d32a1864
Prevent user from escaping from scene or dup group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1431
diff
changeset
|
516 |
1328
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
517 ## \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
|
518 # |
407f321f0d7c
Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents:
1325
diff
changeset
|
519 # 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
|
520 # 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
|
521 # |
1323
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
522 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
|
523 node = spitem.repr |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
524 if node.name() != 'svg:g': |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
525 return # not a group |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
526 |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
527 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
|
528 menu_item_handler = \ |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
529 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
|
530 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
|
531 menu_item_handler) |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
532 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
533 pass |
ffbbd3aa218d
Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
534 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
535 def show(self): |
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
536 self.do_show() |
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1304
diff
changeset
|
537 pass |
956 | 538 pass |