Export_3ds: Improved distance cue node search
[blender-addons.git] / power_sequencer / operators / cut_strips_under_cursor.py
blob21137271b24daa7791b9378614b53a14a6e365cd
1 # SPDX-FileCopyrightText: 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 # SPDX-License-Identifier: GPL-3.0-or-later
5 import bpy
7 from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
8 from .utils.functions import get_mouse_frame_and_channel
11 class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
12 """
13 Splits all strips under cursor including muted strips, but excluding locked strips.
14 Auto selects sequences under the time cursor when you don't have a selection
15 """
17 doc = {
18 "name": doc_name(__qualname__),
19 "demo": "https://i.imgur.com/ZyEd0jD.gif",
20 "description": doc_description(__doc__),
21 "shortcuts": [({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")],
22 "keymap": "Sequencer",
24 bl_idname = doc_idname(__qualname__)
25 bl_label = doc["name"]
26 bl_description = doc_brief(doc["description"])
27 bl_options = {"REGISTER", "UNDO"}
29 side: bpy.props.EnumProperty(
30 items=[("LEFT", "", ""), ("RIGHT", "", "")],
31 name="Side",
32 default="LEFT",
33 options={"HIDDEN"},
36 @classmethod
37 def poll(cls, context):
38 return context.sequences
40 def invoke(self, context, event):
41 frame, channel = get_mouse_frame_and_channel(context, event)
42 self.side = "LEFT" if frame < context.scene.frame_current else "RIGHT"
43 return self.execute(context)
45 def execute(self, context):
46 # Deselect to trigger a call to select_strips_under_cursor below if the
47 # time cursor doesn't overlap any of the selected strip: if so, it
48 # can't cut anything!
49 deselect = True
50 for s in bpy.context.selected_sequences:
51 if s.frame_final_start <= context.scene.frame_current <= s.frame_final_end:
52 deselect = False
53 if deselect:
54 bpy.ops.sequencer.select_all(action="DESELECT")
55 (context.selected_sequences or bpy.ops.power_sequencer.select_strips_under_cursor())
56 return bpy.ops.sequencer.split(frame=context.scene.frame_current, side=self.side)