From e9c18ea9829f9d8bf29db4d44a133c53619c1cfe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Sep 2019 05:56:19 +1000 Subject: [PATCH] Cleanup: redundant code from recent sequence fade operator No need to define class variables which are all overwritten, also use __slots__ to avoid mistakes. Remove redundant length check too. --- .../scripts/startup/bl_operators/sequencer.py | 22 ++++++++++--------- .../scripts/startup/bl_ui/space_sequencer.py | 3 +-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index 32a94349b4b..8772e6597ff 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -20,8 +20,6 @@ import bpy from bpy.types import Operator -from mathutils import Vector -from math import floor from bpy.props import IntProperty @@ -192,6 +190,8 @@ class SequencerFadesAdd(Operator): return context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip def execute(self, context): + from math import floor + # We must create a scene action first if there's none scene = context.scene if not scene.animation_data: @@ -305,16 +305,18 @@ class SequencerFadesAdd(Operator): class Fade: - """ - Data structure to represent fades - """ - type = '' - animated_property = '' - duration = -1 - max_value = 1.0 - start, end = Vector((0, 0)), Vector((0, 0)) + # Data structure to represent fades. + __slots__ = ( + "type", + "animated_property", + "duration", + "max_value", + "start", + "end", + ) def __init__(self, sequence, fade_fcurve, type, animated_property, duration): + from mathutils import Vector self.type = type self.animated_property = animated_property self.duration = duration diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 381808e8479..397355f1f23 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -761,7 +761,7 @@ class SEQUENCER_MT_context_menu(Menu): strip_type = strip.type selected_sequences_count = selected_sequences_len(context) - if strip_type != "SOUND": + if strip_type != 'SOUND': layout.separator() layout.operator_menu_enum("sequencer.strip_modifier_add", "type", text="Add Modifier") layout.operator("sequencer.strip_modifier_copy", text="Copy Modifiers to Selection") @@ -778,7 +778,6 @@ class SEQUENCER_MT_context_menu(Menu): if selected_sequences_count >= 1: col = layout.column() col.operator_menu_enum("sequencer.fades_add", "type", text="Fade") - col.enabled = selected_sequences_len(context) >= 1 layout.operator("sequencer.fades_clear", text="Clear Fade") if strip_type in {