Merge branch 'blender-v4.0-release'
[blender-addons.git] / power_sequencer / operators / jump_time_offset.py
blobfe098d7a79943ae3d4014947eb72a4dcd470206f
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 convert_duration_to_frames
8 from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
11 class POWER_SEQUENCER_OT_jump_time_offset(bpy.types.Operator):
12 """
13 *brief* Jump forward or backward in time
16 Move the time cursor forward or backward, using a duration in seconds.
18 The equivalent tool in Blender only works with frames, meaning the jump
19 will be different if your project's framerate is different. This tool
20 fixes that issue.
21 """
23 doc = {
24 "name": doc_name(__qualname__),
25 "demo": "",
26 "description": doc_description(__doc__),
27 "shortcuts": [
29 {"type": "RIGHT_ARROW", "value": "PRESS", "shift": True},
30 {"direction": "forward"},
31 "Jump Forward",
34 {"type": "LEFT_ARROW", "value": "PRESS", "shift": True},
35 {"direction": "backward"},
36 "Jump Backward",
39 "keymap": "Frames",
41 bl_idname = doc_idname(__qualname__)
42 bl_label = doc["name"]
43 bl_description = doc_brief(doc["description"])
44 bl_options = {"REGISTER"}
46 duration: bpy.props.FloatProperty(
47 name="Duration",
48 description="The length of the jump in seconds (default: 1.0)",
49 default=1.0,
50 min=0,
52 direction: bpy.props.EnumProperty(
53 name="Direction",
54 description="Jump direction, either forward or backward",
55 items=[
56 ("forward", "Forward", "Jump forward in time"),
57 ("backward", "Backward", "Jump backward in time"),
61 @classmethod
62 def poll(cls, context):
63 return context.scene
65 def execute(self, context):
66 direction = 1 if self.direction == "forward" else -1
67 context.scene.frame_current += (
68 convert_duration_to_frames(context, self.duration) * direction
70 return {"FINISHED"}