Cleanup: quiet warnings with descriptions ending with a '.'
[blender-addons.git] / power_sequencer / operators / deselect_all_left_or_right.py
blob3ba794832c9bde5a1e791844d396c4af6fde9553
1 # SPDX-License-Identifier: GPL-3.0-or-later
2 # Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 import bpy
5 from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
8 class POWER_SEQUENCER_OT_deselect_all_strips_left_or_right(bpy.types.Operator):
9 """
10 Deselects all the strips at the left or right of the time cursor, based on the position
11 of the mouse
12 """
14 doc = {
15 "name": doc_name(__qualname__),
16 "demo": "",
17 "description": doc_description(__doc__),
18 "shortcuts": [
20 {"type": "Q", "value": "PRESS", "alt": True},
21 {"side": "left"},
22 "Deselect all strips to the left of the time cursor",
25 {"type": "E", "value": "PRESS", "alt": True},
26 {"side": "right"},
27 "Deselect all strips to the right of the time cursor",
30 "keymap": "Sequencer",
32 bl_idname = doc_idname(__qualname__)
33 bl_label = doc["name"]
34 bl_description = doc_brief(doc["description"])
35 bl_options = {"REGISTER", "UNDO"}
37 side: bpy.props.EnumProperty(
38 name="Side",
39 description="The side to deselect",
40 items=[
42 "mouse",
43 "Mouse position",
44 ("Deselect based on the mouse position relative to the" " time cursor"),
46 ("left", "Left", "Left of the time cursor"),
47 ("right", "Right", "Right of the time cursor"),
49 default="mouse",
52 @classmethod
53 def poll(cls, context):
54 return context.selected_sequences
56 def invoke(self, context, event):
57 frame_current = context.scene.frame_current
58 frame_mouse = context.region.view2d.region_to_view(event.mouse_region_x, 1)[0]
60 for s in context.sequences:
61 if self.side == "left" or frame_mouse < frame_current and self.side == "mouse":
62 if s.frame_final_end < frame_current:
63 self.deselect(s)
64 elif self.side == "right" or frame_mouse >= frame_current and self.side == "mouse":
65 if s.frame_final_start >= frame_current:
66 self.deselect(s)
67 return {"FINISHED"}
69 def deselect(self, strip):
70 strip.select = False
71 strip.select_left_handle = False
72 strip.select_right_handle = False