comparison pyink/MBScene.py @ 1241:e64f5bd2270c

Change naming. - key frame should be marked/unmark, not be added/removed to/from a layer. - layers are inserted into the stack of layers, not be added.
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 13:37:33 +0800
parents 84bcd398cccc
children 1b1eb8f9a866
comparison
equal deleted inserted replaced
1240:84bcd398cccc 1241:e64f5bd2270c
518 518
519 ## \brief Add/insert a layer at given position. 519 ## \brief Add/insert a layer at given position.
520 # 520 #
521 # \param layer_idx is the position in the layer list. 521 # \param layer_idx is the position in the layer list.
522 # 522 #
523 def add_layer(self, layer_idx, layer_group): 523 def insert_layer(self, layer_idx, layer_group):
524 layers = self._layers 524 layers = self._layers
525 525
526 layer = Layer(layer_group) 526 layer = Layer(layer_group)
527 if layer_idx >= len(layers): 527 if layer_idx >= len(layers):
528 layers.append(layer) 528 layers.append(layer)
588 def set_layer_data(self, layer_idx, data): 588 def set_layer_data(self, layer_idx, data):
589 layer = self._layers[layer_idx] 589 layer = self._layers[layer_idx]
590 layer.data = data 590 layer.data = data
591 pass 591 pass
592 592
593 def add_layer_dup_group(self, layer_idx): 593 def create_layer_dup_group(self, layer_idx):
594 layer = self._layers[layer_idx] 594 layer = self._layers[layer_idx]
595 595
596 dup_group = self._doc.createElement('svg:g') 596 dup_group = self._doc.createElement('svg:g')
597 gid = self.new_id() 597 gid = self.new_id()
598 dup_group.setAttribute('id', gid) 598 dup_group.setAttribute('id', gid)
602 602
603 layer.group.appendChild(dup_group) 603 layer.group.appendChild(dup_group)
604 604
605 return dup_group 605 return dup_group
606 606
607 def add_frames(self, layer_idx, frame_idx, num): 607 def insert_frames(self, layer_idx, frame_idx, num):
608 layer = self._layers[layer_idx] 608 layer = self._layers[layer_idx]
609 for scene_node in layer.scenes: 609 for scene_node in layer.scenes:
610 start, end, tween_type = self._parse_one_scene(scene_node) 610 start, end, tween_type = self._parse_one_scene(scene_node)
611 if start >= frame_idx: 611 if start >= frame_idx:
612 self.chg_scene_node(scene_node, start=(start + num)) 612 self.chg_scene_node(scene_node, start=(start + num))
856 start, end, old_fl_tween_type = \ 856 start, end, old_fl_tween_type = \
857 frameline.get_frame_block(key_frame_idx) 857 frameline.get_frame_block(key_frame_idx)
858 if start != key_frame_idx: 858 if start != key_frame_idx:
859 ValueError, 'invalid key frame (%d)' % (key_frame_idx) 859 ValueError, 'invalid key frame (%d)' % (key_frame_idx)
860 if start < end: 860 if start < end:
861 frameline.rm_keyframe(end) 861 frameline.unmark_keyframe(end)
862 pass 862 pass
863 frameline.add_keyframe(right_frame_idx) 863 frameline.mark_keyframe(right_frame_idx)
864 frameline.tween(start, fl_tween_type) 864 frameline.tween(start, fl_tween_type)
865 pass 865 pass
866 866
867 ## \brief Remove key frame. 867 ## \brief Unmark a key frame.
868 # 868 #
869 # Once a key frame was removed, the associated tween was also removed 869 # Once a key frame was unmark, the associated tween was also removed
870 # totally. 870 # totally.
871 # 871 #
872 def rm_keyframe(self, layer_idx, frame_idx): 872 def unmark_keyframe(self, layer_idx, frame_idx):
873 frameline = self._framelines[layer_idx] 873 frameline = self._framelines[layer_idx]
874 start, end, fl_tween_type = frameline.get_frame_block(frame_idx) 874 start, end, fl_tween_type = frameline.get_frame_block(frame_idx)
875 if start != frame_idx: 875 if start != frame_idx:
876 raise ValueError, 'no such key (%d, %d)' % (layer_idx, frame_idx) 876 raise ValueError, 'no such key (%d, %d)' % (layer_idx, frame_idx)
877 877
878 frameline.rm_keyframe(frame_idx) 878 frameline.unmark_keyframe(frame_idx)
879 if start < end: 879 if start < end:
880 frameline.rm_keyframe(end) 880 frameline.unmark_keyframe(end)
881 pass 881 pass
882 pass 882 pass
883 883
884 def add_keyframe(self, layer_idx, frame_idx): 884 ## \brief Makr a key frame.
885 #
886 # Make a frame as a key frame.
887 #
888 def mark_keyframe(self, layer_idx, frame_idx):
885 frameline = self._framelines[layer_idx] 889 frameline = self._framelines[layer_idx]
886 frameline.add_keyframe(frame_idx) 890 frameline.mark_keyframe(frame_idx)
887 pass 891 pass
888 892
889 ## \brief Get data associated with the given key frame. 893 ## \brief Get data associated with the given key frame.
890 # 894 #
891 # The given frame index must be exactly a key frame. 895 # The given frame index must be exactly a key frame.
900 def set_keyframe_data(self, layer_idx, frame_idx, data): 904 def set_keyframe_data(self, layer_idx, frame_idx, data):
901 frameline = self._framelines[layer_idx] 905 frameline = self._framelines[layer_idx]
902 frameline.set_frame_data(frame_idx, data) 906 frameline.set_frame_data(frame_idx, data)
903 pass 907 pass
904 908
905 def add_frames(self, layer_idx, frame_idx, num): 909 ## \brief Insert frames before specified frame.
910 #
911 # Specified frame and frames after it are shift right for \ref num
912 # positions to make a space for new frames.
913 #
914 def insert_frames(self, layer_idx, frame_idx, num):
906 assert num > 0 915 assert num > 0
907 assert frame_idx >= 0 916 assert frame_idx >= 0
908 frameline = self._framelines[layer_idx] 917 frameline = self._framelines[layer_idx]
909 for i in range(num): 918 for i in range(num):
910 frameline.add_frame(frame_idx) 919 frameline.add_frame(frame_idx)
911 pass 920 pass
912 pass 921 pass
913 922
914 ## \brief Remove a number of frames from the frameline. 923 ## \brief Remove a number of frames from the frameline.
915 # 924 #
916 # All key frames and tweens covered by removing range would be removed. 925 # All key frames and associated tween info covered by removing range would
926 # be removed.
917 # 927 #
918 def rm_frames(self, layer_idx, frame_idx, num): 928 def rm_frames(self, layer_idx, frame_idx, num):
919 assert num > 0 929 assert num > 0
920 assert frame_idx >= 0 930 assert frame_idx >= 0
921 931
931 pass 941 pass
932 else: 942 else:
933 if start >= frame_idx and end > last_rm: 943 if start >= frame_idx and end > last_rm:
934 # Left key frame of the tween was removed, but not right one. 944 # Left key frame of the tween was removed, but not right one.
935 frameline.untween(start) 945 frameline.untween(start)
936 frameline.rm_keyframe(end) 946 frameline.unmark_keyframe(end)
937 pass 947 pass
938 pass 948 pass
939 949
940 # 950 #
941 # Remove left key of the tween that right key frame is in removing 951 # Remove left key of the tween that right key frame is in removing
947 pass 957 pass
948 else: 958 else:
949 if start < frame_idx and end <= last_rm: 959 if start < frame_idx and end <= last_rm:
950 # right key frame is in removing range but left one. 960 # right key frame is in removing range but left one.
951 frameline.untween(start) 961 frameline.untween(start)
952 frameline.rm_keyframe(start) 962 frameline.unmark_keyframe(start)
953 frameline.rm_keyframe(end) 963 frameline.unmark_keyframe(end)
954 pass 964 pass
955 pass 965 pass
956 966
957 for i in range(num): 967 for i in range(num):
958 frameline.rm_frame(frame_idx) 968 frameline.rm_frame(frame_idx)
959 pass 969 pass
960 pass 970 pass
961 971
962 ## \brief Set label of a layer. 972 ## \brief Set label for a layer.
963 # 973 #
964 def set_layer_label(self, layer_idx, txt): 974 def set_layer_label(self, layer_idx, txt):
965 frameline = self._framelines[layer_idx] 975 frameline = self._framelines[layer_idx]
966 frameline.label.set_text(txt) 976 frameline.label.set_text(txt)
967 pass 977 pass
968 978
979 ## \brief Register a callback for active frame event.
980 #
981 # The callback would be called when a frame is activated.
982 #
969 def register_active_frame_callback(self, cb): 983 def register_active_frame_callback(self, cb):
970 self._active_frame_callback = cb 984 self._active_frame_callback = cb
971 pass 985 pass
972 pass 986 pass
973 987
974 ## \brief Gateway of DOM-tree to syncrhonize data-model and UI. 988 ## \brief Bridge of DOM-tree to syncrhonize data-model and UI.
975 # 989 #
976 # This class is a wrapper 990 # This class is a wrapper
977 class MBDOM_UI(object): 991 class MBDOM_UI(object):
978 _tween_type_names = ('normal', 'scale') 992 _tween_type_names = ('normal', 'scale')
979 993
989 fl_mgr = self._fl_mgr 1003 fl_mgr = self._fl_mgr
990 scene_nodes = self._dom.get_all_scene_node_of_layer(layer_idx) 1004 scene_nodes = self._dom.get_all_scene_node_of_layer(layer_idx)
991 for scene_node in scene_nodes: 1005 for scene_node in scene_nodes:
992 start, end, tween_name = self._dom._parse_one_scene(scene_node) 1006 start, end, tween_name = self._dom._parse_one_scene(scene_node)
993 1007
994 fl_mgr.add_keyframe(layer_idx, start) 1008 fl_mgr.mark_keyframe(layer_idx, start)
995 fl_mgr.set_keyframe_data(layer_idx, start, scene_node) 1009 fl_mgr.set_keyframe_data(layer_idx, start, scene_node)
996 if start != end: 1010 if start != end:
997 tween_type = self._tween_type_names.index(tween_name) 1011 tween_type = self._tween_type_names.index(tween_name)
998 tween_len = end - start + 1 1012 tween_len = end - start + 1
999 fl_mgr.tween(layer_idx, start, tween_len, tween_type) 1013 fl_mgr.tween(layer_idx, start, tween_len, tween_type)
1016 1030
1017 self._update_frameline_content(layer_idx) 1031 self._update_frameline_content(layer_idx)
1018 pass 1032 pass
1019 pass 1033 pass
1020 1034
1035 ## \brief This method is called to handle a new document.
1036 #
1021 def handle_doc_root(self, doc, root): 1037 def handle_doc_root(self, doc, root):
1022 self._dom.handle_doc_root(doc, root) 1038 self._dom.handle_doc_root(doc, root)
1023 self._fl_mgr._init_framelines() 1039 self._fl_mgr._init_framelines()
1024 self._add_frameline_for_every_layer() 1040 self._add_frameline_for_every_layer()
1025 self._fl_mgr._show_framelines() 1041 self._fl_mgr._show_framelines()
1026 pass 1042 pass
1027 1043
1028 def add_key(self, layer_idx, key_idx): 1044 ## \brief Mark given frame as a key frame.
1045 #
1046 def mark_key(self, layer_idx, key_idx):
1029 scene_group = self._dom.add_scene_group(layer_idx) 1047 scene_group = self._dom.add_scene_group(layer_idx)
1030 scene_group_id = scene_group.getAttribute('id') 1048 scene_group_id = scene_group.getAttribute('id')
1031 1049
1032 scene_node = self._dom.add_scene_node(key_idx, key_idx) 1050 scene_node = self._dom.add_scene_node(key_idx, key_idx)
1033 self._dom.chg_scene_node(scene_node, ref=scene_group_id) 1051 self._dom.chg_scene_node(scene_node, ref=scene_group_id)
1034 1052
1035 self._fl_mgr.add_keyframe(layer_idx, key_idx) 1053 self._fl_mgr.mark_keyframe(layer_idx, key_idx)
1036 self._fl_mgr.set_keyframe_data(layer_idx, key_idx, scene_node) 1054 self._fl_mgr.set_keyframe_data(layer_idx, key_idx, scene_node)
1037 pass 1055 pass
1038 1056
1039 ## \brief Tweening a key frame. 1057 ## \brief Tweening a key frame.
1040 # 1058 #
1059 # To tween a key spanning several frames at right-side.
1041 # The tween of a key frame can be changed by tweening it again. 1060 # The tween of a key frame can be changed by tweening it again.
1042 # 1061 #
1043 def tween(self, layer_idx, key_frame_idx, tween_len, 1062 def tween(self, layer_idx, key_frame_idx, tween_len,
1044 tween_type=TweenObject.TWEEN_TYPE_NORMAL): 1063 tween_type=TweenObject.TWEEN_TYPE_NORMAL):
1045 self._fl_mgr.tween(layer_idx, key_frame_idx, tween_len, tween_type) 1064 self._fl_mgr.tween(layer_idx, key_frame_idx, tween_len, tween_type)
1074 1093
1075 tween_len = end - start + 1 1094 tween_len = end - start + 1
1076 self._fl_mgr.tween(layer_idx, start, tween_len, tween_type) 1095 self._fl_mgr.tween(layer_idx, start, tween_len, tween_type)
1077 pass 1096 pass
1078 1097
1079 def rm_key_n_tween(self, layer_idx, key_frame_idx): 1098 ## \brief Unmark a frame from a key frame.
1099 #
1100 def unmark_key(self, layer_idx, key_frame_idx):
1080 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, key_frame_idx) 1101 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, key_frame_idx)
1081 self._dom.rm_scene_node_n_group(scene_node) 1102 self._dom.rm_scene_node_n_group(scene_node)
1082 1103
1083 self._fl_mgr.rm_keyframe(layer_idx, key_frame_idx) 1104 self._fl_mgr.unmark_keyframe(layer_idx, key_frame_idx)
1084 pass 1105 pass
1085 1106
1086 def add_frames(self, layer_idx, frame_idx, num): 1107 ## \brief Insert frames at specified position.
1087 self._fl_mgr.add_frames(layer_idx, frame_idx, num) 1108 #
1088 self._dom.add_frames(layer_idx, frame_idx, num) 1109 # All frame at and after given position will shift right.
1089 pass 1110 #
1090 1111 def insert_frames(self, layer_idx, frame_idx, num):
1112 self._fl_mgr.insert_frames(layer_idx, frame_idx, num)
1113 self._dom.insert_frames(layer_idx, frame_idx, num)
1114 pass
1115
1116 ## \brief Insert frames at specified position.
1117 #
1118 # All frame at and after given position will shift left, except nearest
1119 # \ref num frames are removed.
1120 #
1091 def rm_frames(self, layer_idx, frame_idx, num): 1121 def rm_frames(self, layer_idx, frame_idx, num):
1092 self._fl_mgr.add_frames(layer_idx, frame_idx, num) 1122 self._fl_mgr.insert_frames(layer_idx, frame_idx, num)
1093 self._dom.rm_frames(layer_idx, frame_idx, num) 1123 self._dom.rm_frames(layer_idx, frame_idx, num)
1094 pass 1124 pass
1095 1125
1096 def add_layer(self, layer_idx): 1126 ## \brief Insert a layer at given position.
1097 self._dom.add_layer(layer_idx) 1127 #
1128 # Original layer \ref layer_idx and later ones would be shifted to make a
1129 # space for the new layer.
1130 #
1131 def insert_layer(self, layer_idx):
1132 self._dom.insert_layer(layer_idx)
1098 self._fl_mgr._add_frameline(layer_idx) 1133 self._fl_mgr._add_frameline(layer_idx)
1099 self._fl_mgr._show_framelines() 1134 self._fl_mgr._show_framelines()
1100 pass 1135 pass
1101 1136
1137 ## \brief Remove given layer.
1138 #
1139 def rm_layer(self, layer_idx):
1140 self._dom.rm_layer(layer_idx)
1141 self._fl_mgr._remove_frameline(layer_idx)
1142 self._fl_mgr._show_framelines()
1143 pass
1144
1102 def set_active_layer_frame(self, layer_idx, frame_idx): 1145 def set_active_layer_frame(self, layer_idx, frame_idx):
1103 self._fl_mgr.active_frame(layer_idx, frame_idx) 1146 self._fl_mgr.active_frame(layer_idx, frame_idx)
1104 pass 1147 pass
1105 1148
1106 ## \bref Return current active frame and its layer. 1149 ## \bref Return current active frame and its layer.
1109 # active one. 1152 # active one.
1110 def get_active_layer_frame(self): 1153 def get_active_layer_frame(self):
1111 layer_idx, frame_idx = self._fl_mgr.get_active_layer_frame() 1154 layer_idx, frame_idx = self._fl_mgr.get_active_layer_frame()
1112 return layer_idx, frame_idx 1155 return layer_idx, frame_idx
1113 1156
1114 def rm_layer(self, layer_idx):
1115 self._dom.rm_layer(layer_idx)
1116 self._fl_mgr._remove_frameline(layer_idx)
1117 self._fl_mgr._show_framelines()
1118 pass
1119
1120 def get_layer_num(self): 1157 def get_layer_num(self):
1121 return self._dom.get_layer_num() 1158 return self._dom.get_layer_num()
1122 1159
1123 ## \brief Return associated group node for a key frame. 1160 ## \brief Return associated group node for a key frame.
1124 # 1161 #
1125 # The given frame index must be exactly a key frame. 1162 # The given frame index must be exactly a key frame.
1126 # 1163 #
1127 def get_keyframe_group(self, layer_idx, frame_idx): 1164 def get_key_group(self, layer_idx, frame_idx):
1128 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, frame_idx) 1165 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, frame_idx)
1129 scene_group_id = scene_node.getAttribute('ref') 1166 scene_group_id = scene_node.getAttribute('ref')
1130 scene_group_node = self._dom.get_node(scene_group_id) 1167 scene_group_node = self._dom.get_node(scene_group_id)
1131 return scene_group_node 1168 return scene_group_node
1132 1169
1133 ## \brief Find an associated key frame and tween info for a group ID. 1170 ## \brief Find an associated key frame and tween info for a group ID.
1134 # 1171 #
1135 def find_keyframe_from_group(self, scene_group_id): 1172 def find_key_from_group(self, scene_group_id):
1136 layer_idx, scene_node = \ 1173 layer_idx, scene_node = \
1137 self._dom.find_layer_n_scene_of_node(scene_group_id) 1174 self._dom.find_layer_n_scene_of_node(scene_group_id)
1138 start, end, tween_name = self._dom._parse_one_scene(scene_node) 1175 start, end, tween_name = self._dom._parse_one_scene(scene_node)
1139 tween_type = self._tween_type_names.index(tween_name) 1176 tween_type = self._tween_type_names.index(tween_name)
1140 return layer_idx, (start, end, tween_type) 1177 return layer_idx, (start, end, tween_type)
1151 def get_left_key(self, layer_idx, frame_idx): 1188 def get_left_key(self, layer_idx, frame_idx):
1152 start, end, tween_type = \ 1189 start, end, tween_type = \
1153 self._fl_mgr.get_left_key_tween(layer_idx, frame_idx) 1190 self._fl_mgr.get_left_key_tween(layer_idx, frame_idx)
1154 return start, end, tween_type 1191 return start, end, tween_type
1155 1192
1193 ## \brief Return information of key frames in the given layer.
1194 #
1156 def get_layer_keys(self, layer_idx): 1195 def get_layer_keys(self, layer_idx):
1157 tweens = self._fl_mgr.get_all_key_tween_of_layer(layer_idx) 1196 key_tweens = self._fl_mgr.get_all_key_tween_of_layer(layer_idx)
1158 return tweens 1197 return key_tweens
1159 1198
1160 ## \brief Return widget showing frames and layers. 1199 ## \brief Return widget showing frames and layers.
1161 # 1200 #
1162 def get_frame_ui_widget(self): 1201 def get_frame_ui_widget(self):
1163 return self._fl_mgr._frameline_box 1202 return self._fl_mgr._frameline_box
1164 1203
1204 ## \brief Register a callback for activating a frame event.
1205 #
1206 # The callback function is called when a frame is activated.
1207 #
1165 def register_active_frame_callback(self, cb): 1208 def register_active_frame_callback(self, cb):
1166 self._fl_mgr.register_active_frame_callback(cb) 1209 self._fl_mgr.register_active_frame_callback(cb)
1167 pass
1168
1169 def set_layer_label(self, txt):
1170 self._fl_mgr.set_layer_label(txt)
1171 pass 1210 pass
1172 1211
1173 ## \brief Get duplicate group of a layer. 1212 ## \brief Get duplicate group of a layer.
1174 # 1213 #
1175 def get_layer_dup_group(self, layer_idx): 1214 def get_layer_dup_group(self, layer_idx):
1201 return child 1240 return child
1202 pass 1241 pass
1203 pass 1242 pass
1204 1243
1205 # Or create a new dup group for the layer 1244 # Or create a new dup group for the layer
1206 dup_group = self._dom.add_layer_dup_group(layer_idx) 1245 dup_group = self._dom.create_layer_dup_group(layer_idx)
1207 data['dup_group_id'] = dup_group.getAttribute('id') 1246 data['dup_group_id'] = dup_group.getAttribute('id')
1208 pass 1247 pass
1209 1248
1210 return dup_group 1249 return dup_group
1211 1250
1259 node = node.parent() 1298 node = node.parent()
1260 continue 1299 continue
1261 1300
1262 try: 1301 try:
1263 layer_idx, (start, end, tween_type) = \ 1302 layer_idx, (start, end, tween_type) = \
1264 self._dom.find_keyframe_from_group(node_id) 1303 self._dom.find_key_from_group(node_id)
1265 except: 1304 except:
1266 pass 1305 pass
1267 else: 1306 else:
1268 self._dom.set_active_layer_frame(layer_idx, start) 1307 self._dom.set_active_layer_frame(layer_idx, start)
1269 break 1308 break
1280 two parts. If the nth is out of any scene, we will append a 1319 two parts. If the nth is out of any scene, we will append a
1281 new scene. 1320 new scene.
1282 1321
1283 """ 1322 """
1284 try: 1323 try:
1285 self._dom.add_key(layer_idx, frame_idx) 1324 self._dom.mark_key(layer_idx, frame_idx)
1286 except ValueError: # existed key frame 1325 except ValueError: # existed key frame
1287 pass 1326 pass
1288 pass 1327 pass
1289 1328
1290 def removeKeyScene(self, layer_idx, frame_idx): 1329 def removeKeyScene(self, layer_idx, frame_idx):
1291 self._dom.rm_key_n_tween(layer_idx, frame_idx) 1330 self._dom.unmark_key(layer_idx, frame_idx)
1292 self.setCurrentScene(frame_idx) 1331 self.setCurrentScene(frame_idx)
1293 pass 1332 pass
1294 1333
1295 def extendScene(self): 1334 def extendScene(self):
1296 layer_idx, frame_idx = self._dom.get_active_layer_frame() 1335 layer_idx, frame_idx = self._dom.get_active_layer_frame()
1297 start, end, tween_type = \ 1336 start, end, tween_type = \
1298 self._dom.get_left_key(layer_idx, frame_idx) 1337 self._dom.get_left_key(layer_idx, frame_idx)
1299 tween_len = frame_idx - start + 1 1338 tween_len = frame_idx - start + 1
1300 self._dom.tween(layer_idx, start, tween_len, tween_type) 1339 self._dom.tween(layer_idx, start, tween_len, tween_type)
1301 1340
1302 scene_group = self._dom.get_keyframe_group(layer_idx, start) 1341 scene_group = self._dom.get_key_group(layer_idx, start)
1303 self._enterGroup(scene_group) 1342 self._enterGroup(scene_group)
1304 pass 1343 pass
1305 1344
1306 def setCurrentScene(self, idx): 1345 def setCurrentScene(self, idx):
1307 """ 1346 """
1330 1369
1331 all_key_tweens = self._dom.get_layer_keys(layer_idx) 1370 all_key_tweens = self._dom.get_layer_keys(layer_idx)
1332 for start, end, tween_type in all_key_tweens: 1371 for start, end, tween_type in all_key_tweens:
1333 if start == idx: # at key frame 1372 if start == idx: # at key frame
1334 scene_group = \ 1373 scene_group = \
1335 self._dom.get_keyframe_group(layer_idx, start) 1374 self._dom.get_key_group(layer_idx, start)
1336 scene_group.setAttribute('style', '') 1375 scene_group.setAttribute('style', '')
1337 elif start < idx and end >= idx: # in Tween 1376 elif start < idx and end >= idx: # in Tween
1338 dup_group.setAttribute('style', '') 1377 dup_group.setAttribute('style', '')
1339 scene_group = \ 1378 scene_group = \
1340 self._dom.get_keyframe_group(layer_idx, start) 1379 self._dom.get_key_group(layer_idx, start)
1341 scene_group.setAttribute('style', 'display: none') 1380 scene_group.setAttribute('style', 'display: none')
1342 1381
1343 try: 1382 try:
1344 next_scene_group = \ 1383 next_scene_group = \
1345 self._dom.get_keyframe_group(layer_idx, end + 1) 1384 self._dom.get_key_group(layer_idx, end + 1)
1346 except: # no next key frame 1385 except: # no next key frame
1347 next_scene_group = scene_group 1386 next_scene_group = scene_group
1348 pass 1387 pass
1349 1388
1350 tween_obj_type = self._tween_obj_tween_types[tween_type] 1389 tween_obj_type = self._tween_obj_tween_types[tween_type]
1356 next_scene_group, 1395 next_scene_group,
1357 percent) 1396 percent)
1358 pass 1397 pass
1359 else: # this scene should not be showed. 1398 else: # this scene should not be showed.
1360 scene_group = \ 1399 scene_group = \
1361 self._dom.get_keyframe_group(layer_idx, start) 1400 self._dom.get_key_group(layer_idx, start)
1362 scene_group.setAttribute('style', 'display: none') 1401 scene_group.setAttribute('style', 'display: none')
1363 pass 1402 pass
1364 pass 1403 pass
1365 pass 1404 pass
1366 pass 1405 pass
1379 try: 1418 try:
1380 start, stop, tween_type = self._dom.get_key(layer_idx, frame_idx) 1419 start, stop, tween_type = self._dom.get_key(layer_idx, frame_idx)
1381 except: 1420 except:
1382 return 1421 return
1383 1422
1384 scene_group = self._dom.get_keyframe_group(layer_idx, start) 1423 scene_group = self._dom.get_key_group(layer_idx, start)
1385 self._enterGroup(scene_group) 1424 self._enterGroup(scene_group)
1386 self.setTweenType(tween_type) 1425 self.setTweenType(tween_type)
1387 pass 1426 pass
1388 1427
1389 def duplicateKeyScene(self): 1428 def duplicateKeyScene(self):
1396 except: 1435 except:
1397 return 1436 return
1398 if left_end >= frame_idx: 1437 if left_end >= frame_idx:
1399 return 1438 return
1400 1439
1401 self._dom.add_key(layer_idx, frame_idx) 1440 self._dom.mark_key(layer_idx, frame_idx)
1402 1441
1403 scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx) 1442 scene_group = self._dom.get_key_group(layer_idx, frame_idx)
1404 left_scene_group = \ 1443 left_scene_group = \
1405 self._dom.get_keyframe_group(layer_idx, left_start) 1444 self._dom.get_key_group(layer_idx, left_start)
1406 1445
1407 dup_group = self._duplicate_group(left_scene_group, scene_group) 1446 dup_group = self._duplicate_group(left_scene_group, scene_group)
1408 1447
1409 self.setCurrentScene(frame_idx) 1448 self.setCurrentScene(frame_idx)
1410 pass 1449 pass
1549 pass 1588 pass
1550 1589
1551 def doInsertFrame(self, w): 1590 def doInsertFrame(self, w):
1552 self.lockui=True 1591 self.lockui=True
1553 layer_idx, frame_idx = self._dom.get_active_layer_frame() 1592 layer_idx, frame_idx = self._dom.get_active_layer_frame()
1554 self._dom.add_frames(layer_idx, frame_idx, 1) 1593 self._dom.insert_frames(layer_idx, frame_idx, 1)
1555 self.lockui=False 1594 self.lockui=False
1556 1595
1557 def doRemoveFrame(self, w): 1596 def doRemoveFrame(self, w):
1558 self.lockui=True 1597 self.lockui=True
1559 layer_idx, frame_idx = self._dom.get_active_layer_frame() 1598 layer_idx, frame_idx = self._dom.get_active_layer_frame()