1 # SPDX-FileCopyrightText: 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 # SPDX-License-Identifier: GPL-3.0-or-later
7 from .utils
.doc
import doc_name
, doc_idname
, doc_brief
, doc_description
10 class POWER_SEQUENCER_OT_select_linked_strips(bpy
.types
.Operator
):
12 Add/Remove linked strips near mouse pointer to/from selection without the need to
13 previously have clicked/manually selected
17 "name": doc_name(__qualname__
),
19 "description": doc_description(__doc__
),
20 "shortcuts": [({"type": "L", "value": "PRESS"}, {}, "Add/Remove Linked to/from Selection")],
21 "keymap": "Sequencer",
23 bl_idname
= doc_idname(__qualname__
)
24 bl_label
= doc
["name"]
25 bl_description
= doc_brief(doc
["description"])
29 def poll(cls
, context
):
30 return context
.scene
.sequence_editor
32 def execute(self
, context
):
33 # save current selection first
34 selection
= set(context
.selected_sequences
)
36 # if previously selected strips are linked select links as well to toggle them too
37 bpy
.ops
.sequencer
.select_linked()
38 selection_new
= set(context
.selected_sequences
).difference(selection
)
39 # deselect & select only the linked strips near mouse pointer
40 bpy
.ops
.sequencer
.select_all(action
="DESELECT")
41 # re-enable linked + add selection near mouse pointer
42 for s
in selection_new
:
44 bpy
.ops
.sequencer
.select_linked()
45 bpy
.ops
.sequencer
.select_linked_pick("INVOKE_DEFAULT", extend
=True)
46 selection_new
= set(context
.selected_sequences
)
48 # identify if linked strips under mouse pointer need to be added or removed
49 action
= len(selection
.intersection(selection_new
)) != len(selection_new
)
51 # re-enable previous selection
55 # take care of toggle for strips under mouse
56 for s
in selection_new
: