@@ -1227,13 +1227,29 @@ def actionAddMarker_trigger(self, event):
1227
1227
marker .data = {"position" : position , "icon" : "blue.png" }
1228
1228
marker .save ()
1229
1229
1230
- def actionPreviousMarker_trigger (self , event ):
1231
- log .info ("actionPreviousMarker_trigger" )
1232
1230
1233
- # Calculate current position (in seconds)
1231
+ def findAllMarkerPositions (self ):
1232
+ """Build and return a list of all seekable locations for the currently-selected timeline elements"""
1233
+
1234
+ def getKeyframePositions (data , clip_start_time , clip_stop_time , fps_float ):
1235
+ """ Add all keyframes of a clip.data to all_marker_positions """
1236
+ positions = []
1237
+ for property in data :
1238
+ try :
1239
+ for point in data [property ]["Points" ] :
1240
+ keyframe_time = (point ["co" ]["X" ]- 1 )/ fps_float - data ["start" ] + data ["position" ]
1241
+ if keyframe_time > clip_start_time and keyframe_time < clip_stop_time :
1242
+ positions .append (keyframe_time )
1243
+ except TypeError :
1244
+ log .info ("%s : %s : not itterable" , property , data [property ])
1245
+ pass
1246
+ except KeyError :
1247
+ log .info ("%s : %s : has no points" , property , data [property ])
1248
+ pass
1249
+ return positions
1250
+
1234
1251
fps = get_app ().project .get ("fps" )
1235
1252
fps_float = float (fps ["num" ]) / float (fps ["den" ])
1236
- current_position = (self .preview_thread .current_frame - 1 ) / fps_float
1237
1253
all_marker_positions = []
1238
1254
1239
1255
# Get list of marker and important positions (like selected clip bounds)
@@ -1245,10 +1261,12 @@ def actionPreviousMarker_trigger(self, event):
1245
1261
# Get selected object
1246
1262
selected_clip = Clip .get (id = clip_id )
1247
1263
if selected_clip :
1248
- all_marker_positions .append (selected_clip .data ["position" ])
1249
- all_marker_positions .append (selected_clip .data ["position" ] + (selected_clip .data ["end" ] - selected_clip .data ["start" ]))
1250
- # add all keyframes. itterate on all properties of Data, look for each points
1251
- addKeyframesToMarkers (selected_clip .data )
1264
+ clip_start_time = selected_clip .data ["position" ]
1265
+ clip_stop_time = selected_clip .data ["position" ] + (selected_clip .data ["end" ] - selected_clip .data ["start" ])
1266
+ all_marker_positions .append (clip_start_time )
1267
+ all_marker_positions .append (clip_stop_time )
1268
+ # add all keyframes
1269
+ all_marker_positions .extend (getKeyframePositions (selected_clip .data , clip_start_time , clip_stop_time , fps_float ))
1252
1270
1253
1271
# Loop through selected transitions (and add key positions)
1254
1272
for tran_id in self .selected_transitions :
@@ -1258,6 +1276,20 @@ def actionPreviousMarker_trigger(self, event):
1258
1276
all_marker_positions .append (selected_tran .data ["position" ])
1259
1277
all_marker_positions .append (selected_tran .data ["position" ] + (selected_tran .data ["end" ] - selected_tran .data ["start" ]))
1260
1278
1279
+ # remove duplicates
1280
+ all_marker_positions = list (set (all_marker_positions ))
1281
+
1282
+ return all_marker_positions
1283
+
1284
+ def actionPreviousMarker_trigger (self , event ):
1285
+ log .info ("actionPreviousMarker_trigger" )
1286
+
1287
+ # Calculate current position (in seconds)
1288
+ fps = get_app ().project .get ("fps" )
1289
+ fps_float = float (fps ["num" ]) / float (fps ["den" ])
1290
+ current_position = (self .preview_thread .current_frame - 1 ) / fps_float
1291
+ all_marker_positions = self .findAllMarkerPositions ()
1292
+
1261
1293
# Loop through all markers, and find the closest one to the left
1262
1294
closest_position = None
1263
1295
for marker_position in sorted (all_marker_positions ):
@@ -1289,28 +1321,7 @@ def actionNextMarker_trigger(self, event):
1289
1321
fps = get_app ().project .get ("fps" )
1290
1322
fps_float = float (fps ["num" ]) / float (fps ["den" ])
1291
1323
current_position = (self .preview_thread .current_frame - 1 ) / fps_float
1292
- all_marker_positions = []
1293
-
1294
- # Get list of marker and important positions (like selected clip bounds)
1295
- for marker in Marker .filter ():
1296
- all_marker_positions .append (marker .data ["position" ])
1297
-
1298
- # Loop through selected clips (and add key positions)
1299
- for clip_id in self .selected_clips :
1300
- # Get selected object
1301
- selected_clip = Clip .get (id = clip_id )
1302
- if selected_clip :
1303
- all_marker_positions .append (selected_clip .data ["position" ])
1304
- all_marker_positions .append (selected_clip .data ["position" ] + (selected_clip .data ["end" ] - selected_clip .data ["start" ]))
1305
- # add all keyframes. itterate on all properties of Data, look for each points
1306
- addKeyframesToMarkers (selected_clip .data )
1307
- # Loop through selected transitions (and add key positions)
1308
- for tran_id in self .selected_transitions :
1309
- # Get selected object
1310
- selected_tran = Transition .get (id = tran_id )
1311
- if selected_tran :
1312
- all_marker_positions .append (selected_tran .data ["position" ])
1313
- all_marker_positions .append (selected_tran .data ["position" ] + (selected_tran .data ["end" ] - selected_tran .data ["start" ]))
1324
+ all_marker_positions = self .findAllMarkerPositions ()
1314
1325
1315
1326
# Loop through all markers, and find the closest one to the right
1316
1327
closest_position = None
@@ -1335,20 +1346,6 @@ def actionNextMarker_trigger(self, event):
1335
1346
get_app ().window .refreshFrameSignal .emit ()
1336
1347
get_app ().window .propertyTableView .select_frame (frame_to_seek )
1337
1348
1338
- def addKeyframesToMarkers (self , data ):
1339
- for property in data :
1340
- try :
1341
- for point in data [property ]["Points" ] :
1342
- keyframe = (point ["co" ]["X" ]- 1 )/ fps_float - data ["start" ] + data ["position" ]
1343
- if keyframe > start and keyframe < stop :
1344
- all_marker_positions .append (keyframe )
1345
- except TypeError :
1346
- log .info ("%s : %s : not itterable" , property , data [property ])
1347
- pass
1348
- except KeyError :
1349
- log .info ("%s : %s : has no points" , property , data [property ])
1350
- pass
1351
-
1352
1349
def actionCenterOnPlayhead_trigger (self , event ):
1353
1350
""" Center the timeline on the current playhead position """
1354
1351
self .timeline .centerOnPlayhead ()
0 commit comments