Skip to content

Commit efc398f

Browse files
[#1363] Code style & transitions keyframes
Renamed getKeyframePositions to getTimelineObjectPositions Moved more logic inside getTimelineObjectPositions getTimelineObjectPositions now only takes the object as argument (eg. selected_clip or selected_trans) Added functionnality for transitions as well as clips
1 parent 624b93d commit efc398f

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/windows/main_window.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -1231,25 +1231,31 @@ def actionAddMarker_trigger(self, event):
12311231
def findAllMarkerPositions(self):
12321232
"""Build and return a list of all seekable locations for the currently-selected timeline elements"""
12331233

1234-
def getKeyframePositions(data, clip_start_time, clip_stop_time, fps_float):
1235-
""" Add all keyframes of a clip.data to all_marker_positions """
1234+
def getTimelineObjectPositions(obj):
1235+
""" Add boundaries & all keyframes of a timeline object (clip, transition...) to all_marker_positions """
12361236
positions = []
1237-
for property in data :
1237+
1238+
fps = get_app().project.get("fps")
1239+
fps_float = float(fps["num"]) / float(fps["den"])
1240+
1241+
clip_start_time=obj.data["position"]
1242+
clip_stop_time=obj.data["position"] + (obj.data["end"] - obj.data["start"])
1243+
1244+
# add clip boundaries
1245+
all_marker_positions.append(clip_start_time)
1246+
all_marker_positions.append(clip_stop_time)
1247+
1248+
# add all keyframes
1249+
for property in obj.data :
12381250
try :
1239-
for point in data[property]["Points"] :
1240-
keyframe_time=(point["co"]["X"]-1)/fps_float - data["start"] + data["position"]
1251+
for point in obj.data[property]["Points"] :
1252+
keyframe_time=(point["co"]["X"]-1)/fps_float - obj.data["start"] + obj.data["position"]
12411253
if keyframe_time > clip_start_time and keyframe_time < clip_stop_time :
12421254
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])
1255+
except (TypeError, KeyError):
12481256
pass
12491257
return positions
12501258

1251-
fps = get_app().project.get("fps")
1252-
fps_float = float(fps["num"]) / float(fps["den"])
12531259
all_marker_positions = []
12541260

12551261
# Get list of marker and important positions (like selected clip bounds)
@@ -1261,20 +1267,14 @@ def getKeyframePositions(data, clip_start_time, clip_stop_time, fps_float):
12611267
# Get selected object
12621268
selected_clip = Clip.get(id=clip_id)
12631269
if selected_clip:
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))
1270+
all_marker_positions.extend(getTimelineObjectPositions(selected_clip))
12701271

12711272
# Loop through selected transitions (and add key positions)
12721273
for tran_id in self.selected_transitions:
12731274
# Get selected object
12741275
selected_tran = Transition.get(id=tran_id)
12751276
if selected_tran:
1276-
all_marker_positions.append(selected_tran.data["position"])
1277-
all_marker_positions.append(selected_tran.data["position"] + (selected_tran.data["end"] - selected_tran.data["start"]))
1277+
all_marker_positions.extend(getTimelineObjectPositions(selected_tran))
12781278

12791279
# remove duplicates
12801280
all_marker_positions = list(set(all_marker_positions))

0 commit comments

Comments
 (0)