Blender V5.3
sequencer_select.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <cmath>
11#include <cstdlib>
12#include <cstring>
13
14#include "BLI_lasso_2d.hh"
15#include "BLI_rect.hh"
16#include "MEM_guardedalloc.h"
17
18#include "BLI_ghash.hh"
19#include "BLI_listbase.hh"
20#include "BLI_math_geom_c.hh"
21#include "BLI_math_vector_c.hh"
23#include "BLI_set.hh"
24#include "BLI_string.hh"
25#include "BLI_utildefines.hh"
26
27#include "DNA_scene_types.h"
28#include "DNA_space_types.h"
29
30#include "BKE_context.hh"
31#include "BKE_report.hh"
32
33#include "BLT_translation.hh"
34
35#include "WM_api.hh"
36#include "WM_types.hh"
37
38#include "RNA_define.hh"
39
40#include "SEQ_channels.hh"
41#include "SEQ_connect.hh"
42#include "SEQ_iterator.hh"
43#include "SEQ_relations.hh"
44#include "SEQ_retiming.hh"
45#include "SEQ_select.hh"
46#include "SEQ_sequencer.hh"
47#include "SEQ_transform.hh"
48
49#include "ED_outliner.hh"
50#include "ED_screen.hh"
51#include "ED_select_utils.hh"
52#include "ED_sequencer.hh"
53
54#include "UI_resources.hh"
55#include "UI_view2d.hh"
56
57#include "sequencer_intern.hh"
58
59namespace blender::ed::vse {
60
61/* -------------------------------------------------------------------- */
64
66 public:
69
70 MouseCoords(const View2D *v2d, int x, int y)
71 {
72 region[0] = x;
73 region[1] = y;
74 ui::view2d_region_to_view(v2d, x, y, &view[0], &view[1]);
75 }
76};
77
78bool deselect_all_strips(const Scene *scene)
79{
80 Editing *ed = seq::editing_get(scene);
81 bool changed = false;
82
83 if (ed == nullptr) {
84 return changed;
85 }
86
87 for (Strip &strip : *seq::active_seqbase_get(ed)) {
88 if (strip.flag & STRIP_ALLSEL) {
89 strip.flag &= ~STRIP_ALLSEL;
90 changed = true;
91 }
92 }
93 return changed;
94}
95
96Strip *strip_under_mouse_get(const Scene *scene, const View2D *v2d, const int mval[2])
97{
98 float mouse_co[2];
99 ui::view2d_region_to_view(v2d, mval[0], mval[1], &mouse_co[0], &mouse_co[1]);
100
101 Vector<Strip *> visible = sequencer_visible_strips_get(scene, v2d);
102 int mouse_channel = int(mouse_co[1]);
103 for (Strip *strip : visible) {
104 if (strip->channel != mouse_channel) {
105 continue;
106 }
107 rctf body = strip_bounds_get(scene, strip);
108 if (BLI_rctf_isect_pt_v(&body, mouse_co)) {
109 return strip;
110 }
111 }
112
113 return nullptr;
114}
115
117{
119 Editing *ed = seq::editing_get(scene);
120 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
121 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
122
123 const bool is_preview = sequencer_view_has_preview_poll(C);
124 if (is_preview) {
125 return seq::query_rendered_strips(scene, channels, seqbase, scene->r.cfra, 0);
126 }
127
128 return seq::query_all_strips(seqbase);
129}
130
132{
133 const Scene *scene = CTX_data_sequencer_scene(C);
134 Editing *ed = seq::editing_get(scene);
135 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
136 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
137
138 const bool is_preview = sequencer_view_has_preview_poll(C);
139
140 if (is_preview) {
141 VectorSet strips = seq::query_rendered_strips(scene, channels, seqbase, scene->r.cfra, 0);
142 strips.remove_if([&](Strip *strip) { return (strip->flag & SEQ_SELECT) == 0; });
143 return strips;
144 }
145
146 return seq::query_selected_strips(seqbase);
147}
148
149static void select_surrounding_handles(Scene *scene, Strip *test) /* XXX BRING BACK */
150{
151 Strip *neighbor;
152
153 neighbor = find_neighboring_strip(scene, test, seq::Side::Left, -1);
154 if (neighbor) {
155 /* Only select neighbor handle if matching handle from test strip is also selected,
156 * or if neighbor was not selected at all up till now.
157 * Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */
158 if (!(neighbor->flag & SEQ_SELECT) || (test->flag & SEQ_LEFTSEL)) {
159 neighbor->flag |= SEQ_RIGHTSEL;
160 }
161 neighbor->flag |= SEQ_SELECT;
162 }
163 neighbor = find_neighboring_strip(scene, test, seq::Side::Right, -1);
164 if (neighbor) {
165 if (!(neighbor->flag & SEQ_SELECT) || (test->flag & SEQ_RIGHTSEL)) { /* See comment above. */
166 neighbor->flag |= SEQ_LEFTSEL;
167 }
168 neighbor->flag |= SEQ_SELECT;
169 }
170}
171
172/* Used for mouse selection in #SEQUENCER_OT_select. */
173static void select_active_side(ListBaseT<Strip> *seqbase,
174 seq::Side sel_side,
175 int channel,
176 int frame)
177{
178
179 for (Strip &strip : *seqbase) {
180 if (channel == strip.channel) {
181 switch (sel_side) {
182 case seq::Side::Left:
183 if (frame > strip.left_handle()) {
184 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
185 strip.flag |= SEQ_SELECT;
186 }
187 break;
188 case seq::Side::Right:
189 if (frame < strip.left_handle()) {
190 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
191 strip.flag |= SEQ_SELECT;
192 }
193 break;
194 case seq::Side::Both:
195 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
196 strip.flag |= SEQ_SELECT;
197 break;
198 default:
199 break;
200 }
201 }
202 }
203}
204
205/* Used for mouse selection in #SEQUENCER_OT_select_side. */
206static void select_active_side_range(ListBaseT<Strip> *seqbase,
207 const seq::Side sel_side,
208 const int frame_ranges[seq::MAX_CHANNELS],
209 const int frame_ignore)
210{
211 for (Strip &strip : *seqbase) {
212 if (strip.channel < seq::MAX_CHANNELS) {
213 const int frame = frame_ranges[strip.channel];
214 if (frame == frame_ignore) {
215 continue;
216 }
217 switch (sel_side) {
218 case seq::Side::Left:
219 if (frame > strip.left_handle()) {
220 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
221 strip.flag |= SEQ_SELECT;
222 }
223 break;
224 case seq::Side::Right:
225 if (frame < strip.left_handle()) {
226 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
227 strip.flag |= SEQ_SELECT;
228 }
229 break;
230 case seq::Side::Both:
231 strip.flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
232 strip.flag |= SEQ_SELECT;
233 break;
234 default:
235 break;
236 }
237 }
238 }
239}
240
241/* Used alongside `select_linked_time` helper function in #SEQUENCER_OT_select. */
242static void select_linked_time_strip(const Scene *scene,
243 const Strip *strip_source,
244 const eStripHandle handle_clicked)
245{
246 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(scene->ed);
247 int source_left = strip_source->left_handle();
248 int source_right = strip_source->right_handle(scene);
249
250 for (Strip &strip_dest : *seqbase) {
251 if (strip_source->channel != strip_dest.channel) {
252 const bool left_match = (strip_dest.left_handle() == source_left);
253 const bool right_match = (strip_dest.right_handle(scene) == source_right);
254
255 if (left_match && right_match) {
256 /* Direct match, copy all selection settings. */
257 strip_dest.flag &= ~STRIP_ALLSEL;
258 strip_dest.flag |= strip_source->flag & STRIP_ALLSEL;
259 }
260 else if (left_match && handle_clicked == STRIP_HANDLE_LEFT) {
261 strip_dest.flag &= ~(SEQ_SELECT | SEQ_LEFTSEL);
262 strip_dest.flag |= strip_source->flag & (SEQ_SELECT | SEQ_LEFTSEL);
263 }
264 else if (right_match && handle_clicked == STRIP_HANDLE_RIGHT) {
265 strip_dest.flag &= ~(SEQ_SELECT | SEQ_RIGHTSEL);
266 strip_dest.flag |= strip_source->flag & (SEQ_SELECT | SEQ_RIGHTSEL);
267 }
268 }
269 }
270}
271
272void select_strip_single(Scene *scene, Strip *strip, bool deselect_all)
273{
274 if (deselect_all) {
275 deselect_all_strips(scene);
276 }
277
278 seq::select_active_set(scene, strip);
279
280 strip->flag |= SEQ_SELECT;
281}
282
283rctf strip_bounds_get(const Scene *scene, const Strip *strip)
284{
285 rctf bounds;
286 bounds.xmin = strip->left_handle();
287 bounds.xmax = strip->right_handle(scene);
288 bounds.ymin = strip->channel + STRIP_OFSBOTTOM;
289 bounds.ymax = strip->channel + STRIP_OFSTOP;
290 return bounds;
291}
292
293Strip *find_neighboring_strip(const Scene *scene, const Strip *test, const seq::Side lr, int sel)
294{
295 /* sel: 0==unselected, 1==selected, -1==don't care. */
296 Editing *ed = seq::editing_get(scene);
297
298 if (ed == nullptr) {
299 return nullptr;
300 }
301
302 if (sel > 0) {
303 sel = SEQ_SELECT;
304 }
305 for (Strip &strip : *ed->current_strips()) {
306 if ((&strip != test) && (test->channel == strip.channel) &&
307 ((sel == -1) || (sel && (strip.flag & SEQ_SELECT)) ||
308 (sel == 0 && (strip.flag & SEQ_SELECT) == 0)))
309 {
310 switch (lr) {
311 case seq::Side::Left:
312 if (test->left_handle() == strip.right_handle(scene)) {
313 return &strip;
314 }
315 break;
316 case seq::Side::Right:
317 if (test->right_handle(scene) == strip.left_handle()) {
318 return &strip;
319 }
320 break;
321 default:
322 break;
323 }
324 }
325 }
326 return nullptr;
327}
328
329bool strip_point_image_isect(const Scene *scene, const Strip *strip, float point_view[2])
330{
331 const Array<float2> strip_image_quad = seq::image_transform_quad_get(scene, strip);
332 return isect_point_quad_v2(point_view,
333 strip_image_quad[0],
334 strip_image_quad[1],
335 strip_image_quad[2],
336 strip_image_quad[3]);
337}
338
344
346
347/* -------------------------------------------------------------------- */
350
352{
353 int action = RNA_enum_get(op->ptr, "action");
355
357 return OPERATOR_CANCELLED;
358 }
359
362 }
363
365
366 if (action == SEL_TOGGLE) {
367 action = SEL_SELECT;
368 for (Strip *strip : strips) {
369 if (strip->flag & STRIP_ALLSEL) {
370 action = SEL_DESELECT;
371 break;
372 }
373 }
374 }
375 if (ELEM(action, SEL_INVERT, SEL_SELECT)) {
376 if (action == SEL_INVERT) {
377 for (Strip *strip : strips) {
378 if (strip->flag & STRIP_ALLSEL) {
379 strips.remove(strip);
380 }
381 }
382 }
383 deselect_all_strips(scene);
384 }
385 for (Strip *strip : strips) {
386 switch (action) {
387 case SEL_SELECT:
388 strip->flag |= SEQ_SELECT;
389 break;
390 case SEL_DESELECT:
391 strip->flag &= ~STRIP_ALLSEL;
392 break;
393 case SEL_INVERT:
394 strip->flag |= SEQ_SELECT;
395 break;
396 }
397 }
400
401 return OPERATOR_FINISHED;
402}
403
405{
406 /* Identifiers. */
407 ot->name = "(De)select All";
408 ot->idname = "SEQUENCER_OT_select_all";
409 ot->description = "Select or deselect all strips";
410
411 /* API callbacks. */
414
415 /* Flags. */
416 ot->flag = OPTYPE_UNDO;
417
419}
420
422
423/* -------------------------------------------------------------------- */
426
427static void sequencer_select_set_active(Scene *scene, Strip *strip)
428{
429 seq::select_active_set(scene, strip);
430}
431
433 const View2D *v2d,
434 const int mval[2],
435 Scene *scene)
436{
437 Editing *ed = seq::editing_get(scene);
438
439 const float x = ui::view2d_region_to_view_x(v2d, mval[0]);
440 for (Strip &strip_iter : *seq::active_seqbase_get(ed)) {
441 if (((x < scene->r.cfra) && (strip_iter.right_handle(scene) <= scene->r.cfra)) ||
442 ((x >= scene->r.cfra) && (strip_iter.left_handle() >= scene->r.cfra)))
443 {
444 /* Select left or right. */
445 strip_iter.flag |= SEQ_SELECT;
446 }
447 }
448
449 {
450 SpaceSeq *sseq = CTX_wm_space_seq(C);
451 if (sseq && sseq->flag & SEQ_MARKER_TRANS) {
452
453 for (TimeMarker &tmarker : scene->markers) {
454 if (((x < scene->r.cfra) && (tmarker.frame <= scene->r.cfra)) ||
455 ((x >= scene->r.cfra) && (tmarker.frame >= scene->r.cfra)))
456 {
457 tmarker.flag |= SELECT;
458 }
459 else {
460 tmarker.flag &= ~SELECT;
461 }
462 }
463 }
464 }
465}
466
468 Strip *strip,
469 const eStripHandle handle_clicked)
470{
472 Editing *ed = seq::editing_get(scene);
473 if (!ELEM(handle_clicked, STRIP_HANDLE_LEFT, STRIP_HANDLE_RIGHT)) {
474 /* First click selects the strip and its adjacent handles (if valid).
475 * Second click selects the strip,
476 * both of its handles and its adjacent handles (if valid). */
477 const bool is_striponly_selected = ((strip->flag & STRIP_ALLSEL) == SEQ_SELECT);
478 strip->flag &= ~STRIP_ALLSEL;
479 strip->flag |= is_striponly_selected ? STRIP_ALLSEL : SEQ_SELECT;
480 select_surrounding_handles(scene, strip);
481 }
482 else {
483 /* Always select the strip under the cursor. */
484 strip->flag |= SEQ_SELECT;
485
486 /* First click selects adjacent handles on that side.
487 * Second click selects all strips in that direction.
488 * If there are no adjacent strips, it just selects all in that direction.
489 */
490 const seq::Side sel_side = (handle_clicked == STRIP_HANDLE_LEFT) ? seq::Side::Left :
492
493 Strip *neighbor = find_neighboring_strip(scene, strip, sel_side, -1);
494 if (neighbor) {
495 switch (sel_side) {
496 case seq::Side::Left:
497 if ((strip->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) {
498 strip->flag |= SEQ_SELECT;
500 ed->current_strips(), seq::Side::Left, strip->channel, strip->left_handle());
501 }
502 else {
503 strip->flag |= SEQ_SELECT;
504 strip->flag |= SEQ_LEFTSEL;
505 neighbor->flag |= SEQ_SELECT;
506 neighbor->flag |= SEQ_RIGHTSEL;
507 }
508 break;
509 case seq::Side::Right:
510 if ((strip->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) {
511 strip->flag |= SEQ_SELECT;
513 ed->current_strips(), seq::Side::Right, strip->channel, strip->left_handle());
514 }
515 else {
516 strip->flag |= SEQ_SELECT;
517 strip->flag |= SEQ_RIGHTSEL;
518 neighbor->flag |= SEQ_SELECT;
519 neighbor->flag |= SEQ_LEFTSEL;
520 }
521 break;
522 default:
523 break;
524 }
525 }
526 else {
527
528 select_active_side(ed->current_strips(), sel_side, strip->channel, strip->left_handle());
529 }
530 }
531}
532
540
541static int strip_sort_for_depth_select(const void *a, const void *b)
542{
543 const SeqSelect_Link *slink_a = static_cast<const SeqSelect_Link *>(a);
544 const SeqSelect_Link *slink_b = static_cast<const SeqSelect_Link *>(b);
545
546 /* Exactly overlapping strips, sort by channel (so the top-most is first). */
547 if (slink_a->strip->channel < slink_b->strip->channel) {
548 return 1;
549 }
550 if (slink_a->strip->channel > slink_b->strip->channel) {
551 return -1;
552 }
553 return 0;
554}
555
556static int strip_sort_for_center_select(const void *a, const void *b)
557{
558 const SeqSelect_Link *slink_a = static_cast<const SeqSelect_Link *>(a);
559 const SeqSelect_Link *slink_b = static_cast<const SeqSelect_Link *>(b);
560 if (slink_a->center_dist_sq > slink_b->center_dist_sq) {
561 return 1;
562 }
563 if (slink_a->center_dist_sq < slink_b->center_dist_sq) {
564 return -1;
565 }
566
567 /* Exactly overlapping strips, use depth. */
569}
570
577 const bContext *C, const int mval[2], const bool toggle, const bool extend, const bool center)
578{
580 Editing *ed = seq::editing_get(scene);
581 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
582 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
583 SpaceSeq *sseq = CTX_wm_space_seq(C);
585
586 float mouseco_view[2];
587 ui::view2d_region_to_view(v2d, mval[0], mval[1], &mouseco_view[0], &mouseco_view[1]);
588
589 /* Always update the coordinates (check extended after). */
590 const bool use_cycle = (!WM_cursor_test_motion_and_update(mval) || extend || toggle);
591
592 /* Allow strips this far from the closest center to be included.
593 * This allows cycling over center points which are near enough
594 * to overlapping from the users perspective. */
595 const float center_dist_sq_max = square_f(75.0f * U.pixelsize);
596 const float center_scale_px[2] = {
599 };
600
602 scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
603
604 SeqSelect_Link *slink_active = nullptr;
605 Strip *strip_active = seq::select_active_get(scene);
606 ListBaseT<SeqSelect_Link> strips_ordered = {nullptr};
607 for (Strip *strip : strips) {
608 bool isect = false;
609 float center_dist_sq_test = 0.0f;
610 if (center) {
611 /* Detect overlapping center points (scaled by the zoom level). */
613 sub_v2_v2(co, mouseco_view);
614 mul_v2_v2(co, center_scale_px);
615 center_dist_sq_test = len_squared_v2(co);
616 isect = center_dist_sq_test <= center_dist_sq_max;
617 if (isect) {
618 /* Use an active strip penalty for "center" selection when cycle is enabled. */
619 if (use_cycle && (strip == strip_active) && (strip_active->flag & SEQ_SELECT)) {
620 center_dist_sq_test = square_f(sqrtf(center_dist_sq_test) + (3.0f * U.pixelsize));
621 }
622 }
623 }
624 else {
625 isect = strip_point_image_isect(scene, strip, mouseco_view);
626 }
627
628 if (isect) {
630 slink->strip = strip;
631 slink->center_dist_sq = center_dist_sq_test;
632 BLI_addtail(&strips_ordered, slink);
633
634 if (strip == strip_active) {
635 slink_active = slink;
636 }
637 }
638 }
639
640 BLI_listbase_sort(&strips_ordered,
642
643 SeqSelect_Link *slink_select = strips_ordered.first();
644 Strip *strip_select = nullptr;
645 if (slink_select != nullptr) {
646 /* Only use special behavior for the active strip when it's selected. */
647 if ((center == false) && slink_active && (strip_active->flag & SEQ_SELECT)) {
648 if (use_cycle) {
649 if (slink_active->next) {
650 slink_select = slink_active->next;
651 }
652 }
653 else {
654 /* Match object selection behavior: keep the current active item unless cycle is enabled.
655 * Clicking again in the same location will cycle away from the active object. */
656 slink_select = slink_active;
657 }
658 }
659 strip_select = slink_select->strip;
660 }
661
662 strips_ordered.free_no_destruct();
663
664 return strip_select;
665}
666
667bool handle_is_selected(const Strip *strip, const eStripHandle handle)
668{
669 return ((strip->flag & SEQ_LEFTSEL) && (handle == STRIP_HANDLE_LEFT)) ||
670 ((strip->flag & SEQ_RIGHTSEL) && (handle == STRIP_HANDLE_RIGHT));
671}
672
678static bool element_already_selected(const StripSelection &selection)
679{
680 if (selection.strip1 == nullptr) {
681 return false;
682 }
683
684 const bool strip1_already_selected = ((selection.strip1->flag & SEQ_SELECT) != 0);
685 if (selection.strip2 == nullptr) {
686 if (selection.handle == STRIP_HANDLE_NONE) {
687 return strip1_already_selected && !(selection.strip1->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL));
688 }
689 return strip1_already_selected && handle_is_selected(selection.strip1, selection.handle);
690 }
691
692 /* If we are here, the strip selection is dual handle. */
693 const bool strip2_already_selected = ((selection.strip2->flag & SEQ_SELECT) != 0);
694 const int strip1_handle = selection.strip1->flag & (SEQ_RIGHTSEL | SEQ_LEFTSEL);
695 const int strip2_handle = selection.strip2->flag & (SEQ_RIGHTSEL | SEQ_LEFTSEL);
696 /* Handles must be selected in XOR fashion, with `strip1` matching `handle_clicked`. */
697 const bool both_handles_selected = strip1_handle == selection.handle && strip2_handle != 0 &&
698 strip1_handle != strip2_handle;
699 return strip1_already_selected && strip2_already_selected && both_handles_selected;
700}
701
703{
704 VectorSet<Strip *> sources;
705 sources.add(selection.strip1);
706 if (selection.strip2) {
707 sources.add(selection.strip2);
708 }
709
710 for (Strip *source : sources) {
711 VectorSet<Strip *> connections = seq::connected_strips_get(source);
712 for (Strip *connection : connections) {
713 /* Copy selection settings exactly for connected strips. */
714 connection->flag &= ~STRIP_ALLSEL;
715 connection->flag |= source->flag & STRIP_ALLSEL;
716 }
717 }
718}
719
721 const StripSelection &selection,
722 VectorSet<Strip *> copy_to)
723{
724 /* TODO(john): Dual handle propagation is not supported for now due to its complexity,
725 * but once we simplify selection assumptions in 5.0 we can add support for it. */
726 if (selection.strip2) {
727 return;
728 }
729
730 Strip *source = selection.strip1;
731 /* Test for neighboring strips in the `copy_to` list. If any border one another, remove them,
732 * since we don't want to mess with dual handles. */
733 VectorSet<Strip *> test(copy_to);
734 test.add(source);
735 for (Strip *test_strip : test) {
736 /* Don't copy left handle over to a `test_strip` that has a strip directly on its left. */
737 if ((source->flag & SEQ_LEFTSEL) &&
738 find_neighboring_strip(scene, test_strip, seq::Side::Left, -1))
739 {
740 /* If this was the source strip, do not copy handles at all and prematurely return. */
741 if (test_strip == source) {
742 return;
743 }
744 copy_to.remove(test_strip);
745 }
746
747 /* Don't copy right handle over to a `test_strip` that has a strip directly on its right. */
748 if ((source->flag & SEQ_RIGHTSEL) &&
749 find_neighboring_strip(scene, test_strip, seq::Side::Right, -1))
750 {
751 /* If this was the source strip, do not copy handles at all and prematurely return. */
752 if (test_strip == source) {
753 return;
754 }
755 copy_to.remove(test_strip);
756 }
757 }
758
759 for (Strip *strip : copy_to) {
760 /* NOTE that this can be `ALLSEL` since `prev_selection` was deselected earlier. */
761 strip->flag &= ~STRIP_ALLSEL;
762 strip->flag |= source->flag & STRIP_ALLSEL;
763 }
764}
765
767 Strip *strip,
768 const eStripHandle handle_clicked,
769 const bool extend,
770 const bool deselect,
771 const bool toggle)
772{
773 const bool is_active = (ed->act_strip == strip);
774
775 /* Exception for active strip handles. */
776 if ((handle_clicked != STRIP_HANDLE_NONE) && (strip->flag & SEQ_SELECT) && is_active && toggle) {
777 if (handle_clicked == STRIP_HANDLE_LEFT) {
778 strip->flag ^= SEQ_LEFTSEL;
779 }
780 else if (handle_clicked == STRIP_HANDLE_RIGHT) {
781 strip->flag ^= SEQ_RIGHTSEL;
782 }
783 return;
784 }
785
786 /* Select strip. */
787 /* Match object selection behavior. */
788 int action = -1;
789 if (extend) {
790 action = 1;
791 }
792 else if (deselect) {
793 action = 0;
794 }
795 else {
796 if (!((strip->flag & SEQ_SELECT) && is_active)) {
797 action = 1;
798 }
799 else if (toggle) {
800 action = 0;
801 }
802 }
803
804 if (action == 1) {
805 strip->flag |= SEQ_SELECT;
806 if (handle_clicked == STRIP_HANDLE_LEFT) {
807 strip->flag |= SEQ_LEFTSEL;
808 }
809 if (handle_clicked == STRIP_HANDLE_RIGHT) {
810 strip->flag |= SEQ_RIGHTSEL;
811 }
812 }
813 else if (action == 0) {
814 strip->flag &= ~STRIP_ALLSEL;
815 }
816}
817
818static void select_linked_time(const Scene *scene,
819 const StripSelection &selection,
820 const bool extend,
821 const bool deselect,
822 const bool toggle)
823{
824 Editing *ed = seq::editing_get(scene);
825
826 sequencer_select_strip_impl(ed, selection.strip1, selection.handle, extend, deselect, toggle);
827 select_linked_time_strip(scene, selection.strip1, selection.handle);
828
829 if (selection.strip2 != nullptr) {
830 eStripHandle strip2_handle_clicked = (selection.handle == STRIP_HANDLE_LEFT) ?
834 ed, selection.strip2, strip2_handle_clicked, extend, deselect, toggle);
835 select_linked_time_strip(scene, selection.strip2, strip2_handle_clicked);
836 }
837}
838
845static float inner_clickable_handle_size_get(const Scene *scene,
846 const Strip *strip,
847 const View2D *v2d)
848{
849 const float pixelx = ui::view2d_pixel_size_get_x(v2d);
850 const float strip_len = strip->right_handle(scene) - strip->left_handle();
851 return min_ff(15.0f * pixelx * U.pixelsize, strip_len / 4);
852}
853
854bool can_select_handle(const Scene *scene, const Strip *strip)
855{
856 if (strip->is_effect_with_inputs()) {
857 return false;
858 }
859
860 Editing *ed = seq::editing_get(scene);
861 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
862 if (seq::transform_is_locked(channels, strip)) {
863 return false;
864 }
865
866 return true;
867}
868
869static void strip_clickable_areas_get(const Scene *scene,
870 const Strip *strip,
871 const View2D *v2d,
872 rctf *r_body,
873 rctf *r_left_handle,
874 rctf *r_right_handle)
875{
876 *r_body = strip_bounds_get(scene, strip);
877 *r_left_handle = *r_body;
878 *r_right_handle = *r_body;
879
880 const float handsize = inner_clickable_handle_size_get(scene, strip, v2d);
881 r_left_handle->xmax = r_body->xmin + handsize;
882 r_right_handle->xmin = r_body->xmax - handsize;
883 BLI_rctf_pad(r_left_handle, handsize / 3, 0.0f);
884 BLI_rctf_pad(r_right_handle, handsize / 3, 0.0f);
885 BLI_rctf_pad(r_body, -handsize, 0.0f);
886}
887
888static rctf strip_clickable_area_get(const Scene *scene, const View2D *v2d, const Strip *strip)
889{
890 rctf body, left, right;
891 strip_clickable_areas_get(scene, strip, v2d, &body, &left, &right);
892 BLI_rctf_union(&body, &left);
893 BLI_rctf_union(&body, &right);
894 return body;
895}
896
897static float strip_to_frame_distance(const Scene *scene,
898 const View2D *v2d,
899 const Strip *strip,
900 float timeline_frame)
901{
902 rctf body, left, right;
903 strip_clickable_areas_get(scene, strip, v2d, &body, &left, &right);
904 return BLI_rctf_length_x(&body, timeline_frame);
905}
906
913 const View2D *v2d,
914 float mouse_co[2])
915{
916 Editing *ed = seq::editing_get(scene);
917
918 if (ed == nullptr) {
919 return {};
920 }
921
922 Vector<Strip *> strips;
923 for (Strip &strip : *ed->current_strips()) {
924 if (strip.channel != int(mouse_co[1])) {
925 continue;
926 }
927 if (strip.left_handle() > v2d->cur.xmax) {
928 continue;
929 }
930 if (strip.right_handle(scene) < v2d->cur.xmin) {
931 continue;
932 }
933 const rctf body = strip_clickable_area_get(scene, v2d, &strip);
934 if (!BLI_rctf_isect_pt_v(&body, mouse_co)) {
935 continue;
936 }
937 strips.append(&strip);
938 }
939
940 std::ranges::sort(strips, [&](const Strip *strip1, const Strip *strip2) {
941 return strip_to_frame_distance(scene, v2d, strip1, mouse_co[0]) <
942 strip_to_frame_distance(scene, v2d, strip2, mouse_co[0]);
943 });
944
945 return strips;
946}
947
948static bool strips_are_adjacent(const Scene *scene, const Strip *strip1, const Strip *strip2)
949{
950 const int s1_left = strip1->left_handle();
951 const int s1_right = strip1->right_handle(scene);
952 const int s2_left = strip2->left_handle();
953 const int s2_right = strip2->right_handle(scene);
954
955 return s1_right == s2_left || s1_left == s2_right;
956}
957
959 const Strip *strip,
960 const View2D *v2d,
961 float mouse_co[2])
962{
963 if (!can_select_handle(scene, strip)) {
964 return STRIP_HANDLE_NONE;
965 }
966
967 rctf body, left, right;
968 strip_clickable_areas_get(scene, strip, v2d, &body, &left, &right);
969 if (BLI_rctf_isect_pt_v(&left, mouse_co)) {
970 return STRIP_HANDLE_LEFT;
971 }
972 if (BLI_rctf_isect_pt_v(&right, mouse_co)) {
973 return STRIP_HANDLE_RIGHT;
974 }
975
976 return STRIP_HANDLE_NONE;
977}
978
980 Vector<Strip *> strips,
981 const View2D *v2d,
982 float mouse_co[2])
983{
984 const eStripHandle strip1_handle = strip_handle_under_cursor_get(
985 scene, strips[0], v2d, mouse_co);
986
987 if (strip1_handle == STRIP_HANDLE_NONE) {
988 return false;
989 }
990 if (!strips_are_adjacent(scene, strips[0], strips[1])) {
991 return false;
992 }
993 const eStripHandle strip2_handle = strip_handle_under_cursor_get(
994 scene, strips[1], v2d, mouse_co);
995 if (strip1_handle == STRIP_HANDLE_RIGHT && strip2_handle != STRIP_HANDLE_LEFT) {
996 return false;
997 }
998 if (strip1_handle == STRIP_HANDLE_LEFT && strip2_handle != STRIP_HANDLE_RIGHT) {
999 return false;
1000 }
1001
1002 return true;
1003}
1004
1005StripSelection pick_strip_and_handle(const Scene *scene, const View2D *v2d, float mouse_co[2])
1006{
1007 StripSelection selection;
1008 /* Do not pick strips when clicking inside time scrub region. */
1009 float time_scrub_y = v2d->cur.ymax - UI_TIME_SCRUB_MARGIN_Y / ui::view2d_scale_get_y(v2d);
1010 if (mouse_co[1] > time_scrub_y) {
1011 return selection;
1012 }
1013
1014 Vector<Strip *> strips = padded_strips_under_mouse_get(scene, v2d, mouse_co);
1015
1016 if (strips.size() == 0) {
1017 return selection;
1018 }
1019
1020 selection.strip1 = strips[0];
1021 selection.handle = strip_handle_under_cursor_get(scene, selection.strip1, v2d, mouse_co);
1022
1023 if (strips.size() == 2 &&
1024 is_mouse_over_both_handles_of_adjacent_strips(scene, strips, v2d, mouse_co))
1025 {
1026 selection.strip2 = strips[1];
1027 }
1028
1029 return selection;
1030}
1031
1033{
1034 const View2D *v2d = ui::view2d_fromcontext(C);
1036 Editing *ed = seq::editing_get(scene);
1037 ARegion *region = CTX_wm_region(C);
1038
1039 if (ed == nullptr) {
1040 return OPERATOR_CANCELLED;
1041 }
1042
1043 if (region->regiontype == RGN_TYPE_PREVIEW) {
1045 return OPERATOR_CANCELLED;
1046 }
1047 const SpaceSeq *sseq = CTX_wm_space_seq(C);
1048 if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) {
1049 return OPERATOR_CANCELLED;
1050 }
1051 }
1052
1053 const bool was_retiming = seq::retiming_keys_are_selected(scene);
1054
1055 MouseCoords mouse_co(v2d, RNA_int_get(op->ptr, "mouse_x"), RNA_int_get(op->ptr, "mouse_y"));
1056
1057 /* Check to see if the mouse cursor intersects with the retiming box; if so, `strip_key_owner` is
1058 * set. If the cursor intersects with a retiming key, `key` will be set too. */
1059 Strip *strip_key_owner = nullptr;
1060 SeqRetimingKey *key = retiming_mouseover_key_get(scene, v2d, mouse_co.region, &strip_key_owner);
1061
1062 if (strip_key_owner != nullptr && retiming_overlay_enabled(CTX_wm_space_seq(C)) &&
1063 seq::retiming_show_keys(strip_key_owner))
1064 {
1065 /* If no key was found, the mouse cursor may still intersect with a "fake key" that has not
1066 * been realized yet. */
1067 if (key == nullptr) {
1068 key = try_to_realize_fake_keys(scene, v2d, strip_key_owner, mouse_co.region);
1069 }
1070 else {
1071 /* There may be a fake key on either side of the strip. It must be realized. Realizing
1072 * reallocates the key array, so `key` has to be looked up again. */
1073 const int key_frame = seq::retiming_key_frame_get(scene, strip_key_owner, key);
1074 seq::realize_fake_keys(scene, strip_key_owner);
1075 key = seq::retiming_key_get_by_frame(scene, strip_key_owner, key_frame);
1076 }
1077
1078 if (key != nullptr) {
1079 if (!was_retiming) {
1080 deselect_all_strips(scene);
1082 }
1083 /* Attempt to realize any other connected strips' fake keys. */
1084 if (seq::is_strip_connected(strip_key_owner)) {
1085 const int key_frame = seq::retiming_key_frame_get(scene, strip_key_owner, key);
1086 VectorSet<Strip *> connections = seq::connected_strips_get(strip_key_owner);
1087 for (Strip *connection : connections) {
1088 if (key_frame == seq::left_fake_key_frame_get(scene, connection) ||
1089 key_frame == seq::right_fake_key_frame_get(scene, connection))
1090 {
1091 seq::realize_fake_keys(scene, connection);
1092 }
1093 }
1094 }
1095 return sequencer_retiming_key_select_exec(C, op, key, strip_key_owner);
1096 }
1097 }
1098
1099 /* We should only reach here if no retiming selection is happening. */
1100 if (was_retiming) {
1103 }
1104
1105 const bool extend = RNA_boolean_get(op->ptr, "extend");
1106 const bool deselect = RNA_boolean_get(op->ptr, "deselect");
1107 const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
1108 const bool toggle = RNA_boolean_get(op->ptr, "toggle");
1109 const bool center = RNA_boolean_get(op->ptr, "center");
1110
1111 StripSelection selection;
1112 if (region->regiontype == RGN_TYPE_PREVIEW) {
1113 selection.strip1 = strip_select_from_preview(C, mouse_co.region, toggle, extend, center);
1114 }
1115 else {
1116 selection = pick_strip_and_handle(scene, v2d, mouse_co.view);
1117 }
1118
1119 /* NOTE: `side_of_frame` and `linked_time` functionality is designed to be shared on one
1120 * keymap, therefore both properties can be true at the same time. */
1121 if (selection.strip1 && RNA_boolean_get(op->ptr, "linked_time")) {
1122 if (!extend && !toggle) {
1123 deselect_all_strips(scene);
1124 }
1125 select_linked_time(scene, selection, extend, deselect, toggle);
1127 sequencer_select_set_active(scene, selection.strip1);
1128 return OPERATOR_FINISHED;
1129 }
1130
1131 /* Select left, right or overlapping the current frame. */
1132 if (RNA_boolean_get(op->ptr, "side_of_frame")) {
1133 if (!extend && !toggle) {
1134 deselect_all_strips(scene);
1135 }
1136 sequencer_select_side_of_frame(C, v2d, mouse_co.region, scene);
1138 return OPERATOR_FINISHED;
1139 }
1140
1141 /* On Alt selection, select the strip and bordering handles. */
1142 if (selection.strip1 && RNA_boolean_get(op->ptr, "linked_handle")) {
1143 if (!extend && !toggle) {
1144 deselect_all_strips(scene);
1145 }
1146 sequencer_select_linked_handle(C, selection.strip1, selection.handle);
1148 sequencer_select_set_active(scene, selection.strip1);
1149 return OPERATOR_FINISHED;
1150 }
1151
1152 const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
1153 const bool already_selected = element_already_selected(selection);
1154
1155 SpaceSeq *sseq = CTX_wm_space_seq(C);
1156 if (selection.handle != STRIP_HANDLE_NONE && already_selected) {
1158 }
1159 else {
1161 }
1162 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
1163
1164 /* Clicking on already selected element falls on modal operation.
1165 * All strips are deselected on mouse button release unless extend mode is used. */
1166 if (already_selected && wait_to_deselect_others && !toggle && !ignore_connections) {
1168 }
1169
1170 VectorSet<Strip *> copy_to;
1171 /* True if the user selects either handle of a strip that is already selected, meaning that
1172 * handles should be propagated to all currently selected strips. */
1173 bool copy_handles_to_sel = (selection.handle != STRIP_HANDLE_NONE) &&
1174 (selection.strip1->flag & SEQ_SELECT);
1175
1176 /* TODO(john): Dual handle propagation is not supported for now due to its complexity,
1177 * but once we simplify selection assumptions in 5.0 we can add support for it. */
1178 copy_handles_to_sel &= (selection.strip2 == nullptr);
1179
1180 if (copy_handles_to_sel) {
1182 copy_to.remove(selection.strip1);
1183 copy_to.remove_if([](Strip *strip) { return strip->is_effect_with_inputs(); });
1184 }
1185
1186 bool changed = false;
1187 /* Deselect everything for now. NOTE that this condition runs for almost every click with no
1188 * modifiers. `sequencer_select_strip_impl` expects this and will re-select any strips in
1189 * `selection`. */
1190 if (deselect_all ||
1191 (selection.strip1 && (extend == false && deselect == false && toggle == false)))
1192 {
1193 changed |= deselect_all_strips(scene);
1194 }
1195
1196 /* Nothing to select, but strips might have been deselected, in which case we should update. */
1197 if (!selection.strip1) {
1198 if (changed) {
1200 }
1201 return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1202 }
1203
1204 /* Do actual selection. */
1205 sequencer_select_strip_impl(ed, selection.strip1, selection.handle, extend, deselect, toggle);
1206 if (selection.strip2 != nullptr) {
1207 /* Invert handle selection for second strip. */
1208 eStripHandle strip2_handle_clicked = (selection.handle == STRIP_HANDLE_LEFT) ?
1212 ed, selection.strip2, strip2_handle_clicked, extend, deselect, toggle);
1213 }
1214
1215 if (!ignore_connections) {
1216 if (copy_handles_to_sel) {
1217 sequencer_copy_handles_to_selected_strips(scene, selection, copy_to);
1218 }
1219
1221 }
1222
1224 sequencer_select_set_active(scene, selection.strip1);
1225 return OPERATOR_FINISHED;
1226}
1227
1229{
1230 const wmOperatorStatus retval = WM_generic_select_invoke(C, op, event);
1231 ARegion *region = CTX_wm_region(C);
1232 if (region && (region->regiontype == RGN_TYPE_PREVIEW)) {
1233 return WM_operator_flag_only_pass_through_on_press(retval, event);
1234 }
1235 return retval;
1236}
1237
1239{
1240 if (RNA_boolean_get(ptr, "ignore_connections")) {
1241 return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Unconnected)");
1242 }
1243 if (RNA_boolean_get(ptr, "linked_time")) {
1244 return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Linked Time)");
1245 }
1246 if (RNA_boolean_get(ptr, "linked_handle")) {
1247 return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Linked Handle)");
1248 }
1249 if (RNA_boolean_get(ptr, "side_of_frame")) {
1250 return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Side of Frame)");
1251 }
1252
1253 return ED_select_pick_get_name(ot, ptr);
1254}
1255
1257{
1258 PropertyRNA *prop;
1259
1260 /* Identifiers. */
1261 ot->name = "Select";
1262 ot->idname = "SEQUENCER_OT_select";
1263 ot->description = "Select a strip (last selected becomes the \"active strip\")";
1264
1265 /* API callbacks. */
1271
1272 /* Flags. */
1273 ot->flag = OPTYPE_UNDO;
1274
1275 /* Properties. */
1277
1279
1280 prop = RNA_def_boolean(
1281 ot->srna,
1282 "center",
1283 false,
1284 "Center",
1285 "Use the object center when selecting, in edit mode used to extend object selection");
1287
1288 prop = RNA_def_boolean(ot->srna,
1289 "linked_handle",
1290 false,
1291 "Linked Handle",
1292 "Select handles next to the active strip");
1294
1295 prop = RNA_def_boolean(ot->srna,
1296 "linked_time",
1297 false,
1298 "Linked Time",
1299 "Select other strips or handles at the same time, or all retiming keys "
1300 "after the current in retiming mode");
1302
1303 prop = RNA_def_boolean(
1304 ot->srna,
1305 "side_of_frame",
1306 false,
1307 "Side of Frame",
1308 "Select all strips on same side of the current frame as the mouse cursor");
1310
1311 prop = RNA_def_boolean(ot->srna,
1312 "ignore_connections",
1313 false,
1314 "Ignore Connections",
1315 "Select strips individually whether or not they are connected");
1317}
1318
1320
1321/* -------------------------------------------------------------------- */
1324
1327{
1328 const View2D *v2d = ui::view2d_fromcontext(C);
1330 Editing *ed = seq::editing_get(scene);
1331
1332 if (ed == nullptr) {
1333 return OPERATOR_CANCELLED;
1334 }
1335
1336 MouseCoords mouse_co(v2d, RNA_int_get(op->ptr, "mouse_x"), RNA_int_get(op->ptr, "mouse_y"));
1337
1338 StripSelection selection = pick_strip_and_handle(scene, v2d, mouse_co.view);
1339 if (selection.strip1 == nullptr || selection.handle == STRIP_HANDLE_NONE) {
1341 }
1342
1343 /* Ignore clicks on retiming keys. */
1344 Strip *strip_key_test = nullptr;
1345 SeqRetimingKey *key = retiming_mouseover_key_get(scene, v2d, mouse_co.region, &strip_key_test);
1346 if (key != nullptr) {
1348 }
1349
1350 SpaceSeq *sseq = CTX_wm_space_seq(C);
1351 if (element_already_selected(selection)) {
1354 }
1356 deselect_all_strips(scene);
1357
1358 /* Do actual selection. */
1359 sequencer_select_strip_impl(ed, selection.strip1, selection.handle, false, false, false);
1360 if (selection.strip2 != nullptr) {
1361 /* Invert handle selection for second strip */
1362 eStripHandle strip2_handle_clicked = (selection.handle == STRIP_HANDLE_LEFT) ?
1365 sequencer_select_strip_impl(ed, selection.strip2, strip2_handle_clicked, false, false, false);
1366 }
1367
1368 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
1369 if (!ignore_connections) {
1371 }
1372
1375 sequencer_select_set_active(scene, selection.strip1);
1377}
1378
1380 wmOperator *op,
1381 const wmEvent *event)
1382{
1383 ARegion *region = CTX_wm_region(C);
1384
1385 int mval[2];
1386 WM_event_drag_start_mval(event, region, mval);
1387
1388 RNA_int_set(op->ptr, "mouse_x", mval[0]);
1389 RNA_int_set(op->ptr, "mouse_y", mval[1]);
1390
1391 return sequencer_select_handle_exec(C, op);
1392}
1393
1395{
1396 PropertyRNA *prop;
1397
1398 /* Identifiers. */
1399 ot->name = "Select Handle";
1400 ot->idname = "SEQUENCER_OT_select_handle";
1401 ot->description = "Select strip handle";
1402
1403 /* API callbacks. */
1407
1408 /* Flags. */
1409 ot->flag = OPTYPE_UNDO;
1410
1411 /* Properties. */
1413
1414 prop = RNA_def_boolean(ot->srna,
1415 "ignore_connections",
1416 false,
1417 "Ignore Connections",
1418 "Select strips individually whether or not they are connected");
1420}
1421
1423
1424/* -------------------------------------------------------------------- */
1427
1428/* Run recursively to select linked. */
1430{
1431 Editing *ed = seq::editing_get(scene);
1432
1433 if (ed == nullptr) {
1434 return false;
1435 }
1436
1437 bool changed = false;
1438
1439 for (Strip &strip : *seq::active_seqbase_get(ed)) {
1440 if ((strip.flag & SEQ_SELECT) == 0) {
1441 continue;
1442 }
1443 /* Only get unselected neighbors. */
1444 Strip *neighbor = find_neighboring_strip(scene, &strip, seq::Side::Left, 0);
1445 if (neighbor) {
1446 neighbor->flag |= SEQ_SELECT;
1447 changed = true;
1448 }
1449 neighbor = find_neighboring_strip(scene, &strip, seq::Side::Right, 0);
1450 if (neighbor) {
1451 neighbor->flag |= SEQ_SELECT;
1452 changed = true;
1453 }
1454 }
1455
1456 return changed;
1457}
1458
1459/* Select only one linked strip on each side. */
1460static bool select_more_less_impl(Scene *scene, bool select_more)
1461{
1462 Editing *ed = seq::editing_get(scene);
1463
1464 if (ed == nullptr) {
1465 return false;
1466 }
1467
1468 Set<Strip *> neighbors;
1469 const int neighbor_selection_filter = select_more ? 0 : 1;
1470 const eStripFlag selection_filter = select_more ? SEQ_SELECT : SEQ_FLAG_NONE;
1471
1472 for (Strip &strip : *seq::active_seqbase_get(ed)) {
1473 if ((strip.flag & SEQ_SELECT) != selection_filter) {
1474 continue;
1475 }
1476 Strip *neighbor = find_neighboring_strip(
1477 scene, &strip, seq::Side::Left, neighbor_selection_filter);
1478 if (neighbor) {
1479 neighbors.add(neighbor);
1480 }
1481 neighbor = find_neighboring_strip(scene, &strip, seq::Side::Right, neighbor_selection_filter);
1482 if (neighbor) {
1483 neighbors.add(neighbor);
1484 }
1485 }
1486
1487 bool changed = false;
1488 for (Strip *neighbor : neighbors) {
1489 if (select_more) {
1490 neighbor->flag |= SEQ_SELECT;
1491 }
1492 else {
1493 neighbor->flag &= ~SEQ_SELECT;
1494 }
1495 changed = true;
1496 }
1497 return changed;
1498}
1499
1501{
1503
1504 if (!select_more_less_impl(scene, true)) {
1505 return OPERATOR_CANCELLED;
1506 }
1507
1509
1511
1512 return OPERATOR_FINISHED;
1513}
1514
1516{
1517 /* Identifiers. */
1518 ot->name = "Select More";
1519 ot->idname = "SEQUENCER_OT_select_more";
1520 ot->description = "Select more strips adjacent to the current selection";
1521
1522 /* API callbacks. */
1525
1526 /* Flags. */
1528}
1529
1531
1532/* -------------------------------------------------------------------- */
1535
1537{
1539
1540 if (!select_more_less_impl(scene, false)) {
1541 return OPERATOR_CANCELLED;
1542 }
1543
1545
1547
1548 return OPERATOR_FINISHED;
1549}
1550
1552{
1553 /* Identifiers. */
1554 ot->name = "Select Less";
1555 ot->idname = "SEQUENCER_OT_select_less";
1556 ot->description = "Shrink the current selection of adjacent selected strips";
1557
1558 /* API callbacks. */
1561
1562 /* Flags. */
1564}
1565
1567
1568/* -------------------------------------------------------------------- */
1571
1573 wmOperator *op,
1574 const wmEvent *event)
1575{
1577 const View2D *v2d = ui::view2d_fromcontext(C);
1578
1579 bool extend = RNA_boolean_get(op->ptr, "extend");
1580
1581 float mouse_co[2];
1582 ui::view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouse_co[0], &mouse_co[1]);
1583
1584 /* This works like UV, not mesh. */
1585 StripSelection mouse_selection = pick_strip_and_handle(scene, v2d, mouse_co);
1586 if (!mouse_selection.strip1) {
1587 return OPERATOR_FINISHED; /* User error as with mesh?? */
1588 }
1589
1590 if (extend == 0) {
1591 deselect_all_strips(scene);
1592 }
1593
1594 mouse_selection.strip1->flag |= SEQ_SELECT;
1595
1596 bool selected = true;
1597 while (selected) {
1598 selected = select_linked_internal(scene);
1599 }
1600
1602
1604
1605 return OPERATOR_FINISHED;
1606}
1607
1609{
1610 /* Identifiers. */
1611 ot->name = "Select Pick Linked";
1612 ot->idname = "SEQUENCER_OT_select_linked_pick";
1613 ot->description = "Select a chain of linked strips nearest to the mouse pointer";
1614
1615 /* API callbacks. */
1618
1619 /* Flags. */
1621
1622 /* Properties. */
1623 PropertyRNA *prop;
1624 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
1626}
1627
1629
1630/* -------------------------------------------------------------------- */
1633
1635{
1637 bool selected;
1638
1639 selected = true;
1640 while (selected) {
1641 selected = select_linked_internal(scene);
1642 }
1643
1645
1647
1648 return OPERATOR_FINISHED;
1649}
1650
1652{
1653 /* Identifiers. */
1654 ot->name = "Select Linked";
1655 ot->idname = "SEQUENCER_OT_select_linked";
1656 ot->description = "Select all strips adjacent to the current selection";
1657
1658 /* API callbacks. */
1661
1662 /* Flags. */
1664}
1665
1667
1668/* -------------------------------------------------------------------- */
1671
1672enum {
1679};
1680
1682 {SEQ_SELECT_HANDLES_SIDE_LEFT, "LEFT", 0, "Left", ""},
1683 {SEQ_SELECT_HANDLES_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
1684 {SEQ_SELECT_HANDLES_SIDE_BOTH, "BOTH", 0, "Both", ""},
1685 {SEQ_SELECT_HANDLES_SIDE_LEFT_NEIGHBOR, "LEFT_NEIGHBOR", 0, "Left Neighbor", ""},
1686 {SEQ_SELECT_HANDLES_SIDE_RIGHT_NEIGHBOR, "RIGHT_NEIGHBOR", 0, "Right Neighbor", ""},
1687 {SEQ_SELECT_HANDLES_SIDE_BOTH_NEIGHBORS, "BOTH_NEIGHBORS", 0, "Both Neighbors", ""},
1688 {0, nullptr, 0, nullptr, nullptr},
1689};
1690
1692{
1694 Editing *ed = seq::editing_get(scene);
1695 int sel_side = RNA_enum_get(op->ptr, "side");
1696 for (Strip &strip : *ed->current_strips()) {
1697 if (strip.flag & SEQ_SELECT) {
1698 Strip *l_neighbor = find_neighboring_strip(scene, &strip, seq::Side::Left, -1);
1699 Strip *r_neighbor = find_neighboring_strip(scene, &strip, seq::Side::Right, -1);
1700
1701 switch (sel_side) {
1703 strip.flag &= ~SEQ_RIGHTSEL;
1704 strip.flag |= SEQ_LEFTSEL;
1705 break;
1707 strip.flag &= ~SEQ_LEFTSEL;
1708 strip.flag |= SEQ_RIGHTSEL;
1709 break;
1711 strip.flag |= SEQ_LEFTSEL | SEQ_RIGHTSEL;
1712 break;
1714 if (l_neighbor) {
1715 if (!(l_neighbor->flag & SEQ_SELECT)) {
1716 l_neighbor->flag |= SEQ_RIGHTSEL;
1717 }
1718 }
1719 break;
1721 if (r_neighbor) {
1722 if (!(r_neighbor->flag & SEQ_SELECT)) {
1723 r_neighbor->flag |= SEQ_LEFTSEL;
1724 }
1725 }
1726 break;
1728 if (l_neighbor) {
1729 if (!(l_neighbor->flag & SEQ_SELECT)) {
1730 l_neighbor->flag |= SEQ_RIGHTSEL;
1731 }
1732 }
1733 if (r_neighbor) {
1734 if (!(r_neighbor->flag & SEQ_SELECT)) {
1735 r_neighbor->flag |= SEQ_LEFTSEL;
1736 }
1737 break;
1738 }
1739 }
1740 }
1741 }
1742 /* Select strips. */
1743 for (Strip &strip : *ed->current_strips()) {
1744 if ((strip.flag & SEQ_LEFTSEL) || (strip.flag & SEQ_RIGHTSEL)) {
1745 if (!(strip.flag & SEQ_SELECT)) {
1746 strip.flag |= SEQ_SELECT;
1747 }
1748 }
1749 }
1750
1752
1754
1755 return OPERATOR_FINISHED;
1756}
1757
1759{
1760 /* Identifiers. */
1761 ot->name = "Select Handles";
1762 ot->idname = "SEQUENCER_OT_select_handles";
1763 ot->description = "Select gizmo handles on the sides of the selected strip";
1764
1765 /* API callbacks. */
1768
1769 /* Flags. */
1771
1772 /* Properties. */
1773 RNA_def_enum(ot->srna,
1774 "side",
1777 "Side",
1778 "The side of the handle that is selected");
1779}
1780
1782
1783/* -------------------------------------------------------------------- */
1786
1788{
1790 Editing *ed = seq::editing_get(scene);
1791 const bool extend = RNA_boolean_get(op->ptr, "extend");
1792 const int side = RNA_enum_get(op->ptr, "side");
1793
1794 if (ed == nullptr) {
1795 return OPERATOR_CANCELLED;
1796 }
1797 if (extend == false) {
1798 deselect_all_strips(scene);
1799 }
1800 const int timeline_frame = scene->r.cfra;
1801 for (Strip &strip : *seq::active_seqbase_get(ed)) {
1802 bool test = false;
1803 switch (side) {
1804 case -1:
1805 test = (timeline_frame >= strip.right_handle(scene));
1806 break;
1807 case 1:
1808 test = (timeline_frame <= strip.left_handle());
1809 break;
1810 case 2:
1811 test = strip.intersects_frame(scene, timeline_frame);
1812 break;
1813 }
1814
1815 if (test) {
1816 strip.flag |= SEQ_SELECT;
1817 }
1818 }
1819
1821
1823
1824 return OPERATOR_FINISHED;
1825}
1826
1828{
1829 static const EnumPropertyItem sequencer_select_left_right_types[] = {
1830 {-1, "LEFT", 0, "Left", "Select to the left of the current frame"},
1831 {1, "RIGHT", 0, "Right", "Select to the right of the current frame"},
1832 {2, "CURRENT", 0, "Current Frame", "Select intersecting with the current frame"},
1833 {0, nullptr, 0, nullptr, nullptr},
1834 };
1835
1836 /* Identifiers. */
1837 ot->name = "Select Side of Frame";
1838 ot->idname = "SEQUENCER_OT_select_side_of_frame";
1839 ot->description = "Select strips relative to the current frame";
1840
1841 /* API callbacks. */
1844
1845 /* Flags. */
1846 ot->flag = OPTYPE_UNDO;
1847
1848 /* Properties. */
1849 PropertyRNA *prop;
1850 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
1852 ot->prop = RNA_def_enum(ot->srna,
1853 "side",
1854 sequencer_select_left_right_types,
1855 0,
1856 "Side",
1857 "Whether to select all strips to the left or right of the current "
1858 "frame, or just those intersecting with it");
1859}
1860
1862
1863/* -------------------------------------------------------------------- */
1866
1868{
1870 Editing *ed = seq::editing_get(scene);
1871
1872 const auto sel_side = seq::Side(RNA_enum_get(op->ptr, "side"));
1873 const int frame_init = sel_side == seq::Side::Left ? INT_MIN : INT_MAX;
1874 int frame_ranges[seq::MAX_CHANNELS];
1875 bool selected = false;
1876
1877 std::fill_n(frame_ranges, ARRAY_SIZE(frame_ranges), frame_init);
1878
1879 for (Strip &strip : *ed->current_strips()) {
1880 if (strip.channel >= seq::MAX_CHANNELS) [[unlikely]] {
1881 continue;
1882 }
1883 int *frame_limit_p = &frame_ranges[strip.channel];
1884 if (strip.flag & SEQ_SELECT) {
1885 selected = true;
1886 if (sel_side == seq::Side::Left) {
1887 *frame_limit_p = max_ii(*frame_limit_p, strip.left_handle());
1888 }
1889 else {
1890 *frame_limit_p = min_ii(*frame_limit_p, strip.left_handle());
1891 }
1892 }
1893 }
1894
1895 if (selected == false) {
1896 return OPERATOR_CANCELLED;
1897 }
1898
1899 select_active_side_range(ed->current_strips(), sel_side, frame_ranges, frame_init);
1900
1902
1904
1905 return OPERATOR_FINISHED;
1906}
1907
1909{
1910 /* Identifiers. */
1911 ot->name = "Select Side";
1912 ot->idname = "SEQUENCER_OT_select_side";
1913 ot->description = "Select strips on the nominated side of the selected strips";
1914
1915 /* API callbacks. */
1918
1919 /* Flags. */
1921
1922 /* Properties. */
1923 RNA_def_enum(ot->srna,
1924 "side",
1926 int(seq::Side::Both),
1927 "Side",
1928 "The side to which the selection is applied");
1929}
1930
1932
1933/* -------------------------------------------------------------------- */
1936
1938 const Strip *strip,
1939 const rctf *rect)
1940{
1941 const Array<float2> strip_image_quad = seq::image_transform_quad_get(scene, strip);
1942 float rect_quad[4][2] = {{rect->xmax, rect->ymax},
1943 {rect->xmax, rect->ymin},
1944 {rect->xmin, rect->ymin},
1945 {rect->xmin, rect->ymax}};
1946
1947 return strip_point_image_isect(scene, strip, rect_quad[0]) ||
1948 strip_point_image_isect(scene, strip, rect_quad[1]) ||
1949 strip_point_image_isect(scene, strip, rect_quad[2]) ||
1950 strip_point_image_isect(scene, strip, rect_quad[3]) ||
1952 strip_image_quad[0], rect_quad[0], rect_quad[1], rect_quad[2], rect_quad[3]) ||
1954 strip_image_quad[1], rect_quad[0], rect_quad[1], rect_quad[2], rect_quad[3]) ||
1956 strip_image_quad[2], rect_quad[0], rect_quad[1], rect_quad[2], rect_quad[3]) ||
1958 strip_image_quad[3], rect_quad[0], rect_quad[1], rect_quad[2], rect_quad[3]);
1959}
1960
1962 const rctf *rect,
1963 const eSelectOp mode)
1964{
1966 Editing *ed = seq::editing_get(scene);
1967 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
1968 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
1969 SpaceSeq *sseq = CTX_wm_space_seq(C);
1970
1972 scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
1973 for (Strip *strip : strips) {
1974 if (!strip_box_select_rect_image_isect(scene, strip, rect)) {
1975 continue;
1976 }
1977
1978 if (ELEM(mode, SEL_OP_ADD, SEL_OP_SET)) {
1979 strip->flag |= SEQ_SELECT;
1980 }
1981 else {
1982 BLI_assert(mode == SEL_OP_SUB);
1983 strip->flag &= ~SEQ_SELECT;
1984 }
1985 }
1986}
1987
1989{
1992 Editing *ed = seq::editing_get(scene);
1993
1994 if (ed == nullptr) {
1995 return OPERATOR_CANCELLED;
1996 }
1997
2000 }
2001
2002 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
2003 const bool handles = RNA_boolean_get(op->ptr, "include_handles");
2004 const bool select = (sel_op != SEL_OP_SUB);
2005
2006 bool changed = false;
2007
2008 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
2009 changed |= deselect_all_strips(scene);
2010 }
2011
2012 rctf rectf;
2014 ui::view2d_region_to_view_rctf(v2d, &rectf, &rectf);
2015
2016 ARegion *region = CTX_wm_region(C);
2017 if (region->regiontype == RGN_TYPE_PREVIEW) {
2019 return OPERATOR_CANCELLED;
2020 }
2021 seq_box_select_strip_from_preview(C, &rectf, sel_op);
2023 return OPERATOR_FINISHED;
2024 }
2025
2026 for (Strip &strip : *ed->current_strips()) {
2027 rctf rq = strip_bounds_get(scene, &strip);
2028 if (BLI_rctf_isect(&rq, &rectf, nullptr)) {
2029 if (handles) {
2030 /* Get the clickable handle size, ignoring padding. */
2031 float handsize = inner_clickable_handle_size_get(scene, &strip, v2d) * 4;
2032
2033 /* Right handle. */
2034 if (rectf.xmax > (strip.right_handle(scene) - handsize)) {
2035 if (select) {
2036 strip.flag |= SEQ_SELECT | SEQ_RIGHTSEL;
2037 }
2038 else {
2039 /* Deselect the strip if it's left with no handles selected. */
2040 if ((strip.flag & SEQ_RIGHTSEL) && ((strip.flag & SEQ_LEFTSEL) == 0)) {
2041 strip.flag &= ~SEQ_SELECT;
2042 }
2043 strip.flag &= ~SEQ_RIGHTSEL;
2044 }
2045
2046 changed = true;
2047 }
2048 /* Left handle. */
2049 if (rectf.xmin < (strip.left_handle() + handsize)) {
2050 if (select) {
2051 strip.flag |= SEQ_SELECT | SEQ_LEFTSEL;
2052 }
2053 else {
2054 /* Deselect the strip if it's left with no handles selected. */
2055 if ((strip.flag & SEQ_LEFTSEL) && ((strip.flag & SEQ_RIGHTSEL) == 0)) {
2056 strip.flag &= ~SEQ_SELECT;
2057 }
2058 strip.flag &= ~SEQ_LEFTSEL;
2059 }
2060 }
2061
2062 changed = true;
2063 }
2064
2065 /* Regular box selection. */
2066 else {
2067 SET_FLAG_FROM_TEST(strip.flag, select, SEQ_SELECT);
2068 strip.flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
2069 changed = true;
2070 }
2071
2072 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
2073 if (!ignore_connections) {
2074 /* Propagate selection to connected strips. */
2075 StripSelection selection;
2076 selection.strip1 = &strip;
2078 }
2079 }
2080 }
2081
2082 if (!changed) {
2083 return OPERATOR_CANCELLED;
2084 }
2085
2087
2088 return OPERATOR_FINISHED;
2089}
2090
2092 wmOperator *op,
2093 const wmEvent *event)
2094{
2096 const View2D *v2d = ui::view2d_fromcontext(C);
2097 ARegion *region = CTX_wm_region(C);
2098
2100 return OPERATOR_CANCELLED;
2101 }
2102
2103 const bool tweak = RNA_boolean_get(op->ptr, "tweak");
2104
2105 if (tweak) {
2106 int mval[2];
2107 float mouse_co[2];
2108 WM_event_drag_start_mval(event, region, mval);
2109 ui::view2d_region_to_view(v2d, mval[0], mval[1], &mouse_co[0], &mouse_co[1]);
2110
2111 StripSelection selection = pick_strip_and_handle(scene, v2d, mouse_co);
2112
2113 if (selection.strip1 != nullptr) {
2115 }
2116 }
2117
2118 const wmOperatorStatus opstatus = WM_gesture_box_invoke(C, op, event);
2119 const SpaceSeq *sseq = CTX_wm_space_seq(C);
2120
2121 wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
2122 if ((sseq->flag & SEQ_CLAMP_VIEW) && gesture->edge_pan_data && scene != nullptr &&
2123 region->regiontype == RGN_TYPE_WINDOW)
2124 {
2125 const rctf view_bounds = sequencer_clamped_view_bounds_get(C, region);
2126 gesture->edge_pan_data->limit.ymin = view_bounds.ymin;
2127 gesture->edge_pan_data->limit.ymax = view_bounds.ymax;
2128 }
2129
2130 return opstatus;
2131}
2132
2134{
2135 PropertyRNA *prop;
2136
2137 /* Identifiers. */
2138 ot->name = "Box Select";
2139 ot->idname = "SEQUENCER_OT_select_box";
2140 ot->description = "Select strips using box selection";
2141
2142 /* API callbacks. */
2147
2149
2150 /* Flags. */
2151 ot->flag = OPTYPE_UNDO;
2152
2153 /* Properties. */
2156
2157 prop = RNA_def_boolean(
2158 ot->srna,
2159 "tweak",
2160 false,
2161 "Tweak",
2162 "Make box select pass through to sequence slide when the cursor is hovering on a strip");
2164
2165 prop = RNA_def_boolean(
2166 ot->srna, "include_handles", false, "Select Handles", "Select the strips and their handles");
2168
2169 prop = RNA_def_boolean(ot->srna,
2170 "ignore_connections",
2171 false,
2172 "Ignore Connections",
2173 "Select strips individually whether or not they are connected");
2175}
2176
2177
2178/* -------------------------------------------------------------------- */
2182 const rcti *clip_rect,
2183 const Span<int2> mcoords,
2184 const float co_test[2])
2185{
2186 int co_screen[2];
2188 &region->v2d, co_test[0], co_test[1], &co_screen[0], &co_screen[1]) &&
2189 BLI_rcti_isect_pt_v(clip_rect, co_screen) &&
2190 BLI_lasso_is_point_inside(mcoords, co_screen[0], co_screen[1], V2D_IS_CLIPPED))
2191 {
2192 return true;
2193 }
2194 return false;
2195}
2196
2197static bool rcti_in_lasso(const rcti rect, const Span<int2> mcoords)
2198{
2199 rcti lasso_rect;
2200 BLI_lasso_boundbox(&lasso_rect, mcoords);
2201 /* Check if edge of strip is in the lasso. */
2203 mcoords, rect.xmin, rect.ymin, rect.xmax, rect.ymin, V2D_IS_CLIPPED) ||
2205 mcoords, rect.xmax, rect.ymin, rect.xmax, rect.ymax, V2D_IS_CLIPPED) ||
2207 mcoords, rect.xmax, rect.ymax, rect.xmin, rect.ymax, V2D_IS_CLIPPED) ||
2209 mcoords, rect.xmin, rect.ymax, rect.xmin, rect.ymin, V2D_IS_CLIPPED))
2210 {
2211 return true;
2212 }
2213
2214 /* Check if lasso is in the strip rect. Used when the lasso is only inside one strip. */
2215 if (BLI_rcti_inside_rcti(&rect, &lasso_rect)) {
2216 return true;
2217 }
2218 return false;
2219}
2220
2222 const Span<int2> mcoords,
2223 ARegion *region,
2224 const eSelectOp sel_op)
2225{
2227 Editing *ed = seq::editing_get(scene);
2228
2229 bool changed = false;
2230 const bool select = (sel_op != SEL_OP_SUB);
2231
2232 for (Strip &strip : ed->seqbase) {
2233 rctf strip_rct = strip_bounds_get(scene, &strip);
2234 rcti region_rct;
2236 &region->v2d, strip_rct.xmin, strip_rct.ymin, &region_rct.xmin, &region_rct.ymin);
2238 &region->v2d, strip_rct.xmax, strip_rct.ymax, &region_rct.xmax, &region_rct.ymax);
2239
2240 if (rcti_in_lasso(region_rct, mcoords)) {
2241 SET_FLAG_FROM_TEST(strip.flag, select, SEQ_SELECT);
2242 changed = true;
2243 }
2244 }
2245 return changed;
2246}
2247
2249 Editing *ed,
2250 const Span<int2> mcoords,
2251 const eSelectOp sel_op)
2252{
2254 const ARegion *region = CTX_wm_region(C);
2255
2256 bool changed = false;
2257 rcti rect;
2258 BLI_lasso_boundbox(&rect, mcoords);
2259
2260 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
2261 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2262 SpaceSeq *sseq = CTX_wm_space_seq(C);
2263
2265 scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
2266 for (Strip *strip : strips) {
2268 if (do_lasso_select_is_origin_inside(region, &rect, mcoords, origin)) {
2269 changed = true;
2270 if (ELEM(sel_op, SEL_OP_ADD, SEL_OP_SET)) {
2271 strip->flag |= SEQ_SELECT;
2272 }
2273 else {
2274 BLI_assert(sel_op == SEL_OP_SUB);
2275 strip->flag &= ~SEQ_SELECT;
2276 }
2277 }
2278 }
2279
2280 return changed;
2281}
2282
2284{
2286 ARegion *region = CTX_wm_region(C);
2288 Editing *ed = seq::editing_get(scene);
2289
2290 if (ed == nullptr) {
2291 return OPERATOR_CANCELLED;
2292 }
2293
2294 if (mcoords.is_empty()) {
2295 return OPERATOR_PASS_THROUGH;
2296 }
2297
2298 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
2299 const bool use_pre_deselect = SEL_OP_USE_PRE_DESELECT(sel_op);
2300 bool changed = false;
2301
2302 if (use_pre_deselect) {
2303 changed |= deselect_all_strips(scene);
2304 }
2305
2306 if (region->regiontype == RGN_TYPE_PREVIEW) {
2307 changed = do_lasso_select_preview(C, ed, mcoords, sel_op);
2308 }
2309 else {
2310 changed = do_lasso_select_timeline(C, mcoords, region, sel_op);
2311 }
2312
2313 if (changed) {
2315 return OPERATOR_FINISHED;
2316 }
2317
2318 return OPERATOR_CANCELLED;
2319}
2320
2322{
2323 ot->name = "Lasso Select";
2324 ot->description = "Select strips using lasso selection";
2325 ot->idname = "SEQUENCER_OT_select_lasso";
2326
2332
2333 /* flags */
2335
2336 /* properties */
2339}
2340
2341
2342/* -------------------------------------------------------------------- */
2346 const Strip *strip,
2347 const int *radius,
2348 const float2 mval)
2349{
2351
2352 float dx = origin.x - float(mval[0]);
2353 float dy = origin.y - float(mval[1]);
2354 float dist_sq = sqrt(dx * dx + dy * dy);
2355
2356 return dist_sq <= *radius;
2357}
2358
2360 int radius,
2361 const float2 mval,
2362 const eSelectOp mode)
2363{
2365 Editing *ed = seq::editing_get(scene);
2366 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
2367 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2368 SpaceSeq *sseq = CTX_wm_space_seq(C);
2369
2371 scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
2372 for (Strip *strip : strips) {
2373 if (!strip_circle_select_radius_image_isect(scene, strip, &radius, mval)) {
2374 continue;
2375 }
2376
2377 if (ELEM(mode, SEL_OP_ADD, SEL_OP_SET)) {
2378 strip->flag |= SEQ_SELECT;
2379 }
2380 else {
2381 BLI_assert(mode == SEL_OP_SUB);
2382 strip->flag &= ~SEQ_SELECT;
2383 }
2384 }
2385}
2386
2388 const float xy[2],
2389 const float x_radius,
2390 const float y_radius)
2391{
2392 float dx, dy;
2393
2394 if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
2395 dx = 0;
2396 }
2397 else {
2398 dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
2399 }
2400
2401 if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
2402 dy = 0;
2403 }
2404 else {
2405 dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
2406 }
2407
2408 return ((dx * dx) / (x_radius * x_radius) + (dy * dy) / (y_radius * y_radius) <= 1.0f);
2409}
2411{
2412 const int radius = RNA_int_get(op->ptr, "radius");
2413 const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")};
2414 wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
2415 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
2416
2419 Editing *ed = seq::editing_get(scene);
2420 ARegion *region = CTX_wm_region(C);
2421
2422 const bool use_pre_deselect = SEL_OP_USE_PRE_DESELECT(sel_op);
2423
2424 if (use_pre_deselect && WM_gesture_is_modal_first(gesture)) {
2425 deselect_all_strips(scene);
2427 }
2428
2429 if (ed == nullptr) {
2430 return OPERATOR_CANCELLED;
2431 }
2432
2433 float2 view_mval;
2434 ui::view2d_region_to_view(v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
2435 float pixel_radius = radius / ui::view2d_scale_get_x(v2d);
2436
2437 if (region->regiontype == RGN_TYPE_PREVIEW) {
2438 seq_circle_select_strip_from_preview(C, pixel_radius, view_mval, sel_op);
2440 return OPERATOR_FINISHED;
2441 }
2442
2443 float x_radius = radius / ui::view2d_scale_get_x(v2d);
2444 float y_radius = radius / ui::view2d_scale_get_y(v2d);
2445 bool changed = false;
2446 for (Strip &strip : *ed->current_strips()) {
2447 rctf rq = strip_bounds_get(scene, &strip);
2448 /* Use custom function to check the distance because in timeline the circle is a ellipse. */
2449 if (check_circle_intersection_in_timeline(&rq, view_mval, x_radius, y_radius)) {
2450 if (ELEM(sel_op, SEL_OP_ADD, SEL_OP_SET)) {
2451 strip.flag |= SEQ_SELECT;
2452 }
2453 else {
2454 BLI_assert(sel_op == SEL_OP_SUB);
2455 strip.flag &= ~SEQ_SELECT;
2456 }
2457 changed = true;
2458
2459 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
2460 if (!ignore_connections) {
2461 /* Propagate selection to connected strips. */
2462 StripSelection selection;
2463 selection.strip1 = &strip;
2465 }
2466 }
2467 }
2468 if (changed) {
2470 }
2471 return OPERATOR_FINISHED;
2472}
2473
2475{
2476 PropertyRNA *prop;
2477
2478 ot->name = "Circle Select";
2479 ot->description = "Select strips using circle selection";
2480 ot->idname = "SEQUENCER_OT_select_circle";
2481
2485
2487
2489
2490 /* flags */
2491 ot->flag = OPTYPE_UNDO;
2492
2493 /* properties */
2496
2497 prop = RNA_def_boolean(ot->srna,
2498 "ignore_connections",
2499 false,
2500 "Ignore Connections",
2501 "Select strips individually whether or not they are connected");
2503}
2504
2506
2507/* -------------------------------------------------------------------- */
2510
2511enum {
2517};
2518
2521 "TYPE",
2522 0,
2523 "Type",
2524 "Select all strips of the same specific type as the active strip"},
2526 "DATA",
2527 0,
2528 "Data",
2529 "Select strips referencing the same source data as the active strip, with matching file "
2530 "directory, scene, clip, or mask"},
2532 "STRIPS_UNDER_EFFECT",
2533 0,
2534 "Strips Under Effect",
2535 "Select strips that are inputs to the same effect type as the active strip"},
2537 "TIME_OVERLAP",
2538 0,
2539 "Time Overlap",
2540 "Select strips on any channel whose time range overlaps the active strip"},
2542 "VISUAL_OVERLAP",
2543 0,
2544 "Visual Overlap",
2545 "Select strips on channels below the active strip's channel whose time range overlaps, plus "
2546 "their full effect chains"},
2547 {0, nullptr, 0, nullptr, nullptr},
2548};
2549
2550/* TODO(john): We can't use `all_strips_from_context` because it checks for a `RGN_TYPE_PREVIEW`,
2551 * and when clicking an enum menu item in the UI, the context is always `RGN_TYPE_WINDOW`. Thus
2552 * we need a separate helper that passes `is_preview`. If we make changes to Sequencer & Preview
2553 * view type context, we can adjust the logic in there to allow it to be re-used here. */
2554static VectorSet<Strip *> strips_from_context(const Scene *scene, bool is_preview)
2555{
2556 const Editing *ed = seq::editing_get(scene);
2557 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
2558 ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2559
2560 VectorSet<Strip *> strips = is_preview ? seq::query_rendered_strips(
2561 scene, channels, seqbase, scene->r.cfra, 0) :
2562 seq::query_all_strips(seqbase);
2563 return strips;
2564}
2565
2566static bool strip_uses_data(const Strip *strip)
2567{
2569 STRIP_HAS_PATH(strip);
2570}
2571
2573 Strip *act_strip,
2574 std::optional<int> channel)
2575{
2576 bool changed = false;
2577
2578 for (Strip *strip : strips) {
2579 if ((!channel || strip->channel == *channel) && strip->type == act_strip->type) {
2580 strip->flag |= SEQ_SELECT;
2581 changed = true;
2582 }
2583 }
2584
2585 return changed;
2586}
2587
2589 Strip *act_strip,
2590 std::optional<int> channel)
2591{
2592 bool changed = false;
2593 const char *dirpath = act_strip->data ? act_strip->data->dirpath : nullptr;
2594
2595 if (!strip_uses_data(act_strip)) {
2596 return changed;
2597 }
2598
2599 auto select_matching = [&](auto condition) {
2600 for (Strip *strip : strips) {
2601 if ((!channel || strip->channel == *channel) && condition(strip)) {
2602 strip->flag |= SEQ_SELECT;
2603 changed = true;
2604 }
2605 }
2606 };
2607
2608 if (STRIP_HAS_PATH(act_strip) && dirpath) {
2609 select_matching([&](Strip *strip) {
2610 return STRIP_HAS_PATH(strip) && strip->data && STREQ(strip->data->dirpath, dirpath);
2611 });
2612 }
2613 else if (act_strip->type == STRIP_TYPE_SCENE) {
2614 Scene *scene = act_strip->scene;
2615 select_matching(
2616 [&](Strip *strip) { return strip->type == STRIP_TYPE_SCENE && strip->scene == scene; });
2617 }
2618 else if (act_strip->type == STRIP_TYPE_MOVIECLIP) {
2619 MovieClip *clip = act_strip->clip;
2620 select_matching(
2621 [&](Strip *strip) { return strip->type == STRIP_TYPE_MOVIECLIP && strip->clip == clip; });
2622 }
2623 else if (act_strip->type == STRIP_TYPE_MASK) {
2624 Mask *mask = act_strip->mask;
2625 select_matching(
2626 [&](Strip *strip) { return strip->type == STRIP_TYPE_MASK && strip->mask == mask; });
2627 }
2628
2629 return changed;
2630}
2631
2633 Strip *act_strip,
2634 std::optional<int> channel)
2635{
2636 bool changed = false;
2637 Set<StripType> effects;
2638
2639 for (const Strip *strip : strips) {
2640 if ((!channel || strip->channel == *channel) && strip->is_effect() &&
2641 seq::relation_is_effect_of_strip(strip, act_strip))
2642 {
2643 effects.add(strip->type);
2644 }
2645 }
2646
2647 for (Strip *strip : strips) {
2648 if ((!channel || strip->channel == *channel) && effects.contains(strip->type)) {
2649 if (strip->input1) {
2650 strip->input1->flag |= SEQ_SELECT;
2651 }
2652 if (strip->input2) {
2653 strip->input2->flag |= SEQ_SELECT;
2654 }
2655 changed = true;
2656 }
2657 }
2658
2659 return changed;
2660}
2661
2662static bool select_grouped_time_overlap(const Scene *scene,
2663 VectorSet<Strip *> strips,
2664 Strip *act_strip)
2665{
2666 bool changed = false;
2667
2668 for (Strip *strip : strips) {
2669 if (strip->left_handle() < act_strip->right_handle(scene) &&
2670 strip->right_handle(scene) > act_strip->left_handle())
2671 {
2672 strip->flag |= SEQ_SELECT;
2673 changed = true;
2674 }
2675 }
2676
2677 return changed;
2678}
2679
2680static bool select_grouped_visual_overlap(const Scene *scene,
2681 VectorSet<Strip *> strips,
2682 Strip *act_strip)
2683{
2684 Editing *ed = seq::editing_get(scene);
2685 VectorSet<Strip *> strips_to_select;
2686
2687 for (Strip *strip : strips) {
2688 if (strip->channel > act_strip->channel) {
2689 continue;
2690 }
2691 if (act_strip->right_handle(scene) <= strip->left_handle() ||
2692 act_strip->left_handle() >= strip->right_handle(scene))
2693 {
2694 continue;
2695 }
2696 strips_to_select.add(strip);
2697 }
2698
2700
2701 const bool changed = !strips_to_select.is_empty();
2702 if (changed) {
2703 for (Strip *strip : strips_to_select) {
2704 strip->flag |= SEQ_SELECT;
2705 }
2706 }
2707
2708 return changed;
2709}
2710
2712{
2714 SpaceSeq *sseq = CTX_wm_space_seq(C);
2715 Strip *act_strip = seq::select_active_get(scene);
2716 const bool is_preview = (sseq && (sseq->view == SEQ_VIEW_PREVIEW) &&
2717 (sseq->mainb == SEQ_DRAW_IMG_IMBUF));
2718
2719 VectorSet<Strip *> strips = strips_from_context(scene, is_preview);
2720 if (act_strip == nullptr || (is_preview && !strips.contains(act_strip))) {
2721 BKE_report(op->reports, RPT_ERROR, "No active strip in context");
2722 return OPERATOR_CANCELLED;
2723 }
2724
2725 const bool extend = RNA_boolean_get(op->ptr, "extend");
2726 bool changed = false;
2727 if (!extend) {
2728 deselect_all_strips(scene);
2729 changed = true;
2730 }
2731
2732 const int type = RNA_enum_get(op->ptr, "type");
2733 const std::optional<int> active_channel = (!is_preview &&
2734 RNA_boolean_get(op->ptr, "use_active_channel") &&
2735 act_strip != nullptr) ?
2736 std::optional<int>(act_strip->channel) :
2737 std::nullopt;
2738
2739 switch (type) {
2741 changed |= select_grouped_type(strips, act_strip, active_channel);
2742 break;
2744 changed |= select_grouped_data(strips, act_strip, active_channel);
2745 break;
2747 changed |= select_grouped_strips_under_effect(strips, act_strip, active_channel);
2748 break;
2750 changed |= select_grouped_time_overlap(scene, strips, act_strip);
2751 break;
2753 changed |= select_grouped_visual_overlap(scene, strips, act_strip);
2754 break;
2755 default:
2756 BLI_assert(0);
2757 break;
2758 }
2759
2760 if (changed) {
2763 return OPERATOR_FINISHED;
2764 }
2765
2766 return OPERATOR_CANCELLED;
2767}
2768
2770{
2771 /* Identifiers. */
2772 ot->name = "Select Grouped";
2773 ot->idname = "SEQUENCER_OT_select_grouped";
2774 ot->description = "Select all strips grouped by various properties";
2775
2776 /* API callbacks. */
2777 ot->invoke = WM_menu_invoke;
2780
2781 /* Flags. */
2783
2784 /* Properties. */
2785 ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", "");
2787 "extend",
2788 false,
2789 "Extend",
2790 "Extend selection instead of deselecting everything first");
2792 "use_active_channel",
2793 false,
2794 "Same Channel",
2795 "If selecting from the timeline, only consider strips on the same channel as "
2796 "the active strip");
2797}
2798
2800
2801/* -------------------------------------------------------------------- */
2804
2805/* Special pseudo-types for this operator. Use a high value to avoid clashing with `STRIP_TYPE`. */
2806enum {
2809};
2810
2812 {STRIP_TYPE_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
2813 {STRIP_TYPE_MOVIECLIP, "MOVIECLIP", ICON_TRACKER, "Clip", ""},
2814 {STRIP_TYPE_MASK, "MASK", ICON_MOD_MASK, "Mask", ""},
2816 {STRIP_TYPE_MOVIE, "MOVIE", ICON_FILE_MOVIE, "Movie", ""},
2817 {STRIP_TYPE_SOUND, "SOUND", ICON_FILE_SOUND, "Sound", ""},
2818 {STRIP_TYPE_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""},
2820 {STRIP_TYPE_COLOR, "COLOR", ICON_COLOR, "Color", ""},
2821 {STRIP_TYPE_TEXT, "TEXT", ICON_FONT_DATA, "Text", ""},
2823 {STRIP_TYPE_ADJUSTMENT, "ADJUSTMENT", ICON_COLOR, "Adjustment Layer", ""},
2824 {STRIP_TYPE_COMPOSITOR, "COMPOSITOR", ICON_NODE_COMPOSITING, "Compositor", ""},
2826 {SEQ_SELECT_TYPE_EFFECT, "EFFECT", ICON_SHADERFX, "Effect", ""},
2828 "VISUAL",
2829 ICON_BLANK1,
2830 "Visual",
2831 "All strips that can produce an image in the preview, which includes everything but sound "
2832 "strips"},
2833 {0, nullptr, 0, nullptr, nullptr},
2834};
2835
2837{
2839 SpaceSeq *sseq = CTX_wm_space_seq(C);
2840 Strip *act_strip = seq::select_active_get(scene);
2841 const bool is_preview = (sseq && (sseq->view == SEQ_VIEW_PREVIEW) &&
2842 (sseq->mainb == SEQ_DRAW_IMG_IMBUF));
2843
2844 const bool extend = RNA_boolean_get(op->ptr, "extend");
2845 bool changed = false;
2846 if (!extend) {
2847 deselect_all_strips(scene);
2848 changed = true;
2849 }
2850
2851 VectorSet<Strip *> strips = strips_from_context(scene, is_preview);
2852 const int type = RNA_enum_get(op->ptr, "type");
2853 const std::optional<int> active_channel = (!is_preview &&
2854 RNA_boolean_get(op->ptr, "use_active_channel") &&
2855 act_strip != nullptr) ?
2856 std::optional<int>(act_strip->channel) :
2857 std::nullopt;
2858
2859 for (Strip *strip : strips) {
2860 if (active_channel && strip->channel != *active_channel) {
2861 continue;
2862 }
2863
2864 bool match;
2865 if (type == SEQ_SELECT_TYPE_EFFECT) {
2866 match = strip->is_effect() && !ELEM(strip->type, STRIP_TYPE_COLOR, STRIP_TYPE_TEXT);
2867 }
2868 else if (type == SEQ_SELECT_TYPE_VISUAL) {
2869 match = strip->type != STRIP_TYPE_SOUND;
2870 }
2871 else {
2872 match = strip->type == type;
2873 }
2874 if (match) {
2875 strip->flag |= SEQ_SELECT;
2876 changed = true;
2877 }
2878 }
2879
2880 if (changed) {
2883 }
2884 return OPERATOR_FINISHED;
2885}
2886
2888{
2889 /* Identifiers. */
2890 ot->name = "Select by Type";
2891 ot->description = "Select all strips that are of a type";
2892 ot->idname = "SEQUENCER_OT_select_by_type";
2893
2894 /* API callbacks. */
2895 ot->invoke = WM_menu_invoke;
2898
2899 /* Flags. */
2901
2902 /* Properties. */
2903 ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_by_type_items, 0, "Type", "");
2905 "extend",
2906 false,
2907 "Extend",
2908 "Extend selection instead of deselecting everything first");
2910 "use_active_channel",
2911 false,
2912 "Same Channel",
2913 "If selecting from the timeline, only consider strips on the same channel as "
2914 "the active strip");
2915}
2916
2918
2919} // namespace blender::ed::vse
#define SELECT
Definition BKE_mask.hh:19
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define STRIP_OFSBOTTOM
#define STRIP_OFSTOP
#define STRIP_HAS_PATH(_strip)
#define SEL_OP_USE_PRE_DESELECT(sel_op)
Read Blender memory allocation and freeing.
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:762
#define C
Definition RandGen.cpp:29
#define UI_TIME_SCRUB_MARGIN_Y
Definition UI_view2d.hh:493
#define V2D_IS_CLIPPED
Definition UI_view2d.hh:46
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_SCENE
Definition WM_types.hh:391
#define NA_SELECTED
Definition WM_types.hh:639
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
bool is_empty() const
Definition BLI_array.hh:275
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
bool remove(const Key &key)
bool add(const Key &key)
bool contains(const Key &key) const
int64_t remove_if(Predicate &&predicate)
int64_t size() const
void append(const T &value)
const T & data(const Action &owning_action) const
MouseCoords(const View2D *v2d, int x, int y)
#define INT_MAX
#define condition(cond)
VectorSet< Strip * > selected_strips_from_context(bContext *C)
Strip * find_neighboring_strip(const Scene *scene, const Strip *test, const seq::Side lr, int sel)
bool sequencer_edit_poll(bContext *C)
static wmOperatorStatus sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool select_grouped_strips_under_effect(VectorSet< Strip * > strips, Strip *act_strip, std::optional< int > channel)
void SEQUENCER_OT_select_by_type(wmOperatorType *ot)
static void sequencer_copy_handles_to_selected_strips(const Scene *scene, const StripSelection &selection, VectorSet< Strip * > copy_to)
static void sequencer_select_linked_handle(const bContext *C, Strip *strip, const eStripHandle handle_clicked)
static Strip * strip_select_from_preview(const bContext *C, const int mval[2], const bool toggle, const bool extend, const bool center)
static bool do_lasso_select_is_origin_inside(const ARegion *region, const rcti *clip_rect, const Span< int2 > mcoords, const float co_test[2])
static void sequencer_select_side_of_frame(const bContext *C, const View2D *v2d, const int mval[2], Scene *scene)
bool retiming_overlay_enabled(const SpaceSeq *sseq)
static bool element_already_selected(const StripSelection &selection)
static wmOperatorStatus sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot)
static std::string sequencer_select_get_name(wmOperatorType *ot, PointerRNA *ptr)
static wmOperatorStatus sequencer_select_more_exec(bContext *C, wmOperator *)
static float inner_clickable_handle_size_get(const Scene *scene, const Strip *strip, const View2D *v2d)
static bool select_more_less_impl(Scene *scene, bool select_more)
rctf strip_bounds_get(const Scene *scene, const Strip *strip)
void SEQUENCER_OT_select_all(wmOperatorType *ot)
static bool check_circle_intersection_in_timeline(const rctf *rect, const float xy[2], const float x_radius, const float y_radius)
StripSelection pick_strip_and_handle(const struct Scene *scene, const View2D *v2d, float mouse_co[2])
static void sequencer_select_connected_strips(const StripSelection &selection)
void SEQUENCER_OT_select_box(wmOperatorType *ot)
static void select_surrounding_handles(Scene *scene, Strip *test)
void SEQUENCER_OT_select_circle(wmOperatorType *ot)
static bool strips_are_adjacent(const Scene *scene, const Strip *strip1, const Strip *strip2)
static void seq_circle_select_strip_from_preview(bContext *C, int radius, const float2 mval, const eSelectOp mode)
bool handle_is_selected(const Strip *strip, eStripHandle handle)
void SEQUENCER_OT_select_side_of_frame(wmOperatorType *ot)
void select_strip_single(Scene *scene, Strip *strip, bool deselect_all)
void SEQUENCER_OT_select_grouped(wmOperatorType *ot)
static void seq_box_select_strip_from_preview(const bContext *C, const rctf *rect, const eSelectOp mode)
SeqRetimingKey * try_to_realize_fake_keys(const Scene *scene, const View2D *v2d, Strip *strip, const int mval[2])
static int strip_sort_for_depth_select(const void *a, const void *b)
static wmOperatorStatus sequencer_select_by_type_exec(bContext *C, wmOperator *op)
static bool is_mouse_over_both_handles_of_adjacent_strips(const Scene *scene, Vector< Strip * > strips, const View2D *v2d, float mouse_co[2])
wmOperatorStatus sequencer_select_exec(bContext *C, wmOperator *op)
static bool do_lasso_select_timeline(bContext *C, const Span< int2 > mcoords, ARegion *region, const eSelectOp sel_op)
void SEQUENCER_OT_select(wmOperatorType *ot)
static bool strip_uses_data(const Strip *strip)
void SEQUENCER_OT_select_side(wmOperatorType *ot)
static wmOperatorStatus sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SEQUENCER_OT_select_less(wmOperatorType *ot)
static void select_active_side(ListBaseT< Strip > *seqbase, seq::Side sel_side, int channel, int frame)
static void select_linked_time_strip(const Scene *scene, const Strip *strip_source, const eStripHandle handle_clicked)
void SEQUENCER_OT_select_more(wmOperatorType *ot)
static bool select_grouped_data(VectorSet< Strip * > strips, Strip *act_strip, std::optional< int > channel)
static void strip_clickable_areas_get(const Scene *scene, const Strip *strip, const View2D *v2d, rctf *r_body, rctf *r_left_handle, rctf *r_right_handle)
static wmOperatorStatus sequencer_select_linked_exec(bContext *C, wmOperator *)
wmOperatorStatus sequencer_retiming_box_select_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_select_handles(wmOperatorType *ot)
static bool strip_circle_select_radius_image_isect(const Scene *scene, const Strip *strip, const int *radius, const float2 mval)
rctf sequencer_clamped_view_bounds_get(const bContext *C, ARegion *region)
static wmOperatorStatus vse_lasso_select_exec(bContext *C, wmOperator *op)
static VectorSet< Strip * > strips_from_context(const Scene *scene, bool is_preview)
void SEQUENCER_OT_select_lasso(wmOperatorType *ot)
static wmOperatorStatus sequencer_select_handle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static float strip_to_frame_distance(const Scene *scene, const View2D *v2d, const Strip *strip, float timeline_frame)
static Vector< Strip * > padded_strips_under_mouse_get(const Scene *scene, const View2D *v2d, float mouse_co[2])
static int strip_sort_for_center_select(const void *a, const void *b)
static const EnumPropertyItem prop_select_handles_side_types[]
static wmOperatorStatus vse_circle_select_exec(bContext *C, wmOperator *op)
Strip * strip_under_mouse_get(const Scene *scene, const View2D *v2d, const int mval[2])
void sequencer_select_do_updates(const bContext *C, Scene *scene)
static eStripHandle strip_handle_under_cursor_get(const Scene *scene, const Strip *strip, const View2D *v2d, float mouse_co[2])
bool sequencer_view_preview_only_poll(const bContext *C)
void SEQUENCER_OT_select_handle(wmOperatorType *ot)
static bool rcti_in_lasso(const rcti rect, const Span< int2 > mcoords)
static const EnumPropertyItem sequencer_prop_select_grouped_types[]
static void select_active_side_range(ListBaseT< Strip > *seqbase, const seq::Side sel_side, const int frame_ranges[seq::MAX_CHANNELS], const int frame_ignore)
bool deselect_all_strips(const Scene *scene)
static void select_linked_time(const Scene *scene, const StripSelection &selection, const bool extend, const bool deselect, const bool toggle)
bool sequencer_view_has_preview_poll(bContext *C)
wmOperatorStatus sequencer_retiming_select_all_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_select_side_exec(bContext *C, wmOperator *op)
SeqRetimingKey * retiming_mouseover_key_get(const Scene *scene, const View2D *v2d, const int mval[2], Strip **r_strip)
static const EnumPropertyItem sequencer_prop_select_by_type_items[]
static wmOperatorStatus sequencer_select_handles_exec(bContext *C, wmOperator *op)
static rctf strip_clickable_area_get(const Scene *scene, const View2D *v2d, const Strip *strip)
static bool select_grouped_time_overlap(const Scene *scene, VectorSet< Strip * > strips, Strip *act_strip)
static wmOperatorStatus sequencer_select_handle_exec(bContext *C, wmOperator *op)
static bool select_grouped_visual_overlap(const Scene *scene, VectorSet< Strip * > strips, Strip *act_strip)
void SEQUENCER_OT_select_linked(wmOperatorType *ot)
bool can_select_handle(const Scene *scene, const Strip *strip)
static wmOperatorStatus sequencer_select_grouped_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_de_select_all_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sequencer_select_less_exec(bContext *C, wmOperator *)
bool strip_point_image_isect(const Scene *scene, const Strip *strip, float point_view[2])
static bool select_grouped_type(VectorSet< Strip * > strips, Strip *act_strip, std::optional< int > channel)
const EnumPropertyItem prop_split_side_types[]
static bool select_linked_internal(Scene *scene)
static wmOperatorStatus sequencer_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void sequencer_select_set_active(Scene *scene, Strip *strip)
static void sequencer_select_strip_impl(const Editing *ed, Strip *strip, const eStripHandle handle_clicked, const bool extend, const bool deselect, const bool toggle)
VectorSet< Strip * > all_strips_from_context(bContext *C)
Vector< Strip * > sequencer_visible_strips_get(const bContext *C)
static wmOperatorStatus sequencer_box_select_exec(bContext *C, wmOperator *op)
static bool strip_box_select_rect_image_isect(const Scene *scene, const Strip *strip, const rctf *rect)
wmOperatorStatus sequencer_retiming_key_select_exec(bContext *C, wmOperator *op, SeqRetimingKey *key, const Strip *key_owner)
static bool do_lasso_select_preview(bContext *C, Editing *ed, const Span< int2 > mcoords, const eSelectOp sel_op)
void realize_fake_keys(const Scene *scene, Strip *strip)
VectorSet< Strip * > query_selected_strips(ListBaseT< Strip > *seqbase)
Definition iterator.cc:164
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:463
Array< float2 > image_transform_quad_get(const Scene *scene, const Strip *strip)
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
int retiming_key_frame_get(const Scene *scene, const Strip *strip, const SeqRetimingKey *key)
void expand_strips(Editing *ed, VectorSet< Strip * > &strips, const StripRelation include)
Definition iterator.cc:70
VectorSet< Strip * > query_all_strips(ListBaseT< Strip > *seqbase)
Definition iterator.cc:155
Strip * select_active_get(const Scene *scene)
constexpr int MAX_CHANNELS
int right_fake_key_frame_get(const Scene *scene, const Strip *strip)
bool is_strip_connected(const Strip *strip)
float2 image_transform_origin_preview_offset_get(const Scene *scene, const Strip *strip)
bool retiming_selection_clear(const Editing *ed)
void select_active_set(Scene *scene, Strip *strip)
bool retiming_show_keys(const Strip *strip)
int left_fake_key_frame_get(const Scene *scene, const Strip *strip)
SeqRetimingKey * retiming_key_get_by_frame(const Scene *scene, const Strip *strip, const int frame)
VectorSet< Strip * > connected_strips_get(const Strip *strip)
bool relation_is_effect_of_strip(const Strip *effect, const Strip *input)
bool transform_is_locked(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
bool retiming_keys_are_selected(const Scene *scene)
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
Definition channels.cc:26
VectorSet< Strip * > query_rendered_strips(const Scene *scene, ListBaseT< SeqTimelineChannel > *channels, ListBaseT< Strip > *seqbase, const int timeline_frame, const int displayed_channel)
Definition iterator.cc:239
float view2d_scale_get_y(const View2D *v2d)
Definition view2d.cc:1906
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
bool view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1684
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
float view2d_pixel_size_get_x(const View2D *v2d)
Definition view2d.cc:1920
float view2d_scale_get_x(const View2D *v2d)
Definition view2d.cc:1902
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
View2D * view2d_fromcontext(const bContext *C)
Definition view2d.cc:1836
MINLINE float min_ff(float a, float b)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::string ED_select_circle_get_name(wmOperatorType *ot, PointerRNA *ptr)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Scene * CTX_data_sequencer_scene(const bContext *C)
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
void ED_outliner_select_sync_from_sequence_tag(const bContext *C)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_operator_flag_only_pass_through_on_press(wmOperatorStatus retval, const wmEvent *event)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
MINLINE int max_ii(int a, int b)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool BLI_lasso_is_point_inside(Span< int2 > mcoords, int sx, int sy, int error_value)
Definition lasso_2d.cc:42
wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_select_all(wmOperatorType *ot)
SpaceSeq * CTX_wm_space_seq(const bContext *C)
MINLINE void mul_v2_v2(float r[2], const float a[2])
void WM_operator_properties_border_to_rctf(wmOperator *op, rctf *r_rect)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
wmOperatorStatus WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_mouse_select(wmOperatorType *ot)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
sqrt(x)+1/max(0
void WM_operator_properties_gesture_box(wmOperatorType *ot)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
void void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
Definition listbase.cc:319
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
float BLI_rctf_length_x(const rctf *rect, float x)
Definition rct.cc:173
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
MINLINE float square_f(float a)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
bool WM_cursor_test_motion_and_update(const int mval[2])
MINLINE void sub_v2_v2(float r[2], const float a[2])
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
bool ED_operator_sequencer_active(bContext *C)
bool WM_gesture_is_modal_first(const wmGesture *gesture)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
Definition rct.cc:200
bool BLI_lasso_is_edge_inside(Span< int2 > mcoords, int x0, int y0, int x1, int y1, int error_value)
Definition lasso_2d.cc:56
wmOperatorStatus WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
MINLINE int min_ii(int a, int b)
std::string ED_select_pick_get_name(wmOperatorType *ot, PointerRNA *ptr)
ARegion * CTX_wm_region(const bContext *C)
void WM_operator_properties_generic_select(wmOperatorType *ot)
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
Definition lasso_2d.cc:21
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
@ SPACE_SEQ_DESELECT_STRIP_HANDLE
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
#define sqrtf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eRegion_Type regiontype
struct Editing * ed
ListBaseT< TimeMarker > markers
struct RenderData r
eSpaceSeq_Flag flag
eSpaceSeq_RegionType mainb
eSpaceSeq_Displays view
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct ReportList * reports