Power Sequencer: address docstring warnings
The previous commit passed tests without warnings or errors here, but LazyDodo sent me a log with warnings he was getting on his machine. This commit attempts to address them. Note: I'm not getting warnings when running unit tests here.
This commit is contained in:
parent
55b820186e
commit
8f11aecde7
|
@ -23,14 +23,16 @@ from .utils.functions import get_mouse_frame_and_channel
|
|||
class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
|
||||
"""
|
||||
Splits all strips under cursor including muted strips, but excluding locked strips.
|
||||
Auto selects sequences under the time cursor when you don't have a selection.
|
||||
Auto selects sequences under the time cursor when you don't have a selection
|
||||
"""
|
||||
|
||||
doc = {
|
||||
"name": doc_name(__qualname__),
|
||||
"demo": "https://i.imgur.com/ZyEd0jD.gif",
|
||||
"description": doc_description(__doc__),
|
||||
"shortcuts": [({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")],
|
||||
"shortcuts": [
|
||||
({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")
|
||||
],
|
||||
"keymap": "Sequencer",
|
||||
}
|
||||
bl_idname = doc_idname(__qualname__)
|
||||
|
@ -39,7 +41,10 @@ class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
|
|||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
side: bpy.props.EnumProperty(
|
||||
items=[("LEFT", "", ""), ("RIGHT", "", "")], name="Side", default="LEFT", options={"HIDDEN"}
|
||||
items=[("LEFT", "", ""), ("RIGHT", "", "")],
|
||||
name="Side",
|
||||
default="LEFT",
|
||||
options={"HIDDEN"},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -61,5 +66,10 @@ class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
|
|||
deselect = False
|
||||
if deselect:
|
||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||
(context.selected_sequences or bpy.ops.power_sequencer.select_strips_under_cursor())
|
||||
return bpy.ops.sequencer.split(frame=context.scene.frame_current, side=self.side)
|
||||
(
|
||||
context.selected_sequences
|
||||
or bpy.ops.power_sequencer.select_strips_under_cursor()
|
||||
)
|
||||
return bpy.ops.sequencer.split(
|
||||
frame=context.scene.frame_current, side=self.side
|
||||
)
|
||||
|
|
|
@ -22,7 +22,7 @@ from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
|
|||
|
||||
class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator):
|
||||
"""
|
||||
Deletes strips without confirmation, and cleans up crossfades nicely.
|
||||
Deletes strips without confirmation, and cleans up crossfades nicely
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -50,7 +50,9 @@ class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator):
|
|||
bl_description = doc_brief(doc["description"])
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
is_removing_transitions: bpy.props.BoolProperty(name="Remove Transitions", default=False)
|
||||
is_removing_transitions: bpy.props.BoolProperty(
|
||||
name="Remove Transitions", default=False
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
|
@ -59,12 +61,17 @@ class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator):
|
|||
def invoke(self, context, event):
|
||||
frame, channel = get_mouse_frame_and_channel(context, event)
|
||||
if not context.selected_sequences:
|
||||
bpy.ops.power_sequencer.select_closest_to_mouse(frame=frame, channel=channel)
|
||||
bpy.ops.power_sequencer.select_closest_to_mouse(
|
||||
frame=frame, channel=channel
|
||||
)
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
selection = context.selected_sequences
|
||||
if self.is_removing_transitions and bpy.ops.power_sequencer.transitions_remove.poll():
|
||||
if (
|
||||
self.is_removing_transitions
|
||||
and bpy.ops.power_sequencer.transitions_remove.poll()
|
||||
):
|
||||
bpy.ops.power_sequencer.transitions_remove()
|
||||
bpy.ops.sequencer.delete()
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator):
|
|||
*Brief* Expand selected strips to surrounding cuts
|
||||
|
||||
Finds potential gaps surrounding each block of selected sequences and extends the corresponding
|
||||
sequence handle to it.
|
||||
sequence handle to it
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -33,7 +33,11 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator):
|
|||
"demo": "",
|
||||
"description": doc_description(__doc__),
|
||||
"shortcuts": [
|
||||
({"type": "E", "value": "PRESS", "ctrl": True}, {}, "Expand to Surrounding Cuts")
|
||||
(
|
||||
{"type": "E", "value": "PRESS", "ctrl": True},
|
||||
{},
|
||||
"Expand to Surrounding Cuts",
|
||||
)
|
||||
],
|
||||
"keymap": "Sequencer",
|
||||
}
|
||||
|
@ -64,34 +68,50 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator):
|
|||
sequences_frame_start = min(
|
||||
sequences, key=lambda s: s.frame_final_start
|
||||
).frame_final_start
|
||||
sequences_frame_end = max(sequences, key=lambda s: s.frame_final_end).frame_final_end
|
||||
sequences_frame_end = max(
|
||||
sequences, key=lambda s: s.frame_final_end
|
||||
).frame_final_end
|
||||
|
||||
frame_left, frame_right = find_closest_cuts(
|
||||
context, sequences_frame_start, sequences_frame_end
|
||||
)
|
||||
if sequences_frame_start == frame_left and sequences_frame_end == frame_right:
|
||||
if (
|
||||
sequences_frame_start == frame_left
|
||||
and sequences_frame_end == frame_right
|
||||
):
|
||||
continue
|
||||
|
||||
to_extend_left = [s for s in sequences if s.frame_final_start == sequences_frame_start]
|
||||
to_extend_right = [s for s in sequences if s.frame_final_end == sequences_frame_end]
|
||||
to_extend_left = [
|
||||
s for s in sequences if s.frame_final_start == sequences_frame_start
|
||||
]
|
||||
to_extend_right = [
|
||||
s for s in sequences if s.frame_final_end == sequences_frame_end
|
||||
]
|
||||
|
||||
for s in to_extend_left:
|
||||
s.frame_final_start = (
|
||||
frame_left if frame_left < sequences_frame_start else sequences_frame_start
|
||||
frame_left
|
||||
if frame_left < sequences_frame_start
|
||||
else sequences_frame_start
|
||||
)
|
||||
for s in to_extend_right:
|
||||
s.frame_final_end = (
|
||||
frame_right if frame_right > sequences_frame_end else sequences_frame_end
|
||||
frame_right
|
||||
if frame_right > sequences_frame_end
|
||||
else sequences_frame_end
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def find_closest_cuts(context, frame_min, frame_max):
|
||||
frame_left = max(
|
||||
context.sequences, key=lambda s: s.frame_final_end if s.frame_final_end <= frame_min else -1
|
||||
context.sequences,
|
||||
key=lambda s: s.frame_final_end if s.frame_final_end <= frame_min else -1,
|
||||
).frame_final_end
|
||||
frame_right = min(
|
||||
context.sequences,
|
||||
key=lambda s: s.frame_final_start if s.frame_final_start >= frame_max else 1000000,
|
||||
key=lambda s: s.frame_final_start
|
||||
if s.frame_final_start >= frame_max
|
||||
else 1000000,
|
||||
).frame_final_start
|
||||
return frame_left, frame_right
|
||||
|
|
|
@ -31,7 +31,7 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
|
|||
- From playhead: the fade animation goes from the start of sequences under the playhead to the playhead
|
||||
- To playhead: the fade animation goes from the playhead to the end of sequences under the playhead
|
||||
|
||||
By default, the duration of the fade is 1 second.
|
||||
By default, the duration of the fade is 1 second
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -51,7 +51,10 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
|
|||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
duration_seconds: bpy.props.FloatProperty(
|
||||
name="Fade Duration", description="Duration of the fade in seconds", default=1.0, min=0.01
|
||||
name="Fade Duration",
|
||||
description="Duration of the fade in seconds",
|
||||
default=1.0,
|
||||
min=0.01,
|
||||
)
|
||||
type: bpy.props.EnumProperty(
|
||||
items=[
|
||||
|
@ -95,8 +98,12 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
|
|||
if s.frame_final_start < context.scene.frame_current < s.frame_final_end
|
||||
]
|
||||
|
||||
max_duration = min(sequences, key=lambda s: s.frame_final_duration).frame_final_duration
|
||||
max_duration = floor(max_duration / 2.0) if self.type == "IN_OUT" else max_duration
|
||||
max_duration = min(
|
||||
sequences, key=lambda s: s.frame_final_duration
|
||||
).frame_final_duration
|
||||
max_duration = (
|
||||
floor(max_duration / 2.0) if self.type == "IN_OUT" else max_duration
|
||||
)
|
||||
|
||||
faded_sequences = []
|
||||
for sequence in sequences:
|
||||
|
@ -106,16 +113,25 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
|
|||
if not self.is_long_enough(sequence, duration):
|
||||
continue
|
||||
|
||||
animated_property = "volume" if hasattr(sequence, "volume") else "blend_alpha"
|
||||
fade_fcurve = fade_find_or_create_fcurve(context, sequence, animated_property)
|
||||
fades = self.calculate_fades(sequence, fade_fcurve, animated_property, duration)
|
||||
animated_property = (
|
||||
"volume" if hasattr(sequence, "volume") else "blend_alpha"
|
||||
)
|
||||
fade_fcurve = fade_find_or_create_fcurve(
|
||||
context, sequence, animated_property
|
||||
)
|
||||
fades = self.calculate_fades(
|
||||
sequence, fade_fcurve, animated_property, duration
|
||||
)
|
||||
fade_animation_clear(context, fade_fcurve, fades)
|
||||
fade_animation_create(fade_fcurve, fades)
|
||||
faded_sequences.append(sequence)
|
||||
|
||||
sequence_string = "sequence" if len(faded_sequences) == 1 else "sequences"
|
||||
self.report(
|
||||
{"INFO"}, "Added fade animation to {} {}.".format(len(faded_sequences), sequence_string)
|
||||
{"INFO"},
|
||||
"Added fade animation to {} {}.".format(
|
||||
len(faded_sequences), sequence_string
|
||||
),
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
@ -216,9 +232,13 @@ class Fade:
|
|||
|
||||
if type == "IN":
|
||||
self.start = Vector((sequence.frame_final_start, 0.0))
|
||||
self.end = Vector((sequence.frame_final_start + self.duration, self.max_value))
|
||||
self.end = Vector(
|
||||
(sequence.frame_final_start + self.duration, self.max_value)
|
||||
)
|
||||
elif type == "OUT":
|
||||
self.start = Vector((sequence.frame_final_end - self.duration, self.max_value))
|
||||
self.start = Vector(
|
||||
(sequence.frame_final_end - self.duration, self.max_value)
|
||||
)
|
||||
self.end = Vector((sequence.frame_final_end, 0.0))
|
||||
|
||||
def calculate_max_value(self, sequence, fade_fcurve):
|
||||
|
@ -233,11 +253,15 @@ class Fade:
|
|||
else:
|
||||
if self.type == "IN":
|
||||
fade_end = sequence.frame_final_start + self.duration
|
||||
keyframes = (k for k in fade_fcurve.keyframe_points if k.co[0] >= fade_end)
|
||||
keyframes = (
|
||||
k for k in fade_fcurve.keyframe_points if k.co[0] >= fade_end
|
||||
)
|
||||
if self.type == "OUT":
|
||||
fade_start = sequence.frame_final_end - self.duration
|
||||
keyframes = (
|
||||
k for k in reversed(fade_fcurve.keyframe_points) if k.co[0] <= fade_start
|
||||
k
|
||||
for k in reversed(fade_fcurve.keyframe_points)
|
||||
if k.co[0] <= fade_start
|
||||
)
|
||||
try:
|
||||
max_value = next(keyframes).co[1]
|
||||
|
@ -251,4 +275,6 @@ class Fade:
|
|||
|
||||
|
||||
def calculate_duration_frames(context, duration_seconds):
|
||||
return round(duration_seconds * context.scene.render.fps / context.scene.render.fps_base)
|
||||
return round(
|
||||
duration_seconds * context.scene.render.fps / context.scene.render.fps_base
|
||||
)
|
||||
|
|
|
@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator):
|
|||
*brief* Removes fade animation from selected sequences.
|
||||
|
||||
Removes opacity or volume animation on selected sequences and resets the
|
||||
property to a value of 1.0. Works on all types of sequences.
|
||||
property to a value of 1.0. Works on all types of sequences
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator):
|
|||
"demo": "",
|
||||
"description": doc_description(__doc__),
|
||||
"shortcuts": [
|
||||
({"type": "F", "value": "PRESS", "alt": True, "ctrl": True}, {}, "Clear Fades")
|
||||
(
|
||||
{"type": "F", "value": "PRESS", "alt": True, "ctrl": True},
|
||||
{},
|
||||
"Clear Fades",
|
||||
)
|
||||
],
|
||||
"keymap": "Sequencer",
|
||||
}
|
||||
|
@ -49,7 +53,9 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator):
|
|||
fcurves = context.scene.animation_data.action.fcurves
|
||||
|
||||
for sequence in context.selected_sequences:
|
||||
animated_property = "volume" if hasattr(sequence, "volume") else "blend_alpha"
|
||||
animated_property = (
|
||||
"volume" if hasattr(sequence, "volume") else "blend_alpha"
|
||||
)
|
||||
data_path = sequence.path_from_id() + "." + animated_property
|
||||
fcurve_map = {
|
||||
curve.data_path: curve
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
import bpy
|
||||
|
||||
from bpy.props import BoolProperty
|
||||
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
|
||||
|
||||
|
||||
|
@ -27,7 +26,7 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator):
|
|||
|
||||
|
||||
WARNING: Currently the operator doesn't recreate any animation data,
|
||||
be careful by choosing to delete the scene after the merge.
|
||||
be careful by choosing to delete the scene after the merge
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -42,7 +41,7 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator):
|
|||
bl_description = doc_brief(doc["description"])
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
delete_scene: BoolProperty(
|
||||
delete_scene: bpy.props.BoolProperty(
|
||||
name="Delete Strip's scene",
|
||||
description="Delete the SceneStrip's scene after the merging",
|
||||
default=True,
|
||||
|
@ -75,7 +74,9 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator):
|
|||
context.window.scene = strip_scene
|
||||
bpy.ops.scene.delete()
|
||||
context.window.scene = start_scene
|
||||
self.report(type={"WARNING"}, message="Merged scenes lose all their animation data.")
|
||||
self.report(
|
||||
type={"WARNING"}, message="Merged scenes lose all their animation data."
|
||||
)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
|
|||
|
||||
class POWER_SEQUENCER_OT_select_all_left_or_right(bpy.types.Operator):
|
||||
"""
|
||||
*Brief* Selects all strips left or right of the time cursor.
|
||||
*Brief* Selects all strips left or right of the time cursor
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
|
|
@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_snap(bpy.types.Operator):
|
|||
"""
|
||||
*Brief* Snaps selected strips to the time cursor ignoring locked sequences.
|
||||
|
||||
Automatically selects sequences if there is no active selection.
|
||||
Automatically selects sequences if there is no active selection
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_snap(bpy.types.Operator):
|
|||
"demo": "",
|
||||
"description": doc_description(__doc__),
|
||||
"shortcuts": [
|
||||
({"type": "S", "value": "PRESS", "shift": True}, {}, "Snap sequences to cursor")
|
||||
(
|
||||
{"type": "S", "value": "PRESS", "shift": True},
|
||||
{},
|
||||
"Snap sequences to cursor",
|
||||
)
|
||||
],
|
||||
"keymap": "Sequencer",
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator):
|
|||
*Brief* Snap the entire selection to the time cursor.
|
||||
|
||||
Automatically selects sequences if there is no active selection.
|
||||
To snap each strip individually, see Snap.
|
||||
To snap each strip individually, see Snap
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator):
|
|||
"demo": "",
|
||||
"description": doc_description(__doc__),
|
||||
"shortcuts": [
|
||||
({"type": "S", "value": "PRESS", "alt": True}, {}, "Snap selection to cursor")
|
||||
(
|
||||
{"type": "S", "value": "PRESS", "alt": True},
|
||||
{},
|
||||
"Snap selection to cursor",
|
||||
)
|
||||
],
|
||||
"keymap": "Sequencer",
|
||||
}
|
||||
|
@ -51,7 +55,9 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator):
|
|||
if context.selected_sequences
|
||||
else get_sequences_under_cursor(context)
|
||||
)
|
||||
frame_first = min(sequences, key=lambda s: s.frame_final_start).frame_final_start
|
||||
frame_first = min(
|
||||
sequences, key=lambda s: s.frame_final_start
|
||||
).frame_final_start
|
||||
time_offset = context.scene.frame_current - frame_first
|
||||
apply_time_offset(context, sequences, time_offset)
|
||||
return {"FINISHED"}
|
||||
|
|
|
@ -26,7 +26,7 @@ class POWER_SEQUENCER_OT_trim_left_or_right_handles(bpy.types.Operator):
|
|||
Trims or extends the handle closest to the time cursor for all selected strips.
|
||||
|
||||
If you keep the Shift key down, the edit will ripple through the timeline.
|
||||
Auto selects sequences under the time cursor when you don't have a selection.
|
||||
Auto selects sequences under the time cursor when you don't have a selection
|
||||
"""
|
||||
|
||||
doc = {
|
||||
|
@ -78,9 +78,16 @@ class POWER_SEQUENCER_OT_trim_left_or_right_handles(bpy.types.Operator):
|
|||
frame_current = context.scene.frame_current
|
||||
|
||||
# Only select sequences under the time cursor
|
||||
sequences = context.selected_sequences if context.selected_sequences else context.sequences
|
||||
sequences = (
|
||||
context.selected_sequences
|
||||
if context.selected_sequences
|
||||
else context.sequences
|
||||
)
|
||||
for s in sequences:
|
||||
s.select = s.frame_final_start <= frame_current and s.frame_final_end >= frame_current
|
||||
s.select = (
|
||||
s.frame_final_start <= frame_current
|
||||
and s.frame_final_end >= frame_current
|
||||
)
|
||||
sequences = [s for s in sequences if s.select]
|
||||
if not sequences:
|
||||
return {"FINISHED"}
|
||||
|
|
Loading…
Reference in New Issue