Export_3ds: Improved distance cue node search
[blender-addons.git] / power_sequencer / operators / value_offset.py
blob244dd95d0f6fc7f4c05a13a582271caf9fec03b6
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_brief, doc_description, doc_idname, doc_name
8 from .utils.functions import convert_duration_to_frames
11 class POWER_SEQUENCER_OT_value_offset(bpy.types.Operator):
12 """Instantly offset selected strips, either using frames or seconds. Allows to
13 nudge the selection quickly, using keyboard shortcuts
14 """
16 doc = {
17 "name": doc_name(__qualname__),
18 "demo": "",
19 "description": doc_description(__doc__),
20 "shortcuts": [
22 {"type": "LEFT_ARROW", "value": "PRESS", "shift": True, "alt": True},
23 {"direction": "left"},
24 "Offset the selection to the left.",
27 {"type": "RIGHT_ARROW", "value": "PRESS", "shift": True, "alt": True},
28 {"direction": "right"},
29 "Offset the selection to the right.",
32 "keymap": "Sequencer",
34 bl_idname = doc_idname(__qualname__)
35 bl_label = doc["name"]
36 bl_description = doc_brief(doc["description"])
37 bl_options = {"REGISTER", "UNDO"}
39 direction: bpy.props.EnumProperty(
40 items=[
41 ("left", "left", "Move the selection to the left"),
42 ("right", "right", "Move the selection to the right"),
44 name="Direction",
45 description="Move the selection given frames or seconds",
46 default="right",
47 options={"HIDDEN"},
49 value_type: bpy.props.EnumProperty(
50 items=[
51 ("seconds", "Seconds", "Move with the value as seconds"),
52 ("frames", "Frames", "Move with the value as frames"),
54 name="Value Type",
55 description="Toggle between offset in frames or seconds",
56 default="seconds",
58 offset: bpy.props.FloatProperty(
59 name="Offset",
60 description="Offset amount to apply",
61 default=1.0,
62 step=5,
63 precision=3,
66 @classmethod
67 def poll(cls, context):
68 return context.selected_sequences
70 def invoke(self, context, event):
71 self.offset = abs(self.offset)
72 if self.direction == "left":
73 self.offset *= -1.0
74 return self.execute(context)
76 def execute(self, context):
77 offset_frames = (
78 convert_duration_to_frames(context, self.offset)
79 if self.value_type == "seconds"
80 else self.offset
82 return bpy.ops.transform.seq_slide(value=(offset_frames, 0))