Blender V5.3
anim_markers.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10
11#include "MEM_guardedalloc.h"
12
13#include "DNA_object_types.h"
14#include "DNA_scene_types.h"
15
16#include "BLI_listbase.hh"
17#include "BLI_math_vector_c.hh"
18#include "BLI_string.hh"
19#include "BLI_string_utf8.hh"
20#include "BLI_utildefines.hh"
21
22#include "BLT_translation.hh"
23
24#include "BKE_animsys.hh"
25#include "BKE_context.hh"
26#include "BKE_idprop.hh"
27#include "BKE_layer.hh"
28#include "BKE_main.hh"
29#include "BKE_report.hh"
30#include "BKE_scene.hh"
31#include "BKE_scene_context.hh"
32#include "BKE_screen.hh"
33#include "BKE_unit.hh"
34
35#include "RNA_access.hh"
36#include "RNA_define.hh"
37#include "RNA_enum_types.hh"
38
39#include "WM_api.hh"
40#include "WM_types.hh"
41
42#include "GPU_immediate.hh"
43#include "GPU_matrix.hh"
44#include "GPU_state.hh"
45
46#include "UI_interface.hh"
47#include "UI_interface_icons.hh"
48#include "UI_resources.hh"
49#include "UI_view2d.hh"
50
51#include "ED_anim_api.hh"
52#include "ED_keyframes_edit.hh"
53#include "ED_markers.hh"
54#include "ED_numinput.hh"
55#include "ED_object.hh"
56#include "ED_screen.hh"
57#include "ED_select_utils.hh"
58#include "ED_transform.hh"
59#include "ED_util.hh"
60
61#include "DEG_depsgraph.hh"
63
64namespace blender {
65
66/* -------------------------------------------------------------------- */
69
70ListBaseT<TimeMarker> *ED_scene_markers_get(const bContext *C, Scene *scene)
71{
72 if (!scene) {
73 return nullptr;
74 }
75
76 bAnimContext ac;
77 if (!ANIM_animdata_get_context(C, &ac)) {
78 return &scene->markers;
79 }
80 return ac.markers;
81}
82
84{
85 if (!scene) {
86 return nullptr;
87 }
88
89 bAnimContext ac;
90 if (!ANIM_animdata_get_context(C, &ac)) {
91 return &scene->id;
92 }
93
94 if (ac.active_action && ac.spacetype == SPACE_ACTION &&
96 {
97 const SpaceAction *saction = ac.area->spacedata.first_as<SpaceAction>();
98 if (saction->flag & SACTION_POSEMARKERS_SHOW) {
99 return &ac.active_action->id;
100 }
101 }
102 return &scene->id;
103}
104
105ListBaseT<TimeMarker> *ED_scene_markers_get_from_area(const Main &bmain,
106 Scene *scene,
107 ViewLayer *view_layer,
108 const ScrArea *area)
109{
110 if (!scene) {
111 return nullptr;
112 }
113
114 /* If the area is the dopesheet, AND it is configured to show scene markers (instead of
115 * pose/action markers), directly go for the scene markers. */
116 if (area->spacetype == SPACE_ACTION) {
117 const SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
118 if (!(saction->flag & SACTION_POSEMARKERS_SHOW)) {
119 return &scene->markers;
120 }
121 }
122
123 bAction *active_action = ANIM_active_action_from_area(bmain, scene, view_layer, area);
124 if (active_action) {
125 return &active_action->markers;
126 }
127 return &scene->markers;
128}
129
130/* ............. */
131
132ListBaseT<TimeMarker> *ED_context_get_markers(const bContext *C)
133{
135}
136
137ListBaseT<TimeMarker> *ED_sequencer_context_get_markers(const bContext *C)
138{
140}
141
142/* --------------------------------- */
143
145 ListBaseT<TimeMarker> *markers, Scene *scene, int mode, float value, char side)
146{
147 float cfra = float(scene->r.cfra);
148 int changed_tot = 0;
149
150 /* sanity check - no markers, or locked markers */
151 if ((scene->toolsettings->lock_markers) || (markers == nullptr)) {
152 return changed_tot;
153 }
154
155 /* affect selected markers - it's unlikely that we will want to affect all in this way? */
156 for (TimeMarker &marker : *markers) {
157 if (marker.flag & SELECT) {
158 switch (mode) {
161 /* apply delta if marker is on the right side of the current frame */
162 if ((side == 'B') || (side == 'L' && marker.frame < cfra) ||
163 (side == 'R' && marker.frame >= cfra))
164 {
165 marker.frame += round_fl_to_int(value);
166 changed_tot++;
167 }
168 break;
169 }
171 /* rescale the distance between the marker and the current frame */
172 marker.frame = cfra + round_fl_to_int(float(marker.frame - cfra) * value);
173 changed_tot++;
174 break;
175 }
176 }
177 }
178 }
179
180 return changed_tot;
181}
182
183/* --------------------------------- */
184
185TimeMarker *ED_markers_find_nearest_marker(ListBaseT<TimeMarker> *markers, const float frame)
186{
187 if (markers == nullptr || markers->is_empty()) {
188 return nullptr;
189 }
190
191 /* Always initialize the first so it's guaranteed to return a marker
192 * even if `frame` is NAN or the deltas are not finite. see: #136059. */
193 TimeMarker *marker = markers->first();
194 TimeMarker *nearest = marker;
195 float min_dist = fabsf(float(marker->frame) - frame);
196 for (marker = marker->next; marker; marker = marker->next) {
197 const float dist = fabsf(float(marker->frame) - frame);
198 if (dist < min_dist) {
199 min_dist = dist;
200 nearest = marker;
201 }
202 }
203
204 return nearest;
205}
206
207int ED_markers_find_nearest_marker_time(ListBaseT<TimeMarker> *markers, float x)
208{
209 TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x);
210 return (nearest) ? (nearest->frame) : round_fl_to_int(x);
211}
212
213void ED_markers_get_minmax(ListBaseT<TimeMarker> *markers,
214 short sel,
215 float *r_first,
216 float *r_last)
217{
218 float min, max;
219
220 /* sanity check */
221 // printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
222 if (ELEM(nullptr, markers, markers->first(), markers->last())) {
223 *r_first = 0.0f;
224 *r_last = 0.0f;
225 return;
226 }
227
228 min = FLT_MAX;
229 max = -FLT_MAX;
230 for (TimeMarker &marker : *markers) {
231 if (!sel || (marker.flag & SELECT)) {
232 if (marker.frame < min) {
233 min = float(marker.frame);
234 }
235 if (marker.frame > max) {
236 max = float(marker.frame);
237 }
238 }
239 }
240
241 /* set the min/max values */
242 *r_first = min;
243 *r_last = max;
244}
245
251{
252 ScrArea *area = CTX_wm_area(C);
253 if (area == nullptr) {
254 return false;
255 }
256
257 if (ui::view2d_fromcontext(C) == nullptr) {
258 return false;
259 }
260
261 switch (area->spacetype) {
262 case SPACE_ACTION: {
263 SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
264 if (saction->flag & SACTION_SHOW_MARKERS) {
265 return true;
266 }
267 break;
268 }
269 case SPACE_GRAPH: {
270 SpaceGraph *sipo = area->spacedata.first_as<SpaceGraph>();
271 if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) {
272 return true;
273 }
274 break;
275 }
276 case SPACE_NLA: {
277 SpaceNla *snla = area->spacedata.first_as<SpaceNla>();
278 if (snla->flag & SNLA_SHOW_MARKERS) {
279 return true;
280 }
281 break;
282 }
283 case SPACE_SEQ: {
284 SpaceSeq *seq = area->spacedata.first_as<SpaceSeq>();
285 if (seq->flag & SEQ_SHOW_MARKERS) {
286 return true;
287 }
288 break;
289 }
290 }
291 return false;
292}
293
295 ListBaseT<TimeMarker> *markers,
296 float region_x)
297{
298 if (markers == nullptr || markers->is_empty()) {
299 return nullptr;
300 }
301
302 float frame_at_position = ui::view2d_region_to_view_x(v2d, region_x);
303 TimeMarker *nearest_marker = ED_markers_find_nearest_marker(markers, frame_at_position);
304 float pixel_distance = ui::view2d_scale_get_x(v2d) *
305 fabsf(nearest_marker->frame - frame_at_position);
306
307 if (pixel_distance <= UI_ICON_SIZE) {
308 return nearest_marker;
309 }
310 return nullptr;
311}
312
313/* --------------------------------- */
314
316static void add_marker_to_cfra_elem(ListBaseT<CfraElem> *lb,
317 TimeMarker *marker,
318 const bool only_selected)
319{
320 CfraElem *ce, *cen;
321
322 /* should this one only be considered if it is selected? */
323 if (only_selected && ((marker->flag & SELECT) == 0)) {
324 return;
325 }
326
327 /* insertion sort - try to find a previous cfra elem */
328 for (ce = lb->first(); ce; ce = ce->next) {
329 if (ce->cfra == marker->frame) {
330 /* do because of double keys */
331 if (marker->flag & SELECT) {
332 ce->sel = marker->flag;
333 }
334 return;
335 }
336 if (ce->cfra > marker->frame) {
337 break;
338 }
339 }
340
341 cen = MEM_new_zeroed<CfraElem>("add_to_cfra_elem");
342 if (ce) {
343 BLI_insertlinkbefore(lb, ce, cen);
344 }
345 else {
346 BLI_addtail(lb, cen);
347 }
348
349 cen->cfra = marker->frame;
350 cen->sel = marker->flag;
351}
352
353void ED_markers_make_cfra_list(ListBaseT<TimeMarker> *markers,
354 ListBaseT<CfraElem> *lb,
355 const bool only_selected)
356{
357 if (lb) {
358 /* Clear the list first, since callers have no way of knowing
359 * whether this terminated early otherwise. This may lead
360 * to crashes if the user didn't clear the memory first.
361 */
362 lb->first_ = lb->last_ = nullptr;
363 }
364 else {
365 return;
366 }
367
368 if (markers == nullptr) {
369 return;
370 }
371
372 for (TimeMarker &marker : *markers) {
373 add_marker_to_cfra_elem(lb, &marker, only_selected);
374 }
375}
376
377void ED_markers_select_all(ListBaseT<TimeMarker> *markers, int action)
378{
379 if (action == SEL_TOGGLE) {
381 }
382
383 for (TimeMarker &marker : *markers) {
384 if (action == SEL_SELECT) {
385 marker.flag |= SELECT;
386 }
387 else if (action == SEL_DESELECT) {
388 marker.flag &= ~SELECT;
389 }
390 else if (action == SEL_INVERT) {
391 marker.flag ^= SELECT;
392 }
393 else {
394 BLI_assert(0);
395 }
396 }
397}
398
399/* --------------------------------- */
400
401TimeMarker *ED_markers_get_first_selected(ListBaseT<TimeMarker> *markers)
402{
403 if (markers) {
404 for (TimeMarker &marker : *markers) {
405 if (marker.flag & SELECT) {
406 return &marker;
407 }
408 }
409 }
410
411 return nullptr;
412}
413
414bool ED_markers_region_visible(const ScrArea *area, const ARegion *region)
415{
416 if (region->winy <= (UI_ANIM_MINY + UI_MARKER_MARGIN_Y)) {
417 return false;
418 }
419
420 switch (area->spacetype) {
421 case SPACE_ACTION: {
422 const SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
423 if ((saction->flag & SACTION_SHOW_MARKERS) == 0) {
424 return false;
425 }
426 break;
427 }
428 case SPACE_GRAPH: {
429 const SpaceGraph *sgraph = area->spacedata.first_as<SpaceGraph>();
430 if (sgraph->mode == SIPO_MODE_DRIVERS) {
431 return false;
432 }
433 if ((sgraph->flag & SIPO_SHOW_MARKERS) == 0) {
434 return false;
435 }
436 break;
437 }
438 case SPACE_NLA: {
439 const SpaceNla *snla = area->spacedata.first_as<SpaceNla>();
440 if ((snla->flag & SNLA_SHOW_MARKERS) == 0) {
441 return false;
442 }
443 break;
444 }
445 case SPACE_SEQ: {
446 const SpaceSeq *seq = area->spacedata.first_as<SpaceSeq>();
447 if ((seq->flag & SEQ_SHOW_MARKERS) == 0) {
448 return false;
449 }
450 break;
451 }
452 default:
453 /* Unexpected editor type that shows no markers. */
455 return false;
456 }
457
458 return true;
459}
460
461/* --------------------------------- */
462
463void debug_markers_print_list(ListBaseT<TimeMarker> *markers)
464{
465 /* NOTE: do NOT make static or use `ifdef`'s as "unused code".
466 * That's too much trouble when we need to use for quick debugging! */
467 if (markers == nullptr) {
468 printf("No markers list to print debug for\n");
469 return;
470 }
471
472 printf("List of markers follows: -----\n");
473
474 for (TimeMarker &marker : *markers) {
475 printf("\t'%s' on %d at %p with %u\n",
476 marker.name,
477 marker.frame,
478 static_cast<void *>(&marker),
479 marker.flag);
480 }
481
482 printf("End of list ------------------\n");
483}
484
486
487/* -------------------------------------------------------------------- */
490
491static void marker_color_get(const TimeMarker *marker, uchar *r_color)
492{
493 if (marker->flag & SELECT) {
495 }
496 else {
498 }
499}
500
501static void draw_marker_name(const uchar *text_color,
502 const uiFontStyle *fstyle,
503 TimeMarker *marker,
504 float marker_x,
505 float xmax,
506 float text_y)
507{
508 const char *name = marker->name;
509 uchar final_text_color[4];
510
511 copy_v4_v4_uchar(final_text_color, text_color);
512
513 if (marker->camera) {
514 Object *camera = marker->camera;
515 name = camera->id.name + 2;
516 if (camera->visibility_flag & OB_HIDE_RENDER) {
517 final_text_color[3] = 100;
518 }
519 }
520
521 const int icon_half_width = UI_ICON_SIZE * 0.6;
522 ui::FontStyleDrawParams fs_params{};
523 fs_params.align = ui::UI_STYLE_TEXT_LEFT;
524 fs_params.word_wrap = 0;
525
526 rcti rect{};
527 rect.xmin = marker_x + icon_half_width;
528 rect.xmax = xmax - icon_half_width;
529 rect.ymin = text_y;
530 rect.ymax = text_y;
531
532 fontstyle_draw(fstyle, &rect, name, strlen(name), final_text_color, &fs_params);
533}
534
535static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
536{
537 GPUVertFormat *format = immVertexFormat();
538 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
539
541
542 float viewport_size[4];
543 GPU_viewport_size_get_f(viewport_size);
544 immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
545
547 immUniform1i("colors_len", 0); /* "simple" mode */
548 immUniform1f("dash_width", 6.0f);
549 immUniform1f("udash_factor", 0.5f);
550
552 immVertex2f(pos, xpos, ymin);
553 immVertex2f(pos, xpos, ymax);
554 immEnd();
555
557}
558
559static int marker_get_icon_id(TimeMarker *marker, int flag)
560{
561 if (flag & DRAW_MARKERS_LOCAL) {
562 return (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
563 }
564 if (marker->camera) {
565 return (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
566 }
567 return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
568}
569
570static void draw_marker(
571 const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int xmax, int flag, int region_height)
572{
573 uchar marker_color[4];
574
575 marker_color_get(marker, marker_color);
576
578
579 draw_marker_line(marker_color, xpos, UI_SCALE_FAC * 22, region_height);
580
581 int icon_id = marker_get_icon_id(marker, flag);
582
583 constexpr int marker_y = 10;
584
585 ui::icon_draw_ex(xpos - (0.5f * UI_ICON_SIZE) - (0.5f * U.pixelsize),
586 UI_SCALE_FAC * marker_y,
587 icon_id,
589 1.0f,
590 0.0f,
591 marker_color,
592 false,
594
596
597 /* Adding an offset because the text is drawn downwards, but the icon is drawn upwards. */
598 float name_y = UI_SCALE_FAC * (marker_y + 5);
599 /* Give an offset to the marker that is elevated. */
600 if (marker->flag & TIME_MARKER_ELEVATED_TEMP) {
601 name_y += UI_SCALE_FAC * 6;
602 }
603 draw_marker_name(marker_color, fstyle, marker, xpos, xmax, name_y);
604}
605
606static void draw_markers_background(const rctf *rect)
607{
608 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
610
611 uchar shade[4];
613
614 immUniformColor4ubv(shade);
615
617
618 immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
619
621
623}
624
625static bool marker_is_in_frame_range(TimeMarker *marker, const int frame_range[2])
626{
627 if (marker->frame < frame_range[0]) {
628 return false;
629 }
630 if (marker->frame > frame_range[1]) {
631 return false;
632 }
633 return true;
634}
635
636static void get_marker_region_rect(View2D *v2d, rctf *r_rect)
637{
638 r_rect->xmin = v2d->cur.xmin;
639 r_rect->xmax = v2d->cur.xmax;
640 r_rect->ymin = 0;
641 r_rect->ymax = UI_MARKER_MARGIN_Y;
642}
643
644static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2])
645{
646 float font_width_max = (10 * UI_SCALE_FAC) / xscale;
647 r_range[0] = v2d->cur.xmin - sizeof(TimeMarker::name) * font_width_max;
648 r_range[1] = v2d->cur.xmax + font_width_max;
649}
650
651static int markers_frame_sort(const void *a, const void *b)
652{
653 const TimeMarker *marker_a = static_cast<const TimeMarker *>(a);
654 const TimeMarker *marker_b = static_cast<const TimeMarker *>(b);
655
656 return marker_a->frame > marker_b->frame;
657}
658
659void ED_markers_draw(const bContext *C, int flag)
660{
661 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
662 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
664 if (markers == nullptr || markers->is_empty()) {
665 return;
666 }
667
668 ARegion *region = CTX_wm_region(C);
670 int cfra = CTX_data_scene(C)->r.cfra;
671
672 GPU_line_width(1.0f);
673
674 rctf markers_region_rect;
675 get_marker_region_rect(v2d, &markers_region_rect);
676
677 draw_markers_background(&markers_region_rect);
678
679 /* no time correction for framelen! space is drawn with old values */
680 float xscale, dummy;
681 ui::view2d_scale_get(v2d, &xscale, &dummy);
683 GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
684
685 int clip_frame_range[2];
686 get_marker_clip_frame_range(v2d, xscale, clip_frame_range);
687
688 const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
689
690 /* Markers are not stored by frame order, so we need to sort it here. */
691 ListBaseT<TimeMarker> sorted_markers;
692
693 BLI_duplicatelist(&sorted_markers, markers);
694 BLI_listbase_sort(&sorted_markers, markers_frame_sort);
695
700 for (TimeMarker &marker : sorted_markers) {
701 const bool is_elevated = (marker.flag & SELECT) ||
702 (cfra >= marker.frame &&
703 (marker.next == nullptr || cfra < marker.next->frame));
704 SET_FLAG_FROM_TEST(marker.flag, is_elevated, TIME_MARKER_ELEVATED_TEMP);
705 }
706
707 /* Separate loops in order to draw selected markers on top. */
708
715 for (TimeMarker &marker : sorted_markers) {
716 if ((marker.flag & TIME_MARKER_ELEVATED_TEMP) == 0 &&
717 marker_is_in_frame_range(&marker, clip_frame_range))
718 {
719 const int xmax = marker.next ? marker.next->frame : clip_frame_range[1] + 1;
720 draw_marker(fstyle, &marker, marker.frame * xscale, xmax * xscale, flag, region->winy);
721 }
722 }
723
724 /* Now draw the elevated markers */
725 for (TimeMarker *marker = sorted_markers.first(); marker != nullptr;) {
726
727 /* Skip this marker if it is elevated or out of the frame range. */
728 if ((marker->flag & TIME_MARKER_ELEVATED_TEMP) == 0 ||
729 !marker_is_in_frame_range(marker, clip_frame_range))
730 {
731 marker = marker->next;
732 continue;
733 }
734
735 /* Find the next elevated marker. */
736 /* We use the next marker to determine how wide our text should be */
737 TimeMarker *next_marker = marker->next;
738 while (next_marker != nullptr && (next_marker->flag & TIME_MARKER_ELEVATED_TEMP) == 0) {
739 next_marker = next_marker->next;
740 }
741
742 const int xmax = next_marker ? next_marker->frame : clip_frame_range[1] + 1;
743 draw_marker(fstyle, marker, marker->frame * xscale, xmax * xscale, flag, region->winy);
744
745 marker = next_marker;
746 }
747
748 /* Reset the elevated flag. */
749 for (TimeMarker &marker : sorted_markers) {
750 marker.flag &= ~TIME_MARKER_ELEVATED_TEMP;
751 }
752
753 sorted_markers.free_no_destruct();
754
756}
757
759
760/* -------------------------------------------------------------------- */
767
768/* ------------------------ */
769
770/* special poll() which checks if there are selected markers first */
772{
773 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
774 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
776
778 return false;
779 }
780
781 /* check if some marker is selected */
782 if (ED_markers_get_first_selected(markers) == nullptr) {
783 CTX_wm_operator_poll_msg_set(C, "No markers are selected");
784 return false;
785 }
786
787 return true;
788}
789
791{
792 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
793 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
796
798 return false;
799 }
800
801 if (ts->lock_markers) {
802 CTX_wm_operator_poll_msg_set(C, "Markers are locked");
803 return false;
804 }
805
806 /* check if some marker is selected */
807 if (ED_markers_get_first_selected(markers) == nullptr) {
808 CTX_wm_operator_poll_msg_set(C, "No markers are selected");
809 return false;
810 }
811
812 return true;
813}
814
815/* special poll() which checks if there are any markers at all first */
817{
818 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
819 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
822
824 return false;
825 }
826
827 /* list of markers must exist, as well as some markers in it! */
828 return (markers && markers->first());
829}
830
832{
833 ScrArea *area = CTX_wm_area(C);
834 if (area == nullptr) {
835 return false;
836 }
837
838 /* Minimum vertical size to select markers, while still scrubbing frames. */
840 if (region && region->winy < UI_MARKERS_MINY) {
841 return false;
842 }
843
845}
846
848{
850 return false;
851 }
852
854 if (ts->lock_markers) {
855 CTX_wm_operator_poll_msg_set(C, "Markers are locked");
856 return false;
857 }
858
859 return true;
860}
861
863
864/* -------------------------------------------------------------------- */
867
868/* add TimeMarker at current frame */
870{
872 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
873 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
875
876 if (markers == nullptr || scene == nullptr) {
877 return OPERATOR_CANCELLED;
878 }
879
880 const int frame = scene->r.cfra;
881
882 /* prefer not having 2 markers at the same place,
883 * though the user can move them to overlap once added */
884 for (TimeMarker &marker : *markers) {
885 if (marker.frame == frame) {
886 return OPERATOR_CANCELLED;
887 }
888 }
889
891
892 TimeMarker *marker = MEM_new<TimeMarker>("TimeMarker");
893 marker->flag = SELECT;
894 marker->frame = frame;
895 SNPRINTF_UTF8(marker->name, "F_%02d", frame);
896 BLI_addtail(markers, marker);
897
900
901 return OPERATOR_FINISHED;
902}
903
905{
906 /* identifiers */
907 ot->name = "Add Time Marker";
908 ot->description = "Add a new time marker";
909 ot->idname = "MARKER_OT_add";
910
911 /* API callbacks. */
914
915 /* flags */
917}
918
920
921/* -------------------------------------------------------------------- */
924
925/* operator state vars used:
926 * frames: delta movement
927 *
928 * functions:
929 *
930 * init() check selection, add customdata with old values and some lookups
931 *
932 * apply() do the actual movement
933 *
934 * exit() cleanup, send notifier
935 *
936 * cancel() to escape from modal
937 *
938 * callbacks:
939 *
940 * exec() calls init, apply, exit
941 *
942 * invoke() calls init, adds modal handler
943 *
944 * modal() accept modal events while doing it, ends with apply and exit, or cancel
945 */
946
949 ListBaseT<TimeMarker> *markers;
950 short event_type, event_val; /* store invoke-event, to verify */
953};
954
956{
957 if (((mm->slink->spacetype == SPACE_SEQ) &&
958 !(reinterpret_cast<SpaceSeq *>(mm->slink)->flag & SEQ_DRAWFRAMES)) ||
959 ((mm->slink->spacetype == SPACE_ACTION) &&
960 (reinterpret_cast<SpaceAction *>(mm->slink)->flag & SACTION_DRAWTIME)) ||
961 ((mm->slink->spacetype == SPACE_GRAPH) &&
962 (reinterpret_cast<SpaceGraph *>(mm->slink)->flag & SIPO_DRAWTIME)) ||
963 ((mm->slink->spacetype == SPACE_NLA) &&
964 (reinterpret_cast<SpaceNla *>(mm->slink)->flag & SNLA_DRAWTIME)))
965 {
966 return true;
967 }
968
969 return false;
970}
971
973{
975 MarkerMove *mm = static_cast<MarkerMove *>(op->customdata);
976 TimeMarker *marker, *selmarker = nullptr;
977 const int ofs = RNA_int_get(op->ptr, "frames");
978 char str[UI_MAX_DRAW_STR];
979 char str_ofs[NUM_STR_REP_LEN];
980 int totmark;
981 const bool use_time = ed_marker_move_use_time(mm);
982
983 for (totmark = 0, marker = mm->markers->first(); marker; marker = marker->next) {
984 if (marker->flag & SELECT) {
985 selmarker = marker;
986 totmark++;
987 }
988 }
989
990 if (hasNumInput(&mm->num)) {
991 outputNumInput(&mm->num, str_ofs, scene->unit);
992 }
993 else if (use_time) {
994 SNPRINTF_UTF8(str_ofs, "%.2f", FRA2TIME(ofs));
995 }
996 else {
997 SNPRINTF_UTF8(str_ofs, "%d", ofs);
998 }
999
1000 if (totmark == 1 && selmarker) {
1001 /* we print current marker value */
1002 if (use_time) {
1003 SNPRINTF_UTF8(str, IFACE_("Marker %.2f offset %s"), FRA2TIME(selmarker->frame), str_ofs);
1004 }
1005 else {
1006 SNPRINTF_UTF8(str, IFACE_("Marker %d offset %s"), selmarker->frame, str_ofs);
1007 }
1008 }
1009 else {
1010 SNPRINTF_UTF8(str, IFACE_("Marker offset %s"), str_ofs);
1011 }
1012
1014}
1015
1016/* copy selection to temp buffer */
1017/* return 0 if not OK */
1019{
1021 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1022 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1024 MarkerMove *mm;
1025 TimeMarker *marker;
1026 int a, totmark;
1027
1028 if (markers == nullptr) {
1029 return false;
1030 }
1031
1032 for (totmark = 0, marker = markers->first(); marker; marker = marker->next) {
1033 if (marker->flag & SELECT) {
1034 totmark++;
1035 }
1036 }
1037
1038 if (totmark == 0) {
1039 return false;
1040 }
1041
1042 op->customdata = mm = MEM_new_zeroed<MarkerMove>("Markermove");
1043 mm->slink = CTX_wm_space_data(C);
1044 mm->markers = markers;
1045 mm->oldframe = MEM_new_array_zeroed<int>(totmark, "MarkerMove oldframe");
1046
1047 initNumInput(&mm->num);
1048 mm->num.idx_max = 0; /* one axis */
1049 mm->num.val_flag[0] |= NUM_NO_FRACTION;
1050 mm->num.unit_sys = scene->unit.system;
1051 /* No time unit supporting frames currently... */
1053
1054 for (a = 0, marker = markers->first(); marker; marker = marker->next) {
1055 if (marker->flag & SELECT) {
1056 mm->oldframe[a] = marker->frame;
1057 a++;
1058 }
1059 }
1060
1061 return true;
1062}
1063
1064/* free stuff */
1066{
1067 MarkerMove *mm = static_cast<MarkerMove *>(op->customdata);
1068
1069 /* free data */
1070 MEM_delete(mm->oldframe);
1071 MEM_delete(mm);
1072 op->customdata = nullptr;
1073
1074 /* clear custom header prints */
1076}
1077
1079{
1080 const bool tweak = RNA_struct_find_property(op->ptr, "tweak") &&
1081 RNA_boolean_get(op->ptr, "tweak");
1082
1083 if (tweak) {
1084 ARegion *region = CTX_wm_region(C);
1085 View2D *v2d = &region->v2d;
1086 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1087 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1089 if (!region_position_is_over_marker(v2d, markers, event->xy[0] - region->winrct.xmin)) {
1091 }
1092 }
1093
1094 if (ed_marker_move_init(C, op)) {
1095 MarkerMove *mm = static_cast<MarkerMove *>(op->customdata);
1096
1097 mm->evtx = event->xy[0];
1098 mm->firstx = event->xy[0];
1099 mm->event_type = event->type;
1100 mm->event_val = event->val;
1101
1102 /* add temp handler */
1104
1105 /* Reset frames delta. */
1106 RNA_int_set(op->ptr, "frames", 0);
1107
1109
1111 }
1112
1113 return OPERATOR_CANCELLED;
1114}
1115
1116/* NOTE: init has to be called successfully. */
1118{
1119 bScreen *screen = CTX_wm_screen(C);
1121 Object *camera = scene->camera;
1122 MarkerMove *mm = static_cast<MarkerMove *>(op->customdata);
1123 TimeMarker *marker;
1124 int a, ofs;
1125
1126 ofs = RNA_int_get(op->ptr, "frames");
1127 for (a = 0, marker = mm->markers->first(); marker; marker = marker->next) {
1128 if (marker->flag & SELECT) {
1129 marker->frame = mm->oldframe[a] + ofs;
1130 a++;
1131 }
1132 }
1133
1136
1137 /* so we get view3d redraws */
1139
1140 if (camera != scene->camera) {
1141 BKE_screen_view3d_scene_sync(screen, scene);
1143 }
1144}
1145
1146/* only for modal */
1148{
1149 RNA_int_set(op->ptr, "frames", 0);
1152}
1153
1155{
1157 MarkerMove *mm = static_cast<MarkerMove *>(op->customdata);
1159 const bool has_numinput = hasNumInput(&mm->num);
1160 const bool use_time = ed_marker_move_use_time(mm);
1161
1162 /* Modal numinput active, try to handle numeric inputs first... */
1163 if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &mm->num, event)) {
1164 float value = float(RNA_int_get(op->ptr, "frames"));
1165
1166 applyNumInput(&mm->num, &value);
1167 if (use_time) {
1168 value = TIME2FRA(value);
1169 }
1170
1171 RNA_int_set(op->ptr, "frames", int(value));
1174 }
1175 else {
1176 bool handled = false;
1177 switch (event->type) {
1178 case EVT_ESCKEY:
1180 return OPERATOR_CANCELLED;
1181 case RIGHTMOUSE:
1182 /* press = user manually demands transform to be canceled */
1183 if (event->val == KM_PRESS) {
1185 return OPERATOR_CANCELLED;
1186 }
1187 /* else continue; <--- see if release event should be caught for tweak-end */
1189
1190 case EVT_RETKEY:
1191 case EVT_PADENTER:
1192 case LEFTMOUSE:
1193 case MIDDLEMOUSE:
1194 if (WM_event_is_modal_drag_exit(event, mm->event_type, mm->event_val)) {
1198 return OPERATOR_FINISHED;
1199 }
1200 break;
1201 case MOUSEMOVE:
1202 if (!has_numinput) {
1203 float dx;
1204
1205 dx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
1206
1207 if (event->xy[0] != mm->evtx) { /* XXX maybe init for first time */
1208 float fac;
1209
1210 mm->evtx = event->xy[0];
1211 fac = (float(event->xy[0] - mm->firstx) * dx);
1212
1213 apply_keyb_grid((event->modifier & KM_SHIFT) != 0,
1214 (event->modifier & KM_CTRL) != 0,
1215 &fac,
1216 0.0,
1217 scene->frames_per_second(),
1218 0.1 * scene->frames_per_second(),
1219 0);
1220
1221 RNA_int_set(op->ptr, "frames", int(fac));
1224 }
1225 }
1226 break;
1227 default: {
1228 break;
1229 }
1230 }
1231
1232 if (!handled && event->val == KM_PRESS && handleNumInput(C, &mm->num, event)) {
1233 float value = float(RNA_int_get(op->ptr, "frames"));
1234
1235 applyNumInput(&mm->num, &value);
1236 if (use_time) {
1237 value = TIME2FRA(value);
1238 }
1239
1240 RNA_int_set(op->ptr, "frames", int(value));
1243 }
1244 }
1245
1247}
1248
1250{
1251 if (ed_marker_move_init(C, op)) {
1254 return OPERATOR_FINISHED;
1255 }
1256 return OPERATOR_PASS_THROUGH;
1257}
1258
1260{
1261 /* identifiers */
1262 ot->name = "Move Time Marker";
1263 ot->description = "Move selected time marker(s)";
1264 ot->idname = "MARKER_OT_move";
1265
1266 /* API callbacks. */
1272
1273 /* flags */
1275
1276 /* rna storage */
1277 RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
1279 ot->srna, "tweak", false, "Tweak", "Operator has been activated using a click-drag event");
1281}
1282
1284
1285/* -------------------------------------------------------------------- */
1288
1289/* operator state vars used:
1290 * frames: delta movement
1291 *
1292 * functions:
1293 *
1294 * apply() do the actual duplicate
1295 *
1296 * callbacks:
1297 *
1298 * exec() calls apply, move_exec
1299 *
1300 * invoke() calls apply, move_invoke
1301 *
1302 * modal() uses move_modal
1303 */
1304
1305/* duplicate selected TimeMarkers */
1307{
1308 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1309 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1311 if (markers == nullptr) {
1312 return;
1313 }
1314
1315 /* go through the list of markers, duplicate selected markers and add duplicated copies
1316 * to the beginning of the list (unselect original markers)
1317 */
1318 for (TimeMarker &marker : *markers) {
1319 if (marker.flag & SELECT) {
1320 /* unselect selected marker */
1321 marker.flag &= ~SELECT;
1322
1323 /* create and set up new marker */
1324 TimeMarker *newmarker = MEM_new<TimeMarker>("TimeMarker");
1325 newmarker->flag = SELECT;
1326 newmarker->frame = marker.frame;
1327 STRNCPY_UTF8(newmarker->name, marker.name);
1328 newmarker->camera = marker.camera;
1329
1330 if (marker.prop != nullptr) {
1331 newmarker->prop = IDP_CopyProperty(marker.prop);
1332 }
1333
1334 /* new marker is added to the beginning of list */
1335 /* FIXME: bad ordering! */
1336 BLI_addhead(markers, newmarker);
1337 }
1338 }
1339}
1340
1342{
1344 ed_marker_move_exec(C, op); /* Assumes frame delta set. */
1345
1346 return OPERATOR_FINISHED;
1347}
1348
1350 wmOperator *op,
1351 const wmEvent *event)
1352{
1354 return ed_marker_move_invoke(C, op, event);
1355}
1356
1358{
1359 /* identifiers */
1360 ot->name = "Duplicate Time Marker";
1361 ot->description = "Duplicate selected time marker(s)";
1362 ot->idname = "MARKER_OT_duplicate";
1363
1364 /* API callbacks. */
1370
1371 /* flags */
1373
1374 /* rna storage */
1375 RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
1376}
1377
1379
1380/* -------------------------------------------------------------------- */
1385
1387 bContext *C, bool camera, bool extend, ListBaseT<TimeMarker> *markers, int cfra)
1388{
1389 using namespace blender::ed;
1391 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1392 const Main *bmain = CTX_data_main(C);
1393 Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
1394
1395 ViewLayer *view_layer = CTX_data_view_layer(C);
1396 Base *base;
1397 int sel = 0;
1398
1399 if (!extend) {
1400 BKE_view_layer_base_deselect_all(*bmain, scene, view_layer);
1401 }
1402
1403 for (TimeMarker &marker : *markers) {
1404 if (marker.frame == cfra && marker.camera) {
1405 sel = (marker.flag & SELECT);
1406 break;
1407 }
1408 }
1409
1410 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1411
1412 for (TimeMarker &marker : *markers) {
1413 if (marker.camera) {
1414 if (marker.frame == cfra) {
1415 base = BKE_view_layer_base_find(view_layer, marker.camera);
1416 if (base) {
1418 if (!extend) {
1419 object::base_activate(C, base);
1420 }
1421 }
1422 }
1423 }
1424 }
1425
1428 }
1429}
1430
1432 const int mval[2],
1433 bool extend,
1434 bool deselect_all,
1435 bool camera,
1436 bool wait_to_deselect_others)
1437{
1438 /* NOTE: keep this functionality in sync with #ACTION_OT_clickselect.
1439 * The logic here closely matches its internals.
1440 * From a user perspective the functions should also behave in much the same way.
1441 * The main difference with marker selection is support for selecting the camera.
1442 *
1443 * The variables (`sel_op` & `deselect_all`) have been included so marker
1444 * selection can use identical checks to dope-sheet selection. */
1445
1446 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1447 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1449
1450 const View2D *v2d = ui::view2d_fromcontext(C);
1452 TimeMarker *nearest_marker = region_position_is_over_marker(v2d, markers, mval[0]);
1453 const float frame_at_mouse_position = ui::view2d_region_to_view_x(v2d, mval[0]);
1454 const int cfra = ED_markers_find_nearest_marker_time(markers, frame_at_mouse_position);
1455 const bool found = (nearest_marker != nullptr);
1456 const bool is_selected = (nearest_marker && nearest_marker->flag & SELECT);
1457
1458 eSelectOp sel_op = (extend) ? (is_selected ? SEL_OP_SUB : SEL_OP_ADD) : SEL_OP_SET;
1459
1460 if ((sel_op == SEL_OP_SET && found) || (!found && deselect_all)) {
1461 sel_op = SEL_OP_ADD;
1462
1463 /* Rather than deselecting others, users may want to drag to box-select (drag from empty space)
1464 * or tweak-translate an already selected item. If these cases may apply, delay deselection. */
1465 if (wait_to_deselect_others && (!found || is_selected)) {
1466 ret_val = OPERATOR_RUNNING_MODAL;
1467 }
1468 else {
1470 }
1471 }
1472
1473 if (found) {
1474 TimeMarker *marker, *marker_cycle_selected = nullptr;
1475 TimeMarker *marker_found = nullptr;
1476
1477 /* Support for selection cycling. */
1478 for (TimeMarker &marker : *markers) {
1479 if (marker.frame == cfra) {
1480 if (marker.flag & SELECT) {
1481 marker_cycle_selected = static_cast<TimeMarker *>(marker.next ? marker.next :
1482 markers->first());
1483 break;
1484 }
1485 }
1486 }
1487
1488 /* If extend is not set, then deselect markers. */
1489 LISTBASE_CIRCULAR_FORWARD_BEGIN (TimeMarker *, markers, marker, marker_cycle_selected) {
1490 /* This way a not-extend select will always give 1 selected marker. */
1491 if (marker->frame == cfra) {
1492 marker_found = marker;
1493 break;
1494 }
1495 }
1496 LISTBASE_CIRCULAR_FORWARD_END(TimeMarker *, markers, marker, marker_cycle_selected);
1497
1498 if (marker_found) {
1499 if (sel_op == SEL_OP_SUB) {
1500 marker_found->flag &= ~SELECT;
1501 }
1502 else {
1503 marker_found->flag |= SELECT;
1504 }
1505 }
1506 }
1507 /* If extend is set (by holding Shift), then add the camera to the selection too. */
1508 if (found && camera) {
1509 select_marker_camera_switch(C, true, extend, markers, nearest_marker->frame);
1510 }
1511
1514
1515 /* Allowing tweaks, but needs OPERATOR_FINISHED, otherwise renaming fails, see #25987. */
1516 return ret_val;
1517}
1518
1520{
1521 const bool extend = RNA_boolean_get(op->ptr, "extend");
1522 const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
1523
1524 int mval[2];
1525 mval[0] = RNA_int_get(op->ptr, "mouse_x");
1526 mval[1] = RNA_int_get(op->ptr, "mouse_y");
1527 const View2D *v2d = ui::view2d_fromcontext(C);
1528
1529 const float marker_frame = ui::view2d_region_to_view_x(v2d, mval[0]);
1530 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1531 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1533 const TimeMarker *marker = ED_markers_find_nearest_marker(markers, marker_frame);
1534 const bool is_over_marker = region_position_is_over_marker(v2d, markers, mval[0]);
1535
1536 const bool camera = RNA_boolean_get(op->ptr, "camera");
1537
1538 if (camera && marker && marker->camera && CTX_data_mode_enum(C) != CTX_MODE_OBJECT) {
1539 /* Supporting mode switching from this operator doesn't seem so useful.
1540 * So only select the camera in object-mode. */
1541 BKE_report(op->reports,
1543 "Automatic selection of the camera bound to this marker is only supported in "
1544 "object mode");
1545 }
1546
1547 if (camera && !is_over_marker) {
1548 /* Activating a camera can only work if the marker is clicked. Exit early if not on a marker to
1549 * let the MARKER_OT_select_leftright operator work. */
1550 return OPERATOR_PASS_THROUGH;
1551 }
1552
1553 const bool deselect_all = true;
1555 C, mval, extend, deselect_all, camera, wait_to_deselect_others);
1556
1558}
1559
1561{
1562 PropertyRNA *prop;
1563
1564 /* identifiers */
1565 ot->name = "Select Time Marker";
1566 ot->description = "Select time marker(s)";
1567 ot->idname = "MARKER_OT_select";
1568
1569 /* API callbacks. */
1574
1575 /* flags */
1576 ot->flag = OPTYPE_UNDO;
1577
1579 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
1581 prop = RNA_def_boolean(ot->srna, "camera", false, "Camera", "Select the camera");
1583}
1584
1586
1587/* -------------------------------------------------------------------- */
1590
1591/* operator state vars used: (added by default WM callbacks)
1592 * xmin, ymin
1593 * xmax, ymax
1594 *
1595 * customdata: the wmGesture pointer, with sub-window.
1596 *
1597 * callbacks:
1598 *
1599 * exec() has to be filled in by user
1600 *
1601 * invoke() default WM function
1602 * adds modal handler
1603 *
1604 * modal() default WM function
1605 * accept modal events while doing it, calls exec(), handles ESC and border drawing
1606 *
1607 * poll() has to be filled in by user for context
1608 */
1609
1611 wmOperator *op,
1612 const wmEvent *event)
1613{
1614 ARegion *region = CTX_wm_region(C);
1615 View2D *v2d = &region->v2d;
1616
1617 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1618 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1620 bool over_marker = region_position_is_over_marker(
1621 v2d, markers, event->xy[0] - region->winrct.xmin) != nullptr;
1622
1623 bool tweak = RNA_boolean_get(op->ptr, "tweak");
1624 if (tweak && over_marker) {
1626 }
1627
1628 return WM_gesture_box_invoke(C, op, event);
1629}
1630
1632{
1634 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1635 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1637 rctf rect;
1638
1640 ui::view2d_region_to_view_rctf(v2d, &rect, &rect);
1641
1642 if (markers == nullptr) {
1643 return OPERATOR_CANCELLED;
1644 }
1645
1646 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
1647 const bool select = (sel_op != SEL_OP_SUB);
1648 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
1650 }
1651
1652 for (TimeMarker &marker : *markers) {
1653 if (BLI_rctf_isect_x(&rect, marker.frame)) {
1654 SET_FLAG_FROM_TEST(marker.flag, select, SELECT);
1655 }
1656 }
1657
1660
1661 return OPERATOR_FINISHED;
1662}
1663
1665{
1666 /* identifiers */
1667 ot->name = "Marker Box Select";
1668 ot->description = "Select all time markers using box selection";
1669 ot->idname = "MARKER_OT_select_box";
1670
1671 /* API callbacks. */
1676
1678
1679 /* flags */
1680 ot->flag = OPTYPE_UNDO;
1681
1682 /* properties */
1685
1687 ot->srna, "tweak", false, "Tweak", "Operator has been activated using a click-drag event");
1689}
1690
1692
1693/* -------------------------------------------------------------------- */
1696
1698{
1699 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1700 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1702 if (markers == nullptr) {
1703 return OPERATOR_CANCELLED;
1704 }
1705
1706 int action = RNA_enum_get(op->ptr, "action");
1707 ED_markers_select_all(markers, action);
1708
1711
1712 return OPERATOR_FINISHED;
1713}
1714
1716{
1717 /* identifiers */
1718 ot->name = "(De)select all Markers";
1719 ot->description = "Change selection of all time markers";
1720 ot->idname = "MARKER_OT_select_all";
1721
1722 /* API callbacks. */
1725
1726 /* flags */
1728
1729 /* rna */
1731}
1732
1734
1735/* -------------------------------------------------------------------- */
1738
1744
1746 {MARKERS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
1747 {MARKERS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
1748 {MARKERS_LRSEL_CLICK_SIDE, "CLICK_SIDE", 0, "Mouse Click Side", ""},
1749 {0, nullptr, 0, nullptr, nullptr},
1750};
1751
1753{
1755 RNA_enum_get(op->ptr, "mode"));
1756 const bool extend = RNA_boolean_get(op->ptr, "extend");
1757 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1758 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1760 Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
1761
1762 if (!markers || !scene) {
1763 return OPERATOR_CANCELLED;
1764 }
1765
1766 if (!extend) {
1768 }
1769
1770 const float cfra = BKE_scene_frame_get(scene);
1771 for (TimeMarker &marker : *markers) {
1772 if ((mode == MARKERS_LRSEL_LEFT && marker.frame <= cfra) ||
1773 (mode == MARKERS_LRSEL_RIGHT && marker.frame >= cfra))
1774 {
1775 marker.flag |= SELECT;
1776 }
1777 }
1778
1779 if (is_sequencer) {
1782 }
1783 else {
1785 }
1786
1787 return OPERATOR_FINISHED;
1788}
1789
1791 wmOperator *op,
1792 const wmEvent *event)
1793{
1794 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1795 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1797 Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
1798 const View2D *v2d = ui::view2d_fromcontext(C);
1799
1800 if (!markers || !v2d || !scene) {
1801 return OPERATOR_PASS_THROUGH;
1802 }
1803
1804 /* Check if the user clicked on a marker or empty space. */
1805 if (region_position_is_over_marker(v2d, markers, event->mval[0])) {
1806 /* User clicked a marker so let 'select_marker_camera_switch' take care of it. */
1807 return OPERATOR_PASS_THROUGH;
1808 }
1809
1811 RNA_enum_get(op->ptr, "mode"));
1812
1813 if (mode == MARKERS_LRSEL_CLICK_SIDE) {
1814 const float mouse_frame = ui::view2d_region_to_view_x(v2d, event->mval[0]);
1815 const float scene_frame = BKE_scene_frame_get(scene);
1816 mode = mouse_frame < scene_frame ? MARKERS_LRSEL_LEFT : MARKERS_LRSEL_RIGHT;
1817 }
1818 RNA_enum_set(op->ptr, "mode", mode);
1819
1821}
1822
1824{
1825 /* identifiers */
1826 ot->name = "Select Markers Before/After Current Frame";
1827 ot->description = "Select markers on and left/right of the current frame";
1828 ot->idname = "MARKER_OT_select_leftright";
1829
1830 /* API callbacks. */
1834
1835 /* flags */
1837
1838 /* rna storage */
1841 RNA_def_boolean(ot->srna, "extend", false, "Extend Select", "");
1842}
1843
1845
1846/* -------------------------------------------------------------------- */
1851
1853
1854{
1855 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1856 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1858 TimeMarker *marker, *nmarker;
1859 bool changed = false;
1860
1861 if (markers == nullptr) {
1862 return OPERATOR_CANCELLED;
1863 }
1864
1865 for (marker = markers->first(); marker; marker = nmarker) {
1866 nmarker = marker->next;
1867 if (marker->flag & SELECT) {
1868 if (marker->prop != nullptr) {
1869 IDP_FreeProperty(marker->prop);
1870 }
1871 BLI_freelinkN(markers, marker);
1872 changed = true;
1873 }
1874 }
1875
1876 if (changed) {
1879 }
1880
1881 return OPERATOR_FINISHED;
1882}
1883
1885 wmOperator *op,
1886 const wmEvent * /*event*/)
1887{
1888 if (RNA_boolean_get(op->ptr, "confirm")) {
1890 op,
1891 IFACE_("Delete selected markers?"),
1892 nullptr,
1893 IFACE_("Delete"),
1895 false);
1896 }
1897 return ed_marker_delete_exec(C, op);
1898}
1899
1901{
1902 /* identifiers */
1903 ot->name = "Delete Markers";
1904 ot->description = "Delete selected time marker(s)";
1905 ot->idname = "MARKER_OT_delete";
1906
1907 /* API callbacks. */
1911
1912 /* flags */
1915}
1916
1918
1919/* -------------------------------------------------------------------- */
1924
1926{
1927 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1928 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1930 TimeMarker *marker = ED_markers_get_first_selected(markers);
1931
1932 if (marker) {
1933 RNA_string_get(op->ptr, "name", marker->name);
1934
1937
1938 return OPERATOR_FINISHED;
1939 }
1940
1941 return OPERATOR_CANCELLED;
1942}
1943
1945{
1946 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1947 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1949 /* must initialize the marker name first if there is a marker selected */
1950 TimeMarker *marker = ED_markers_get_first_selected(markers);
1951 if (marker) {
1952 RNA_string_set(op->ptr, "name", marker->name);
1953 }
1954
1956 C, op, event, IFACE_("Rename Selected Time Marker"), IFACE_("Rename"));
1957}
1958
1960{
1961 /* identifiers */
1962 ot->name = "Rename Marker";
1963 ot->description = "Rename first selected time marker";
1964 ot->idname = "MARKER_OT_rename";
1965
1966 /* API callbacks. */
1970
1971 /* flags */
1973
1974 /* properties */
1975 ot->prop = RNA_def_string(
1976 ot->srna, "name", "RenamedMarker", sizeof(TimeMarker::name), "Name", "New name for marker");
1977#if 0
1979 "ensure_unique",
1980 0,
1981 "Ensure Unique",
1982 "Ensure that new name is unique within collection of markers");
1983#endif
1984}
1985
1987
1988/* -------------------------------------------------------------------- */
1991
1993{
1994 Main *bmain = CTX_data_main(C);
1995 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
1996 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
1998 Scene *scene_to = static_cast<Scene *>(
1999 BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")));
2000 TimeMarker *marker_new;
2001
2002 if (scene_to == nullptr) {
2003 BKE_report(op->reports, RPT_ERROR, "Scene not found");
2004 return OPERATOR_CANCELLED;
2005 }
2006
2007 if (scene_to == CTX_data_scene(C)) {
2008 BKE_report(op->reports, RPT_ERROR, "Cannot re-link markers into the same scene");
2009 return OPERATOR_CANCELLED;
2010 }
2011
2012 if (scene_to->toolsettings->lock_markers) {
2013 BKE_report(op->reports, RPT_ERROR, "Target scene has locked markers");
2014 return OPERATOR_CANCELLED;
2015 }
2016
2017 /* copy markers */
2018 for (TimeMarker &marker : *markers) {
2019 if (marker.flag & SELECT) {
2020 marker_new = BKE_copy_time_marker(marker, 0);
2021 BLI_addtail(&scene_to->markers, marker_new);
2022 }
2023 }
2024
2025 return OPERATOR_FINISHED;
2026}
2027
2029{
2030 PropertyRNA *prop;
2031
2032 /* identifiers */
2033 ot->name = "Copy Markers to Scene";
2034 ot->description = "Copy selected markers to another scene";
2035 ot->idname = "MARKER_OT_make_links_scene";
2036
2037 /* API callbacks. */
2039 ot->invoke = WM_menu_invoke;
2041
2042 /* flags */
2044
2045 /* properties */
2046 prop = RNA_def_enum(ot->srna, "scene", rna_enum_dummy_NULL_items, 0, "Scene", "");
2049 ot->prop = prop;
2050}
2051
2053
2054/* -------------------------------------------------------------------- */
2057
2059{
2060 bScreen *screen = CTX_wm_screen(C);
2062 if (!scene) {
2063 return OPERATOR_CANCELLED;
2064 }
2065 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
2066 ListBaseT<TimeMarker> *markers = is_sequencer ? ED_sequencer_context_get_markers(C) :
2069 TimeMarker *marker;
2070
2071 /* Don't do anything if we don't have a camera selected */
2072 if (ob == nullptr) {
2073 BKE_report(op->reports, RPT_ERROR, "Select a camera to bind to a marker on this frame");
2074 return OPERATOR_CANCELLED;
2075 }
2076
2077 /* add new marker, unless we already have one on this frame, in which case, replace it */
2078 if (markers == nullptr) {
2079 return OPERATOR_CANCELLED;
2080 }
2081
2082 marker = ED_markers_find_nearest_marker(markers, scene->r.cfra);
2083 if ((marker == nullptr) || (marker->frame != scene->r.cfra)) {
2084 /* Deselect other markers, so that the user can move the camera marker more easily. */
2086
2087 marker = MEM_new<TimeMarker>("Camera TimeMarker");
2088 /* This marker's name is only displayed in the viewport statistics, animation editors use the
2089 * camera's name when bound to a marker. */
2090 SNPRINTF_UTF8(marker->name, "F_%02d", scene->r.cfra);
2091 marker->flag = SELECT;
2092 marker->frame = scene->r.cfra;
2093 BLI_addtail(markers, marker);
2094 }
2095
2096 /* bind to the nominated camera (as set in operator props) */
2097 marker->camera = ob;
2098
2099 /* camera may have changes */
2101 BKE_screen_view3d_scene_sync(screen, scene);
2103 /* Need to sync to all windows so cameras are updated in viewports there. */
2105 WM_windows_scene_data_sync(&wm->windows, scene);
2106
2109 WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); /* so we get view3d redraws */
2110
2111 return OPERATOR_FINISHED;
2112}
2113
2115{
2116 /* identifiers */
2117 ot->name = "Bind Camera to Markers";
2118 ot->description = "Bind the selected camera to a marker on the current frame";
2119 ot->idname = "MARKER_OT_camera_bind";
2120
2121 /* API callbacks. */
2124
2125 /* flags */
2127}
2128
2130
2131/* -------------------------------------------------------------------- */
2134
2149
2151{
2152 WM_keymap_ensure(keyconf, "Markers", SPACE_EMPTY, RGN_TYPE_WINDOW);
2153}
2154
2156
2157} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
#define ATTR_FALLTHROUGH
#define LISTBASE_CIRCULAR_FORWARD_BEGIN(type, lb, lb_iter, lb_init)
#define LISTBASE_CIRCULAR_FORWARD_END(type, lb, lb_iter, lb_init)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
#define TIME2FRA(a)
#define FRA2TIME(a)
#define UI_SCALE_FAC
#define UI_INV_SCALE_FAC
#define UI_ICON_SIZE
#define NUM_STR_REP_LEN
#define SEL_OP_USE_PRE_DESELECT(sel_op)
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_FSTYLE_WIDGET
#define UI_NO_ICON_OVERLAY_TEXT
#define UI_MAX_DRAW_STR
#define UI_ANIM_MINY
Definition UI_view2d.hh:495
#define UI_MARKER_MARGIN_Y
Definition UI_view2d.hh:492
#define UI_MARKERS_MINY
Definition UI_view2d.hh:496
#define NC_ANIMATION
Definition WM_types.hh:401
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define NA_EDITED
Definition WM_types.hh:634
#define ND_MARKERS
Definition WM_types.hh:452
#define ND_KEYFRAME
Definition WM_types.hh:537
#define NA_SELECTED
Definition WM_types.hh:639
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
btScalar max
#define str(s)
#define FLT_MAX
#define INT_MAX
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
Scene * scene_or_sequencer_scene_from_context(const bContext &C)
void base_activate(bContext *C, Base *base)
void base_select(Base *base, eObjectSelect_Mode mode)
void get_color_4ubv(int colorid, unsigned char col[4])
void icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], bool mono_border, const IconTextOverlay *text_overlay, const bool inverted=false, float scale=1.0f)
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
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
void view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1893
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void MARKER_OT_duplicate(wmOperatorType *ot)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
bool WM_event_is_modal_drag_exit(const wmEvent *event, const short init_event_type, const short init_event_val)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
ScrArea * CTX_wm_area(const bContext *C)
int RNA_enum_get(PointerRNA *ptr, const char *name)
static void MARKER_OT_camera_bind(wmOperatorType *ot)
static wmOperatorStatus ed_marker_delete_invoke(bContext *C, wmOperator *op, const wmEvent *)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
static bool ed_markers_poll_selected_markers(bContext *C)
TimeMarker * BKE_copy_time_marker(const TimeMarker &marker_src, int flag)
Definition anim_sys.cc:3953
Scene * CTX_data_sequencer_scene(const bContext *C)
void immEnd()
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static void MARKER_OT_make_links_scene(wmOperatorType *ot)
ID * ED_markers_get_owner_id(const bContext *C, Scene *scene)
void ED_markers_make_cfra_list(ListBaseT< TimeMarker > *markers, ListBaseT< CfraElem > *lb, const bool only_selected)
ListBaseT< TimeMarker > * ED_scene_markers_get_from_area(const Main &bmain, Scene *scene, ViewLayer *view_layer, const ScrArea *area)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
unsigned int uint
Definition BKE_text.h:55
@ ANIMCONT_SHAPEKEY
@ ANIMCONT_ACTION
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
Definition numinput.cc:344
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
ListBaseT< TimeMarker > * ED_context_get_markers(const bContext *C)
MINLINE int round_fl_to_int(float a)
static void MARKER_OT_select_box(wmOperatorType *ot)
static wmOperatorStatus ed_marker_select_all_exec(bContext *C, wmOperator *op)
void immUniform2f(const char *name, float x, float y)
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
Definition listbase.cc:834
TimeMarker * ED_markers_find_nearest_marker(ListBaseT< TimeMarker > *markers, const float frame)
GPUVertFormat * immVertexFormat()
static void add_marker_to_cfra_elem(ListBaseT< CfraElem > *lb, TimeMarker *marker, const bool only_selected)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:986
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
static int marker_get_icon_id(TimeMarker *marker, int flag)
static void ed_marker_move_cancel(bContext *C, wmOperator *op)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
void ED_markers_draw(const bContext *C, int flag)
bool ED_markers_region_visible(const ScrArea *area, const ARegion *region)
static void MARKER_OT_add(wmOperatorType *ot)
void immBegin(GPUPrimType, uint vertex_len)
void ED_keymap_marker(wmKeyConfig *keyconf)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus ed_marker_select_exec(bContext *C, wmOperator *op)
static void MARKER_OT_select(wmOperatorType *ot)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
static bool ed_markers_poll_no_locked_markers(bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
static wmOperatorStatus ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
@ TH_TIME_MARKER_LINE
@ TH_TIME_SCRUB_BACKGROUND
@ TH_TIME_MARKER_LINE_SELECTED
static void MARKER_OT_select_leftright(wmOperatorType *ot)
static int markers_frame_sort(const void *a, const void *b)
static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bAction * ANIM_active_action_from_area(const Main &bmain, Scene *scene, ViewLayer *view_layer, const ScrArea *area, ID **r_action_user)
void immUnbindProgram()
void ED_markers_select_all(ListBaseT< TimeMarker > *markers, int action)
@ CTX_MODE_OBJECT
ViewLayer * CTX_data_view_layer(const bContext *C)
static void ed_marker_move_exit(bContext *C, wmOperator *op)
void WM_operator_properties_select_all(wmOperatorType *ot)
SpaceSeq * CTX_wm_space_seq(const bContext *C)
void GPU_line_width(float width)
Definition gpu_state.cc:151
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
static wmOperatorStatus ed_marker_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ListBaseT< TimeMarker > * ED_scene_markers_get(const bContext *C, Scene *scene)
bool BLI_rctf_isect_x(const rctf *rect, float x)
Definition rct.cc:95
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
static wmOperatorStatus ed_marker_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_border_to_rctf(wmOperator *op, rctf *r_rect)
static bool ed_marker_move_init(bContext *C, wmOperator *op)
@ TIME_MARKER_ELEVATED_TEMP
static bool ed_marker_move_use_time(MarkerMove *mm)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
static void MARKER_OT_delete(wmOperatorType *ot)
void ED_operatortypes_marker()
void debug_markers_print_list(ListBaseT< TimeMarker > *markers)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void immUniform1f(const char *name, float x)
static bool ed_markers_poll_markers_exist(bContext *C)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
static bool ed_markers_poll_markers_exist_visible(bContext *C)
static void ed_marker_move_apply(bContext *C, wmOperator *op)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
void DEG_id_tag_update(ID *id, unsigned int flags)
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2595
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2])
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
wmWindowManager * CTX_wm_manager(const bContext *C)
void initNumInput(NumInput *n)
Definition numinput.cc:85
static TimeMarker * region_position_is_over_marker(const View2D *v2d, ListBaseT< TimeMarker > *markers, float region_x)
static void draw_markers_background(const rctf *rect)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
static bool marker_is_in_frame_range(TimeMarker *marker, const int frame_range[2])
static wmOperatorStatus ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
eMarkers_LeftRightSelect_Mode
@ MARKERS_LRSEL_CLICK_SIDE
@ MARKERS_LRSEL_RIGHT
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
TimeMarker * ED_markers_get_first_selected(ListBaseT< TimeMarker > *markers)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
@ DRAW_MARKERS_LOCAL
Definition ED_markers.hh:34
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
wmOperatorStatus WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus ed_marker_rename_exec(bContext *C, wmOperator *op)
static void MARKER_OT_rename(wmOperatorType *ot)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
static void ed_marker_move_update_header(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:378
static const EnumPropertyItem prop_markers_select_leftright_modes[]
static wmOperatorStatus ed_marker_rename_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:207
void void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
Definition listbase.cc:319
void BKE_view_layer_base_deselect_all(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
static wmOperatorStatus ed_marker_duplicate_exec(bContext *C, wmOperator *op)
static void draw_marker(const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int xmax, int flag, int region_height)
void WM_windows_scene_data_sync(const ListBaseT< wmWindow > *win_lb, Scene *scene)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
const EnumPropertyItem * RNA_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:1024
SpaceLink * CTX_wm_space_data(const bContext *C)
static void marker_color_get(const TimeMarker *marker, uchar *r_color)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
static wmOperatorStatus ed_marker_delete_exec(bContext *C, wmOperator *)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static wmOperatorStatus ed_marker_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene)
Definition screen.cc:1249
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void IDP_FreeProperty(IDProperty *prop)
Definition idprop.cc:1403
bool BKE_scene_camera_switch_update(Scene *scene)
Definition scene.cc:2480
int ED_markers_find_nearest_marker_time(ListBaseT< TimeMarker > *markers, float x)
static wmOperatorStatus ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:104
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_ENUM_NO_TRANSLATE
Definition RNA_types.hh:502
@ PROP_HIDDEN
Definition RNA_types.hh:408
static void ed_marker_duplicate_apply(bContext *C)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
static wmOperatorStatus ed_marker_add_exec(bContext *C, wmOperator *)
static bool operator_markers_region_active(bContext *C)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
static wmOperatorStatus ed_marker_select(bContext *C, const int mval[2], bool extend, bool deselect_all, bool camera, bool wait_to_deselect_others)
static void draw_marker_name(const uchar *text_color, const uiFontStyle *fstyle, TimeMarker *marker, float marker_x, float xmax, float text_y)
@ SACTION_POSEMARKERS_SHOW
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
@ OPTYPE_GRAB_CURSOR_X
Definition WM_types.hh:198
static void get_marker_region_rect(View2D *v2d, rctf *r_rect)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus ed_marker_select_leftright_exec(bContext *C, wmOperator *op)
void immUniform1i(const char *name, int x)
static wmOperatorStatus ed_marker_move_exec(bContext *C, wmOperator *op)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus ed_marker_box_select_exec(bContext *C, wmOperator *op)
void immUniformColor4ubv(const unsigned char rgba[4])
@ B_UNIT_TIME
Definition BKE_unit.hh:171
@ B_UNIT_NONE
Definition BKE_unit.hh:165
void GPU_matrix_pop()
static void MARKER_OT_select_all(wmOperatorType *ot)
static void select_marker_camera_switch(bContext *C, bool camera, bool extend, ListBaseT< TimeMarker > *markers, int cfra)
int ED_markers_post_apply_transform(ListBaseT< TimeMarker > *markers, Scene *scene, int mode, float value, char side)
void ED_markers_get_minmax(ListBaseT< TimeMarker > *markers, short sel, float *r_first, float *r_last)
Object * CTX_data_active_object(const bContext *C)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
ListBaseT< TimeMarker > * ED_sequencer_context_get_markers(const bContext *C)
void WM_operator_properties_generic_select(wmOperatorType *ot)
static wmOperatorStatus ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
void apply_keyb_grid(bool shift, bool ctrl, float *val, float fac1, float fac2, float fac3, int invert)
Definition ed_util.cc:342
void GPU_matrix_push()
static void MARKER_OT_move(wmOperatorType *ot)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
@ NUM_NO_FRACTION
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< TimeMarker > * markers
int unit_type[NUM_MAX_ELEMENTS]
short val_flag[NUM_MAX_ELEMENTS]
struct Object * camera
ListBaseT< TimeMarker > markers
struct UnitSettings unit
struct RenderData r
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
eGraphEdit_Flag flag
eGraphEdit_Mode mode
eSpaceNla_Flag flag
eSpaceSeq_Flag flag
struct Object * camera
struct IDProperty * prop
struct TimeMarker * next
ListBaseT< struct TimeMarker > markers
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
wmEventType type
Definition WM_types.hh:817
wmEventModifierFlag modifier
Definition WM_types.hh:834
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
struct ReportList * reports