Export_3ds: Improved distance cue node search
[blender-addons.git] / power_sequencer / operators / trim_three_point_edit.py
blobd1fe2ff81ba9fd697c4efd1b73c4af742196ea39
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.functions import get_mouse_frame_and_channel
8 from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
11 class POWER_SEQUENCER_OT_trim_three_point_edit(bpy.types.Operator):
12 """
13 Trim the closest strip under the mouse cursor in or out
14 """
16 doc = {
17 "name": doc_name(__qualname__),
18 "demo": "",
19 "description": doc_description(__doc__),
20 "shortcuts": [
21 ({"type": "I", "value": "PRESS"}, {"side": "LEFT"}, "Trim In"),
22 ({"type": "O", "value": "PRESS"}, {"side": "RIGHT"}, "Trim Out"),
24 "keymap": "Sequencer",
26 bl_idname = doc_idname(__qualname__)
27 bl_label = doc["name"]
28 bl_description = doc_brief(doc["description"])
29 bl_options = {"REGISTER", "UNDO"}
31 side: bpy.props.EnumProperty(
32 items=[("LEFT", "Left", "Left side"), ("RIGHT", "Right", "Right side")],
33 name="Trim side",
34 description="Side of the strip(s) to trim, either LEFT or RIGHT",
35 default="LEFT",
38 @classmethod
39 def poll(cls, context):
40 return context.sequences
42 def invoke(self, context, event):
43 frame, channel = get_mouse_frame_and_channel(context, event)
44 bpy.ops.sequencer.select_all(action="DESELECT")
45 bpy.ops.power_sequencer.select_closest_to_mouse(frame=frame, channel=channel)
46 if not context.selected_sequences:
47 bpy.ops.power_sequencer.select_strips_under_cursor()
48 return self.execute(context)
50 def execute(self, context):
51 if not context.selected_sequences:
52 return {"CANCELLED"}
53 bpy.ops.power_sequencer.trim_left_or_right_handles(side=self.side)
54 return {"FINISHED"}