annotate pyink/domview_ui.py @ 1532:4a92b639a1cd

Clear selection set when switching current scene. To clear selection set after switching away from current to another scene. It avoids Inkscape select on nodes they are not saw after switching.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 30 Sep 2011 12:31:33 +0800
parents b7d70341ee57
children
rev   line source
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 import gtk
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
2 from tween import TweenObject
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
3 from frameline import frameline, frameruler
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
4 from domview import domview
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1252
diff changeset
5 import consistency
1299
6949e2b6cae2 Add unlink clone checker.
Thinker K.F. Li <thinker@codemud.net>
parents: 1294
diff changeset
6 import unlink_clone
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
7
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
8 ## \brief Maintain a stack of frameline UI component.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
10 # Every layer is assocated with a frameline. Framelines are showed/stacked in
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
11 # virtical. Framelines of lower layers are placed at lower position on the
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
12 # screen. This class provide a set of API to access framelines with layer and
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
13 # frame index number. You access/set content of frameline by specifing layer
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
14 # index and frame index.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
15 #
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
16 class frameline_stack(object):
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
17 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
18 frameline.TWEEN_TYPE_SHAPE)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
19 _num_frames_of_line = 100
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21 _framelines = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
23 def __init__(self, *args, **kws):
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
24 super(frameline_stack, self).__init__(*args, **kws)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
25
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
26 self._last_mouse_over_frameline = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
27 self._last_active_frameline = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
28 self._active_frame_callback = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
29 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
30
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
31 def _change_hover_frameline(self, widget, event):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
32 """
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
33 Hide all hover frames. This is a hack. We should use the lost focus
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
34 event instead in the future to reduce the overhead.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
35 """
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
36 if self._last_mouse_over_frameline and \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
37 widget != self._last_mouse_over_frameline:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
38 self._last_mouse_over_frameline.mouse_leave()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
39 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
40 self._last_mouse_over_frameline = widget
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
41 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
42
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
43 ## \brief Switch to new active frameline.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
44 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
45 # Hide active frame mark for the active frame of old active frameline. It
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
46 # always shows at most one active frame mark. When a frame is activated,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
47 # all active frame mark of other frameline should be hidden.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
48 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
49 def _active_frameline(self, frameline):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
50 last = self._last_active_frameline
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
51
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
52 if last and last != frameline:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
53 last.deactive()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
54 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
55
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
56 self._last_active_frameline = frameline
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
57 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
58
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
59 ## \brief Called for changing of active frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
60 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
61 # This handle deactive previous frameline that owns an active frame when a
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
62 # frame in another frameline is activated.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
63 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
64 def _change_active_frame(self, frameline, frame_idx, button):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
65 frameline.active_frame(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
66 self._active_frameline(frameline)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
67
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
68 if self._active_frame_callback:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
69 layer_idx = frameline.layer_idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
70 self._active_frame_callback(layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
71 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
72 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
73
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
74 ## \brief Add a frameline into the frameline box for the given layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
75 #
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
76 def add_frameline(self, layer_idx):
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
77 if layer_idx > len(self._framelines):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
78 raise ValueError, 'layer number should be a consequence'
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
79 vbox = self._frameline_vbox
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
80
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
81 line = frameline(self._num_frames_of_line)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
82 line.set_size_request(self._num_frames_of_line * 10, 20)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
83
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
84 hbox = gtk.HBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
85 label = gtk.Label('')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
86 label.set_size_request(100,0)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
87 hbox.pack_start(label,expand=False, fill=True)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
88 hbox.pack_start(line)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
89 vbox.pack_start(hbox, False)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
90
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
91 # Put later one on the top of earier one, but after the ruler.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
92 position = len(self._framelines) - layer_idx + 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
93 vbox.reorder_child(hbox, position)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
94
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
95 self._framelines[layer_idx: layer_idx] = [line]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
96
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
97 for idx in range(layer_idx, len(self._framelines)):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
98 self._framelines[idx].layer_idx = idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
99 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
100
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
101 line.label = label
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
102 line.connect('motion-notify-event', self._change_hover_frameline)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
103 line.connect(frameline.FRAME_BUT_PRESS, self._change_active_frame)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
104 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
105
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
106 ## \brief Remove the given frameline from the frameline box.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
107 #
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
108 def remove_frameline(self, layer_idx):
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
109 vbox = self._frameline_vbox
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
110 line = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
111
1355
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
112 if self._last_active_frameline == line:
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
113 self._last_active_frameline = None
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
114 pass
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
115 if self._last_mouse_over_frameline == line:
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
116 self._last_mouse_over_frameline = None
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
117 pass
f1fa284fc9c9 Fix error bug for showing mouse over on frameline after removing a layer
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
118
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
119 hbox = line.parent
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
120 vbox.remove(hbox)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
121 del self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
122
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
123 for idx in range(layer_idx, len(self._framelines)):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
124 self._framelines[idx].layer_idx = idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
125 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
126 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
127
1320
6090be010927 Fix issue of selecting frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1316
diff changeset
128 ## \brief Remove all framelines from the stack.
6090be010927 Fix issue of selecting frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1316
diff changeset
129 #
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
130 def remove_all_framelines(self):
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: 1262
diff changeset
131 num = len(self._framelines)
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: 1262
diff changeset
132
1271
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
133 for idx in range(0, num):
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: 1262
diff changeset
134 line = self._framelines[idx]
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: 1262
diff changeset
135 hbox = line.parent
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: 1262
diff changeset
136 self._frameline_vbox.remove(hbox)
1271
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
137 pass
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
138
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
139 self._framelines = []
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: 1262
diff changeset
140 self._last_mouse_over_frameline = None
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: 1262
diff changeset
141 self._last_active_frameline = None
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: 1262
diff changeset
142 pass
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: 1262
diff changeset
143
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
144 def init_framelines(self):
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: 1262
diff changeset
145 if self._framelines!= None:
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: 1262
diff changeset
146 return
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
147 self._framelines = []
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
148
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
149 box = gtk.ScrolledWindow()
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
150 self.frameline_box = box
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
151 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
152 box.set_size_request(-1, 150)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
153 vbox = gtk.VBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
154 self._frameline_vbox = vbox
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
155 box.add_with_viewport(vbox)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
156
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
157 nframes = self._num_frames_of_line
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
158
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
159 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
160 # Set up a ruler
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
161 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
162 ruler = frameruler(nframes)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
163 ruler.set_size_request(nframes * 10, 20)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
164 ruler.show()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
165 hbox = gtk.HBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
166 label=gtk.Label('')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
167 label.set_size_request(100,0)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
168 hbox.pack_start(label,expand=False,fill=True)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
169 hbox.pack_start(ruler)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
170 vbox.pack_start(hbox, False)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
171 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
172
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
173 ## \brief Show framelines on the screen.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
174 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
175 # When a frameline was inserted or removed, it would not be showed
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
176 # immediately. This function is used to notify toolkit to update the
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
177 # screen and drawing framelines.
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
178 def show_framelines(self):
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
179 self._frameline_vbox.show_all()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
180 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
181
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
182 ## \brief Make given frame as current active frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
183 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
184 def active_frame(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
185 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
186 self._active_frameline(frameline)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
187 frameline.active_frame(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
188 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
189
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
190 ## \brief Get layer and frame index of current active frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
191 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
192 # \return (-1, -1) for no active, (layer_idx, frame_idx) for current
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
193 # active.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
194 def get_active_layer_frame(self):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
195 if self._last_active_frameline:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
196 layer_idx = self._last_active_frameline.layer_idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
197 frame_idx = self._last_active_frameline.get_active_frame()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
198 if frame_idx != -1:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
199 return layer_idx, frame_idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
200 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
201 return -1, -1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
202
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
203 ## \brief Get information of the key frame at left-side.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
204 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
205 # The key frame, returned, is at the place of the give frame or its
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
206 # left-side.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
207 def get_left_key_tween(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
208 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
209 start, end, fl_tween_type = frameline.get_frame_block_floor(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
210 tween_type = self._frameline_tween_types.index(fl_tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
211 return start, end, tween_type
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
212
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
213 ## \brief Return information of a key frame and its tweening.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
214 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
215 # This method return the key frame that the given frame is, or is in its
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
216 # tween.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
217 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
218 # \return (start, end, tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
219 def get_key_tween(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
220 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
221 start, end, fl_tween_type = frameline.get_frame_block(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
222
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
223 tween_type = self._frameline_tween_types.index(fl_tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
224 return start, end, tween_type
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
225
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
226 def get_all_key_tween_of_layer(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
227 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
228 info = frameline.get_frame_blocks()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
229 tweens = [(tween[0], tween[1],
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
230 self._frameline_tween_types.index(tween[2]))
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
231 for tween in info]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
232 return tweens
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
233
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
234 ## \brief Tweening key frame to a give size
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
235 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
236 # The tween can be changed by tweening it again.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
237 def tween(self, layer_idx, key_frame_idx, tween_len,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
238 tween_type=TweenObject.TWEEN_TYPE_NORMAL):
1293
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
239 assert tween_len > 1
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
240 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
241 right_frame_idx = key_frame_idx + tween_len - 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
242 fl_tween_type = self._frameline_tween_types[tween_type]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
244 start, end, old_fl_tween_type = \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
245 frameline.get_frame_block(key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
246 if start != key_frame_idx:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
247 ValueError, 'invalid key frame (%d)' % (key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
248 if start < end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
249 frameline.unmark_keyframe(end)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
250 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
251 frameline.mark_keyframe(right_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
252 frameline.tween(start, fl_tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
253 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
254
1293
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
255 def untween(self, layer_idx, key_frame_idx):
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
256 frameline = self._framelines[layer_idx]
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
257 start, end, tween_type = \
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
258 frameline.get_frame_block(key_frame_idx)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
259 if start < end:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
260 frameline.untween(start)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
261 frameline.unmark_keyframe(end)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
262 pass
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
263 pass
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
264
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
265 ## \brief Unmark a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
266 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
267 # Once a key frame was unmark, the associated tween was also removed
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
268 # totally.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
269 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
270 def unmark_keyframe(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
271 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
272 start, end, fl_tween_type = frameline.get_frame_block(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
273 if start != frame_idx:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
274 raise ValueError, 'no such key (%d, %d)' % (layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
275
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
276 frameline.unmark_keyframe(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
277 if start < end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
278 frameline.unmark_keyframe(end)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
279 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
280 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
281
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
282 ## \brief Makr a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
283 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
284 # Make a frame as a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
285 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
286 def mark_keyframe(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
287 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
288 frameline.mark_keyframe(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
289 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
290
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
291 ## \brief Get data associated with the given key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
292 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
293 # The given frame index must be exactly a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
294 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
295 def get_keyframe_data(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
296 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
297 data = frameline.get_frame_data(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
298 return data
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
299
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
300 ## \brief Set/associate data with the given key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
301 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
302 def set_keyframe_data(self, layer_idx, frame_idx, data):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
303 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
304 frameline.set_frame_data(frame_idx, data)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
305 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
306
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
307 ## \brief Insert frames before specified frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
308 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
309 # Specified frame and frames after it are shift right for \ref num
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
310 # positions to make a space for new frames.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
311 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
312 def insert_frames(self, layer_idx, frame_idx, num):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
313 assert num > 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
314 assert frame_idx >= 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
315 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
316 for i in range(num):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
317 frameline.add_frame(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
318 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
319 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
320
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
321 ## \brief Remove a number of frames from the frameline.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
322 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
323 # All key frames and associated tween info covered by removing range would
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
324 # be removed.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
325 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
326 def rm_frames(self, layer_idx, frame_idx, num):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
327 assert num > 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
328 assert frame_idx >= 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
329
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
330 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
331
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
332 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
333 # Remove right key frame of last tween which left one will be removed.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
334 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
335 last_rm = frame_idx + num - 1 # last removed frame
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
336 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
337 start, end, tween_type = frameline.get_frame_block(last_rm)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
338 except ValueError: # last removed frame is not in any tween
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
339 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
340 else:
1292
00833f8912a9 Revert function of domview_ui to changeset #4686f3131f2a
Thinker K.F. Li <thinker@codemud.net>
parents: 1284
diff changeset
341 if start >= frame_idx and end > last_rm:
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
342 # Left key frame of the tween was removed, but not right one.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
343 frameline.untween(start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
344 frameline.unmark_keyframe(end)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
345 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
346 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
347
1292
00833f8912a9 Revert function of domview_ui to changeset #4686f3131f2a
Thinker K.F. Li <thinker@codemud.net>
parents: 1284
diff changeset
348 #
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
349 # Remove left key of the tween that right key frame is in removing
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
350 # range.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
351 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
352 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
353 start, end, tween_type = frameline.get_frame_block(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
354 except ValueError:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
355 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
356 else:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
357 if start < frame_idx and end <= last_rm:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
358 # right key frame is in removing range but left one.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
359 frameline.untween(start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
360 frameline.unmark_keyframe(start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
361 frameline.unmark_keyframe(end)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
362 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
363 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
364
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
365 for i in range(num):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
366 frameline.rm_frame(frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
367 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
368 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
369
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
370 ## \brief Set label for a layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
371 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
372 def set_layer_label(self, layer_idx, txt):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
373 frameline = self._framelines[layer_idx]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
374 frameline.label.set_text(txt)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
375 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
376
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
377 ## \brief Register a callback for active frame event.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
378 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
379 # The callback would be called when a frame is activated.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
380 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
381 def register_active_frame_callback(self, cb):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
382 self._active_frame_callback = cb
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
383 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
384 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
385
1246
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
386
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
387 ## \biref Components and timelines management for domview.
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
388 #
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
389 # This is mix-in for domview_ui to provide components and timelines
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1306
diff changeset
390 # management functions. This class expose a lot of methods from class
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1306
diff changeset
391 # component_manager.
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
392 #
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
393 class domview_ui_comp(object):
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
394 def __init__(self):
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
395 from comp_dock import comp_dock
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
396
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
397 self._comp_dock = comp_dock(self)
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
398 pass
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
399
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
400 def _ui_comp_refresh(self):
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
401 self._comp_dock.refresh()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
402 pass
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
403
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
404 ## \brief Setup desktop that the document will be serviced.
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
405 #
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
406 # This method must be called before handle_doc_root.
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
407 #
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
408 def set_desktop(self, desktop):
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
409 self._desktop = desktop
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1306
diff changeset
410 self._comp_dock.install_dock(desktop)
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
411 pass
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
412
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
413 def add_component(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
414 self._dom.add_component(name)
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
415 self._comp_dock.dom_add_component(name)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
416 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
417
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
418 def rm_component(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
419 self._dom.rm_component(name)
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
420 self._comp_dock.dom_rm_component(name)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
421 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
422
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
423 def switch_component(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
424 self._dom.switch_component(name)
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
425 self._framelines_refresh() # from domview_ui
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
426 self._comp_dock.refresh_timelines()
1431
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
427
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
428 cur_layer_idx, cur_frame_idx = self._dom.get_current_frame()
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
429 self._fl_stack.active_frame(cur_layer_idx, cur_frame_idx)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
430 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
431
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
432 def all_comp_names(self):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
433 names = self._dom.all_comp_names()
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
434 return names
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
435
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
436 def has_component(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
437 r = self._dom.has_component(name)
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
438 return r
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
439
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
440 def get_current_component(self):
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
441 return self._dom.get_current_component()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
442
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
443 def add_timeline(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
444 self._dom.add_timeline(name)
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
445 self._comp_dock.dom_add_timeline(name)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
446 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
447
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
448 def rm_timeline(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
449 self._dom.rm_timeline(name)
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
450 self._comp_dock.dom_rm_timeline(name)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
451 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
452
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
453 def switch_timeline(self, name):
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
454 self._dom.switch_timeline(name)
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
455 self._framelines_refresh() # from domview_ui
1431
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
456
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
457 cur_layer_idx, cur_frame_idx = self._dom.get_current_frame()
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
458 self._fl_stack.active_frame(cur_layer_idx, cur_frame_idx)
1306
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
459 pass
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
460
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
461 def all_timeline_names(self):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
462 names = self._dom.all_timeline_names()
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
463 return names
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
464
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
465 def has_timeline(self, name):
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
466 r = self._dom.has_timeline(name)
8c0a4684c1f7 Expose methods from component_manager
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
467 return r
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
468
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
469 def get_current_timeline(self):
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
470 return self._dom.get_current_timeline()
1323
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
471
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
472 ## \brief Add a new component from a group node.
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
473 #
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
474 # The group node is reparented to the group of first layer of
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
475 # specified component.
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
476 #
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
477 def add_component_from_group(self, comp_name, group):
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
478 self.add_component(comp_name)
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
479 self._dom.mv_group_to_component(group, comp_name)
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
480 pass
1328
407f321f0d7c Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
481
407f321f0d7c Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
482 def link_to_component(self, comp_name, parent_group):
407f321f0d7c Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
483 link_node = self._dom.link_to_component(comp_name, parent_group)
407f321f0d7c Add a svg:use after transform a group to a component
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
484 return link_node
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
485
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
486 def rename_component(self, comp_name, new_name):
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
487 self._dom.rename_component(comp_name, new_name)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
488 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
489
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
490 def rename_timeline_of_component(self, timeline_name, new_name, comp_name):
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
491 self._dom.rename_timeline_of_component(timeline_name, new_name,
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
492 comp_name)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
493 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
494
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
495 def rename_timeline(self, timeline_name, new_name):
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
496 self._dom.rename_timeline(timeline_name, new_name)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1328
diff changeset
497 pass
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
498
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
499 def refresh_components(self):
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
500 self._dom.reparse_components()
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
501 dock = self._comp_dock
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
502 dock.refresh_components()
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
503 pass
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
504
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
505 def refresh_timelines(self):
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
506 self._dom.reparse_timelines()
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
507 dock = self._comp_dock
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
508 dock.refresh_timelines()
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
509 pass
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
510 pass
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
511
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
512
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
513 ## \brief FSM management interface for domview_ui.
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
514 #
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
515 class domview_ui_FSM(object):
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
516 def __init__(self):
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
517 super(domview_ui_FSM, self).__init__()
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
518 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
519
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
520 def all_state_names(self, comp_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
521 return self._dom.all_state_names(comp_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
522
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
523 def get_start_state_name(self, comp_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
524 return self._dom.get_start_state_name(comp_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
525
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
526 def rm_state(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
527 self._dom.rm_state(comp_name, state_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
528 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
529
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
530 def add_state(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
531 self._dom.add_state(comp_name, state_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
532 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
533
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
534 def rename_state(self, comp_name, state_name, new_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
535 self._dom.rename_state(comp_name, state_name, new_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
536 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
537
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
538 def set_start_state(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
539 self._dom.set_start_state(comp_name, state_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
540 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
541
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
542 def set_state_entry_action(self, comp_name, state_name, entry_action):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
543 self._dom.set_state_entry_action(comp_name, state_name, entry_action)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
544 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
545
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
546 def set_state_r(self, comp_name, state_name, r):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
547 self._dom.set_state_r(comp_name, state_name, r)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
548 pass
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
549
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
550 def set_state_xy(self, comp_name, state_name, x, y):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
551 self._dom.set_state_xy(comp_name, state_name, x, y)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
552 pass
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
553
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
554 def get_state_entry_action(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
555 action = self._dom.get_state_entry_action(comp_name, state_name)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
556 return action
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
557
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
558 def get_state_r(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
559 r = self._dom.get_state_r(comp_name, state_name)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
560 return r
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
561
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
562 def get_state_xy(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
563 xy = self._dom.get_state_xy(comp_name, state_name)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
564 return xy
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
565
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
566 def all_transitions(self, comp_name, state_name):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
567 return self._dom.all_transitions(comp_name, state_name)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
568
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
569 def add_transition(self, comp_name, state_name, cond, target):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
570 self._dom.add_transition(comp_name, state_name, cond, target)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
571 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
572
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
573 def rm_transition(self, comp_name, state_name, cond):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
574 self._dom.rm_transition(comp_name, state_name, cond)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
575 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
576
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
577 def change_transition_cond(self, comp_name, state_name,
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
578 old_cond, new_cond):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
579 self._dom.change_transition_cond(comp_name, state_name,
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
580 old_cond, new_cond)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
581 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
582
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
583 def get_transition(self, comp_name, state_name, cond):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
584 return self._dom.get_transition(comp_name, state_name, cond)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
585
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
586 def set_transition_action(self, comp_name, state_name, cond, action):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
587 self._dom.set_transition_action(comp_name, state_name, cond, action)
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
588 pass
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
589
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
590 def set_transition_path(self, comp_name, state_name, cond, path):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
591 self._dom.set_transition_path(comp_name, state_name, cond, path)
1469
c1e70540541c Drawing functions for states and transitions
Thinker K.F. Li <thinker@codemud.net>
parents: 1466
diff changeset
592 pass
1511
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
593 def chg_transition_cond(self, comp_name, state_name, cond, new_cond):
4c349b214877 FSM_window use _compview to decorate domview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1506
diff changeset
594 self._dom.chg_transition_cond(comp_name, state_name, cond, new_cond)
1501
4a57650bb926 Apply changes returned from transition editor
Thinker K.F. Li <thinker@codemud.net>
parents: 1469
diff changeset
595 pass
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
596 pass
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
597
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
598
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
599 ## \brief Bridge of DOM-tree to syncrhonize data-model and UI.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
600 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
601 # This class is a wrapper
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
602 class domview_ui(object):
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
603 _tween_type_names = ('normal', 'scale')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
604
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
605 def __init__(self):
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
606 super(domview_ui, self).__init__()
1304
94e6594dea59 Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1299
diff changeset
607
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
608 self._fl_stack = frameline_stack()
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
609 self._dom = domview()
1304
94e6594dea59 Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1299
diff changeset
610 self._desktop = None
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
611 self._doc = None
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
612 self._root = None
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
613 self._lock = False
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
614 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
615
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
616 ## \brief Update content of a frameline from scenes of respective layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
617 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
618 def _update_frameline_content(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
619 fl_stack = self._fl_stack
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
620 scene_nodes = self._dom.get_all_scene_node_of_layer(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
621 for scene_node in scene_nodes:
1274
a4d3838264dd Make public APIs being public for domview
Thinker K.F. Li <thinker@codemud.net>
parents: 1273
diff changeset
622 start, end, tween_name = self._dom.parse_one_scene(scene_node)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
623
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
624 fl_stack.mark_keyframe(layer_idx, start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
625 fl_stack.set_keyframe_data(layer_idx, start, scene_node)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
626 if start != end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
627 tween_type = self._tween_type_names.index(tween_name)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
628 tween_len = end - start + 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
629 fl_stack.tween(layer_idx, start, tween_len, tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
630 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
631 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
632 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
633
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
634 ## \brief Add a frameline for every found layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
635 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
636 # This method is called to create a frameline for every layer found when
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
637 # loading a document.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
638 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
639 def _add_frameline_for_every_layer(self):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
640 for layer_idx in range(self._dom.get_layer_num()):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
641 layer_group_node = self._dom.get_layer_group(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
642 label = layer_group_node.getAttribute('inkscape:label')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
643
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
644 self._fl_stack.add_frameline(layer_idx)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
645 self._fl_stack.set_layer_label(layer_idx, label)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
646
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
647 self._update_frameline_content(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
648 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
649 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
650
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
651 ## \brief This method is called to handle a new document.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
652 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
653 def handle_doc_root(self, doc, root):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
654 self._dom.handle_doc_root(doc, root)
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
655 self._fl_stack.init_framelines()
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
656 self._add_frameline_for_every_layer()
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
657 self._fl_stack.show_framelines()
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
658 self._ui_comp_refresh() # from domview_ui_comp
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
659
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
660 self._doc = doc
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
661 self._root = root
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
662 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
663
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
664 ## \brief Update framelines according domview.
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
665 #
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
666 def _framelines_refresh(self):
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
667 self._fl_stack.remove_all_framelines()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
668 self._add_frameline_for_every_layer()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
669 self._fl_stack.show_framelines()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
670 pass
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
671
1315
fcff6978f9bf User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
672 ## \brief Parse the document from the scratch and update 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: 1262
diff changeset
673 #
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: 1262
diff changeset
674 def reset(self):
1275
776b024ae8f9 Fix the buggy implementation of reset()
Thinker K.F. Li <thinker@codemud.net>
parents: 1274
diff changeset
675 self._dom.reset()
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
676 self._framelines_refresh()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
677 self._ui_comp_refresh() # from domview_ui_comp
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: 1262
diff changeset
678 pass
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: 1262
diff changeset
679
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
680 ## \brief Mark given frame as a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
681 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
682 def mark_key(self, layer_idx, key_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
683 scene_group = self._dom.add_scene_group(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
684 scene_group_id = scene_group.getAttribute('id')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
685
1247
45e9566ea5c0 Fix bugs of inserting/removing frames.
Thinker K.F. Li <thinker@codemud.net>
parents: 1246
diff changeset
686 scene_node = self._dom.add_scene_node(layer_idx, key_idx, key_idx)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
687 self._dom.chg_scene_node(scene_node, ref=scene_group_id)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
688
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
689 self._fl_stack.mark_keyframe(layer_idx, key_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
690 self._fl_stack.set_keyframe_data(layer_idx, key_idx, scene_node)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
691 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
692
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
693 ## \brief Tweening a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
694 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
695 # To tween a key spanning several frames at right-side.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
696 # The tween of a key frame can be changed by tweening it again.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
697 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
698 def tween(self, layer_idx, key_frame_idx, tween_len,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
699 tween_type=TweenObject.TWEEN_TYPE_NORMAL):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
700 self._fl_stack.tween(layer_idx, key_frame_idx, tween_len, tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
701
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
702 end_frame_idx = key_frame_idx + tween_len - 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
703 scene_node = self._fl_stack.get_keyframe_data(layer_idx, key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
704 tween_name = self._tween_type_names[tween_type]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
705 self._dom.chg_scene_node(scene_node, end=end_frame_idx,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
706 tween_type=tween_name)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
707 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
708
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
709 ## \brief Change tween info of a key frame
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
710 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
711 def chg_tween(self, layer_idx, key_frame_idx,
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
712 tween_len=None, tween_type=None):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
713 scene_node = self._fl_stack.get_keyframe_data(layer_idx, key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
714 start, end, old_tween_type = \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
715 self._fl_stack.get_key_tween(layer_idx, key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
716
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
717 if tween_len is not None:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
718 end = start + tween_len - 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
719 self._dom.chg_scene_node(scene_node, end=end)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
720 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
721 if tween_type is not None:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
722 tween_name = self._tween_type_names[tween_type]
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
723 self._dom.chg_scene_node(scene_node, tween_type=tween_name)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
724 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
725
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
726 if tween_type is None:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
727 tween_type = old_tween_type
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
728 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
729
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
730 tween_len = end - start + 1
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
731 self._fl_stack.tween(layer_idx, start, tween_len, tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
732 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
733
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
734 ## \brief Unmark a frame from a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
735 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
736 def unmark_key(self, layer_idx, key_frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
737 scene_node = self._fl_stack.get_keyframe_data(layer_idx, key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
738 self._dom.rm_scene_node_n_group(scene_node)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
739
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
740 self._fl_stack.unmark_keyframe(layer_idx, key_frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
741 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
742
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
743 ## \brief Insert frames at specified position.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
744 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
745 # All frame at and after given position will shift right.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
746 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
747 def insert_frames(self, layer_idx, frame_idx, num):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
748 self._fl_stack.insert_frames(layer_idx, frame_idx, num)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
749 self._dom.insert_frames(layer_idx, frame_idx, num)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
750 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
751
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
752 ## \brief Insert frames at specified position.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
753 #
1293
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
754 # All frames at and after given position will shift left, except nearest
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
755 # \ref num frames are removed.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
756 #
1293
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
757 # - For a tween that only right part is covered by removing
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
758 # range, its tween length would be shrinked just before
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
759 # removing range.
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
760 # - For a tween that only left part is covered by removing range,
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
761 # key and tween are fully removed.
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
762 # - For a tween that only middle part is covered, tween length is
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
763 # also shrinked according length of covered part.
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
764 #
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
765 def rm_frames(self, layer_idx, frame_idx, num):
1293
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
766 #
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
767 # Check the key that is partially covered key tween, but not
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
768 # include key frame.
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
769 #
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
770 last_rm_idx = frame_idx + num - 1
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
771 try:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
772 start, end, tween_type = \
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
773 self._fl_stack.get_left_key_tween(layer_idx, frame_idx)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
774 except ValueError:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
775 pass # no key at left
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
776 else:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
777 if start < frame_idx and end >= frame_idx:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
778 #
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
779 # Key frame is not covered, only part of a key tween
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
780 # is covered. Shrink its tween length, size of the
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
781 # covered part, or the key will be unmarked.
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
782 #
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
783 shrink_sz = min(end - frame_idx + 1, num)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
784
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
785 tween_len = end - start + 1 - shrink_sz
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
786 if tween_len == 1:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
787 self._fl_stack.untween(layer_idx, start)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
788 else:
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
789 self._fl_stack.tween(layer_idx, start, tween_len,
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
790 tween_type)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
791 pass
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
792
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
793 scene_end = end - shrink_sz
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
794 scene_node = self._fl_stack.get_keyframe_data(layer_idx, start)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
795 self._dom.chg_scene_node(scene_node, end=scene_end)
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
796
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
797 frame_idx = scene_end + 1 # to shift/remove keys at right side
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
798 pass
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
799 pass
10bffaffef82 Fix the supporting of removing key tween partially.
Thinker K.F. Li <thinker@codemud.net>
parents: 1292
diff changeset
800
1247
45e9566ea5c0 Fix bugs of inserting/removing frames.
Thinker K.F. Li <thinker@codemud.net>
parents: 1246
diff changeset
801 self._fl_stack.rm_frames(layer_idx, frame_idx, num)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
802 self._dom.rm_frames(layer_idx, frame_idx, num)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
803 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
804
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
805 ## \brief Insert a layer at given position.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
806 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
807 # Original layer \ref layer_idx and later ones would be shifted to make a
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
808 # space for the new layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
809 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
810 def insert_layer(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
811 self._dom.insert_layer(layer_idx)
1528
b7d70341ee57 Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents: 1511
diff changeset
812 layer_name = self._dom.get_layer_name(layer_idx)
b7d70341ee57 Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents: 1511
diff changeset
813
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
814 self._fl_stack.add_frameline(layer_idx)
1528
b7d70341ee57 Insert layer with unique name
Thinker K.F. Li <thinker@codemud.net>
parents: 1511
diff changeset
815 self._fl_stack.set_layer_label(layer_idx, layer_name)
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
816 self._fl_stack.show_framelines()
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
817 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
818
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
819 ## \brief Remove given layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
820 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
821 def rm_layer(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
822 self._dom.rm_layer(layer_idx)
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
823 self._fl_stack.remove_frameline(layer_idx)
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
824 self._fl_stack.show_framelines()
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
825 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
826
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
827 def set_active_layer_frame(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
828 self._fl_stack.active_frame(layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
829 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
830
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
831 ## \bref Return current active frame and its layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
832 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
833 # \return (layer_idx, frame_idx) of active frame, or (-1, -1) when no
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
834 # active one.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
835 def get_active_layer_frame(self):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
836 layer_idx, frame_idx = self._fl_stack.get_active_layer_frame()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
837 return layer_idx, frame_idx
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
838
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
839 def get_layer_num(self):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
840 return self._dom.get_layer_num()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
841
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
842 ## \brief Return associated group node for a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
843 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
844 # The given frame index must be exactly a key frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
845 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
846 def get_key_group(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
847 scene_node = self._fl_stack.get_keyframe_data(layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
848 scene_group_id = scene_node.getAttribute('ref')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
849 scene_group_node = self._dom.get_node(scene_group_id)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
850 return scene_group_node
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
851
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
852 ## \brief Find an associated key frame and tween info for a group ID.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
853 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
854 def find_key_from_group(self, scene_group_id):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
855 layer_idx, scene_node = \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
856 self._dom.find_layer_n_scene_of_node(scene_group_id)
1259
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
857 if layer_idx == -1:
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
858 raise ValueError, \
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
859 'can not find the key for group %s' % (scene_group_id)
1274
a4d3838264dd Make public APIs being public for domview
Thinker K.F. Li <thinker@codemud.net>
parents: 1273
diff changeset
860 start, end, tween_name = self._dom.parse_one_scene(scene_node)
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
861 tween_type = self._tween_type_names.index(tween_name)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
862 return layer_idx, (start, end, tween_type)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
863
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
864 ## \brief Return key and tween info for given frame index.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
865 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
866 # The return key is at given frame, or its tween covers given frame.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
867 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
868 def get_key(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
869 start, end, tween_type = \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
870 self._fl_stack.get_key_tween(layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
871 return start, end, tween_type
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
872
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
873 def get_left_key(self, layer_idx, frame_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
874 start, end, tween_type = \
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
875 self._fl_stack.get_left_key_tween(layer_idx, frame_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
876 return start, end, tween_type
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
877
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
878 ## \brief Return information of key frames in the given layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
879 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
880 def get_layer_keys(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
881 key_tweens = self._fl_stack.get_all_key_tween_of_layer(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
882 return key_tweens
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
883
1246
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
884 ## \brief Copy content of a source key frame to a destinate.
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
885 #
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
886 # Copy content of the scene group of a source key frame to the
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
887 # scene group of a destinate key frame.
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
888 #
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
889 def copy_key_group(self, layer_idx, src_frame_idx, dst_frame_idx):
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
890 src_group = self.get_key_group(layer_idx, src_frame_idx)
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
891 dst_group = self.get_key_group(layer_idx, dst_frame_idx)
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
892 self._dom.copy_group_children(src_group, dst_group)
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
893 pass
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
894
1294
Thinker K.F. Li <thinker@codemud.net>
parents: 1293 1288
diff changeset
895 def clone_key_group(self, layer_idx, src_frame_idx, dst_frame_idx):
1288
fb44830c8a81 Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
wycc
parents: 1284
diff changeset
896 src_group = self.get_key_group(layer_idx, src_frame_idx)
fb44830c8a81 Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
wycc
parents: 1284
diff changeset
897 dst_group = self.get_key_group(layer_idx, dst_frame_idx)
1294
Thinker K.F. Li <thinker@codemud.net>
parents: 1293 1288
diff changeset
898 self._dom.clone_group_children(src_group, dst_group)
1288
fb44830c8a81 Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
wycc
parents: 1284
diff changeset
899 pass
fb44830c8a81 Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
wycc
parents: 1284
diff changeset
900
1323
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
901 ## \brief To test a graphic node.
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
902 #
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
903 # A graphic node is a SVG node that is not layer group, scene
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
904 # group, ... etc. It is only a normal node in a layer group or a
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
905 # scene group.
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
906 def is_graph_node(self, node):
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
907 return self._dom.is_graph_node(node)
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
908
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
909 ## \brief Return widget showing frames and layers.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
910 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
911 def get_frame_ui_widget(self):
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
912 return self._fl_stack.frameline_box
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
913
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
914 ## \brief Register a callback for activating a frame event.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
915 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
916 # The callback function is called when a frame is activated.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
917 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
918 def register_active_frame_callback(self, cb):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
919 self._fl_stack.register_active_frame_callback(cb)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
920 pass
1259
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
921
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
922 ## \brief Find the layer index associated with a given layer group.
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
923 #
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
924 def find_layer_from_group(self, group_id):
1261
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1259
diff changeset
925 layer_idx = self._dom.find_layer_of_group(group_id)
1259
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
926 if layer_idx == -1:
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
927 raise ValueError, \
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
928 'can not find the layer for group %s' % (group_id)
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
929 return layer_idx
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
930
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
931 ## \brief Get duplicate group of a layer.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
932 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
933 def get_layer_dup_group(self, layer_idx):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
934 data = self._dom.get_layer_data(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
935 if not data:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
936 data = dict()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
937 self._dom.set_layer_data(layer_idx, data)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
938 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
939
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
940 dup_group = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
941 if data.has_key('dup_group_id'):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
942 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
943 dup_group = self._dom.get_node(data['dup_group_id'])
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
944 except KeyError:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
945 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
946 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
947
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
948 if not dup_group:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
949 # Search dup group from children of the layer group
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
950 layer_group = self._dom.get_layer_group(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
951 for child in layer_group.childList():
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
952 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
953 label = child.getAttribute('inkscape:label')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
954 except:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
955 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
956 else:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
957 if label == 'dup':
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
958 data['dup_group_id'] = child
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
959 return child
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
960 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
961 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
962
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
963 # Or create a new dup group for the layer
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
964 dup_group = self._dom.create_layer_dup_group(layer_idx)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
965 data['dup_group_id'] = dup_group.getAttribute('id')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
966 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
967
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
968 return dup_group
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
969
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
970 def get_max_frame(self):
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
971 max_frame = self._dom.get_max_frame()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
972 return max_frame
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
973
1432
8e8c9ab3818f Add documentation
Thinker K.F. Li <thinker@codemud.net>
parents: 1431
diff changeset
974 ## \brief Remember current frame and layer on the scenes node.
8e8c9ab3818f Add documentation
Thinker K.F. Li <thinker@codemud.net>
parents: 1431
diff changeset
975 #
1431
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
976 def remember_current_frame(self, layer_idx, frame_idx):
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
977 self._dom.remember_current_frame(layer_idx, frame_idx)
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
978 pass
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
979
1432
8e8c9ab3818f Add documentation
Thinker K.F. Li <thinker@codemud.net>
parents: 1431
diff changeset
980 ## \brief Get current frame and layer from the scenes node.
8e8c9ab3818f Add documentation
Thinker K.F. Li <thinker@codemud.net>
parents: 1431
diff changeset
981 #
1431
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
982 def get_current_frame(self):
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
983 return self._dom.get_current_frame()
60f2c9a24cdb Keep the same active layer and frame when switching back a timeline.
Thinker K.F. Li <thinker@codemud.net>
parents: 1355
diff changeset
984
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: 1262
diff changeset
985 ## \brief add the current position to the undo buffer.
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: 1262
diff changeset
986 #
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: 1262
diff changeset
987 # The msg will be displayed in the UI to indicate the undo set.
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: 1262
diff changeset
988 def mark_undo(self, msg):
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: 1262
diff changeset
989 self._dom.mark_undo(msg)
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: 1262
diff changeset
990 pass
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: 1262
diff changeset
991
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
992 @property
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
993 def doc(self):
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
994 return self._doc
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
995
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
996 @property
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
997 def root(self):
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
998 return self._root
1248
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
999
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
1000 def lock(self):
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
1001 if self._lock:
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
1002 return False
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
1003 self._lock = True
1248
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
1004 return True
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
1005
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
1006 def unlock(self):
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
1007 self._lock = False
1248
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
1008 return True
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1009 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1010
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1011
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1012 ## \brief Expose some internal interface.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1013 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1014 # This is a mix-in to provide API for internal using, for example,
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1015 # consistency_checker.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1016 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1017 class domview_internal(object):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1018 ## \brief Search a node by a ID.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1019 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1020 def get_node(self, node_id):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1021 node = self._dom.get_node(node_id)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1022 return node
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1023
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1024 ## \brief Search scene node by scene group ID.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1025 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1026 def get_scene_by_group(self, scene_group_id):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1027 scene_node = self._dom.get_scene(scene_group_id)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1028 return scene_node
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1029
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1030 ## \brief Manage a scene node that is unknown by domview_ui before.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1031 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1032 def manage_scene_node(self, scene_node, scene_group):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1033 layer_group = scene_group.parent()
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1034 layer_group_id = layer_group.getAttribute('id')
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1035 layer_idx = self.find_layer_from_group(layer_group_id)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1036 self._dom.manage_scene_node(layer_idx, scene_node)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1037
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1038 start, end, tween_name = \
1274
a4d3838264dd Make public APIs being public for domview
Thinker K.F. Li <thinker@codemud.net>
parents: 1273
diff changeset
1039 self._dom.parse_one_scene(scene_node)
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1040 tween_type = self._tween_type_names.index(tween_name)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1041
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1042 tween_len = end - start + 1
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1043 self._fl_stack.mark_keyframe(layer_idx, start)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1044 self._fl_stack.set_keyframe_data(layer_idx, start, scene_node)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1045 self._fl_stack.tween(layer_idx, start, tween_len, tween_type)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1046 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1047
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1048 ## \brief Manage a layer group that is unknown by domview_ui before.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1049 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1050 def manage_layer_group(self, layer_group):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1051 try:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1052 layer_group_id = layer_group.getAttribute('id')
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1053 except:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1054 return
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1055
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1056 layer_idx = self._dom.manage_layer_group(layer_group_id)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1057 if layer_idx == -1:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1058 return
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1059
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
1060 self._fl_stack.add_frameline(layer_idx)
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
1061 self._fl_stack.show_framelines()
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1062 try:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1063 label = layer_group.getAttribute('inkscape:label')
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1064 except:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1065 label = layer_group.getAttribute('id')
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1066 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1067 self._fl_stack.set_layer_label(layer_idx, label)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1068 pass
1323
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1069
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1070 ## \brief Get layer group.
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1071 #
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1072 def get_layer_group(self, layer_idx):
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1073 layer_group = self._dom.get_layer_group(layer_idx)
ffbbd3aa218d Make a component from a group.
Thinker K.F. Li <thinker@codemud.net>
parents: 1320
diff changeset
1074 return layer_group
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1075 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1076
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
1077
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1078 ## \brief Oven domview_ui and all mix-ins
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1079 #
1466
1829b0cc9721 Add FSM management interface for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1432
diff changeset
1080 class domview_ui_oven(domview_ui, domview_ui_comp, domview_ui_FSM):
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1081 def __init__(self):
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1082 super(domview_ui_oven, self).__init__()
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1083 pass
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1084 pass
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1085
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1086 ## \brief A mix-in to enable workers for a domview_ui.
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1087 #
1305
573a51b1eb37 domview_ui_comp as a mix-in to oven comp_dock and domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1304
diff changeset
1088 class domview_ui_with_workers(domview_ui_oven, domview_internal):
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1089 def __init__(self):
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1090 super(domview_ui_with_workers, self).__init__()
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1091
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1092 self._consistency_checker = consistency.consistency_checker(self)
1299
6949e2b6cae2 Add unlink clone checker.
Thinker K.F. Li <thinker@codemud.net>
parents: 1294
diff changeset
1093 self._unlink_clone_checker = unlink_clone.unlink_clone_checker(self)
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1094 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1095
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1096 def handle_doc_root(self, doc, root):
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1097 super(domview_ui_with_workers, self).handle_doc_root(doc, root)
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1098
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1099 self._consistency_checker.handle_doc_root(doc, root)
1299
6949e2b6cae2 Add unlink clone checker.
Thinker K.F. Li <thinker@codemud.net>
parents: 1294
diff changeset
1100 self._unlink_clone_checker.handle_doc_root(doc, root)
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1101 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1102 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1103
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1104
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1105 ## \brief Factory function of domview_ui.
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1106 #
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1107 def create_domview_ui():
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1108 domview = domview_ui_with_workers()
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1109 return domview
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
1110