annotate pyink/domview_ui.py @ 1278:f7395e788aaf

Show the new created framelines after we reload the layers.
author wycc
date Thu, 13 Jan 2011 23:49:22 +0800
parents 776b024ae8f9
children a6aba785656e
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
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
6
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
7 ## \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
8 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9 # 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
10 # 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
11 # 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
12 # 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
13 # 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
14 #
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
15 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
16 _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
17 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
18 _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
19
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20 _framelines = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22 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
23 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
24
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
25 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
26 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
27 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
28 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
29
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
30 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
31 """
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
32 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
33 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
34 """
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
35 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
36 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
37 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
38 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
39 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
40 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
41
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
42 ## \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
43 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
44 # 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
45 # 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
46 # 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
47 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
48 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
49 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
50
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
51 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
52 last.deactive()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
53 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
54
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
55 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
56 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
57
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
58 ## \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
59 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
60 # 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
61 # 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
62 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
63 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
64 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
65 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
66
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
67 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
68 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
69 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
70 pass
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
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
73 ## \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
74 #
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
75 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
76 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
77 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
78 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
79
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
80 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
81 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
82
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
83 hbox = gtk.HBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
84 label = gtk.Label('')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
85 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
86 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
87 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
88 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
89
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
90 # 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
91 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
92 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
93
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
94 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
95
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
96 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
97 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
98 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
99
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
100 line.label = label
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
101 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
102 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
103 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
104
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
105 ## \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
106 #
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
107 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
108 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
109 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
110
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
111 hbox = line.parent
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
112 vbox.remove(hbox)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
113 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
114
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
115 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
116 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
117 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
118 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
119
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
120 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
121 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
122
1271
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
123 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
124 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
125 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
126 self._frameline_vbox.remove(hbox)
1271
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
127 pass
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
128
0daf68f3c1f9 Coding style
Thinker K.F. Li <thinker@codemud.net>
parents: 1265
diff changeset
129 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
130 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
131 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
132 self._active_frame_callback = 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
133 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
134
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
135 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
136 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
137 return
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
138 self._framelines = []
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
139
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
140 box = gtk.ScrolledWindow()
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
141 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
142 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
143 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
144 vbox = gtk.VBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
145 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
146 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
147
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
148 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
149
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
150 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
151 # 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
152 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
153 ruler = frameruler(nframes)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
154 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
155 ruler.show()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
156 hbox = gtk.HBox()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
157 label=gtk.Label('')
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
158 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
159 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
160 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
161 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
162 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
163
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
164 ## \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
165 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
166 # 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
167 # 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
168 # 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
169 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
170 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
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 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
174 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
175 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
176 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
177 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
178 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
179 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
180
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
181 ## \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
182 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
183 # \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
184 # active.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
185 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
186 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
187 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
188 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
189 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
190 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
191 pass
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
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
193
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
194 ## \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
195 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
196 # 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
197 # left-side.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
198 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
199 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
200 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
201 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
202 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
203
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
204 ## \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
205 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
206 # 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
207 # tween.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
208 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
209 # \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
210 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
211 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
212 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
213
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
214 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
215 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
216
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
217 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
218 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
219 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
220 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
221 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
222 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
223 return tweens
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
224
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
225 ## \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
226 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
227 # 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
228 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
229 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
230 assert tween_len > 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
231 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
232 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
233 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
234
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
235 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
236 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
237 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
238 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
239 if start < end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
240 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
241 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
242 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
243 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
244 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
245
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
246 ## \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
247 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
248 # 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
249 # totally.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
250 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
251 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
252 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
253 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
254 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
255 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
256
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
257 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
258 if start < end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
259 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
260 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
261 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
262
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
263 ## \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
264 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
265 # 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
266 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
267 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
268 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
269 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
270 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
271
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
272 ## \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
273 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
274 # 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
275 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
276 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
277 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
278 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
279 return data
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
280
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
281 ## \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
282 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
283 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
284 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
285 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
286 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
287
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
288 ## \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
289 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
290 # 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
291 # 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
292 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
293 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
294 assert num > 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
295 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
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 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
298 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
299 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
300 pass
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 ## \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
303 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
304 # 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
305 # be removed.
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 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
308 assert num > 0
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
309 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
310
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
311 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
312
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
313 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
314 # 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
315 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
316 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
317 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
318 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
319 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
320 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
321 else:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
322 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
323 # 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
324 frameline.untween(start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
325 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
326 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
327 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
328
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 # 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
331 # range.
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 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
334 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
335 except ValueError:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
336 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
337 else:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
338 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
339 # 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
340 frameline.untween(start)
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
341 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
342 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
343 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
344 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
345
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
346 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
347 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
348 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
349 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
350
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
351 ## \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
352 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
353 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
354 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
355 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
356 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
357
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
358 ## \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
359 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
360 # 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
361 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
362 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
363 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
364 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
365 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
366
1246
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
367
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
368 ## \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
369 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
370 # 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
371 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
372 _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
373
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
374 def __init__(self):
1244
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
375 super(domview_ui, self).__init__()
b241f9768833 Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents: 1243
diff changeset
376 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
377 self._dom = domview()
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
378 self._doc = None
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
379 self._root = None
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
380 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
381 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
382
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
383 ## \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
384 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
385 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
386 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
387 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
388 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
389 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
390
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
391 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
392 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
393 if start != end:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
394 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
395 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
396 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
397 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
398 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
399 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
400
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
401 ## \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
402 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
403 # 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
404 # loading a document.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
405 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
406 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
407 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
408 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
409 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
410
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
411 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
412 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
413
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
414 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
415 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
416 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
417
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
418 ## \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
419 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
420 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
421 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
422 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
423 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
424 self._fl_stack.show_framelines()
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
425
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
426 self._doc = doc
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
427 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
428 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
429
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
430 ## \brief Reload the document.
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
431 #
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
432 def reset(self):
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
433 self._fl_stack.remove_all_framelines()
1275
776b024ae8f9 Fix the buggy implementation of reset()
Thinker K.F. Li <thinker@codemud.net>
parents: 1274
diff changeset
434 self._dom.reset()
776b024ae8f9 Fix the buggy implementation of reset()
Thinker K.F. Li <thinker@codemud.net>
parents: 1274
diff changeset
435 self._add_frameline_for_every_layer()
1278
f7395e788aaf Show the new created framelines after we reload the layers.
wycc
parents: 1275
diff changeset
436 self._fl_stack.show_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
437 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
438
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
439 ## \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
440 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
441 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
442 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
443 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
444
1247
45e9566ea5c0 Fix bugs of inserting/removing frames.
Thinker K.F. Li <thinker@codemud.net>
parents: 1246
diff changeset
445 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
446 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
447
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
448 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
449 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
450 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
451
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
452 ## \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
453 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
454 # 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
455 # 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
456 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
457 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
458 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
459 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
460
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
461 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
462 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
463 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
464 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
465 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
466 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
467
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
468 ## \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
469 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
470 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
471 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
472 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
473 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
474 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
475
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
476 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
477 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
478 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
479 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
480 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
481 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
482 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
483 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
484
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
485 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
486 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
487 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
488
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
489 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
490 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
491 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
492
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
493 ## \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
494 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
495 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
496 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
497 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
498
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
499 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
500 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
501
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
502 ## \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
503 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
504 # 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
505 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
506 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
507 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
508 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
509 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
510
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
511 ## \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
512 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
513 # All frame at and after given position will shift left, except nearest
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
514 # \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
515 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
516 def rm_frames(self, layer_idx, frame_idx, num):
1247
45e9566ea5c0 Fix bugs of inserting/removing frames.
Thinker K.F. Li <thinker@codemud.net>
parents: 1246
diff changeset
517 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
518 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
519 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
520
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
521 ## \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
522 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
523 # 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
524 # 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
525 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
526 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
527 self._dom.insert_layer(layer_idx)
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
528 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
529 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
530 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
531
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
532 ## \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
533 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
534 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
535 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
536 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
537 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
538 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
539
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
540 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
541 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
542 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
543
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
544 ## \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
545 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
546 # \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
547 # active one.
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
548 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
549 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
550 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
551
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
552 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
553 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
554
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
555 ## \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
556 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
557 # 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
558 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
559 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
560 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
561 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
562 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
563 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
564
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
565 ## \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
566 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
567 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
568 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
569 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
570 if layer_idx == -1:
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
571 raise ValueError, \
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
572 '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
573 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
574 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
575 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
576
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
577 ## \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
578 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
579 # 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
580 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
581 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
582 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
583 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
584 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
585
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
586 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
587 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
588 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
589 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
590
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
591 ## \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
592 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
593 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
594 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
595 return key_tweens
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
596
1246
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
597 ## \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
598 #
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
599 # 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
600 # 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
601 #
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
602 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
603 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
604 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
605 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
606 pass
42c4874c8d1e Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1245
diff changeset
607
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
608 ## \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
609 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
610 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
611 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
612
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
613 ## \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
614 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
615 # 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
616 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
617 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
618 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
619 pass
1259
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
620
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
621 ## \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
622 #
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
623 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
624 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
625 if layer_idx == -1:
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
626 raise ValueError, \
df474448364e Add find_layer_from_group() for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1258
diff changeset
627 '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
628 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
629
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
630 ## \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
631 #
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
632 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
633 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
634 if not data:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
635 data = dict()
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
636 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
637 pass
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 dup_group = None
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
640 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
641 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
642 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
643 except KeyError:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
644 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
645 pass
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 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
648 # 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
649 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
650 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
651 try:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
652 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
653 except:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
654 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
655 else:
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
656 if label == 'dup':
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
657 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
658 return child
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
659 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
660 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
661
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
662 # 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
663 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
664 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
665 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
666
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
667 return dup_group
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
668
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
669 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
670 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
671 return max_frame
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
672
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 ## \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
674 #
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
675 # 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
676 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
677 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
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
1245
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
680 @property
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
681 def doc(self):
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
682 return self._doc
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
683
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
684 @property
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
685 def root(self):
ccbf0c5d01d1 Move code of setCurrentScene to tween.py.
Thinker K.F. Li <thinker@codemud.net>
parents: 1244
diff changeset
686 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
687
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
688 def lock(self):
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
689 if self._lock:
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
690 return False
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
691 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
692 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
693
2f9fa5d59e67 Add data_monitor meta-class to monitor accessing on domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents: 1247
diff changeset
694 def unlock(self):
1252
71222a6b4c06 Implement lock for domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1248
diff changeset
695 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
696 return True
1243
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
697 pass
d5f70928e9f1 Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
698
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
699
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
700 ## \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
701 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
702 # 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
703 # consistency_checker.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
704 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
705 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
706 ## \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
707 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
708 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
709 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
710 return node
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
711
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
712 ## \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
713 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
714 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
715 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
716 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
717
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
718 ## \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
719 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
720 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
721 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
722 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
723 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
724 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
725
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
726 start, end, tween_name = \
1274
a4d3838264dd Make public APIs being public for domview
Thinker K.F. Li <thinker@codemud.net>
parents: 1273
diff changeset
727 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
728 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
729
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
730 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
731 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
732 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
733 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
734 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
735
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
736 ## \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
737 #
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
738 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
739 try:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
740 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
741 except:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
742 return
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
743
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
744 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
745 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
746 return
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
747
1273
1d0474f2f6fa Make public APIs being public for frameline_stack
Thinker K.F. Li <thinker@codemud.net>
parents: 1272
diff changeset
748 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
749 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
750 try:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
751 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
752 except:
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
753 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
754 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
755 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
756 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
757 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
758
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
759
1258
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
760 ## \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
761 #
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
762 class domview_ui_with_workers(domview_ui, 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
763 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
764 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
765
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
766 self._consistency_checker = consistency.consistency_checker(self)
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
767 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
768
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
769 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
770 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
771
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
772 self._consistency_checker.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
773 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
774 pass
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
775
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
776
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
777 ## \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
778 #
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
779 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
780 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
781 return domview
2609b219703d Move initialize of consistency_checker to domview_ui_with_workers
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
782