Skip to content

Commit

Permalink
Merge pull request #5670 from OpenShot/improved-ripple-slice
Browse files Browse the repository at this point in the history
Improved ripple slice & auto-show property dock for keyframes/effects
  • Loading branch information
jonoomph authored Dec 18, 2024
2 parents 1fc91df + ad8f2ec commit f1b4a1e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/windows/views/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,7 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0, ripp

# Emit signal to ignore updates (start ignoring updates)
get_app().window.IgnoreUpdates.emit(True)
new_starting_frame = -1

try:
# Get the nearest starting frame position to the playhead (snap to frame boundaries)
Expand Down Expand Up @@ -2040,6 +2041,9 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0, ripp
clip.data["position"] = original_position # Move right side back to original position
self.ripple_delete_gap(playhead_position, clip.data["layer"], removed_duration)

# Seek to new starting frame
new_starting_frame = original_position * (fps_num / fps_den) + 1

elif action == MenuSlice.KEEP_BOTH:
# Update clip data for the left clip
clip.data["end"] = start_of_clip + (playhead_position - original_position)
Expand Down Expand Up @@ -2093,6 +2097,9 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0, ripp
trans.data["position"] = original_position
self.ripple_delete_gap(playhead_position, trans.data["layer"], removed_duration)

# Seek to new starting frame
new_starting_frame = original_position * (fps_num / fps_den) + 1

elif action == MenuSlice.KEEP_BOTH:
# Update data for the left transition
trans.data["end"] = start_of_tran + (playhead_position - original_position)
Expand All @@ -2119,6 +2126,10 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0, ripp
# Emit signal to resume updates (stop ignoring updates)
get_app().window.IgnoreUpdates.emit(False)

if new_starting_frame != -1:
# Seek to new position (if needed)
self.window.SeekSignal.emit(round(new_starting_frame))

def ripple_delete_gap(self, ripple_start, layer, ripple_gap):
"""Remove the ripple gap and adjust subsequent items"""
# Get all clips and transitions right of ripple_start in the given layer
Expand Down Expand Up @@ -2882,6 +2893,9 @@ def SeekToKeyframe(self, frame_number):
# Seek to frame
self.window.SeekSignal.emit(frame_number)

# Display properties (if not visible)
self.window.actionProperties.trigger()

@pyqtSlot(int)
def PlayheadMoved(self, position_frames):

Expand Down Expand Up @@ -2933,6 +2947,9 @@ def SetPlayheadFollow(self, enable_follow):
def addSelection(self, item_id, item_type, clear_existing=False):
""" Add the selected item to the current selection """
self.window.SelectionAdded.emit(item_id, item_type, clear_existing)
if item_id and item_type == "effect":
# Display properties for effect (if not visible)
self.window.actionProperties.trigger()

def addRippleSelection(self, item_id, item_type):
if item_type == "clip":
Expand Down

0 comments on commit f1b4a1e

Please sign in to comment.