diff options
author | Nathan Lovato <nathan@gdquest.com> | 2020-05-14 23:40:24 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-05-29 10:53:11 +0300 |
commit | 9286d97d67270264665b280774ecd61616a6c151 (patch) | |
tree | 62ead0b40c012174f0b02e5ca5d6080a9e0e74af | |
parent | 2972e7a94218dc55376551017de4876fa5bcafd2 (diff) |
Power Sequencer: update to version 1.5, fix for Blender 2.83
This makes the add-on compatible with Blender 2.83 after renaming the cut operator to split.
The update brings mainly bug fixes and quality of life improvements.
Changelog: https://github.com/GDQuest/blender-power-sequencer/blob/master/CHANGELOG.md#power-sequencer-1
36 Commits: https://github.com/GDQuest/blender-power-sequencer/compare/1.4.0...fb55bc77cf31920ddfe6fd4342b11e53ac988c93
103 files changed, 344 insertions, 291 deletions
diff --git a/power_sequencer/__init__.py b/power_sequencer/__init__.py index 3ec6999f..1817a7d6 100755 --- a/power_sequencer/__init__.py +++ b/power_sequencer/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -38,11 +38,11 @@ bl_info = { "name": "Power Sequencer", "description": "Video editing tools for content creators", "author": "Nathan Lovato", - "version": (1, 4, 0), - "blender": (2, 80, 0), + "version": (1, 5, 0), + "blender": (2, 81, 0), "location": "Sequencer", "tracker_url": "https://github.com/GDquest/Blender-power-sequencer/issues", - "doc_url": "https://www.gdquest.com/docs/documentation/power-sequencer/", + "wiki_url": "https://www.gdquest.com/docs/documentation/power-sequencer/", "support": "COMMUNITY", "category": "Sequencer", } @@ -70,13 +70,11 @@ def register(): bpy.utils.register_class(cls) # Register tools - version_min_toolbar = (2, 83, 0) - if is_blender_version_compatible(version_min_toolbar): - classes_tool = get_tool_classes() - last_tool = {"builtin.cut"} - for index, cls in enumerate(classes_tool): - bpy.utils.register_tool(cls, after=last_tool, separator=index == 0) - last_tool = {cls.bl_idname} + classes_tool = get_tool_classes() + last_tool = {"builtin.cut"} + for index, cls in enumerate(classes_tool): + bpy.utils.register_tool(cls, after=last_tool, separator=index == 0) + last_tool = {cls.bl_idname} # Register keymaps keymaps = register_shortcuts(classes_operator) @@ -98,10 +96,8 @@ def unregister(): for cls in classes_operator: bpy.utils.unregister_class(cls) - version_min_toolbar = (2, 82, 0) - if is_blender_version_compatible(version_min_toolbar): - for cls in classes_tool: - bpy.utils.unregister_tool(cls) + for cls in classes_tool: + bpy.utils.unregister_tool(cls) unregister_ui() unregister_preferences() @@ -109,11 +105,3 @@ def unregister(): unregister_handlers() print("Unregistered {}".format(bl_info["name"])) - - -def is_blender_version_compatible(version: Tuple[int, int, int]) -> bool: - """Returns True if the `version` is greater or equal to the current Blender version. - Converts the versions to integers to compare them.""" - version_int = version[0] * 1000 + version[1] * 10 + version[2] - blender_version_int = bpy.app.version[0] * 1000 + bpy.app.version[1] * 10 + bpy.app.version[2] - return blender_version_int >= version_int diff --git a/power_sequencer/addon_preferences.py b/power_sequencer/addon_preferences.py index fcc67e9c..0ca31330 100644 --- a/power_sequencer/addon_preferences.py +++ b/power_sequencer/addon_preferences.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/addon_properties.py b/power_sequencer/addon_properties.py index 06cbe1da..45c5bc20 100644 --- a/power_sequencer/addon_properties.py +++ b/power_sequencer/addon_properties.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/handlers.py b/power_sequencer/handlers.py index 8e93bb27..b960662f 100644 --- a/power_sequencer/handlers.py +++ b/power_sequencer/handlers.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/__init__.py b/power_sequencer/operators/__init__.py index 65f84902..3ab79520 100755 --- a/power_sequencer/operators/__init__.py +++ b/power_sequencer/operators/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -28,7 +28,7 @@ def get_operator_classes(): classes = [] print(__name__) for path in module_paths: - module = importlib.import_module(path, package="power_sequencer.operators") + module = importlib.import_module(path, package="blender_power_sequencer.operators") operator_names = [entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_OT")] classes.extend([getattr(module, name) for name in operator_names]) return classes diff --git a/power_sequencer/operators/align_audios.py b/power_sequencer/operators/align_audios.py index a280f1fd..0bd99aba 100644 --- a/power_sequencer/operators/align_audios.py +++ b/power_sequencer/operators/align_audios.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -15,6 +15,7 @@ # not, see <https://www.gnu.org/licenses/>. # import bpy +import subprocess from .utils.doc import doc_name, doc_idname, doc_brief, doc_description diff --git a/power_sequencer/operators/audiosync/__init__.py b/power_sequencer/operators/audiosync/__init__.py index 9fc19da4..74dd6f5a 100644 --- a/power_sequencer/operators/audiosync/__init__.py +++ b/power_sequencer/operators/audiosync/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/convert_and_trim.py b/power_sequencer/operators/audiosync/convert_and_trim.py index 859186d8..fddf702d 100644 --- a/power_sequencer/operators/audiosync/convert_and_trim.py +++ b/power_sequencer/operators/audiosync/convert_and_trim.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/cross_correlation.py b/power_sequencer/operators/audiosync/cross_correlation.py index b18ab35e..dc337475 100644 --- a/power_sequencer/operators/audiosync/cross_correlation.py +++ b/power_sequencer/operators/audiosync/cross_correlation.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/ensure_non_zero.py b/power_sequencer/operators/audiosync/ensure_non_zero.py index 911ab91b..589da529 100644 --- a/power_sequencer/operators/audiosync/ensure_non_zero.py +++ b/power_sequencer/operators/audiosync/ensure_non_zero.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/find_offset.py b/power_sequencer/operators/audiosync/find_offset.py index 35b17a14..02287839 100644 --- a/power_sequencer/operators/audiosync/find_offset.py +++ b/power_sequencer/operators/audiosync/find_offset.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/mfcc/__init__.py b/power_sequencer/operators/audiosync/mfcc/__init__.py index 2b20af43..204646ca 100644 --- a/power_sequencer/operators/audiosync/mfcc/__init__.py +++ b/power_sequencer/operators/audiosync/mfcc/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/mfcc/mfcc.py b/power_sequencer/operators/audiosync/mfcc/mfcc.py index d63c3e33..3cb1c7dd 100644 --- a/power_sequencer/operators/audiosync/mfcc/mfcc.py +++ b/power_sequencer/operators/audiosync/mfcc/mfcc.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -16,6 +16,10 @@ # import numpy as np +from scipy.signal import hamming, lfilter +from scipy.fftpack import fft +from scipy.fftpack.realtransforms import dct + from .trfbank import trfbank from .segment_axis import segment_axis @@ -52,10 +56,6 @@ def mfcc(input, nwin=256, nfft=512, fs=16000, nceps=13): spoken sentences", IEEE Trans. Acoustics. Speech, Signal Proc. ASSP-28 (4): 357-366, August 1980.""" - from scipy.signal import hamming, lfilter - from scipy.fftpack import fft - from scipy.fftpack.realtransforms import dct - # MFCC parameters: taken from auditory toolbox over = nwin - 160 # Pre-emphasis factor (to take into account the -6dB/octave rolloff of the diff --git a/power_sequencer/operators/audiosync/mfcc/segment_axis.py b/power_sequencer/operators/audiosync/mfcc/segment_axis.py index a8345833..b5b8740c 100644 --- a/power_sequencer/operators/audiosync/mfcc/segment_axis.py +++ b/power_sequencer/operators/audiosync/mfcc/segment_axis.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/mfcc/trfbank.py b/power_sequencer/operators/audiosync/mfcc/trfbank.py index 00558944..15baac54 100644 --- a/power_sequencer/operators/audiosync/mfcc/trfbank.py +++ b/power_sequencer/operators/audiosync/mfcc/trfbank.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/audiosync/std_mfcc.py b/power_sequencer/operators/audiosync/std_mfcc.py index 3fccae0c..8e56a2da 100644 --- a/power_sequencer/operators/audiosync/std_mfcc.py +++ b/power_sequencer/operators/audiosync/std_mfcc.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/channel_offset.py b/power_sequencer/operators/channel_offset.py index 2779faac..35da1b47 100644 --- a/power_sequencer/operators/channel_offset.py +++ b/power_sequencer/operators/channel_offset.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -18,6 +18,13 @@ import bpy from operator import attrgetter from .utils.doc import doc_name, doc_idname, doc_brief, doc_description +from .utils.functions import ( + slice_selection, + get_frame_range, + get_channel_range, + trim_strips, + find_strips_in_range, +) class POWER_SEQUENCER_OT_channel_offset(bpy.types.Operator): @@ -36,10 +43,20 @@ class POWER_SEQUENCER_OT_channel_offset(bpy.types.Operator): "Move to Open Channel Above", ), ( + {"type": "UP_ARROW", "value": "PRESS", "ctrl": True, "alt": True}, + {"direction": "up", "trim_target_channel": True}, + "Move to Channel Above and Trim", + ), + ( {"type": "DOWN_ARROW", "value": "PRESS", "alt": True}, {"direction": "down"}, "Move to Open Channel Below", ), + ( + {"type": "DOWN_ARROW", "value": "PRESS", "ctrl": True, "alt": True}, + {"direction": "down", "trim_target_channel": True}, + "Move to Channel Below and Trim", + ), ], "keymap": "Sequencer", } @@ -57,6 +74,11 @@ class POWER_SEQUENCER_OT_channel_offset(bpy.types.Operator): description="Move the sequences up or down", default="up", ) + trim_target_channel: bpy.props.BoolProperty( + name="Trim strips", + description="Trim strips to make space in the target channel", + default=False, + ) @classmethod def poll(cls, context): @@ -65,15 +87,27 @@ class POWER_SEQUENCER_OT_channel_offset(bpy.types.Operator): def execute(self, context): selection = [s for s in context.selected_sequences if not s.lock] if not selection: - return {"CANCELLED"} + return {"FINISHED"} + + selection_blocks = slice_selection(context, selection) + for block in selection_blocks: + sequences = sorted(block, key=attrgetter("channel", "frame_final_start")) + frame_start, frame_end = get_frame_range(sequences) + channel_start, channel_end = get_channel_range(sequences) - selection = sorted(selection, key=attrgetter("channel", "frame_final_start")) + if self.trim_target_channel: + to_delete, to_trim = find_strips_in_range(frame_start, frame_end, context.sequences) + channel_trim = ( + channel_end + 1 if self.direction == "up" else max(1, channel_start - 1) + ) + to_trim = [s for s in to_trim if s.channel == channel_trim] + to_delete = [s for s in to_delete if s.channel == channel_trim] + trim_strips(context, frame_start, frame_end, to_trim, to_delete) - if self.direction == "up": - for s in reversed(selection): - s.channel += 1 - elif self.direction == "down": - for s in selection: - if s.channel > 1: - s.channel -= 1 + if self.direction == "up": + for s in reversed(sequences): + s.channel += 1 + elif self.direction == "down": + for s in sequences: + s.channel = max(1, s.channel - 1) return {"FINISHED"} diff --git a/power_sequencer/operators/concatenate_strips.py b/power_sequencer/operators/concatenate_strips.py index 11dff248..d9119124 100644 --- a/power_sequencer/operators/concatenate_strips.py +++ b/power_sequencer/operators/concatenate_strips.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/copy_selected_sequences.py b/power_sequencer/operators/copy_selected_sequences.py index 69f66714..e7bc7384 100644 --- a/power_sequencer/operators/copy_selected_sequences.py +++ b/power_sequencer/operators/copy_selected_sequences.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/crossfade_add.py b/power_sequencer/operators/crossfade_add.py index 11558e56..d4ffbe02 100644 --- a/power_sequencer/operators/crossfade_add.py +++ b/power_sequencer/operators/crossfade_add.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/crossfade_edit.py b/power_sequencer/operators/crossfade_edit.py index 553251c9..dd5ff822 100644 --- a/power_sequencer/operators/crossfade_edit.py +++ b/power_sequencer/operators/crossfade_edit.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/cut_strips_under_cursor.py b/power_sequencer/operators/cut_strips_under_cursor.py index de1fff3e..b7c64135 100644 --- a/power_sequencer/operators/cut_strips_under_cursor.py +++ b/power_sequencer/operators/cut_strips_under_cursor.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -62,4 +62,4 @@ class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator): 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.cut(frame=context.scene.frame_current, side=self.side) + return bpy.ops.sequencer.split(frame=context.scene.frame_current, side=self.side) diff --git a/power_sequencer/operators/delete_direct.py b/power_sequencer/operators/delete_direct.py index 2650ddb1..c6d77131 100644 --- a/power_sequencer/operators/delete_direct.py +++ b/power_sequencer/operators/delete_direct.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/deselect_all_left_or_right.py b/power_sequencer/operators/deselect_all_left_or_right.py index c250095d..e3c5b888 100644 --- a/power_sequencer/operators/deselect_all_left_or_right.py +++ b/power_sequencer/operators/deselect_all_left_or_right.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/deselect_handles_and_grab.py b/power_sequencer/operators/deselect_handles_and_grab.py index 78365906..20bfd426 100644 --- a/power_sequencer/operators/deselect_handles_and_grab.py +++ b/power_sequencer/operators/deselect_handles_and_grab.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/duplicate_move.py b/power_sequencer/operators/duplicate_move.py index 8a72e28e..6d13b1d0 100644 --- a/power_sequencer/operators/duplicate_move.py +++ b/power_sequencer/operators/duplicate_move.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/expand_to_surrounding_cuts.py b/power_sequencer/operators/expand_to_surrounding_cuts.py index 852268bb..d18e5bf6 100644 --- a/power_sequencer/operators/expand_to_surrounding_cuts.py +++ b/power_sequencer/operators/expand_to_surrounding_cuts.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/fade_add.py b/power_sequencer/operators/fade_add.py index d72f034d..1bb808cd 100644 --- a/power_sequencer/operators/fade_add.py +++ b/power_sequencer/operators/fade_add.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/fade_clear.py b/power_sequencer/operators/fade_clear.py index ebccbe23..9cba7e16 100644 --- a/power_sequencer/operators/fade_clear.py +++ b/power_sequencer/operators/fade_clear.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/gap_remove.py b/power_sequencer/operators/gap_remove.py index 88a3484a..413d5466 100644 --- a/power_sequencer/operators/gap_remove.py +++ b/power_sequencer/operators/gap_remove.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -53,6 +53,11 @@ class POWER_SEQUENCER_OT_gap_remove(bpy.types.Operator): description="Frame to remove gaps from, defaults at the time cursor", default=-1, ) + move_time_cursor: bpy.props.BoolProperty( + name="Move Time Cursor", + description="Move the time cursor when closing the gap.", + default=False, + ) @classmethod def poll(cls, context): @@ -84,11 +89,14 @@ class POWER_SEQUENCER_OT_gap_remove(bpy.types.Operator): ) self.gaps_remove(context, blocks_after_gap, gap_frame) + if self.move_time_cursor: + context.scene.frame_current = gap_frame return {"FINISHED"} def find_gap_frame(self, context, frame, sorted_sequences): """ - Takes a list sequences sorted by frame_final_start + Finds and returns the frame at which the gap starts. + Takes a list sequences sorted by frame_final_start. """ strips_start = min(sorted_sequences, key=attrgetter("frame_final_start")).frame_final_start strips_end = max(sorted_sequences, key=attrgetter("frame_final_end")).frame_final_end @@ -108,7 +116,7 @@ class POWER_SEQUENCER_OT_gap_remove(bpy.types.Operator): def gaps_remove(self, context, sequence_blocks, gap_frame_start): """ - Recursively removes gaps between blocks of sequences + Recursively removes gaps between blocks of sequences. """ gap_frame = gap_frame_start diff --git a/power_sequencer/operators/grab.py b/power_sequencer/operators/grab.py index dd198668..036a1493 100644 --- a/power_sequencer/operators/grab.py +++ b/power_sequencer/operators/grab.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/grab_closest_handle_or_cut.py b/power_sequencer/operators/grab_closest_handle_or_cut.py index 7d772d79..d9cc3681 100644 --- a/power_sequencer/operators/grab_closest_handle_or_cut.py +++ b/power_sequencer/operators/grab_closest_handle_or_cut.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/grab_sequence_handles.py b/power_sequencer/operators/grab_sequence_handles.py index e2a38ed1..7780b4d2 100644 --- a/power_sequencer/operators/grab_sequence_handles.py +++ b/power_sequencer/operators/grab_sequence_handles.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/import_local_footage.py b/power_sequencer/operators/import_local_footage.py index 5ffee493..b17e803f 100644 --- a/power_sequencer/operators/import_local_footage.py +++ b/power_sequencer/operators/import_local_footage.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/jump_time_offset.py b/power_sequencer/operators/jump_time_offset.py index bc72e98e..1249c7c8 100644 --- a/power_sequencer/operators/jump_time_offset.py +++ b/power_sequencer/operators/jump_time_offset.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/jump_to_cut.py b/power_sequencer/operators/jump_to_cut.py index 8de9224a..aff4a01c 100644 --- a/power_sequencer/operators/jump_to_cut.py +++ b/power_sequencer/operators/jump_to_cut.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/make_still_image.py b/power_sequencer/operators/make_hold_frame.py index 73a3ed66..b8aef4c0 100644 --- a/power_sequencer/operators/make_still_image.py +++ b/power_sequencer/operators/make_hold_frame.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -22,13 +22,12 @@ from .utils.functions import convert_duration_to_frames from .utils.doc import doc_name, doc_idname, doc_brief, doc_description -class POWER_SEQUENCER_OT_make_still_image(bpy.types.Operator): +class POWER_SEQUENCER_OT_make_hold_frame(bpy.types.Operator): """ - *brief* Make still image from active strip + *brief* Make a hold frame from the active strip. - - Converts image under the cursor to a still image, to create a pause effect in the video, - using the active sequence + Converts the image under the cursor to a hold frame, to create a pause effect in the video, + using the active sequence. """ doc = { @@ -52,7 +51,7 @@ class POWER_SEQUENCER_OT_make_still_image(bpy.types.Operator): @classmethod def poll(cls, context): - return context.selected_sequences + return context.scene.sequence_editor.active_strip.type in SequenceTypes.VIDEO def invoke(self, context, event): window_manager = context.window_manager @@ -64,56 +63,42 @@ class POWER_SEQUENCER_OT_make_still_image(bpy.types.Operator): sequencer = bpy.ops.sequencer transform = bpy.ops.transform - start_frame = scene.frame_current - offset = convert_duration_to_frames(context, self.strip_duration) + frame_start = scene.frame_current - if active.type not in SequenceTypes.VIDEO: - self.report( - {"ERROR_INVALID_INPUT"}, - "You must select a video or meta strip. \ - You selected a strip of type" - + str(active.type) - + " instead.", - ) - return {"CANCELLED"} - - if not active.frame_final_start <= start_frame < active.frame_final_end: - self.report( - {"ERROR_INVALID_INPUT"}, - "Your time cursor must be on the frame you want \ - to convert to a still image.", - ) - return {"CANCELLED"} - - if start_frame == active.frame_final_start: - scene.frame_current = start_frame + 1 + if not active.frame_final_start <= frame_start < active.frame_final_end: + return {"FINISHED"} - if self.strip_duration <= 0.0: - strips = sorted( - scene.sequence_editor.sequences, key=operator.attrgetter("frame_final_start") - ) + if frame_start == active.frame_final_start: + scene.frame_current = frame_start + 1 - for s in strips: - if s.frame_final_start > active.frame_final_start and s.channel == active.channel: - next = s - break - offset = next.frame_final_start - active.frame_final_end + # Detect the gap automatically + offset = convert_duration_to_frames(context, self.strip_duration) + if self.strip_duration <= 0.0: + try: + next_strip_start = next( + s + for s in sorted(context.sequences, key=operator.attrgetter("frame_final_start")) + if s.frame_final_start > active.frame_final_end + ).frame_final_start + offset = next_strip_start - active.frame_final_end + except Exception: + pass active.select = True source_blend_type = active.blend_type - sequencer.cut(frame=scene.frame_current, type="SOFT", side="RIGHT") + sequencer.split(frame=scene.frame_current, type="SOFT", side="RIGHT") transform.seq_slide(value=(offset, 0)) - sequencer.cut(frame=scene.frame_current + offset + 1, type="SOFT", side="LEFT") + sequencer.split(frame=scene.frame_current + offset + 1, type="SOFT", side="LEFT") transform.seq_slide(value=(-offset, 0)) sequencer.meta_make() active = scene.sequence_editor.active_strip - active.name = "Still image" + active.name = "Hold frame" active.blend_type = source_blend_type active.select_right_handle = True transform.seq_slide(value=(offset, 0)) - scene.frame_current = start_frame + scene.frame_current = frame_start active.select = True active.select_right_handle = False diff --git a/power_sequencer/operators/marker_delete_closest.py b/power_sequencer/operators/marker_delete_closest.py index e5c8d2c0..6c71759f 100644 --- a/power_sequencer/operators/marker_delete_closest.py +++ b/power_sequencer/operators/marker_delete_closest.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/marker_delete_direct.py b/power_sequencer/operators/marker_delete_direct.py index 153e494e..5ebbbd74 100644 --- a/power_sequencer/operators/marker_delete_direct.py +++ b/power_sequencer/operators/marker_delete_direct.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/marker_snap_to_cursor.py b/power_sequencer/operators/marker_snap_to_cursor.py index aa480761..0320454a 100644 --- a/power_sequencer/operators/marker_snap_to_cursor.py +++ b/power_sequencer/operators/marker_snap_to_cursor.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/markers_as_timecodes.py b/power_sequencer/operators/markers_as_timecodes.py index 6fdfd19d..020bdfdd 100644 --- a/power_sequencer/operators/markers_as_timecodes.py +++ b/power_sequencer/operators/markers_as_timecodes.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/markers_create_from_selected.py b/power_sequencer/operators/markers_create_from_selected.py index 94ebafc9..b826a8c1 100644 --- a/power_sequencer/operators/markers_create_from_selected.py +++ b/power_sequencer/operators/markers_create_from_selected.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/markers_set_preview_in_between.py b/power_sequencer/operators/markers_set_preview_in_between.py index f505c278..3d4ee5a2 100644 --- a/power_sequencer/operators/markers_set_preview_in_between.py +++ b/power_sequencer/operators/markers_set_preview_in_between.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/markers_snap_matching_strips.py b/power_sequencer/operators/markers_snap_matching_strips.py index bdfba314..0487880e 100644 --- a/power_sequencer/operators/markers_snap_matching_strips.py +++ b/power_sequencer/operators/markers_snap_matching_strips.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/meta_resize_to_content.py b/power_sequencer/operators/meta_resize_to_content.py index 0697104e..b75c20cb 100644 --- a/power_sequencer/operators/meta_resize_to_content.py +++ b/power_sequencer/operators/meta_resize_to_content.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -47,5 +47,5 @@ class POWER_SEQUENCER_OT_meta_resize_to_content(bpy.types.Operator): def execute(self, context): selected_meta_strips = (s for s in context.selected_sequences if s.type == "META") for s in selected_meta_strips: - s.frame_final_start, s.frame_final_end = get_frame_range(context, s.sequences) + s.frame_final_start, s.frame_final_end = get_frame_range(s.sequences) return {"FINISHED"} diff --git a/power_sequencer/operators/meta_trim_content_to_bounds.py b/power_sequencer/operators/meta_trim_content_to_bounds.py index 0e77681b..af101235 100644 --- a/power_sequencer/operators/meta_trim_content_to_bounds.py +++ b/power_sequencer/operators/meta_trim_content_to_bounds.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/meta_ungroup_and_trim.py b/power_sequencer/operators/meta_ungroup_and_trim.py index e639570a..ffcd2711 100644 --- a/power_sequencer/operators/meta_ungroup_and_trim.py +++ b/power_sequencer/operators/meta_ungroup_and_trim.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/mouse_toggle_mute.py b/power_sequencer/operators/mouse_toggle_mute.py index 44a1e7d5..3b0ab96b 100644 --- a/power_sequencer/operators/mouse_toggle_mute.py +++ b/power_sequencer/operators/mouse_toggle_mute.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/mouse_trim_instantly.py b/power_sequencer/operators/mouse_trim_instantly.py index aeba2325..849b23e5 100644 --- a/power_sequencer/operators/mouse_trim_instantly.py +++ b/power_sequencer/operators/mouse_trim_instantly.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -96,15 +96,18 @@ class POWER_SEQUENCER_OT_mouse_trim_instantly(bpy.types.Operator): for s in context.sequences if s.frame_final_start <= frame <= s.frame_final_end and not s.lock ] + if not to_trim: + return {"FINISHED"} - frame_cut_closest = min(get_frame_range(context, to_trim), key=lambda f: abs(frame - f)) + frame_cut_closest = min(get_frame_range(to_trim), key=lambda f: abs(frame - f)) frame_start = min(frame, frame_cut_closest) frame_end = max(frame, frame_cut_closest) trim_strips(context, frame_start, frame_end, to_trim=to_trim) - context.scene.frame_current = frame_start + context.scene.frame_current = frame + if self.gap_remove and self.select_mode == "CURSOR": - bpy.ops.power_sequencer.gap_remove() + bpy.ops.power_sequencer.gap_remove(frame=frame_start, move_time_cursor=True) return {"FINISHED"} diff --git a/power_sequencer/operators/mouse_trim_modal.py b/power_sequencer/operators/mouse_trim_modal.py index b75985b7..4fbffd47 100644 --- a/power_sequencer/operators/mouse_trim_modal.py +++ b/power_sequencer/operators/mouse_trim_modal.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -267,7 +267,7 @@ class POWER_SEQUENCER_OT_mouse_trim(bpy.types.Operator): else: frame_current = context.scene.frame_current context.scene.frame_current = self.trim_start - bpy.ops.sequencer.cut(frame=context.scene.frame_current, type="SOFT", side="BOTH") + bpy.ops.sequencer.split(frame=context.scene.frame_current, type="SOFT", side="BOTH") context.scene.frame_current = frame_current def find_strips_to_cut(self, context): diff --git a/power_sequencer/operators/open_project_directory.py b/power_sequencer/operators/open_project_directory.py index 4fc4cf38..8c721051 100644 --- a/power_sequencer/operators/open_project_directory.py +++ b/power_sequencer/operators/open_project_directory.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/playback_speed_decrease.py b/power_sequencer/operators/playback_speed_decrease.py index 5d5a9605..a6799927 100644 --- a/power_sequencer/operators/playback_speed_decrease.py +++ b/power_sequencer/operators/playback_speed_decrease.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/playback_speed_increase.py b/power_sequencer/operators/playback_speed_increase.py index 572bd9bc..f03d9cea 100644 --- a/power_sequencer/operators/playback_speed_increase.py +++ b/power_sequencer/operators/playback_speed_increase.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/playback_speed_set.py b/power_sequencer/operators/playback_speed_set.py index 2dab7412..af1737c6 100644 --- a/power_sequencer/operators/playback_speed_set.py +++ b/power_sequencer/operators/playback_speed_set.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/preview_closest_cut.py b/power_sequencer/operators/preview_closest_cut.py index dccf69e3..ec1af0d2 100644 --- a/power_sequencer/operators/preview_closest_cut.py +++ b/power_sequencer/operators/preview_closest_cut.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -77,7 +77,7 @@ class POWER_SEQUENCER_OT_preview_closest_cut(bpy.types.Operator): return {"CANCELLED"} if scene.frame_preview_start == start and scene.frame_preview_end == end: - start, end = get_frame_range(context, context.sequences) + start, end = get_frame_range(context.sequences) set_preview_range(context, start, end) return {"FINISHED"} diff --git a/power_sequencer/operators/preview_to_selection.py b/power_sequencer/operators/preview_to_selection.py index f084e767..956da506 100644 --- a/power_sequencer/operators/preview_to_selection.py +++ b/power_sequencer/operators/preview_to_selection.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -54,6 +54,6 @@ class POWER_SEQUENCER_OT_preview_to_selection(bpy.types.Operator): if len(context.selected_sequences) >= 1 else context.sequences ) - frame_start, frame_end = get_frame_range(context, sequences) + frame_start, frame_end = get_frame_range(sequences) set_preview_range(context, frame_start, frame_end - 1) return {"FINISHED"} diff --git a/power_sequencer/operators/render_apply_preset.py b/power_sequencer/operators/render_apply_preset.py index dee19dbd..670d637a 100644 --- a/power_sequencer/operators/render_apply_preset.py +++ b/power_sequencer/operators/render_apply_preset.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/render_presets/twitter_720p.py b/power_sequencer/operators/render_presets/twitter_720p.py index 466646b5..47f235c4 100644 --- a/power_sequencer/operators/render_presets/twitter_720p.py +++ b/power_sequencer/operators/render_presets/twitter_720p.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/render_presets/youtube_1080.py b/power_sequencer/operators/render_presets/youtube_1080.py index 49d0a651..343e7081 100644 --- a/power_sequencer/operators/render_presets/youtube_1080.py +++ b/power_sequencer/operators/render_presets/youtube_1080.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/ripple_delete.py b/power_sequencer/operators/ripple_delete.py index a469148d..929e468f 100644 --- a/power_sequencer/operators/ripple_delete.py +++ b/power_sequencer/operators/ripple_delete.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -81,7 +81,7 @@ class POWER_SEQUENCER_OT_ripple_delete(bpy.types.Operator): sequencer.select_all(action="DESELECT") for s in block: s.select = True - selection_start = get_frame_range(context, block)[0] + selection_start = get_frame_range(block)[0] sequencer.delete() scene.frame_current = selection_start diff --git a/power_sequencer/operators/save_direct.py b/power_sequencer/operators/save_direct.py index f9ae5a61..cd181f2d 100644 --- a/power_sequencer/operators/save_direct.py +++ b/power_sequencer/operators/save_direct.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/scene_create_from_selection.py b/power_sequencer/operators/scene_create_from_selection.py index 4cf837d7..14b08768 100644 --- a/power_sequencer/operators/scene_create_from_selection.py +++ b/power_sequencer/operators/scene_create_from_selection.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -53,35 +53,41 @@ class POWER_SEQUENCER_OT_scene_create_from_selection(bpy.types.Operator): def execute(self, context): start_scene_name = context.scene.name + + if len(context.selected_sequences) != 0: + selection = context.selected_sequences[:] + selection_start_frame = min( + selection, key=attrgetter("frame_final_start") + ).frame_final_start + selection_start_channel = min(selection, key=attrgetter("channel")).channel - selection = context.selected_sequences - selection_start_frame = min( - selection, key=attrgetter("frame_final_start") - ).frame_final_start - selection_start_channel = min(selection, key=attrgetter("channel")).channel + # Create new scene for the scene strip + bpy.ops.scene.new(type="FULL_COPY") + + context.window.scene.name = context.selected_sequences[0].name + print(context.selected_sequences[0].name) + new_scene_name = context.window.scene.name + + + ###after full copy also unselected strips are in the sequencer... Delete those strips + bpy.ops.sequencer.select_all(action="INVERT") + bpy.ops.power_sequencer.delete_direct() + frame_offset = selection_start_frame - 1 + for s in context.sequences: + try: + s.frame_start -= frame_offset + except Exception: + continue + bpy.ops.sequencer.select_all() + bpy.ops.power_sequencer.preview_to_selection() - # Create new scene for the scene strip - bpy.ops.scene.new(type="FULL_COPY") - new_scene_name = context.scene.name + # Back to start scene + bpy.context.window.scene = bpy.data.scenes[start_scene_name] - bpy.ops.sequencer.select_all(action="INVERT") - bpy.ops.power_sequencer.delete_direct() - frame_offset = selection_start_frame - 1 - for s in context.sequences: - try: - s.frame_start -= frame_offset - except Exception: - continue - bpy.ops.sequencer.select_all() - bpy.ops.power_sequencer.preview_to_selection() - - # Back to start scene - context.screen.scene = bpy.data.scenes[start_scene_name] - - bpy.ops.power_sequencer.delete_direct() - bpy.ops.sequencer.scene_strip_add( - frame_start=selection_start_frame, channel=selection_start_channel, scene=new_scene_name - ) - scene_strip = context.selected_sequences[0] - scene_strip.use_sequence = True + bpy.ops.power_sequencer.delete_direct() + bpy.ops.sequencer.scene_strip_add( + frame_start=selection_start_frame, channel=selection_start_channel, scene=new_scene_name + ) + scene_strip = context.selected_sequences[0] + # scene_strip.use_sequence = True return {"FINISHED"} diff --git a/power_sequencer/operators/scene_cycle.py b/power_sequencer/operators/scene_cycle.py index f0e5cb81..cedbd4d6 100644 --- a/power_sequencer/operators/scene_cycle.py +++ b/power_sequencer/operators/scene_cycle.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/scene_merge_from.py b/power_sequencer/operators/scene_merge_from.py index 792799e8..4e695b02 100644 --- a/power_sequencer/operators/scene_merge_from.py +++ b/power_sequencer/operators/scene_merge_from.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -42,7 +42,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: BoolProperty( name="Delete Strip's scene", description="Delete the SceneStrip's scene after the merging", default=True, @@ -75,34 +75,42 @@ 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="All animations on source scene were lost") + self.report(type={"WARNING"}, message="Merged scenes lose all their animation data.") return {"FINISHED"} def merge_strips(self, context, source_scene, target_scene): context.window.scene = source_scene + current_frame = context.scene.frame_current + context.scene.frame_current = context.scene.frame_start bpy.ops.sequencer.select_all(action="SELECT") bpy.ops.sequencer.copy() + context.scene.frame_current = current_frame context.window.scene = target_scene current_frame = context.scene.frame_current active = context.scene.sequence_editor.active_strip - context.scene.frame_current = active.frame_final_start + context.scene.frame_current = active.frame_start bpy.ops.sequencer.select_all(action="DESELECT") bpy.ops.sequencer.paste() context.scene.frame_current = current_frame - def merge_markers(self, source_scene, target_scene): + def merge_markers(self, context, source_scene, target_scene): + if len(source_scene.timeline_markers) == 0: + return + if len(target_scene.timeline_markers) > 0: bpy.ops.marker.select_all(action="DESELECT") - bpy.context.screen.scene = source_scene + bpy.context.window.scene = source_scene bpy.ops.marker.select_all(action="SELECT") bpy.ops.marker.make_links_scene(scene=target_scene.name) - bpy.context.screen.scene = target_scene - active = bpy.context.screen.scene.sequence_editor.active_strip - time_offset = active.frame_final_start + bpy.context.window.scene = target_scene + active = bpy.context.window.scene.sequence_editor.active_strip + + # Offset to account for source scenes starting on any frame. + time_offset = active.frame_start - source_scene.frame_start bpy.ops.marker.move(frames=time_offset) bpy.ops.marker.select_all(action="DESELECT") diff --git a/power_sequencer/operators/scene_open_from_strip.py b/power_sequencer/operators/scene_open_from_strip.py index 8bcbef77..db512a9d 100644 --- a/power_sequencer/operators/scene_open_from_strip.py +++ b/power_sequencer/operators/scene_open_from_strip.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -49,5 +49,5 @@ class POWER_SEQUENCER_OT_open_scene_strip(bpy.types.Operator): return {"FINISHED"} strip_scene = active_strip.scene - context.screen.scene = bpy.data.scenes[strip_scene.name] + context.window.scene = bpy.data.scenes[strip_scene.name] return {"FINISHED"} diff --git a/power_sequencer/operators/scene_rename_with_strip.py b/power_sequencer/operators/scene_rename_with_strip.py index 245909b5..91ca8204 100644 --- a/power_sequencer/operators/scene_rename_with_strip.py +++ b/power_sequencer/operators/scene_rename_with_strip.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_all_left_or_right.py b/power_sequencer/operators/select_all_left_or_right.py index e92a2f7d..9f570b4b 100644 --- a/power_sequencer/operators/select_all_left_or_right.py +++ b/power_sequencer/operators/select_all_left_or_right.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_closest_to_mouse.py b/power_sequencer/operators/select_closest_to_mouse.py index 66860565..8a8b8bc6 100644 --- a/power_sequencer/operators/select_closest_to_mouse.py +++ b/power_sequencer/operators/select_closest_to_mouse.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_linked_effect.py b/power_sequencer/operators/select_linked_effect.py index 56e38276..8a863062 100644 --- a/power_sequencer/operators/select_linked_effect.py +++ b/power_sequencer/operators/select_linked_effect.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_linked_strips.py b/power_sequencer/operators/select_linked_strips.py index 86aa8d01..f6d77bbb 100644 --- a/power_sequencer/operators/select_linked_strips.py +++ b/power_sequencer/operators/select_linked_strips.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_related_strips.py b/power_sequencer/operators/select_related_strips.py index 30a8b24a..3accb616 100644 --- a/power_sequencer/operators/select_related_strips.py +++ b/power_sequencer/operators/select_related_strips.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/select_strips_under_cursor.py b/power_sequencer/operators/select_strips_under_cursor.py index 2fd37a60..0cc13c32 100644 --- a/power_sequencer/operators/select_strips_under_cursor.py +++ b/power_sequencer/operators/select_strips_under_cursor.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/set_timeline_range.py b/power_sequencer/operators/set_timeline_range.py index 7877c799..4b652bb1 100644 --- a/power_sequencer/operators/set_timeline_range.py +++ b/power_sequencer/operators/set_timeline_range.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/snap.py b/power_sequencer/operators/snap.py index 29668e56..cee5ad56 100644 --- a/power_sequencer/operators/snap.py +++ b/power_sequencer/operators/snap.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/snap_selection.py b/power_sequencer/operators/snap_selection.py index db661d06..7ad81b4d 100644 --- a/power_sequencer/operators/snap_selection.py +++ b/power_sequencer/operators/snap_selection.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/space_sequences.py b/power_sequencer/operators/space_sequences.py index 40985afb..519c2218 100644 --- a/power_sequencer/operators/space_sequences.py +++ b/power_sequencer/operators/space_sequences.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/speed_remove_effect.py b/power_sequencer/operators/speed_remove_effect.py index d969e902..2d835fb2 100644 --- a/power_sequencer/operators/speed_remove_effect.py +++ b/power_sequencer/operators/speed_remove_effect.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/speed_up_movie_strip.py b/power_sequencer/operators/speed_up_movie_strip.py index 27b66130..daa68b2b 100644 --- a/power_sequencer/operators/speed_up_movie_strip.py +++ b/power_sequencer/operators/speed_up_movie_strip.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/swap_strips.py b/power_sequencer/operators/swap_strips.py index 3eeb07c1..00c45107 100644 --- a/power_sequencer/operators/swap_strips.py +++ b/power_sequencer/operators/swap_strips.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -57,6 +57,9 @@ class POWER_SEQUENCER_OT_swap_strips(bpy.types.Operator): return context.selected_sequences def execute(self, context): + if len(context.selected_sequences) != 2: + return {"CANCELLED"} + strip_1 = context.selected_sequences[0] if len(context.selected_sequences) == 1: strip_2 = self.find_closest_strip_vertical(context, strip_1, self.direction) @@ -229,19 +232,19 @@ class POWER_SEQUENCER_OT_swap_strips(bpy.types.Operator): return return max(strips_below, key=attrgetter("channel")) - def are_linked(self, strip_1, strip_2): - return ( - strip_1.frame_final_start == strip_2.frame_final_start - and strip_1.frame_final_end == strip_2.frame_final_end - ) + def are_linked(self, strip_1, strip_2): + return ( + strip_1.frame_final_start == strip_2.frame_final_start + and strip_1.frame_final_end == strip_2.frame_final_end + ) - def swap_with_effect(self, strip_1, strip_2): - effect_strip = strip_1 if hasattr(strip_1, "input_1") else strip_2 - other_strip = strip_1 if effect_strip != strip_1 else strip_2 + def swap_with_effect(self, strip_1, strip_2): + effect_strip = strip_1 if hasattr(strip_1, "input_1") else strip_2 + other_strip = strip_1 if effect_strip != strip_1 else strip_2 - effect_strip_channel = effect_strip.channel - other_strip_channel = other_strip.channel + effect_strip_channel = effect_strip.channel + other_strip_channel = other_strip.channel - effect_strip.channel -= 1 - other_strip.channel = effect_strip_channel - effect_strip.channel = other_strip_channel + effect_strip.channel -= 1 + other_strip.channel = effect_strip_channel + effect_strip.channel = other_strip_channel diff --git a/power_sequencer/operators/toggle_selected_mute.py b/power_sequencer/operators/toggle_selected_mute.py index cd445205..362a9bd4 100644 --- a/power_sequencer/operators/toggle_selected_mute.py +++ b/power_sequencer/operators/toggle_selected_mute.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/toggle_waveforms.py b/power_sequencer/operators/toggle_waveforms.py index c3e45980..9dac9179 100644 --- a/power_sequencer/operators/toggle_waveforms.py +++ b/power_sequencer/operators/toggle_waveforms.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/transitions_remove.py b/power_sequencer/operators/transitions_remove.py index 4ebd2b44..8aa9f55f 100644 --- a/power_sequencer/operators/transitions_remove.py +++ b/power_sequencer/operators/transitions_remove.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/trim_left_or_right_handles.py b/power_sequencer/operators/trim_left_or_right_handles.py index 75a461da..675814ce 100644 --- a/power_sequencer/operators/trim_left_or_right_handles.py +++ b/power_sequencer/operators/trim_left_or_right_handles.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/trim_three_point_edit.py b/power_sequencer/operators/trim_three_point_edit.py index aa4d888f..c10ffc42 100644 --- a/power_sequencer/operators/trim_three_point_edit.py +++ b/power_sequencer/operators/trim_three_point_edit.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/trim_to_surrounding_cuts.py b/power_sequencer/operators/trim_to_surrounding_cuts.py index 0d4c012b..15982393 100644 --- a/power_sequencer/operators/trim_to_surrounding_cuts.py +++ b/power_sequencer/operators/trim_to_surrounding_cuts.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -22,7 +22,7 @@ import bpy from .utils.functions import convert_duration_to_frames, trim_strips from .utils.doc import doc_name, doc_idname, doc_brief, doc_description -from .utils.functions import find_closest_surrounding_cuts_frames +from .utils.functions import find_closest_surrounding_cuts_frames, find_strips_in_range class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): @@ -87,7 +87,9 @@ class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): ) return {"CANCELLED"} - to_delete, to_trim = self.find_strips_in_range(context, left_cut_frame, right_cut_frame) + to_delete, to_trim = find_strips_in_range( + left_cut_frame, right_cut_frame, context.sequences + ) trim_start, trim_end = (left_cut_frame + margin_frame, right_cut_frame - margin_frame) trim_strips(context, trim_start, trim_end, to_trim, to_delete) @@ -100,36 +102,3 @@ class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): context.scene.frame_current = trim_start return {"FINISHED"} - - def find_strips_in_range( - self, context, start_frame, end_frame, sequences=[], find_overlapping=True - ): - """ - Returns strips which start and end within a certain frame range, or that overlap a - certain frame range - Args: - - start_frame, the start of the frame range - - end_frame, the end of the frame range - - sequences (optional): only work with these sequences. - If it doesn't receive any, the function works with all the sequences in the current context - - find_overlapping (optional): find and return a list of strips that overlap the - frame range - - Returns a tuple of two lists: - [0], strips entirely in the frame range - [1], strips that only overlap the frame range - """ - strips_in_range = [] - strips_overlapping_range = [] - sequences = sequences if sequences else context.sequences - for s in sequences: - if start_frame < s.frame_final_start <= end_frame: - if start_frame <= s.frame_final_end < end_frame: - strips_in_range.append(s) - elif find_overlapping: - strips_overlapping_range.append(s) - elif find_overlapping and start_frame <= s.frame_final_end <= end_frame: - strips_overlapping_range.append(s) - if s.frame_final_start < start_frame and s.frame_final_end > end_frame: - strips_overlapping_range.append(s) - return strips_in_range, strips_overlapping_range diff --git a/power_sequencer/operators/utils/__init__.py b/power_sequencer/operators/utils/__init__.py index ad15033c..34d53626 100644 --- a/power_sequencer/operators/utils/__init__.py +++ b/power_sequencer/operators/utils/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/utils/doc.py b/power_sequencer/operators/utils/doc.py index 0a3e0a83..84ec923c 100644 --- a/power_sequencer/operators/utils/doc.py +++ b/power_sequencer/operators/utils/doc.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/utils/draw.py b/power_sequencer/operators/utils/draw.py index 0d993a53..6c13e27f 100644 --- a/power_sequencer/operators/utils/draw.py +++ b/power_sequencer/operators/utils/draw.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/utils/functions.py b/power_sequencer/operators/utils/functions.py index e2ea3672..3462b767 100644 --- a/power_sequencer/operators/utils/functions.py +++ b/power_sequencer/operators/utils/functions.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -40,7 +40,7 @@ def find_linked(context, sequences, selected_sequences): Returns a list of all the linked sequences, but not the sequences passed to the function """ - start, end = get_frame_range(context, sequences, selected_sequences) + start, end = get_frame_range(sequences, selected_sequences) sequences_in_range = [s for s in sequences if is_in_range(context, s, start, end)] effects = (s for s in sequences_in_range if s.type in SequenceTypes.EFFECT) selected_effects = (s for s in sequences if s.type in SequenceTypes.EFFECT) @@ -158,7 +158,7 @@ def find_strips_mouse(context, frame, channel, select_linked=False): return sequences -def get_frame_range(context, sequences=[], get_from_start=False): +def get_frame_range(sequences, get_from_start=False): """ Returns a tuple with the minimum and maximum frames of the list of passed sequences. @@ -177,6 +177,16 @@ def get_frame_range(context, sequences=[], get_from_start=False): return start, end +def get_channel_range(sequences): + """ + Returns a tuple with the minimum and maximum channels of the + list of passed sequences. + """ + start = min(sequences, key=attrgetter("channel")).channel + end = max(sequences, key=attrgetter("channel")).channel + return start, end + + def get_mouse_frame_and_channel(context, event): """ Convert mouse coordinates from the event, from @@ -259,12 +269,13 @@ def slice_selection(context, sequences): return broken_selection -def trim_strips(context, start_frame, end_frame, to_trim=[], to_delete=[]): +def trim_strips(context, frame_start, frame_end, to_trim, to_delete=[]): """ - Remove the footage and audio between start_frame and end_frame. + Removes the footage and audio between frame_start and frame_end. + You must pass the list of strips to trim to the function for it to work. """ - trim_start = min(start_frame, end_frame) - trim_end = max(start_frame, end_frame) + trim_start = min(frame_start, frame_end) + trim_end = max(frame_start, frame_end) to_trim = [s for s in to_trim if s.type in SequenceTypes.CUTABLE] @@ -276,8 +287,8 @@ def trim_strips(context, start_frame, end_frame, to_trim=[], to_delete=[]): if is_strip_longer_than_trim_range: bpy.ops.sequencer.select_all(action="DESELECT") s.select = True - bpy.ops.sequencer.cut(frame=trim_start, type="SOFT", side="RIGHT") - bpy.ops.sequencer.cut(frame=trim_end, type="SOFT", side="LEFT") + bpy.ops.sequencer.split(frame=trim_start, type="SOFT", side="RIGHT") + bpy.ops.sequencer.split(frame=trim_end, type="SOFT", side="LEFT") to_delete.append(context.selected_sequences[0]) continue @@ -291,11 +302,11 @@ def trim_strips(context, start_frame, end_frame, to_trim=[], to_delete=[]): return {"FINISHED"} -def delete_strips(to_delete=[]): +def delete_strips(to_delete): """ - Remove the footage and audio between start_frame and end_frame. + Deletes the list of sequences `to_delete` """ - if to_delete == []: + if not to_delete: return bpy.ops.sequencer.select_all(action="DESELECT") for s in to_delete: @@ -391,3 +402,39 @@ def apply_time_offset(context, sequences=[], offset=0): bpy.ops.sequencer.select_all(action="DESELECT") for s in selection: s.select = True + + +def find_strips_in_range(frame_start, frame_end, sequences, find_overlapping=True): + """ + Returns a tuple of two lists: (strips_inside_range, strips_overlapping_range) + strips_inside_range are strips entirely contained in the frame range. + strips_overlapping_range are strips that only overlap the frame range. + + Args: + - frame_start, the start of the frame range + - frame_end, the end of the frame range + - sequences (optional): only work with these sequences. + If it doesn't receive any, the function works with all the sequences in the current context + - find_overlapping (optional): find and return a list of strips that overlap the + frame range + + """ + strips_inside_range = [] + strips_overlapping_range = [] + for s in sequences: + if ( + frame_start <= s.frame_final_start <= frame_end + and frame_start <= s.frame_final_end <= frame_end + ): + strips_inside_range.append(s) + elif find_overlapping: + if ( + frame_start <= s.frame_final_end <= frame_end + or frame_start <= s.frame_final_start <= frame_end + ): + strips_overlapping_range.append(s) + + if find_overlapping: + if s.frame_final_start < frame_start and s.frame_final_end > frame_end: + strips_overlapping_range.append(s) + return strips_inside_range, strips_overlapping_range diff --git a/power_sequencer/operators/utils/global_settings.py b/power_sequencer/operators/utils/global_settings.py index 03d94365..34ffd369 100644 --- a/power_sequencer/operators/utils/global_settings.py +++ b/power_sequencer/operators/utils/global_settings.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/operators/utils/info_progress_bar.py b/power_sequencer/operators/utils/info_progress_bar.py index fc23c3c1..8e679d72 100644 --- a/power_sequencer/operators/utils/info_progress_bar.py +++ b/power_sequencer/operators/utils/info_progress_bar.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/scripts/BPSProxy/bpsproxy/commands.py b/power_sequencer/scripts/BPSProxy/bpsproxy/commands.py index fd41619d..4a28241b 100644 --- a/power_sequencer/scripts/BPSProxy/bpsproxy/commands.py +++ b/power_sequencer/scripts/BPSProxy/bpsproxy/commands.py @@ -101,7 +101,7 @@ def get_commands_video_1(cfg, clargs, **kwargs): out: iter(tuple(str)) Iterator containing commands. """ - cmd = "ffmpeg -hwaccel auto -y -v quiet -stats -i '{path_i_1}' {common_all}" + cmd = "ffmpeg -hwaccel auto -y -v quiet -stats -noautorotate -i '{path_i_1}' {common_all}" common = ( "-pix_fmt yuv420p" " -g 1" @@ -186,5 +186,5 @@ def get_commands_vi(cfg, clargs, **kwargs): An iterator with the 1st element as a tag (the `what` parameter) and the 2nd element as the iterator of the actual commands. """ - ws = filter(lambda x: x != "all", cfg["extensions"]) + ws = filter(lambda x: x is not "all", cfg["extensions"]) return chain.from_iterable(map(lambda w: get_commands(cfg, clargs, what=w, **kwargs), ws)) diff --git a/power_sequencer/scripts/BPSProxy/bpsproxy/utils.py b/power_sequencer/scripts/BPSProxy/bpsproxy/utils.py index 2f5b7c5e..832a0beb 100644 --- a/power_sequencer/scripts/BPSProxy/bpsproxy/utils.py +++ b/power_sequencer/scripts/BPSProxy/bpsproxy/utils.py @@ -36,7 +36,7 @@ def checktools(tools): msg = ["BPSProxy couldn't find external dependencies:"] msg += [ "[{check}] {tool}: {path}".format( - check="v" if path != "" else "X", tool=tool, path=path or "NOT FOUND" + check="v" if path is not "" else "X", tool=tool, path=path or "NOT FOUND" ) for tool, path in check["tools"] ] diff --git a/power_sequencer/scripts/BPSProxy/setup.py b/power_sequencer/scripts/BPSProxy/setup.py index 2581fe63..9676ef60 100644 --- a/power_sequencer/scripts/BPSProxy/setup.py +++ b/power_sequencer/scripts/BPSProxy/setup.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # +from setuptools import setup + def readme(): with open("README.md") as f: @@ -21,11 +23,9 @@ def readme(): if __name__ == "__main__": - from setuptools import setup - setup( name="bpsproxy", - version="0.2.0", + version="0.2.1", description="Blender Power Sequencer proxy generator tool", long_description=readme(), long_description_content_type="text/markdown", diff --git a/power_sequencer/scripts/BPSRender/bpsrender/__init__.py b/power_sequencer/scripts/BPSRender/bpsrender/__init__.py index f14cfb6a..35a40273 100644 --- a/power_sequencer/scripts/BPSRender/bpsrender/__init__.py +++ b/power_sequencer/scripts/BPSRender/bpsrender/__init__.py @@ -14,3 +14,4 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # + diff --git a/power_sequencer/scripts/BPSRender/bpsrender/helpers.py b/power_sequencer/scripts/BPSRender/bpsrender/helpers.py index 58f79775..9ebcf2b0 100644 --- a/power_sequencer/scripts/BPSRender/bpsrender/helpers.py +++ b/power_sequencer/scripts/BPSRender/bpsrender/helpers.py @@ -41,7 +41,7 @@ def checktools(tools): msg = ["BPSRender couldn't find external dependencies:"] msg += [ "[{check}] {tool}: {path}".format( - check="v" if path != "" else "X", tool=tool, path=path or "NOT FOUND" + check="v" if path is not "" else "X", tool=tool, path=path or "NOT FOUND" ) for tool, path in check["tools"] ] diff --git a/power_sequencer/scripts/BPSRender/setup.py b/power_sequencer/scripts/BPSRender/setup.py index 3d829d64..1f17b9ba 100644 --- a/power_sequencer/scripts/BPSRender/setup.py +++ b/power_sequencer/scripts/BPSRender/setup.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # +from setuptools import setup + def readme(): with open("README.rst") as f: @@ -21,8 +23,6 @@ def readme(): if __name__ == "__main__": - from setuptools import setup - setup( name="bpsrender", version="0.1.40.post1", diff --git a/power_sequencer/tools/__init__.py b/power_sequencer/tools/__init__.py index 463c3762..4c0e75ca 100644 --- a/power_sequencer/tools/__init__.py +++ b/power_sequencer/tools/__init__.py @@ -27,7 +27,7 @@ def get_tool_classes(): module_paths = ["." + os.path.splitext(f)[0] for f in module_files] classes = [] for path in module_paths: - module = importlib.import_module(path, package="power_sequencer.tools") + module = importlib.import_module(path, package="blender_power_sequencer.tools") tool_names = [entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_TOOL")] classes.extend([getattr(module, name) for name in tool_names]) return classes diff --git a/power_sequencer/ui/__init__.py b/power_sequencer/ui/__init__.py index 61edcb35..7cabf4fa 100644 --- a/power_sequencer/ui/__init__.py +++ b/power_sequencer/ui/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/ui/menu_contextual.py b/power_sequencer/ui/menu_contextual.py index c145beab..632821c2 100644 --- a/power_sequencer/ui/menu_contextual.py +++ b/power_sequencer/ui/menu_contextual.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/ui/menu_toolbar.py b/power_sequencer/ui/menu_toolbar.py index 3510d157..a00e26ec 100755 --- a/power_sequencer/ui/menu_toolbar.py +++ b/power_sequencer/ui/menu_toolbar.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # @@ -68,7 +68,7 @@ class POWER_SEQUENCER_MT_strips(bpy.types.Menu): layout.separator() - layout.operator("power_sequencer.make_still_image") + layout.operator("power_sequencer.make_hold_frame") class POWER_SEQUENCER_MT_transitions(bpy.types.Menu): diff --git a/power_sequencer/utils/addon_auto_imports.py b/power_sequencer/utils/addon_auto_imports.py index e570f53c..a1dea3a8 100644 --- a/power_sequencer/utils/addon_auto_imports.py +++ b/power_sequencer/utils/addon_auto_imports.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # diff --git a/power_sequencer/utils/register_shortcuts.py b/power_sequencer/utils/register_shortcuts.py index 5ecfdb30..beb75778 100644 --- a/power_sequencer/utils/register_shortcuts.py +++ b/power_sequencer/utils/register_shortcuts.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2019 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors +# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors # # This file is part of Power Sequencer. # |