Blender V5.3
sequencer_timeline_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 * SPDX-FileCopyrightText: 2024 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later */
5
9
10#include <cmath>
11#include <fmt/format.h>
12
13#include "BLI_listbase.hh"
14#include "BLI_math_color_c.hh"
15#include "BLI_math_vector_c.hh"
16#include "BLI_path_utils.hh"
17#include "BLI_string_utf8.hh"
18#include "BLI_string_utils.hh"
19#include "BLI_task.hh"
20#include "BLI_threads.hh"
21#include "BLI_utildefines.hh"
22
23#include "DNA_scene_types.h"
24#include "DNA_screen_types.h"
25#include "DNA_sequence_types.h"
26#include "DNA_sound_types.h"
27#include "DNA_space_types.h"
28#include "DNA_userdef_types.h"
29#include "DNA_workspace_types.h"
30
31#include "BKE_context.hh"
32#include "BKE_fcurve.hh"
33#include "BKE_global.hh"
34#include "BKE_layer.hh"
35#include "BKE_main.hh"
36#include "BKE_screen.hh"
37#include "BKE_sound.hh"
38
39#include "ED_anim_api.hh"
40#include "ED_gizmo_utils.hh"
41#include "ED_markers.hh"
42#include "ED_mask.hh"
43#include "ED_sequencer.hh"
44#include "ED_space_api.hh"
45#include "ED_time_scrub_ui.hh"
46
47#include "GPU_immediate.hh"
48#include "GPU_matrix.hh"
49#include "GPU_state.hh"
50
51#include "PRF_profile.hh"
52
53#include "RNA_prototypes.hh"
54
55#include "SEQ_channels.hh"
56#include "SEQ_connect.hh"
57#include "SEQ_edit.hh"
58#include "SEQ_effects.hh"
59#include "SEQ_iterator.hh"
60#include "SEQ_prefetch.hh"
61#include "SEQ_relations.hh"
62#include "SEQ_render.hh"
63#include "SEQ_retiming.hh"
64#include "SEQ_select.hh"
65#include "SEQ_sequencer.hh"
67#include "SEQ_time.hh"
68#include "SEQ_transform.hh"
69#include "SEQ_utils.hh"
70
71#include "UI_interface_c.hh"
72#include "UI_interface_icons.hh"
73#include "UI_resources.hh"
74#include "UI_view2d.hh"
75
76#include "WM_api.hh"
77#include "WM_toolsystem.hh"
78#include "WM_types.hh"
79
80#include "BLF_api.hh"
81
82#include "sequencer_intern.hh"
85
86namespace blender::ed::vse {
87
88constexpr int MUTE_ALPHA = 120;
89
90constexpr float ICON_SIZE = 12.0f;
91constexpr float ICON_SIZE_THUMBNAIL = 20.0f;
92
97
99{
100 const Editing *ed = seq::editing_get(scene);
101 Vector<Strip *> strips;
102
103 for (Strip &strip : *ed->current_strips()) {
104 if (min_ii(strip.left_handle(), strip.content_start()) > v2d->cur.xmax) {
105 continue;
106 }
107 if (max_ii(strip.right_handle(scene), strip.content_end(scene)) < v2d->cur.xmin) {
108 continue;
109 }
110 if (strip.channel + 1.0f < v2d->cur.ymin) {
111 continue;
112 }
113 if (strip.channel > v2d->cur.ymax) {
114 continue;
115 }
116 strips.append(&strip);
117 }
118 return strips;
119}
120
122{
124
125 ctx.C = C;
126 ctx.region = CTX_wm_region(C);
128 ctx.sseq = CTX_wm_space_seq(C);
130
131 ctx.ed = ctx.scene ? seq::editing_get(ctx.scene) : nullptr;
132 ctx.channels = ctx.ed ? seq::channels_displayed_get(ctx.ed) : nullptr;
133
136
139
141
142 ctx.quads = quads_batch;
143
144 return ctx;
145}
146
147static bool seq_draw_waveforms_poll(const SpaceSeq *sseq, const Strip *strip)
148{
149 const bool strip_is_valid = strip->type == STRIP_TYPE_SOUND && strip->sound != nullptr;
150 const bool overlays_enabled = (sseq->flag & SEQ_SHOW_OVERLAY) != 0;
151 const bool overlay_option = ((sseq->timeline_overlay.flag & SEQ_TIMELINE_ALL_WAVEFORMS) != 0 ||
152 (strip->flag & SEQ_AUDIO_DRAW_WAVEFORM));
153
155 return false;
156 }
157
158 if (strip_is_valid && overlays_enabled && overlay_option) {
159 return true;
160 }
161
162 return false;
163}
164
166 const StripDrawContext &strip_ctx)
167{
168 return seq_draw_waveforms_poll(ctx.sseq, strip_ctx.strip) ||
170}
171
173 StripDrawContext &strip_ctx)
174{
175 float threshold = 8 * UI_SCALE_FAC;
176 if (strip_hides_text_overlay_first(ctx, strip_ctx)) {
177 threshold = 20 * UI_SCALE_FAC;
178 }
179
180 const bool overlays_enabled = (ctx.sseq->timeline_overlay.flag &
183
184 strip_ctx.can_draw_text_overlay = (strip_ctx.top - strip_ctx.bottom) / ctx.pixely >= threshold;
185 strip_ctx.can_draw_text_overlay &= overlays_enabled;
186}
187
189 StripDrawContext &strip_ctx)
190{
191 float threshold = 20 * UI_SCALE_FAC;
192 if (strip_hides_text_overlay_first(ctx, strip_ctx)) {
193 threshold = 8 * UI_SCALE_FAC;
194 }
195
196 strip_ctx.can_draw_strip_content = ((strip_ctx.top - strip_ctx.bottom) / ctx.pixely) > threshold;
197}
198
200 StripDrawContext &strip_ctx)
201{
202 float2 threshold{15 * UI_SCALE_FAC, 25 * UI_SCALE_FAC};
203 strip_ctx.can_draw_retiming_overlay = (strip_ctx.top - strip_ctx.bottom) / ctx.pixely >=
204 threshold.y;
205 strip_ctx.can_draw_retiming_overlay &= strip_ctx.strip_length / ctx.pixelx >= threshold.x;
207}
208
210{
211 return min_ff(0.40f, 20 * UI_SCALE_FAC * ctx.pixely);
212}
213
215{
216 using namespace seq;
217 StripDrawContext strip_ctx;
218 Scene *scene = ctx.scene;
219
220 strip_ctx.strip = strip;
221 strip_ctx.bottom = strip->channel + STRIP_OFSBOTTOM;
222 strip_ctx.top = strip->channel + STRIP_OFSTOP;
223 strip_ctx.left_handle = strip->left_handle();
224 strip_ctx.right_handle = strip->right_handle(scene);
225 strip_ctx.content_start = strip->content_start();
226 strip_ctx.content_end = strip->content_end(scene);
227
228 if (strip->type == STRIP_TYPE_SOUND && strip->sound != nullptr) {
229 /* Visualize sub-frame sound offsets. */
230 const double sound_offset = (strip->sound->offset_time + strip->sound_offset) *
231 scene->frames_per_second();
232 strip_ctx.content_start += sound_offset;
233 strip_ctx.content_end += sound_offset;
234 }
235
236 /* Limit body to strip bounds. */
237 strip_ctx.content_start = min_ff(strip_ctx.content_start, strip_ctx.right_handle);
238 strip_ctx.content_end = max_ff(strip_ctx.content_end, strip_ctx.left_handle);
239
240 strip_ctx.strip_length = strip_ctx.right_handle - strip_ctx.left_handle;
241
245 strip_ctx.strip_is_too_small = (!strip_ctx.can_draw_text_overlay &&
246 !strip_ctx.can_draw_strip_content);
247 strip_ctx.is_active_strip = strip == select_active_get(scene);
248 strip_ctx.is_single_image = transform_single_image_check(strip);
249 strip_ctx.handle_width = strip_handle_draw_size_get(ctx.scene, strip, ctx.pixelx);
252
253 /* Determine if strip (or contents of meta strip) has missing data/media. */
254 strip_ctx.missing_data_block = !strip_has_valid_data(strip);
255 strip_ctx.missing_media = media_presence_is_missing(scene, strip);
256 strip_ctx.is_connected = is_strip_connected(strip);
257 strip_ctx.has_retiming = retiming_has_keys(strip);
258 if (strip->type == STRIP_TYPE_META) {
259 const ListBaseT<Strip> *seqbase = &strip->seqbase;
260 for (const Strip &sub : *seqbase) {
261 if (!strip_has_valid_data(&sub)) {
262 strip_ctx.missing_data_block = true;
263 }
264 if (media_presence_is_missing(scene, &sub)) {
265 strip_ctx.missing_media = true;
266 }
267 }
268 }
269
270 if (strip_ctx.can_draw_text_overlay) {
271 strip_ctx.strip_content_top = strip_ctx.top - strip_header_size_get(ctx);
272 }
273 else {
274 strip_ctx.strip_content_top = strip_ctx.top;
275 }
276
277 strip_ctx.is_muted = render_is_muted(ctx.channels, strip);
278 strip_ctx.curve = nullptr;
279 return strip_ctx;
280}
281
283 StripDrawContext &strip_ctx)
284{
285 strip_ctx.curve = nullptr;
286 const bool showing_curve_overlay = strip_ctx.can_draw_strip_content &&
287 (ctx.sseq->flag & SEQ_SHOW_OVERLAY) != 0 &&
290 const bool showing_waveform = (strip_ctx.strip->type == STRIP_TYPE_SOUND) &&
291 !strip_ctx.strip_is_too_small &&
292 seq_draw_waveforms_poll(ctx.sseq, strip_ctx.strip);
293 if (showing_curve_overlay || showing_waveform) {
294 const char *prop_name = strip_ctx.strip->type == STRIP_TYPE_SOUND ? "volume" : "blend_alpha";
295 strip_ctx.curve = id_data_find_fcurve(
296 &ctx.scene->id, strip_ctx.strip, RNA_Strip, prop_name, 0, nullptr);
297 if (strip_ctx.curve && BKE_fcurve_is_empty(strip_ctx.curve)) {
298 strip_ctx.curve = nullptr;
299 }
300 }
301}
302
303static void color3ubv_from_seq(const Scene *curscene,
304 const Strip *strip,
305 const bool show_strip_color_tag,
306 const bool is_muted,
307 uchar r_col[3])
308{
309 if (show_strip_color_tag && uint(strip->color_tag) < STRIP_COLOR_TOT &&
310 strip->color_tag != STRIP_COLOR_NONE)
311 {
312 const bTheme *btheme = ui::theme::theme_get();
313 const ThemeStripColor *strip_color = &btheme->strip_color[strip->color_tag];
314 copy_v3_v3_uchar(r_col, strip_color->color);
315 return;
316 }
317
318 uchar blendcol[3];
319
320 /* Sometimes the active theme is not the sequencer theme, e.g. when an operator invokes the file
321 * browser. This makes sure we get the right color values for the theme. */
322 ui::theme::bThemeState theme_state;
323 ui::theme::theme_store(&theme_state);
325
326 switch (strip->type) {
327 case STRIP_TYPE_IMAGE:
329 break;
330
331 case STRIP_TYPE_META:
333 break;
334
335 case STRIP_TYPE_MOVIE:
337 break;
338
341 break;
342
343 case STRIP_TYPE_MASK:
345 break;
346
347 case STRIP_TYPE_SCENE:
349
350 if (strip->scene == curscene) {
351 ui::theme::get_color_shade_3ubv(r_col, 20, r_col);
352 }
353 break;
354
355 /* Transitions use input colors, fallback for when the input is a transition itself. */
356 case STRIP_TYPE_CROSS:
358 case STRIP_TYPE_WIPE:
361
362 /* Slightly offset hue to distinguish different transition types. */
363 if (strip->type == STRIP_TYPE_GAMCROSS) {
365 }
366 else if (strip->type == STRIP_TYPE_WIPE) {
368 }
369 else if (strip->type == STRIP_TYPE_COMPOSITOR) {
370 rgb_byte_set_hue_float_offset(r_col, -0.03f);
371 }
372 break;
373
374 /* Effects. */
375 case STRIP_TYPE_SPEED:
376 case STRIP_TYPE_ADD:
377 case STRIP_TYPE_SUB:
378 case STRIP_TYPE_MUL:
381 case STRIP_TYPE_GLOW:
387
388 /* Slightly offset hue to distinguish different effects. */
389 if (strip->type == STRIP_TYPE_ADD) {
391 }
392 else if (strip->type == STRIP_TYPE_SUB) {
394 }
395 else if (strip->type == STRIP_TYPE_MUL) {
397 }
398 else if (strip->type == STRIP_TYPE_ALPHAOVER) {
400 }
401 else if (strip->type == STRIP_TYPE_ALPHAUNDER) {
403 }
404 else if (strip->type == STRIP_TYPE_COLORMIX) {
406 }
407 else if (strip->type == STRIP_TYPE_GAUSSIAN_BLUR) {
409 }
410 else if (strip->type == STRIP_TYPE_GLOW) {
412 }
413 else if (strip->type == STRIP_TYPE_ADJUSTMENT) {
415 }
416 else if (strip->type == STRIP_TYPE_SPEED) {
418 }
419 else if (strip->type == STRIP_TYPE_MULTICAM) {
421 }
422 break;
423
424 case STRIP_TYPE_COLOR:
426 break;
427
428 case STRIP_TYPE_SOUND:
430 blendcol[0] = blendcol[1] = blendcol[2] = 128;
431 if (is_muted) {
432 ui::theme::get_color_blend_shade_3ubv(r_col, blendcol, 0.5, 20, r_col);
433 }
434 break;
435
436 case STRIP_TYPE_TEXT:
438 break;
439
440 default:
441 r_col[0] = 10;
442 r_col[1] = 255;
443 r_col[2] = 40;
444 break;
445 }
446
447 ui::theme::theme_restore(&theme_state);
448}
449
450static void waveform_job_start_if_needed(const bContext *C, const Strip *strip)
451{
454 }
455}
456
457static float align_frame_with_pixel(float frame_coord, float frames_per_pixel)
458{
459 return round_fl_to_int(frame_coord / frames_per_pixel) * frames_per_pixel;
460}
461
463 const StripDrawContext &strip_ctx)
464{
465 if (!seq_draw_waveforms_poll(ctx.sseq, strip_ctx.strip) || strip_ctx.strip_is_too_small) {
466 return;
467 }
468
469 PRF_scope_with_name("SeqTimelineWaveform", ProfileCategory::Draw);
470
471 const View2D *v2d = ctx.v2d;
472 Scene *scene = ctx.scene;
473 Strip *strip = strip_ctx.strip;
474
475 const bool half_style = (ctx.sseq->timeline_overlay.flag & SEQ_TIMELINE_WAVEFORMS_HALF) != 0;
476
477 const float frames_per_pixel = BLI_rctf_size_x(&v2d->cur) / ctx.region->winx;
478 const float samples_per_frame = SOUND_WAVE_SAMPLES_PER_SECOND / scene->frames_per_second();
479 const float samples_per_pixel = samples_per_frame * frames_per_pixel;
480 const float bottom = strip_ctx.bottom + ctx.pixely * 2.0f;
481 const float top = strip_ctx.strip_content_top;
482 /* The y coordinate of signal level zero. */
483 const float y_zero = half_style ? bottom : (bottom + top) / 2.0f;
484 /* The y range of unit signal level. */
485 const float y_scale = half_style ? top - bottom : (top - bottom) / 2.0f;
486
487 /* Align strip start with nearest pixel to prevent waveform flickering. */
488 const float strip_start_aligned = align_frame_with_pixel(
489 strip_ctx.left_handle + ctx.pixelx * 3.0f, frames_per_pixel);
490 /* Offset x1 and x2 values, to match view min/max, if strip is out of bounds. */
491 const float draw_start_frame = max_ff(v2d->cur.xmin, strip_start_aligned);
492 const float draw_end_frame = min_ff(v2d->cur.xmax, strip_ctx.right_handle - ctx.pixelx * 3.0f);
493 /* Offset must be also aligned, otherwise waveform flickers when moving left handle. */
494 float sample_start_frame = draw_start_frame - (strip->sound->offset_time + strip->sound_offset) *
495 scene->frames_per_second();
496
497 const int pixels_to_draw = round_fl_to_int((draw_end_frame - draw_start_frame) /
498 frames_per_pixel);
499
500 if (pixels_to_draw < 2) {
501 return; /* Not much to draw, exit before running job. */
502 }
503
505
506 const Vector<float> *waveform = BKE_sound_runtime_get_waveform(strip->sound);
507 if (waveform == nullptr || waveform->is_empty()) {
508 return; /* Waveform was not built. */
509 }
510
511 /* Draw zero line (when actual samples close to zero are drawn, they might not cover a pixel). */
512 uchar color[4] = {255, 255, 255, 127};
513 uchar color_clip[4] = {255, 0, 0, 127};
514 uchar color_rms[4] = {255, 255, 255, 204};
515 ctx.quads->add_line(draw_start_frame, y_zero, draw_end_frame, y_zero, color);
516
517 const int waveform_sample_count = waveform->size() / 3;
518 float prev_y_mid = y_zero;
519 for (int i = 0; i < pixels_to_draw; i++) {
520 float timeline_frame = sample_start_frame + i * frames_per_pixel;
521 float frame_index = seq::give_frame_index(scene, strip, timeline_frame) + strip->anim_startofs;
522 float sample = frame_index * samples_per_frame;
523 int sample_index = round_fl_to_int(sample);
524
525 if (sample_index < 0) {
526 continue;
527 }
528
529 if (sample_index >= waveform_sample_count) {
530 break;
531 }
532
533 float value_min = (*waveform)[sample_index * 3];
534 float value_max = (*waveform)[sample_index * 3 + 1];
535 float rms = (*waveform)[sample_index * 3 + 2];
536
537 if (samples_per_pixel > 1.0f) {
538 /* We need to sum up the values we skip over until the next step. */
539 float next_pos = sample + samples_per_pixel;
540 int end_idx = round_fl_to_int(next_pos);
541
542 for (int j = sample_index + 1; (j < waveform_sample_count) && (j < end_idx); j++) {
543 value_min = min_ff(value_min, (*waveform)[j * 3]);
544 value_max = max_ff(value_max, (*waveform)[j * 3 + 1]);
545 rms = max_ff(rms, (*waveform)[j * 3 + 2]);
546 }
547 }
548
549 float volume = strip->volume;
550 if (strip_ctx.curve != nullptr) {
551 float evaltime = draw_start_frame + (i * frames_per_pixel);
552 volume = evaluate_fcurve(strip_ctx.curve, evaltime);
553 CLAMP_MIN(volume, 0.0f);
554 }
555
556 value_min *= volume;
557 value_max *= volume;
558 rms *= volume;
559
560 bool is_clipping = false;
561 float clamped_min = clamp_f(value_min, -1.0f, 1.0f);
562 float clamped_max = clamp_f(value_max, -1.0f, 1.0f);
563 if (clamped_min != value_min || clamped_max != value_max) {
564 is_clipping = true;
565 }
566 value_min = clamped_min;
567 value_max = clamped_max;
568
569 /* We are drawing only half to the waveform, mirroring the lower part upwards.
570 * If both min and max are on the same side of zero line, we want to draw a bar
571 * between them. If min and max cross zero, we want to fill bar from zero to max
572 * of those. */
573 if (half_style) {
574 bool pos_min = value_min > 0.0f;
575 bool pos_max = value_max > 0.0f;
576 float abs_min = std::abs(value_min);
577 float abs_max = std::abs(value_max);
578 if (pos_min == pos_max) {
579 value_min = std::min(abs_min, abs_max);
580 value_max = std::max(abs_min, abs_max);
581 }
582 else {
583 value_min = 0;
584 value_max = std::max(abs_min, abs_max);
585 }
586 }
587
588 float x1 = draw_start_frame + i * frames_per_pixel;
589 float x2 = draw_start_frame + (i + 1) * frames_per_pixel;
590 float y_min = y_zero + value_min * y_scale;
591 float y_max = y_zero + value_max * y_scale;
592 float y_mid = (y_max + y_min) * 0.5f;
593
594 /* If a bar would be below 2px, make it a line. */
595 if (y_max - y_min < ctx.pixely * 2) {
596 /* If previous segment was also a line of different enough
597 * height, join them. */
598 if (std::abs(y_mid - prev_y_mid) > ctx.pixely) {
599 float x0 = draw_start_frame + (i - 1) * frames_per_pixel;
600 ctx.quads->add_line(x0, prev_y_mid, x1, y_mid, is_clipping ? color_clip : color);
601 }
602 ctx.quads->add_line(x1, y_mid, x2, y_mid, is_clipping ? color_clip : color);
603 }
604 else {
605 float rms_min = y_zero + max_ff(-rms, value_min) * y_scale;
606 float rms_max = y_zero + min_ff(rms, value_max) * y_scale;
607 /* RMS */
608 ctx.quads->add_quad(x1, rms_min, x2, rms_max, is_clipping ? color_clip : color_rms);
609 /* Sample */
610 ctx.quads->add_quad(x1, y_min, x2, y_max, is_clipping ? color_clip : color);
611 }
612
613 prev_y_mid = y_mid;
614 }
615}
616
618 const StripDrawContext &strip_ctx,
619 float corner_radius)
620{
621 using namespace seq;
622 Strip *strip_meta = strip_ctx.strip;
623 if (!strip_ctx.can_draw_strip_content || (ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0) {
624 return;
625 }
626 if ((strip_meta->type != STRIP_TYPE_META) &&
627 ((strip_meta->type != STRIP_TYPE_SCENE) || (strip_meta->flag & SEQ_SCENE_STRIPS) == 0))
628 {
629 return;
630 }
631
632 Scene *scene = ctx.scene;
633
634 uchar col[4];
635
636 int chan_min = MAX_CHANNELS;
637 int chan_max = 0;
638 int chan_range = 0;
639 /* Some vertical margin to account for rounded corners, so that contents do
640 * not draw outside them. Can be removed when meta contents are drawn with
641 * full rounded corners masking shader. */
642 const float bottom = strip_ctx.bottom + corner_radius * 0.8f * ctx.pixely;
643 const float top = strip_ctx.strip_content_top - corner_radius * 0.8f * ctx.pixely;
644 const float draw_range = top - bottom;
645 if (draw_range < ctx.pixely) {
646 return;
647 }
648
649 ListBaseT<SeqTimelineChannel> *meta_channels;
650 int offset;
651
652 ListBaseT<Strip> *meta_seqbase = get_seqbase_from_strip(strip_meta, &meta_channels, &offset);
653
654 if (!meta_seqbase || meta_seqbase->is_empty()) {
655 return;
656 }
657
658 if (strip_meta->type == STRIP_TYPE_SCENE) {
659 offset = strip_meta->start - offset;
660 }
661 else {
662 offset = 0;
663 }
664
665 for (Strip &strip : *meta_seqbase) {
666 chan_min = min_ii(chan_min, strip.channel);
667 chan_max = max_ii(chan_max, strip.channel);
668 }
669
670 chan_range = (chan_max - chan_min) + 1;
671 float draw_height = draw_range / chan_range;
672
673 col[3] = 196; /* Alpha, used for all meta children. */
674
675 const float meta_x1 = strip_ctx.left_handle;
676 const float meta_x2 = strip_ctx.right_handle;
677
678 /* Draw only immediate children (1 level depth). */
679 for (Strip &strip : *meta_seqbase) {
680 float x1_chan = strip.left_handle() + offset;
681 float x2_chan = strip.right_handle(scene) + offset;
682 if (x1_chan <= meta_x2 && x2_chan >= meta_x1) {
683 float y_chan = (strip.channel - chan_min) / float(chan_range) * draw_range;
684
685 if (strip.type == STRIP_TYPE_COLOR) {
686 SolidColorVars *colvars = static_cast<SolidColorVars *>(strip.effectdata);
687 rgb_float_to_uchar(col, colvars->col);
688 }
689 else {
690 color3ubv_from_seq(scene, &strip, strip_ctx.show_strip_color_tag, strip_ctx.is_muted, col);
691 }
692
693 if (strip_ctx.is_muted || render_is_muted(meta_channels, &strip)) {
694 col[3] = 64;
695 }
696 else {
697 col[3] = 196;
698 }
699
700 const bool missing_data = !strip_has_valid_data(&strip);
701 const bool missing_media = media_presence_is_missing(scene, &strip);
702 if (missing_data || missing_media) {
703 col[0] = 112;
704 col[1] = 0;
705 col[2] = 0;
706 }
707
708 /* Clamp within parent sequence strip bounds. */
709 x1_chan = max_ff(x1_chan, meta_x1);
710 x2_chan = min_ff(x2_chan, meta_x2);
711
712 float y1_chan = bottom + y_chan + (draw_height * STRIP_OFSBOTTOM);
713 float y2_chan = bottom + y_chan + (draw_height * STRIP_OFSTOP);
714
715 ctx.quads->add_quad(x1_chan, y1_chan, x2_chan, y2_chan, col);
716 }
717 }
718}
719
721 const StripDrawContext &strip_ctx,
722 eStripHandle handle)
723{
724 /* Draw numbers for start and end of the strip next to its handles. */
725 if (strip_ctx.strip_is_too_small || (strip_ctx.strip->flag & SEQ_SELECT) == 0) {
726 return;
727 }
728
729 if (handle_is_selected(strip_ctx.strip, handle) == 0 && (G.moving & G_TRANSFORM_SEQ) == 0) {
730 return;
731 }
732
733 char numstr[64];
735
736 /* Calculate if strip is wide enough for showing the labels. */
737 size_t numstr_len = SNPRINTF_UTF8_RLEN(
738 numstr, "%d%d", int(strip_ctx.left_handle), int(strip_ctx.right_handle));
739 const float tot_width = BLF_width(BLF_default(), numstr, numstr_len);
740
741 if (strip_ctx.strip_length / ctx.pixelx < 20 + tot_width) {
742 return;
743 }
744
745 constexpr uchar col[4] = {255, 255, 255, 255};
746 const float text_margin = 1.2f * strip_ctx.handle_width;
747 const float text_y = strip_ctx.bottom + 0.09f;
748 float text_x = strip_ctx.left_handle;
749
750 if (handle == STRIP_HANDLE_LEFT) {
751 numstr_len = SNPRINTF_UTF8_RLEN(numstr, "%d", int(strip_ctx.left_handle));
752 text_x += text_margin;
753 }
754 else {
755 numstr_len = SNPRINTF_UTF8_RLEN(numstr, "%d", int(strip_ctx.right_handle - 1));
756 text_x = strip_ctx.right_handle -
757 (text_margin + ctx.pixelx * BLF_width(BLF_default(), numstr, numstr_len));
758 }
759 ui::view2d_text_cache_add(ctx.v2d, text_x, text_y, numstr, numstr_len, col);
760}
761
762float strip_handle_draw_size_get(const Scene *scene, const Strip *strip, const float pixelx)
763{
764 const float handle_size = pixelx * (5.0f * U.pixelsize);
765
766 /* Ensure that the handle is not wider than a quarter of the strip. */
767 return min_ff(handle_size, (float(strip->right_handle(scene) - strip->left_handle()) / 4.0f));
768}
769
770static const char *draw_seq_text_get_name(const Strip *strip)
771{
772 const char *name = strip->name + 2;
773 if (name[0] == '\0') {
774 name = seq::strip_give_name(strip);
775 }
776 return name;
777}
778
779static void draw_seq_text_get_source(const Strip *strip, char *r_source, size_t source_maxncpy)
780{
781 *r_source = '\0';
782
783 /* Set source for the most common types. */
784 switch (strip->type) {
785 case STRIP_TYPE_IMAGE:
786 case STRIP_TYPE_MOVIE: {
788 r_source, source_maxncpy, strip->data->dirpath, strip->data->stripdata->filename);
789 break;
790 }
791 case STRIP_TYPE_SOUND: {
792 if (strip->sound != nullptr) {
793 if (strip->sound->packedfile != nullptr) {
794 /* The sound data has been packed, don't display the path. */
795 BLI_strncpy_utf8(r_source, "<Packed File>", source_maxncpy);
796 }
797 else {
798 BLI_strncpy_utf8(r_source, strip->sound->filepath, source_maxncpy);
799 }
800 }
801 break;
802 }
803 case STRIP_TYPE_MULTICAM: {
804 BLI_snprintf_utf8(r_source, source_maxncpy, "Channel: %d", strip->multicam_source);
805 break;
806 }
807 case STRIP_TYPE_TEXT: {
808 const TextVars *textdata = static_cast<TextVars *>(strip->effectdata);
809 BLI_strncpy_utf8(r_source, textdata->text_ptr, source_maxncpy);
810 break;
811 }
812 case STRIP_TYPE_SCENE: {
813 if (strip->scene != nullptr) {
814 if (strip->scene_camera != nullptr) {
815 BLI_snprintf_utf8(r_source,
816 source_maxncpy,
817 "%s (%s)",
818 strip->scene->id.name + 2,
819 strip->scene_camera->id.name + 2);
820 }
821 else {
822 BLI_strncpy_utf8(r_source, strip->scene->id.name + 2, source_maxncpy);
823 }
824 }
825 break;
826 }
828 if (strip->clip != nullptr) {
829 BLI_strncpy_utf8(r_source, strip->clip->id.name + 2, source_maxncpy);
830 }
831 break;
832 }
833 case STRIP_TYPE_MASK: {
834 if (strip->mask != nullptr) {
835 BLI_strncpy_utf8(r_source, strip->mask->id.name + 2, source_maxncpy);
836 }
837 break;
838 }
839 default:
840 break;
841 }
842}
843
845 const StripDrawContext &strip_ctx,
846 char *r_overlay_string,
847 size_t overlay_string_maxncpy)
848{
849 const Strip *strip = strip_ctx.strip;
850
851 const char *text_sep = " | ";
852 const char *text_array[7];
853 int i = 0;
854
856 text_array[i++] = draw_seq_text_get_name(strip);
857 }
858
859 char source[FILE_MAX];
861 draw_seq_text_get_source(strip, source, sizeof(source));
862 if (source[0] != '\0') {
863 if (i != 0) {
864 text_array[i++] = text_sep;
865 }
866 text_array[i++] = source;
867 }
868
869 if (strip->type == STRIP_TYPE_SCENE && strip->scene != nullptr &&
870 (strip->flag & SEQ_SCENE_STRIPS) == 0)
871 {
872 BLI_assert(strip->scene_view_layer_name != nullptr);
873 if (i != 0) {
874 text_array[i++] = text_sep;
875 }
876 text_array[i++] = strip->scene_view_layer_name;
877 }
878 }
879
880 char strip_duration_text[16];
882 SNPRINTF_UTF8(strip_duration_text, "%d", int(strip_ctx.strip_length));
883 if (i != 0) {
884 text_array[i++] = text_sep;
885 }
886 text_array[i++] = strip_duration_text;
887 }
888
889 BLI_assert(i <= ARRAY_SIZE(text_array));
890
891 return BLI_string_join_array(r_overlay_string, overlay_string_maxncpy, text_array, i);
892}
893
894static void get_strip_text_color(const StripDrawContext &strip_ctx, uchar r_col[4])
895{
896 const Strip *strip = strip_ctx.strip;
897 const bool active_or_selected = (strip->flag & SEQ_SELECT) || strip_ctx.is_active_strip;
898
899 /* Text: white when selected/active, black otherwise. */
900 r_col[0] = r_col[1] = r_col[2] = r_col[3] = 255;
901
902 /* If not active or selected, draw text black. */
903 if (!active_or_selected) {
904 r_col[0] = r_col[1] = r_col[2] = 0;
905
906 /* On missing media/data-block strips: a blend between alert and text color. */
907 if (strip_ctx.missing_data_block || strip_ctx.missing_media) {
908 uchar col_alert[4];
910 ui::theme::get_color_blend_3ubv(TH_REDALERT, TH_TEXT_HI, col_alert[3] / 255.0f, r_col);
911 }
912
913 /* On muted strips: gray color, reduce opacity. */
914 if (strip_ctx.is_muted) {
915 r_col[0] = r_col[1] = r_col[2] = 192;
916 r_col[3] *= 0.66f;
917 }
918 }
919}
920
921static int get_icon_id_from_strip_type(const Strip *strip)
922{
923 switch (strip->type) {
924 case STRIP_TYPE_SCENE:
925 return ICON_SCENE_DATA;
927 return ICON_TRACKER;
928 case STRIP_TYPE_MASK:
929 return ICON_MOD_MASK;
930 case STRIP_TYPE_MOVIE:
931 return ICON_FILE_MOVIE;
932 case STRIP_TYPE_SOUND:
933 return ICON_FILE_SOUND;
934 case STRIP_TYPE_IMAGE:
935 return ICON_FILE_IMAGE;
936 case STRIP_TYPE_COLOR:
938 return ICON_COLOR;
939 case STRIP_TYPE_TEXT:
940 return ICON_FONT_DATA;
942 return ICON_NODE_COMPOSITING;
943 case STRIP_TYPE_CROSS:
944 case STRIP_TYPE_ADD:
945 case STRIP_TYPE_SUB:
949 case STRIP_TYPE_MUL:
950 case STRIP_TYPE_WIPE:
951 case STRIP_TYPE_GLOW:
952 case STRIP_TYPE_SPEED:
956 return ICON_SHADERFX;
957 default:
958 return ICON_SEQ_STRIP;
959 }
960}
961
963 const rctf &rect,
964 int icon_id,
965 const uchar color[4],
966 const float size = ICON_SIZE)
967{
970
971 const float icon_size = size * UI_SCALE_FAC;
972 if (BLI_rctf_size_x(&rect) * 1.1f < icon_size * ctx.pixelx ||
973 BLI_rctf_size_y(&rect) * 1.1f < icon_size * ctx.pixely)
974 {
976 return;
977 }
978
979 const float left = ((rect.xmin - ctx.v2d->cur.xmin) / ctx.pixelx);
980 const float right = ((rect.xmax - ctx.v2d->cur.xmin) / ctx.pixelx);
981 const float bottom = ((rect.ymin - ctx.v2d->cur.ymin) / ctx.pixely);
982 const float top = ((rect.ymax - ctx.v2d->cur.ymin) / ctx.pixely);
983 const float x_offset = (right - left - icon_size) * 0.5f;
984 const float y_offset = (top - bottom - icon_size) * 0.5f;
985
986 const float inv_scale_fac = (ICON_DEFAULT_HEIGHT / size) * UI_INV_SCALE_FAC;
987
988 ui::icon_draw_ex(left + x_offset,
989 bottom + y_offset,
990 icon_id,
991 inv_scale_fac,
992 1.0f,
993 0.0f,
994 color,
995 false,
997
998 /* Restore view matrix. */
1000}
1001
1003 const Vector<StripDrawContext> &strips)
1004{
1005 for (const StripDrawContext &strip : strips) {
1006 const bool missing_data = strip.missing_data_block;
1007 const bool missing_media = strip.missing_media;
1008 const bool is_connected = strip.is_connected;
1009 const bool has_retiming = strip.has_retiming;
1010 if (!missing_data && !missing_media && !is_connected && !has_retiming) {
1011 continue;
1012 }
1013
1014 /* Draw icon in the title bar area. */
1015 if ((ctx.sseq->flag & SEQ_SHOW_OVERLAY) != 0 && !strip.strip_is_too_small) {
1016 uchar col[4];
1017 get_strip_text_color(strip, col);
1018
1019 const float icon_size_x = ICON_SIZE * ctx.pixelx * UI_SCALE_FAC;
1020 const float icon_indent = 2.0f * strip.handle_width - 4 * ctx.pixelx * UI_SCALE_FAC;
1021 const float icon_spacing = 3.0f * ctx.pixelx * UI_SCALE_FAC;
1022 rctf rect;
1023 rect.ymin = strip.top - strip_header_size_get(ctx);
1024 rect.ymax = strip.top;
1025 rect.xmin = max_ff(strip.left_handle, ctx.v2d->cur.xmin) + icon_indent;
1026 if (missing_data) {
1027 rect.xmax = min_ff(strip.right_handle - strip.handle_width,
1028 rect.xmin + icon_size_x + icon_spacing);
1029 draw_icon_centered(ctx, rect, ICON_LIBRARY_DATA_BROKEN, col);
1030 rect.xmin = rect.xmax;
1031 }
1032 if (missing_media) {
1033 rect.xmax = min_ff(strip.right_handle - strip.handle_width,
1034 rect.xmin + icon_size_x + icon_spacing);
1035 draw_icon_centered(ctx, rect, ICON_STATUS_ERROR_FILLED, col);
1036 rect.xmin = rect.xmax;
1037 }
1038 if (is_connected) {
1039 rect.xmax = min_ff(strip.right_handle - strip.handle_width,
1040 rect.xmin + icon_size_x + icon_spacing);
1041 draw_icon_centered(ctx, rect, ICON_LINKED, col);
1042 rect.xmin = rect.xmax;
1043 }
1044 if (has_retiming) {
1045 rect.xmax = min_ff(strip.right_handle - strip.handle_width,
1046 rect.xmin + icon_size_x + icon_spacing);
1047 draw_icon_centered(ctx, rect, ICON_MOD_TIME, col);
1048 }
1049 }
1050
1051 /* Draw icon in center of content. */
1052 if (strip.can_draw_strip_content && strip.strip->type != STRIP_TYPE_META) {
1053 rctf rect;
1054 rect.xmin = strip.left_handle + strip.handle_width;
1055 rect.xmax = strip.right_handle - strip.handle_width;
1056
1057 const float pad_y = 5.0f * UI_SCALE_FAC * ctx.pixely;
1058 rect.ymin = strip.bottom + pad_y;
1059 rect.ymax = strip.strip_content_top - pad_y;
1060
1061 const int icon_id = get_icon_id_from_strip_type(strip.strip);
1062
1063 const float avail_size = BLI_rctf_size_y(&rect) / ctx.pixely * UI_INV_SCALE_FAC;
1064 const float icon_size = min_ff(ICON_SIZE_THUMBNAIL, avail_size);
1065
1066 uchar col[4];
1068
1069 if (icon_size >= ICON_SIZE) {
1070 if (missing_data) {
1071 draw_icon_centered(ctx, rect, icon_id, col, icon_size);
1072 }
1073 if (missing_media) {
1074 draw_icon_centered(ctx, rect, icon_id, col, icon_size);
1075 }
1076 }
1077 }
1078 }
1079}
1080
1081/* Draw info text on a sequence strip. */
1083 const StripDrawContext &strip_ctx)
1084{
1085 if ((ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0) {
1086 return;
1087 }
1088 /* Draw text only if there is enough horizontal or vertical space. */
1089 if ((strip_ctx.strip_length <= 32 * ctx.pixelx * UI_SCALE_FAC) || strip_ctx.strip_is_too_small ||
1090 !strip_ctx.can_draw_text_overlay)
1091 {
1092 return;
1093 }
1094
1095 char overlay_string[FILE_MAX];
1096 size_t overlay_string_len = draw_seq_text_get_overlay_string(
1097 ctx, strip_ctx, overlay_string, sizeof(overlay_string));
1098
1099 if (overlay_string_len == 0) {
1100 return;
1101 }
1102
1103 uchar col[4];
1104 get_strip_text_color(strip_ctx, col);
1105
1106 /* Note that the subtracted portion is half of `icon_indent`'s in `draw_strip_icons`. */
1107 float text_margin = 2.0f * strip_ctx.handle_width - 2 * ctx.pixelx * UI_SCALE_FAC;
1108 rctf rect;
1109 rect.xmin = strip_ctx.left_handle + text_margin;
1110 rect.xmax = strip_ctx.right_handle - text_margin;
1111 rect.ymax = strip_ctx.top;
1112 /* Depending on the vertical space, draw text on top or in the center of strip. */
1113 rect.ymin = !strip_ctx.can_draw_strip_content ? strip_ctx.bottom : strip_ctx.strip_content_top;
1114 rect.xmin = max_ff(rect.xmin, ctx.v2d->cur.xmin + text_margin);
1115 int num_icons = 0;
1116 if (strip_ctx.missing_data_block) {
1117 num_icons++;
1118 }
1119 if (strip_ctx.missing_media) {
1120 num_icons++;
1121 }
1122 if (strip_ctx.is_connected) {
1123 num_icons++;
1124 }
1125 if (strip_ctx.has_retiming) {
1126 num_icons++;
1127 }
1128 rect.xmin += num_icons * ICON_SIZE * ctx.pixelx * UI_SCALE_FAC; /* Icon widths. */
1129 rect.xmin += num_icons * 3.0f * ctx.pixelx * UI_SCALE_FAC; /* Icon spacings. */
1130 rect.xmin = min_ff(rect.xmin, ctx.v2d->cur.xmax);
1131
1132 CLAMP(rect.xmax, ctx.v2d->cur.xmin + text_margin, ctx.v2d->cur.xmax);
1133 if (rect.xmin >= rect.xmax) { /* No space for label left. */
1134 return;
1135 }
1136
1137 ui::view2d_text_cache_add_rectf(ctx.v2d, &rect, overlay_string, overlay_string_len, col);
1138}
1139
1140static void draw_strip_offsets(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
1141{
1142 const Strip *strip = strip_ctx.strip;
1143 if ((ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0) {
1144 return;
1145 }
1146 if (strip_ctx.is_single_image || ctx.pixely <= 0) {
1147 return;
1148 }
1150 (strip_ctx.strip != special_preview_get()) &&
1151 !flag_is_set(strip_ctx.strip->runtime->flag, seq::StripRuntimeFlag::ShowOffsets))
1152 {
1153 return;
1154 }
1155
1156 const Scene *scene = ctx.scene;
1157
1158 uchar col[4], blend_col[4];
1159 color3ubv_from_seq(scene, strip, strip_ctx.show_strip_color_tag, strip_ctx.is_muted, col);
1160 if (strip->flag & SEQ_SELECT) {
1161 ui::theme::get_color_shade_3ubv(col, 50, col);
1162 }
1163 col[3] = strip_ctx.is_muted ? MUTE_ALPHA : 200;
1164 ui::theme::get_color_shade_3ubv(col, 10, blend_col);
1165 blend_col[3] = 255;
1166
1167 if (strip_ctx.left_handle > strip_ctx.content_start) {
1168 ctx.quads->add_quad(strip_ctx.left_handle,
1169 strip_ctx.bottom - ctx.pixely,
1170 strip_ctx.content_start,
1171 strip_ctx.bottom - STRIP_OFSBOTTOM,
1172 col);
1173 ctx.quads->add_wire_quad(strip_ctx.left_handle,
1174 strip_ctx.bottom - ctx.pixely,
1175 strip_ctx.content_start,
1176 strip_ctx.bottom - STRIP_OFSBOTTOM,
1177 blend_col);
1178 }
1179 if (strip_ctx.right_handle < strip_ctx.content_end) {
1180 ctx.quads->add_quad(strip_ctx.right_handle,
1181 strip_ctx.top + ctx.pixely,
1182 strip_ctx.content_end,
1183 strip_ctx.top + STRIP_OFSBOTTOM,
1184 col);
1185 ctx.quads->add_wire_quad(strip_ctx.right_handle,
1186 strip_ctx.top + ctx.pixely,
1187 strip_ctx.content_end,
1188 strip_ctx.top + STRIP_OFSBOTTOM,
1189 blend_col);
1190 }
1191}
1192
1199 const StripDrawContext &strip_ctx)
1200{
1201 if (!strip_ctx.can_draw_strip_content || (ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0 ||
1203 {
1204 return;
1205 }
1206 if (strip_ctx.curve == nullptr) {
1207 return;
1208 }
1209
1210 PRF_scope_with_name("SeqTimelineFCurve", ProfileCategory::Draw);
1211
1212 const int eval_step = max_ii(1, floor(ctx.pixelx));
1213 uchar color[4] = {0, 0, 0, 38};
1214
1215 /* Clamp curve evaluation to the editor's borders. */
1216 int eval_start = max_ff(strip_ctx.left_handle, ctx.v2d->cur.xmin);
1217 int eval_end = min_ff(strip_ctx.right_handle, ctx.v2d->cur.xmax + 1);
1218 if (eval_start >= eval_end) {
1219 return;
1220 }
1221
1222 const float y_height = strip_ctx.top - strip_ctx.bottom;
1223 float prev_x = eval_start;
1224 float prev_val = evaluate_fcurve(strip_ctx.curve, eval_start);
1225 CLAMP(prev_val, 0.0f, 1.0f);
1226 bool skip = false;
1227
1228 for (int timeline_frame = eval_start + eval_step; timeline_frame <= eval_end;
1229 timeline_frame += eval_step)
1230 {
1231 float curve_val = evaluate_fcurve(strip_ctx.curve, timeline_frame);
1232 CLAMP(curve_val, 0.0f, 1.0f);
1233
1234 /* Avoid adding adjacent verts that have the same value. */
1235 if (curve_val == prev_val && timeline_frame < eval_end - eval_step) {
1236 skip = true;
1237 continue;
1238 }
1239
1240 /* If some frames were skipped above, we need to close the shape. */
1241 if (skip) {
1242 ctx.quads->add_quad(prev_x,
1243 (prev_val * y_height) + strip_ctx.bottom,
1244 prev_x,
1245 strip_ctx.top,
1246 timeline_frame - eval_step,
1247 (prev_val * y_height) + strip_ctx.bottom,
1248 timeline_frame - eval_step,
1249 strip_ctx.top,
1250 color);
1251 skip = false;
1252 prev_x = timeline_frame - eval_step;
1253 }
1254
1255 ctx.quads->add_quad(prev_x,
1256 (prev_val * y_height) + strip_ctx.bottom,
1257 prev_x,
1258 strip_ctx.top,
1259 timeline_frame,
1260 (curve_val * y_height) + strip_ctx.bottom,
1261 timeline_frame,
1262 strip_ctx.top,
1263 color);
1264 prev_x = timeline_frame;
1265 prev_val = curve_val;
1266 }
1267}
1268
1269/* When active strip is a Multi-cam strip, highlight its source channel. */
1271 const StripDrawContext &strip_ctx)
1272{
1273 Strip *act_strip = seq::select_active_get(ctx.scene);
1274
1275 if (strip_ctx.strip != act_strip || act_strip == nullptr) {
1276 return;
1277 }
1278 if ((act_strip->flag & SEQ_SELECT) == 0 || act_strip->type != STRIP_TYPE_MULTICAM) {
1279 return;
1280 }
1281
1282 int channel = act_strip->multicam_source;
1283
1284 if (channel == 0) {
1285 return;
1286 }
1287
1288 View2D *v2d = ctx.v2d;
1289 uchar color[4] = {255, 255, 255, 48};
1290 ctx.quads->add_quad(v2d->cur.xmin, channel, v2d->cur.xmax, channel + 1, color);
1291}
1292
1293/* Force redraw, when prefetching and using cache view. */
1294static void seq_prefetch_wm_notify(const bContext *C, Scene *scene)
1295{
1296 if (seq::prefetch_need_redraw(C, scene)) {
1298 }
1299}
1300
1302{
1303 View2D *v2d = ctx.v2d;
1304
1306 uchar4 color;
1308
1309 /* Alternating horizontal stripes. */
1310 int i = max_ii(1, int(v2d->cur.ymin) - 1);
1311 while (i < v2d->cur.ymax) {
1312 if (i & 1) {
1313 ctx.quads->add_quad(v2d->cur.xmin, i, v2d->cur.xmax, i + 1, color);
1314 }
1315 i++;
1316 }
1317
1318 ctx.quads->draw();
1320}
1321
1322/* Get visible strips into two sets: regular strips, and strips
1323 * that are dragged over other strips right now (e.g. dragging
1324 * selection in the timeline). This is to make the dragged strips
1325 * always render "on top" of others. */
1327 Vector<StripDrawContext> &r_bottom_layer,
1328 Vector<StripDrawContext> &r_top_layer)
1329{
1330 r_bottom_layer.clear();
1331 r_top_layer.clear();
1332
1334 r_bottom_layer.reserve(strips.size());
1335
1336 for (Strip *strip : strips) {
1337 StripDrawContext strip_ctx = strip_draw_context_get(ctx, strip);
1338 if (!flag_is_set(strip->runtime->flag, seq::StripRuntimeFlag::Overlap)) {
1339 r_bottom_layer.append(strip_ctx);
1340 }
1341 else {
1342 r_top_layer.append(strip_ctx);
1343 }
1344 }
1345
1346 /* Finding which curves (if any) drive a strip is expensive, do these lookups
1347 * in parallel. */
1348 threading::parallel_for(IndexRange(r_bottom_layer.size()), 64, [&](IndexRange range) {
1349 for (int64_t index : range) {
1350 strip_draw_context_curve_get(ctx, r_bottom_layer[index]);
1351 }
1352 });
1353 threading::parallel_for(IndexRange(r_top_layer.size()), 64, [&](IndexRange range) {
1354 for (int64_t index : range) {
1355 strip_draw_context_curve_get(ctx, r_top_layer[index]);
1356 }
1357 });
1358}
1359
1361 StripsDrawBatch &strips_batch,
1362 const Vector<StripDrawContext> &strips)
1363{
1366
1368
1369 const bool show_overlay = (ctx.sseq->flag & SEQ_SHOW_OVERLAY) != 0;
1370 const Scene *scene = ctx.scene;
1371 for (const StripDrawContext &strip : strips) {
1372 SeqStripDrawData &data = strips_batch.add_strip(strip.content_start,
1373 strip.content_end,
1374 strip.top,
1375 strip.bottom,
1376 strip.strip_content_top,
1377 strip.left_handle,
1378 strip.right_handle,
1379 strip.handle_width,
1380 strip.is_single_image);
1381
1382 /* Background color. */
1383 uchar col[4];
1385 color3ubv_from_seq(scene, strip.strip, strip.show_strip_color_tag, strip.is_muted, col);
1386 col[3] = strip.is_muted ? MUTE_ALPHA : 255;
1387 /* Muted strips: turn almost gray. */
1388 if (strip.is_muted) {
1389 uchar muted_color[3] = {128, 128, 128};
1390 ui::theme::get_color_blend_shade_3ubv(col, muted_color, 0.5f, 0, col);
1391 }
1392
1393 /* Missing media. */
1394 if (strip.missing_data_block || strip.missing_media) {
1395 uchar alert_color[4];
1397 ui::theme::get_color_blend_shade_3ubv(col, alert_color, alert_color[3] / 255.0f, -20, col);
1398 }
1399
1400 data.col_background = color_pack(col);
1401
1402 const bool show_thumbnails = (ctx.sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS);
1403 /* Darker color band for thumbnail strips. */
1404 if (show_overlay && seq::strip_can_have_thumbnail(scene, strip.strip) && show_thumbnails) {
1405 /* The more negative the offset, darker the color. */
1406 const int color_offset = -15;
1407 uchar col_in[3] = {col[0], col[1], col[2]};
1408 uchar col_out[3];
1409
1410 ui::theme::get_color_shade_3ubv(col_in, color_offset, col_out);
1411
1412 col[0] = col_out[0];
1413 col[1] = col_out[1];
1414 col[2] = col_out[2];
1415
1417 data.col_color_band = color_pack(col);
1418 }
1419
1420 /* Color band state. */
1421 if (show_overlay && (strip.strip->type == STRIP_TYPE_COLOR)) {
1423 SolidColorVars *colvars = static_cast<SolidColorVars *>(strip.strip->effectdata);
1424 rgb_float_to_uchar(col, colvars->col);
1425 data.col_color_band = color_pack(col);
1426 }
1427
1428 /* Transition state. */
1429 if (show_overlay && strip.can_draw_strip_content &&
1430 seq::effect_is_transition(strip.strip->type) && strip.strip->input1 && strip.strip->input2)
1431 {
1433
1434 const Strip *input1 = strip.strip->input1;
1435 const Strip *input2 = strip.strip->input2;
1436
1437 /* Left side. */
1438 if (input1->type == STRIP_TYPE_COLOR) {
1439 rgb_float_to_uchar(col, (static_cast<const SolidColorVars *>(input1->effectdata))->col);
1440 }
1441 else {
1442 color3ubv_from_seq(scene, input1, strip.show_strip_color_tag, strip.is_muted, col);
1443 }
1444 data.col_transition_in = color_pack(col);
1445
1446 /* Right side. */
1447 if (input2->type == STRIP_TYPE_COLOR) {
1448 rgb_float_to_uchar(col, (static_cast<const SolidColorVars *>(input2->effectdata))->col);
1449 }
1450 else {
1451 color3ubv_from_seq(scene, input2, strip.show_strip_color_tag, strip.is_muted, col);
1452 /* If the transition inputs are of the same type, draw the right side slightly darker. */
1453 if (input1->type == input2->type) {
1454 ui::theme::get_color_shade_3ubv(col, -15, col);
1455 }
1456 }
1457 data.col_transition_out = color_pack(col);
1458 }
1459 }
1460 strips_batch.flush_batch();
1463}
1464
1467{
1468 if (strip.missing_data_block || strip.missing_media) {
1469 /* Do not tint title area for muted strips; we want to see gray for them. */
1470 if (!strip.is_muted) {
1472 }
1473 /* Do not tint content area for meta strips; we want to display children. */
1474 if (strip.strip->type != STRIP_TYPE_META) {
1476 }
1477 }
1478}
1479
1481 const TimelineDrawContext &ctx,
1483{
1484 if (seq::transform_is_locked(ctx.channels, strip.strip)) {
1485 data.flags |= GPU_SEQ_FLAG_LOCKED;
1486 }
1487}
1488
1490 const TimelineDrawContext &ctx,
1492{
1493 const bool active = strip.is_active_strip;
1494 const bool selected = strip.strip->flag & SEQ_SELECT;
1495 uchar4 col{0, 0, 0, 255};
1496
1497 if (selected) {
1499 data.flags |= GPU_SEQ_FLAG_SELECTED;
1500 }
1501 if (active) {
1502 if (selected) {
1504 }
1505 else {
1507 }
1508 data.flags |= GPU_SEQ_FLAG_ACTIVE;
1509 }
1510 if (!selected && !active) {
1511 /* Color for unselected strips is a bit darker than the background. */
1513 }
1514
1515 const bool translating = (G.moving & G_TRANSFORM_SEQ);
1516
1518 const bool use_overwrite = overlap_mode == SEQ_OVERLAP_OVERWRITE;
1519 const bool overlaps = flag_is_set(strip.strip->runtime->flag, seq::StripRuntimeFlag::Overlap) &&
1520 translating;
1521
1522 const bool clamped_l = flag_is_set(strip.strip->runtime->flag, seq::StripRuntimeFlag::ClampedLH);
1523 const bool clamped_r = flag_is_set(strip.strip->runtime->flag, seq::StripRuntimeFlag::ClampedRH);
1524
1525 /* Strip outline is:
1526 * - Red when overlapping with other strips or handles are clamped.
1527 * - Slightly lighter while translating strips. */
1528 if ((translating && overlaps && !use_overwrite) || clamped_l || clamped_r) {
1529 col[0] = 255;
1530 col[1] = col[2] = 33;
1531 data.flags |= GPU_SEQ_FLAG_OVERLAP;
1532 }
1533 else if (translating && selected) {
1534 ui::theme::get_color_shade_3ubv(col, 70, col);
1535 }
1536
1537 data.col_outline = color_pack(col);
1538}
1539
1541 const TimelineDrawContext &ctx,
1543{
1544 const Strip *act_strip = seq::select_active_get(ctx.scene);
1545 const Strip *special_preview = special_preview_get();
1546 /* Highlight if strip is an input of an active strip, or if the strip is solo preview. */
1547 if (act_strip != nullptr && (act_strip->flag & SEQ_SELECT) != 0) {
1548 if (act_strip->input1 == strip.strip || act_strip->input2 == strip.strip) {
1550 }
1551 }
1552 if (special_preview == strip.strip) {
1554 }
1555}
1556
1558 const TimelineDrawContext &ctx,
1560{
1561 const Scene *scene = ctx.scene;
1562 const bool selected = strip.strip->flag & SEQ_SELECT;
1563 /* Handles on left/right side. */
1564 if (!seq::transform_is_locked(ctx.channels, strip.strip) &&
1565 can_select_handle(scene, strip.strip))
1566 {
1567 const bool selected_l = selected && handle_is_selected(strip.strip, STRIP_HANDLE_LEFT);
1568 const bool selected_r = selected && handle_is_selected(strip.strip, STRIP_HANDLE_RIGHT);
1569 if (selected_l) {
1571 }
1572 if (selected_r) {
1574 }
1575 }
1576}
1577
1579 StripsDrawBatch &strips_batch,
1580 const Vector<StripDrawContext> &strips)
1581{
1585
1586 for (const StripDrawContext &strip : strips) {
1587 SeqStripDrawData &data = strips_batch.add_strip(strip.content_start,
1588 strip.content_end,
1589 strip.top,
1590 strip.bottom,
1591 strip.strip_content_top,
1592 strip.left_handle,
1593 strip.right_handle,
1594 strip.handle_width,
1595 strip.is_single_image);
1596 data.flags |= GPU_SEQ_FLAG_BORDER;
1598 strip_data_lock_flags_set(strip, ctx, data);
1599 strip_data_handle_flags_set(strip, ctx, data);
1602 }
1603
1604 strips_batch.flush_batch();
1607}
1608
1610 const Vector<StripDrawContext> &strips)
1611{
1614
1615 for (const StripDrawContext &strip_ctx : strips) {
1616 sequencer_retiming_draw_segments(ctx, strip_ctx);
1617 }
1618 ctx.quads->draw();
1619
1621}
1622
1624 const StripsDrawBatch &batch,
1625 const Vector<StripDrawContext> &strips)
1626{
1627 /* Nothing to do if we're not showing thumbnails overall. */
1628 const bool show_thumbnails = (ctx.sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS);
1629 if ((ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0 || !show_thumbnails) {
1630 return;
1631 }
1632
1635
1636 std::lock_guard lock(seq::text_runtime_mutex_get());
1637
1638 for (const StripDrawContext &strip : strips) {
1639 if (!strip.can_draw_strip_content || strip.strip->type != STRIP_TYPE_TEXT) {
1640 continue;
1641 }
1642
1643 TextVars *data = static_cast<TextVars *>(strip.strip->effectdata);
1644 if (data == nullptr || data->text_len_bytes < 1 || data->color[3] < 0.01f) {
1645 continue;
1646 }
1647
1648 const float content_height_px = (strip.strip_content_top - strip.bottom) / ctx.pixely;
1649 if (content_height_px <= 10 * UI_SCALE_FAC) {
1650 continue;
1651 }
1652
1653 const FontFlags font_flags = ((data->flag & SEQ_TEXT_BOLD) ? BLF_BOLD : BLF_NONE) |
1654 ((data->flag & SEQ_TEXT_ITALIC) ? BLF_ITALIC : BLF_NONE) |
1656
1657 const int font = seq::text_effect_font_get(*data);
1658 float font_size = std::min(data->text_size, content_height_px * 0.5f);
1659 const float lightness = srgb_to_grayscale(data->color);
1660 const bool outline_is_dark = lightness > 0.37f;
1661 float outline_dark_color[4] = {0, 0, 0, 0.8f * data->color[3]};
1662 float outline_light_color[4] = {1, 1, 1, 0.8f * data->color[3]};
1663
1664 BLF_enable(font, font_flags);
1665 BLF_size(font, font_size);
1666 BLF_shadow(
1667 font, FontShadowType::None, outline_is_dark ? outline_dark_color : outline_light_color);
1668 BLF_shadow_offset(font, 1, -1);
1669
1670 BLF_color4fv(font, data->color);
1671
1672 constexpr float margin = 2.0f;
1673 const float x1 = batch.pos_to_pixel_space_x(strip.left_handle) + margin;
1674 const float x2 = batch.pos_to_pixel_space_x(strip.right_handle) - margin;
1675 const float y1 = batch.pos_to_pixel_space_y(strip.bottom) + margin;
1676 const float y2 = batch.pos_to_pixel_space_y(strip.strip_content_top) - margin;
1677
1678 BLF_clipping(font, int(x1), int(y1), int(x2), int(y2));
1679 BLF_position(font, x1 + margin, (y1 + y2) * 0.5f - font_size * 0.25f, 0.0f);
1680 BLF_draw(font, data->text_ptr, data->text_len_bytes);
1681
1682 BLF_disable(font, font_flags);
1683 }
1684
1686}
1687
1689 StripsDrawBatch &strips_batch,
1690 const Vector<StripDrawContext> &strips)
1691{
1692 if (strips.is_empty()) {
1693 return;
1694 }
1695
1696 PRF_scope_with_name("SeqTimelineStrips", ProfileCategory::Draw);
1697
1699
1700 /* Draw parts of strips below thumbnails. */
1701 draw_strips_background(ctx, strips_batch, strips);
1702
1704 const float round_radius = calc_strip_round_radius(ctx.pixely);
1705 for (const StripDrawContext &strip_ctx : strips) {
1706 draw_strip_offsets(ctx, strip_ctx);
1707 drawmeta_contents(ctx, strip_ctx, round_radius);
1708 }
1709 ctx.quads->draw();
1710
1711 /* Draw thumbnails and text strip content. */
1712 draw_strip_thumbnails(ctx, strips_batch, strips);
1713 draw_strip_texts(ctx, strips_batch, strips);
1714
1715 /* Draw parts of strips above thumbnails. */
1717 for (const StripDrawContext &strip_ctx : strips) {
1718 draw_seq_fcurve_overlay(ctx, strip_ctx);
1719 draw_seq_waveform_overlay(ctx, strip_ctx);
1720 draw_multicam_highlight(ctx, strip_ctx);
1723 draw_seq_text_overlay(ctx, strip_ctx);
1725 }
1726 ctx.quads->draw();
1727
1728 draw_retiming_segments(ctx, strips);
1729 sequencer_retiming_keys_draw(ctx, strips);
1730
1731 draw_strips_foreground(ctx, strips_batch, strips);
1732
1733 /* Draw icons. */
1734 draw_strip_icons(ctx, strips);
1735
1736 /* Draw text labels. */
1739}
1740
1741static void draw_seq_strips(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch)
1742{
1743 if (ctx.ed == nullptr) {
1744 return;
1745 }
1746
1747 /* Discard thumbnail requests that are far enough from viewing area:
1748 * by +- 30 frames and +-2 channels outside of current view. */
1749 rctf rect = ctx.v2d->cur;
1750 rect.xmin -= 30;
1751 rect.xmax += 30;
1752 rect.ymin -= 2;
1753 rect.ymax += 2;
1756
1757 Vector<StripDrawContext> bottom_layer, top_layer;
1758 visible_strips_ordered_get(ctx, bottom_layer, top_layer);
1759 draw_seq_strips(ctx, strips_batch, bottom_layer);
1760 draw_seq_strips(ctx, strips_batch, top_layer);
1761}
1762
1764{
1765 const Scene *scene = ctx.scene;
1766 if (!scene) {
1767 return;
1768 }
1769 const View2D *v2d = ctx.v2d;
1770 const Editing *ed = seq::editing_get(scene);
1771 const int frame_sta = scene->r.sfra;
1772 /* The VSE timeline uses a different convention of displaying frame ranges, since the VSE has to
1773 * display the duration the frame. This is why there is the + 1 for the end frame. */
1774 const int frame_end = scene->r.efra + 1;
1775
1777
1778 /* Draw overlay outside of frame range. */
1779 uchar4 color;
1781
1782 if (frame_sta < frame_end) {
1783 ctx.quads->add_quad(v2d->cur.xmin, v2d->cur.ymin, float(frame_sta), v2d->cur.ymax, color);
1784 ctx.quads->add_quad(float(frame_end), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax, color);
1785 }
1786 else {
1787 ctx.quads->add_quad(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax, color);
1788 }
1789
1790 /* Draw frame range boundary. */
1792
1793 ctx.quads->add_line(frame_end, v2d->cur.ymin, frame_end, v2d->cur.ymax, color);
1794 ctx.quads->add_line(frame_end, v2d->cur.ymin, frame_end, v2d->cur.ymax, color);
1795
1796 ctx.quads->draw();
1797
1798 /* While in meta strip, draw a checkerboard overlay outside of frame range. */
1799 if (ed && !ed->metastack.is_empty()) {
1800 const MetaStack *ms = ed->metastack.last();
1801
1802 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1804
1805 immUniform4f("color1", 0.0f, 0.0f, 0.0f, 0.22f);
1806 immUniform4f("color2", 1.0f, 1.0f, 1.0f, 0.0f);
1807 immUniform1i("size", 8);
1808
1809 immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, ms->disp_range[0], v2d->cur.ymax);
1810 immRectf(pos, ms->disp_range[1], v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
1811
1813
1815 ctx.quads->add_line(ms->disp_range[0], v2d->cur.ymin, ms->disp_range[0], v2d->cur.ymax, color);
1816 ctx.quads->add_line(ms->disp_range[1], v2d->cur.ymin, ms->disp_range[1], v2d->cur.ymax, color);
1817 ctx.quads->draw();
1818 }
1819
1821}
1822
1830
1831/* Draw final cache entries on top of the timeline. */
1832static void draw_cache_final_iter_fn(void *userdata, int timeline_frame)
1833{
1834 CacheDrawData *drawdata = static_cast<CacheDrawData *>(userdata);
1835
1836 /* Same as movie clip cache color, see ED_region_cache_draw_cached_segments. */
1837 const uchar4 col{108, 108, 210, 255};
1838
1839 const View2D *v2d = drawdata->v2d;
1840 float stripe_top = v2d->cur.ymax - (UI_TIME_SCRUB_MARGIN_Y / ui::view2d_scale_get_y(v2d));
1841 float stripe_bot = stripe_top - (UI_TIME_CACHE_MARGIN_Y / ui::view2d_scale_get_y(v2d));
1842 drawdata->quads->add_quad(timeline_frame, stripe_bot, timeline_frame + 1, stripe_top, col);
1843}
1844
1845/* Draw source cache entries at bottom of the strips. */
1846static void draw_cache_source_iter_fn(void *userdata, const Strip *strip, int timeline_frame)
1847{
1848 CacheDrawData *drawdata = static_cast<CacheDrawData *>(userdata);
1849
1850 const uchar4 col{255, 25, 5, 100};
1851 float stripe_bot = strip->channel + STRIP_OFSBOTTOM + drawdata->stripe_ofs_y;
1852 float stripe_top = stripe_bot + drawdata->stripe_ht;
1854 drawdata->quads->add_quad(
1855 strip->left_handle(), stripe_bot, strip->right_handle(drawdata->scene), stripe_top, col);
1856 return;
1857 }
1858 drawdata->quads->add_quad(timeline_frame, stripe_bot, timeline_frame + 1, stripe_top, col);
1859}
1860
1861static void draw_cache_stripe(const Scene *scene,
1862 const Strip *strip,
1863 SeqQuadsBatch &quads,
1864 const float stripe_bot,
1865 const float stripe_ht,
1866 const uchar color[4])
1867{
1868 quads.add_quad(
1869 strip->left_handle(), stripe_bot, strip->right_handle(scene), stripe_bot + stripe_ht, color);
1870}
1871
1872static void draw_cache_background(const bContext *C, const CacheDrawData *draw_data)
1873{
1874 const Scene *scene = CTX_data_sequencer_scene(C);
1875 const View2D *v2d = ui::view2d_fromcontext(C);
1876 const SpaceSeq *sseq = CTX_wm_space_seq(C);
1877
1878 /* NOTE: Final bg color is the same as the movie clip cache color.
1879 * See ED_region_cache_draw_background.
1880 */
1881 const uchar4 bg_final{78, 78, 145, 255};
1882 const uchar4 bg_raw{255, 25, 5, 25};
1883
1884 float stripe_bot;
1885 bool dev_ui = (U.flag & USER_DEVELOPER_UI);
1886
1888 /* Draw the final cache on top of the timeline */
1889 float stripe_top = v2d->cur.ymax - (UI_TIME_SCRUB_MARGIN_Y / ui::view2d_scale_get_y(v2d));
1890 stripe_bot = stripe_top - (UI_TIME_CACHE_MARGIN_Y / ui::view2d_scale_get_y(v2d));
1891
1892 draw_data->quads->add_quad(scene->r.sfra, stripe_bot, scene->r.efra, stripe_top, bg_final);
1893 }
1894
1895 if (!dev_ui) {
1896 /* Don't show these cache types below unless developer extras is on. */
1897 return;
1898 }
1899
1901 strips.remove_if([&](const Strip *strip) { return strip->type == STRIP_TYPE_SOUND; });
1902
1903 for (const Strip *strip : strips) {
1904 stripe_bot = strip->channel + STRIP_OFSBOTTOM + draw_data->stripe_ofs_y;
1906 draw_cache_stripe(scene, strip, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_raw);
1907 }
1908 }
1909}
1910
1911static void draw_cache_view(const bContext *C)
1912{
1914 const View2D *v2d = ui::view2d_fromcontext(C);
1915 const SpaceSeq *sseq = CTX_wm_space_seq(C);
1916
1917 if ((sseq->flag & SEQ_SHOW_OVERLAY) == 0 || (sseq->cache_overlay.flag & SEQ_CACHE_SHOW) == 0) {
1918 return;
1919 }
1920
1921 float stripe_ofs_y = ui::view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin;
1922 float stripe_ht = ui::view2d_region_to_view_y(v2d, 4.0f * UI_SCALE_FAC * U.pixelsize) -
1923 v2d->cur.ymin;
1924
1925 CLAMP_MAX(stripe_ht, 0.2f);
1926 CLAMP_MIN(stripe_ofs_y, stripe_ht / 2);
1927
1928 SeqQuadsBatch quads;
1929 CacheDrawData userdata;
1930 userdata.scene = scene;
1931 userdata.v2d = v2d;
1932 userdata.stripe_ofs_y = stripe_ofs_y;
1933 userdata.stripe_ht = stripe_ht;
1934 userdata.quads = &quads;
1935
1937
1938 draw_cache_background(C, &userdata);
1941 }
1942 if ((U.flag & USER_DEVELOPER_UI) && (sseq->cache_overlay.flag & SEQ_CACHE_SHOW_RAW)) {
1944 }
1945
1946 quads.draw();
1948}
1949
1950static void draw_overlay_frame_indicator(const Scene *scene, const View2D *v2d)
1951{
1952 int overlay_frame = (scene->ed->overlay_frame_flag & SEQ_EDIT_OVERLAY_FRAME_ABS) ?
1953 scene->ed->overlay_frame_abs :
1954 scene->r.cfra + scene->ed->overlay_frame_ofs;
1955
1956 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1958 float viewport_size[4];
1959 GPU_viewport_size_get_f(viewport_size);
1960 immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
1961 /* Shader may have color set from past usage - reset it. */
1962 immUniform1i("colors_len", 0);
1963 immUniform1f("dash_width", 20.0f * U.pixelsize);
1964 immUniform1f("udash_factor", 0.5f);
1966
1968 immVertex2f(pos, overlay_frame, v2d->cur.ymin);
1969 immVertex2f(pos, overlay_frame, v2d->cur.ymax);
1970 immEnd();
1971
1973}
1974
1976{
1977 if ((ctx.sseq->flag & SEQ_SHOW_OVERLAY) == 0 ||
1979 {
1980 return;
1981 }
1982
1983 if (ctx.scene == nullptr) {
1984 /* If we don't have a scene available, pick what we defined as default for frame-rate to show
1985 * *something*. */
1986 Scene scene = {};
1988 ctx.v2d, &scene, (ctx.sseq->flag & SEQ_DRAWFRAMES) == 0, false, false);
1989 }
1990 else {
1992 ctx.v2d, ctx.scene, (ctx.sseq->flag & SEQ_DRAWFRAMES) == 0, false, false);
1993 }
1994}
1995
1997{
1999 return;
2000 }
2001 if (ctx.scene == nullptr) {
2002 return;
2003 }
2004
2005 ui::view2d_view_orthoSpecial(ctx.region, ctx.v2d, true);
2008}
2009
2011{
2012 if ((ctx.sseq->gizmo_flag & SEQ_GIZMO_HIDE) != 0) {
2013 return;
2014 }
2015
2017}
2018
2027
2034
2035void draw_timeline_seq(const bContext *C, const ARegion *region)
2036{
2037 PRF_scope_with_name("SeqTimelineDraw", ProfileCategory::Draw);
2038
2039 SeqQuadsBatch quads_batch;
2040 TimelineDrawContext ctx = timeline_draw_context_get(C, &quads_batch);
2041 StripsDrawBatch strips_batch(ctx.v2d);
2042
2045
2048 draw_timeline_grid(ctx);
2050 draw_seq_strips(ctx, strips_batch);
2052 if (ctx.scene) {
2053 ANIM_draw_previewrange(ctx.scene, ctx.v2d, 1);
2054 }
2057
2059
2061 if (ctx.scene) {
2062 const int fps = round_db_to_int(ctx.scene->frames_per_second());
2063 ED_time_scrub_draw(region, ctx.scene, !(ctx.sseq->flag & SEQ_DRAWFRAMES), true, fps);
2064 }
2065
2066 if (ctx.scene) {
2068 }
2069}
2070
2072{
2073 const Scene *scene = CTX_data_sequencer_scene(C);
2074 if (!scene) {
2075 return;
2076 }
2077 const SpaceSeq *sseq = CTX_wm_space_seq(C);
2078 View2D *v2d = &region->v2d;
2079
2080 if (scene->ed != nullptr) {
2084 draw_overlay_frame_indicator(scene, v2d);
2085 }
2087 }
2088
2090 region, scene, !(sseq->flag & SEQ_DRAWFRAMES), region->winy >= UI_ANIM_MINY);
2091
2092 if (region->winy > UI_ANIM_MINY) {
2093 if (const Editing *ed = seq::editing_get(scene)) {
2094 const ListBaseT<Strip> *seqbase = seq::active_seqbase_get(ed);
2095 seq::timeline_boundbox(scene, seqbase, &v2d->tot);
2096 const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask);
2097 region->v2d.scroll |= V2D_SCROLL_BOTTOM;
2098 ui::view2d_scrollers_draw(v2d, &scroller_mask);
2099 }
2100 }
2101 else {
2102 region->v2d.scroll &= ~V2D_SCROLL_BOTTOM;
2103 }
2104}
2105
2107{
2108 ScrArea *area = CTX_wm_area(C);
2109 const bToolRef *tref = area->runtime.tool;
2110 if (tref == nullptr || !STREQ(tref->idname, "builtin.blade")) {
2111 return false;
2112 }
2114 return scene != nullptr && seq::editing_get(scene) != nullptr;
2115}
2116
2118{
2120 WM_operatortype_find("SEQUENCER_OT_box_blade", false));
2121}
2122
2123/* Expand to the strips each split propagates to, skip chains that fail to split. */
2125 Strip *strip,
2126 const seq::StripRelation include,
2127 VectorSet<Strip *> &targets)
2128{
2129 if (targets.contains(strip)) {
2130 return;
2131 }
2132 VectorSet<Strip *> chain;
2133 chain.add(strip);
2134 seq::expand_strips(ed, chain, include);
2135 const ListBaseT<SeqTimelineChannel> *channels = seq::channels_displayed_get(ed);
2136 for (Strip *strip_chain : chain) {
2137 if (seq::transform_is_locked(channels, strip_chain)) {
2138 return;
2139 }
2140 }
2141 targets.add_multiple(chain.as_span());
2142}
2143
2144static void box_blade_draw(Scene *scene, const ARegion *region, wmOperator *op)
2145{
2146 Editing *ed = seq::editing_get(scene);
2147 const View2D *v2d = &region->v2d;
2148
2149 const rctf box_rect = box_blade_rect_get(op, v2d);
2150 const bool remove_gaps = RNA_boolean_get(op->ptr, "remove_gaps");
2151 const bool only_selected = split_only_selected_get(op);
2152 const bool ignore_connections = RNA_boolean_get(op->ptr, "ignore_connections");
2154 if (!ignore_connections) {
2155 include |= only_selected ? seq::StripRelation::SelectedConnected :
2157 }
2158 const int2 rect_frames = {round_fl_to_int(box_rect.xmin), round_fl_to_int(box_rect.xmax)};
2159
2160 /* Gather the strips the cut propagates to, like the split preview does. */
2161 VectorSet<Strip *> targets;
2162 for (Strip &candidate : *ed->current_strips()) {
2163 if (only_selected && (candidate.flag & SEQ_SELECT) == 0) {
2164 continue;
2165 }
2166 rctf strip_rect = strip_bounds_get(scene, &candidate);
2167 if (!BLI_rctf_isect(&strip_rect, &box_rect, nullptr)) {
2168 continue;
2169 }
2170 split_expand_strips(ed, &candidate, include, targets);
2171 }
2172
2173 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
2176
2177 /* Paint cursors draw in window space, not region space. */
2178 auto draw_view_rect = [&](const rctf &rect) {
2179 rcti rect_region;
2180 ui::view2d_view_to_region_rcti(v2d, &rect, &rect_region);
2181 BLI_rcti_translate(&rect_region, region->winrct.xmin, region->winrct.ymin);
2182 immRectf(pos, rect_region.xmin, rect_region.ymin, rect_region.xmax, rect_region.ymax);
2183 };
2184
2185 if (remove_gaps) {
2186 const int channel_min = max_ii(int(box_rect.ymin), 1);
2187 const int channel_max = min_ii(int(box_rect.ymax) - 1, seq::MAX_CHANNELS);
2188 /* Slightly brighten all channels that the box touches. */
2189 immUniformColor4ub(255, 255, 255, 15);
2190 for (int channel = channel_min; channel <= channel_max; channel++) {
2191 draw_view_rect({v2d->cur.xmin, v2d->cur.xmax, float(channel), float(channel + 1)});
2192 }
2193 }
2194
2196 for (const Strip *strip : targets) {
2197 rctf cut_rect = strip_bounds_get(scene, strip);
2198 cut_rect.xmin = max_ff(cut_rect.xmin, rect_frames[0]);
2199 cut_rect.xmax = min_ff(cut_rect.xmax, rect_frames[1]);
2200 if (cut_rect.xmin < cut_rect.xmax) {
2201 draw_view_rect(cut_rect);
2202 }
2203 }
2204
2207}
2208
2210 const char *identifier,
2211 const bool default_value)
2212{
2213 if (tref == nullptr) {
2214 return default_value;
2215 }
2216
2217 wmOperatorType *ot_split = WM_operatortype_find("SEQUENCER_OT_split", false);
2218 if (ot_split == nullptr) {
2219 return default_value;
2220 }
2221
2222 PointerRNA tool_props;
2223 if (!WM_toolsystem_ref_properties_get_from_operator(tref, ot_split, &tool_props)) {
2224 return default_value;
2225 }
2226
2227 return RNA_boolean_get(&tool_props, identifier);
2228}
2229
2235
2236static std::optional<BladeSplit> blade_split_get(
2237 Scene *scene, const ARegion *region, const wmWindow *win, bToolRef *tref, const int2 &xy)
2238{
2239 const View2D *v2d = &region->v2d;
2240 Editing *ed = seq::editing_get(scene);
2241
2242 const int2 mval = xy - int2(region->winrct.xmin, region->winrct.ymin);
2243 float2 mouse_co;
2244 ui::view2d_region_to_view(v2d, mval.x, mval.y, &mouse_co.x, &mouse_co.y);
2245 const int split_frame = round_fl_to_int(mouse_co.x);
2246
2247 const wmEvent *event = win->runtime->eventstate;
2248 const bool all_channels = (event->modifier & KM_SHIFT) != 0 ||
2249 split_tool_prop_from_toolsettings(tref, "all_channels", false);
2250 const bool only_selected = split_tool_prop_from_toolsettings(tref, "only_selected", false);
2251 const bool ignore_connections = !all_channels && ((event->modifier & KM_ALT) != 0 ||
2253 tref, "ignore_connections", false));
2255 if (!ignore_connections) {
2256 include |= only_selected ? seq::StripRelation::SelectedConnected :
2258 }
2259
2260 const std::optional<int> channel = all_channels ? std::nullopt :
2261 std::optional<int>(int(mouse_co.y));
2262 BladeSplit split = {split_frame, all_channels, {}};
2263 for (Strip *strip : seq::edit_split_strips_get(scene, split_frame, channel, only_selected)) {
2264 split_expand_strips(ed, strip, include, split.strips);
2265 }
2266
2267 if (split.strips.is_empty() && !all_channels) {
2268 return std::nullopt;
2269 }
2270 return split;
2271}
2272
2273static void blade_split_draw(Scene *scene, const ARegion *region, const BladeSplit &split)
2274{
2275 const View2D *v2d = &region->v2d;
2276 const int split_frame = split.frame;
2277
2278 /* Paint cursors draw in window space, not region space. */
2279 const float2 region_offset = {float(region->winrct.xmin), float(region->winrct.ymin)};
2280
2281 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
2284
2285 if (split.all_channels) {
2286 const float x = ui::view2d_view_to_region_x(v2d, split_frame) + region_offset.x;
2288 immRectf(pos, x - 1.5f, region_offset.y, x + 1.5f, region_offset.y + region->winy);
2289 }
2290
2291 auto draw_lines = [&](const float expand) {
2292 for (const Strip *strip : split.strips) {
2293 if (!seq::edit_frame_splits_strip(scene, strip, split_frame)) {
2294 continue;
2295 }
2296 const rctf bounds = strip_bounds_get(scene, strip);
2297 float x, y_bottom, y_top;
2298 ui::view2d_view_to_region_fl(v2d, split_frame, bounds.ymin, &x, &y_bottom);
2299 ui::view2d_view_to_region_fl(v2d, split_frame, bounds.ymax, &x, &y_top);
2300 immRectf(pos,
2301 x + region_offset.x - expand,
2302 y_bottom + region_offset.y - (expand - 1.0f),
2303 x + region_offset.x + expand,
2304 y_top + region_offset.y + (expand - 1.0f));
2305 }
2306 };
2307
2308 /* Draw dark outline underneath so the line is visible on light strips too. */
2309 immUniformColor4f(0.0f, 0.0f, 0.0f, 0.8f);
2310 draw_lines(2.5f);
2312 draw_lines(1.5f);
2314
2316}
2317
2319 const int2 &xy,
2320 const float2 & /*tilt*/,
2321 void *customdata)
2322{
2323 wmWindow *win = CTX_wm_window(C);
2324 ScrArea *area = CTX_wm_area(C);
2325 ARegion *region = CTX_wm_region(C);
2327
2328 if (region != customdata) {
2329 return;
2330 }
2331
2332 if (wmOperator *box_blade_op = box_blade_op_get(win)) {
2333 box_blade_draw(scene, region, box_blade_op);
2334 }
2335 else if (const std::optional<BladeSplit> split = blade_split_get(
2336 scene, region, win, area->runtime.tool, xy))
2337 {
2338 blade_split_draw(scene, region, *split);
2339 }
2340}
2341
2342static void blade_paint_cursor_free_fn(void *customdata)
2343{
2344 if (G_MAIN->wm.first()) {
2345 WM_paint_cursor_end(static_cast<wmPaintCursor *>(customdata));
2346 }
2347}
2348
2356
2358{
2359 gzgt->name = "Blade Widget";
2360 gzgt->idname = "SEQUENCER_GGT_blade";
2361
2364
2367}
2368
2369static std::string blade_frame_str_get(const Scene *scene, const int frame, const bool timecode)
2370{
2371 char str[64];
2372 ED_time_scrub_frame_str_get(scene, timecode, frame, str, sizeof(str));
2373 return str;
2374}
2375
2376/* Shown without delay & re-created on every cursor move, unlike regular tooltips. */
2378 bContext *C, ARegion *region, int * /*pass*/, double * /*pass_delay*/, bool *r_exit_on_event)
2379{
2380 wmWindow *win = CTX_wm_window(C);
2381 ScrArea *area = CTX_wm_area(C);
2383 const wmEvent *event = win->runtime->eventstate;
2384
2385 *r_exit_on_event = false;
2386
2387 std::string frames_str, timecode_str;
2388 /* Box blade. */
2389 if (wmOperator *box_blade_op = box_blade_op_get(win)) {
2390 const rctf box_rect = box_blade_rect_get(box_blade_op, &region->v2d);
2391 const int2 rect_frames = {round_fl_to_int(box_rect.xmin), round_fl_to_int(box_rect.xmax)};
2392 auto range_str_get = [&](const bool timecode) {
2393 return fmt::format("{} " BLI_STR_UTF8_RIGHTWARDS_ARROW " {} ({})",
2394 blade_frame_str_get(scene, rect_frames[0], timecode),
2395 blade_frame_str_get(scene, rect_frames[1], timecode),
2396 blade_frame_str_get(scene, rect_frames[1] - rect_frames[0], timecode));
2397 };
2398 frames_str = range_str_get(false);
2399 timecode_str = range_str_get(true);
2400 }
2401 /* Regular blade. */
2402 else if (const std::optional<BladeSplit> split = blade_split_get(
2403 scene, region, win, area->runtime.tool, int2(event->xy)))
2404 {
2405 frames_str = blade_frame_str_get(scene, split->frame, false);
2406 timecode_str = blade_frame_str_get(scene, split->frame, true);
2407 }
2408 else {
2409 return nullptr;
2410 }
2411
2412 /* Offset the tooltip to the right to avoid covering the split line. */
2413 const float right_offset = UI_SCALE_FAC * 55.0f;
2414 const float init_position[2] = {float(event->xy[0]) + right_offset, float(event->xy[1])};
2415
2417 C,
2418 [&](ui::TooltipData &data) {
2421 },
2422 init_position);
2423}
2424
2430
2432{
2433 wmWindow *win = CTX_wm_window(C);
2434 ScrArea *area = CTX_wm_area(C);
2435 ARegion *region = CTX_wm_region(C);
2437 if (scene == nullptr || scene->ed == nullptr) {
2438 return;
2439 }
2440
2441 std::optional<int> frame;
2443 if (const std::optional<BladeSplit> split = blade_split_get(
2444 scene, region, win, area->runtime.tool, int2(win->runtime->eventstate->xy)))
2445 {
2446 frame = split->frame;
2447 }
2448 }
2449 scene->ed->edit_point_set(scene, frame);
2450}
2451
2452static int blade_handler(bContext *C, const wmEvent *event, void * /*user_data*/)
2453{
2454 if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type)) {
2456 }
2458 if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type)) {
2460 }
2461 }
2463}
2464
2466{
2467 /* Region init can run more than once, keep a single instance of the handler. */
2468 WM_event_remove_ui_handler(&region->runtime->handlers, blade_handler, nullptr, nullptr, false);
2470 &region->runtime->handlers,
2472 nullptr,
2473 nullptr,
2475}
2476
2477} // namespace blender::ed::vse
#define G_MAIN
#define SOUND_WAVE_SAMPLES_PER_SECOND
Definition BKE_sound.hh:21
#define FILE_MAX
#define BLI_path_join(...)
#define SNPRINTF_UTF8(dst, format,...)
#define SNPRINTF_UTF8_RLEN(dst, format,...)
#define BLI_STR_UTF8_RIGHTWARDS_ARROW
#define STRIP_OFSBOTTOM
#define STRIP_OFSTOP
#define UI_SCALE_FAC
#define UI_INV_SCALE_FAC
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
@ GPU_SEQ_FLAG_HIGHLIGHT
@ GPU_SEQ_FLAG_BACKGROUND
@ GPU_SEQ_FLAG_LOCKED
@ GPU_SEQ_FLAG_MISSING_CONTENT
@ GPU_SEQ_FLAG_SELECTED
@ GPU_SEQ_FLAG_BORDER
@ GPU_SEQ_FLAG_THUMBNAILS_BACKGROUND
@ GPU_SEQ_FLAG_COLOR_BAND
@ GPU_SEQ_FLAG_TRANSITION
@ GPU_SEQ_FLAG_SELECTED_LH
@ GPU_SEQ_FLAG_SELECTED_RH
@ GPU_SEQ_FLAG_OVERLAP
@ GPU_SEQ_FLAG_ACTIVE
@ GPU_SEQ_FLAG_MISSING_TITLE
#define PRF_scope_with_name(ui_name, category)
#define C
Definition RandGen.cpp:29
#define ICON_DEFAULT_HEIGHT
#define UI_NO_ICON_OVERLAY_TEXT
#define UI_ANIM_MINY
Definition UI_view2d.hh:495
#define UI_TIME_CACHE_MARGIN_Y
Definition UI_view2d.hh:494
#define UI_TIME_SCRUB_MARGIN_Y
Definition UI_view2d.hh:493
#define WM_toolsystem_ref_properties_get_from_operator(tref, ot, r_ptr)
#define ND_SEQUENCER_PREFETCH
Definition WM_types.hh:517
#define WM_UI_HANDLER_CONTINUE
Definition WM_types.hh:361
#define NC_SCENE
Definition WM_types.hh:391
volatile int lock
#define CLAMP(a, b, c)
#define CLAMP_MAX(a, c)
#define ELEM(...)
#define STREQ(a, b)
#define CLAMP_MIN(a, b)
constexpr IndexRange()=default
bool add(const Key &key)
void add_multiple(Span< Key > keys)
bool contains(const Key &key) const
Span< Key > as_span() const
int64_t size() const
int64_t remove_if(Predicate &&predicate)
void append(const T &value)
bool is_empty() const
void reserve(const int64_t min_capacity)
const T & data(const Action &owning_action) const
void add_quad(float x1, float y1, float x2, float y2, const uchar color[4])
void add_line(float x1, float y1, float x2, float y2, const uchar color[4])
void add_wire_quad(float x1, float y1, float x2, float y2, const uchar color[4])
SeqStripDrawData & add_strip(float content_start, float content_end, float top, float bottom, float content_top, float left_handle, float right_handle, float handle_width, bool single_image)
#define str(s)
#define floor
void sequencer_preview_add_sound(const bContext *C, const Strip *strip)
static void draw_seq_timeline_channels(const TimelineDrawContext &ctx)
float calc_strip_round_radius(float pixely)
static const char * draw_seq_text_get_name(const Strip *strip)
static void draw_cache_final_iter_fn(void *userdata, int timeline_frame)
float strip_handle_draw_size_get(const Scene *scene, const Strip *strip, float pixelx)
bool retiming_overlay_enabled(const SpaceSeq *sseq)
static void draw_icon_centered(const TimelineDrawContext &ctx, const rctf &rect, int icon_id, const uchar color[4], const float size=ICON_SIZE)
static void draw_strip_icons(const TimelineDrawContext &ctx, const Vector< StripDrawContext > &strips)
rctf strip_bounds_get(const Scene *scene, const Strip *strip)
static void draw_timeline_markers(const TimelineDrawContext &ctx)
static void draw_overlay_frame_indicator(const Scene *scene, const View2D *v2d)
static float align_frame_with_pixel(float frame_coord, float frames_per_pixel)
static void draw_multicam_highlight(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static void blade_paint_cursor_draw(bContext *C, const int2 &xy, const float2 &, void *customdata)
static void draw_seq_text_overlay(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
bool handle_is_selected(const Strip *strip, eStripHandle handle)
static void blade_paint_cursor_free_fn(void *customdata)
void draw_timeline_seq(const bContext *C, const ARegion *region)
static void draw_seq_strips(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch, const Vector< StripDrawContext > &strips)
static void draw_cache_background(const bContext *C, const CacheDrawData *draw_data)
void draw_strip_thumbnails(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch, const Vector< StripDrawContext > &strips)
static std::string blade_frame_str_get(const Scene *scene, const int frame, const bool timecode)
static bool seq_draw_waveforms_poll(const SpaceSeq *sseq, const Strip *strip)
void SEQUENCER_GGT_blade(wmGizmoGroupType *gzgt)
static void strip_data_outline_params_set(const StripDrawContext &strip, const TimelineDrawContext &ctx, SeqStripDrawData &data)
static void draw_strip_offsets(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static void draw_strips_foreground(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch, const Vector< StripDrawContext > &strips)
uint color_pack(const uchar rgba[4])
void sequencer_blade_tooltip_show(bContext *C)
static void blade_edit_point_update(bContext *C)
static void draw_timeline_gizmos(const TimelineDrawContext &ctx)
static size_t draw_seq_text_get_overlay_string(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx, char *r_overlay_string, size_t overlay_string_maxncpy)
static wmOperator * box_blade_op_get(wmWindow *win)
static void draw_timeline_grid(const TimelineDrawContext &ctx)
static void strip_data_highlight_flags_set(const StripDrawContext &strip, const TimelineDrawContext &ctx, SeqStripDrawData &data)
static int blade_handler(bContext *C, const wmEvent *event, void *)
static void strip_draw_context_set_text_overlay_visibility(const TimelineDrawContext &ctx, StripDrawContext &strip_ctx)
static ARegion * blade_tooltip_init(bContext *C, ARegion *region, int *, double *, bool *r_exit_on_event)
static TimelineDrawContext timeline_draw_context_get(const bContext *C, SeqQuadsBatch *quads_batch)
static void draw_strip_texts(const TimelineDrawContext &ctx, const StripsDrawBatch &batch, const Vector< StripDrawContext > &strips)
static void draw_cache_view(const bContext *C)
void sequencer_blade_handlers_add(ARegion *region)
rctf box_blade_rect_get(wmOperator *op, const View2D *v2d)
static void WIDGETGROUP_blade_setup(const bContext *C, wmGizmoGroup *gzgroup)
static void strip_draw_context_set_retiming_overlay_visibility(const TimelineDrawContext &ctx, StripDrawContext &strip_ctx)
static void draw_seq_fcurve_overlay(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static bool blade_paint_cursor_poll(bContext *C)
static void draw_timeline_post_view_callbacks(const TimelineDrawContext &ctx)
void sequencer_retiming_draw_segments(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static void strip_data_lock_flags_set(const StripDrawContext &strip, const TimelineDrawContext &ctx, SeqStripDrawData &data)
static void blade_split_draw(Scene *scene, const ARegion *region, const BladeSplit &split)
static bool strip_hides_text_overlay_first(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
constexpr float ICON_SIZE_THUMBNAIL
static void strip_draw_context_set_strip_content_visibility(const TimelineDrawContext &ctx, StripDrawContext &strip_ctx)
static void strip_data_handle_flags_set(const StripDrawContext &strip, const TimelineDrawContext &ctx, SeqStripDrawData &data)
static void seq_prefetch_wm_notify(const bContext *C, Scene *scene)
static void draw_retiming_segments(const TimelineDrawContext &ctx, const Vector< StripDrawContext > &strips)
static void draw_cache_stripe(const Scene *scene, const Strip *strip, SeqQuadsBatch &quads, const float stripe_bot, const float stripe_ht, const uchar color[4])
static void draw_strips_background(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch, const Vector< StripDrawContext > &strips)
static void draw_cache_source_iter_fn(void *userdata, const Strip *strip, int timeline_frame)
static StripDrawContext strip_draw_context_get(const TimelineDrawContext &ctx, Strip *strip)
void draw_timeline_seq_display(const bContext *C, ARegion *region)
static void strip_data_missing_media_flags_set(const StripDrawContext &strip, SeqStripDrawData &data)
void sequencer_retiming_keys_draw(const TimelineDrawContext &ctx, Span< StripDrawContext > strips)
static void waveform_job_start_if_needed(const bContext *C, const Strip *strip)
static void strip_draw_context_curve_get(const TimelineDrawContext &ctx, StripDrawContext &strip_ctx)
bool can_select_handle(const Scene *scene, const Strip *strip)
static void draw_timeline_pre_view_callbacks(const TimelineDrawContext &ctx)
static void draw_timeline_sfra_efra(const TimelineDrawContext &ctx)
static void draw_handle_transform_text(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx, eStripHandle handle)
static int get_icon_id_from_strip_type(const Strip *strip)
static void drawmeta_contents(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx, float corner_radius)
static void color3ubv_from_seq(const Scene *curscene, const Strip *strip, const bool show_strip_color_tag, const bool is_muted, uchar r_col[3])
static bool split_tool_prop_from_toolsettings(bToolRef *tref, const char *identifier, const bool default_value)
static void split_expand_strips(Editing *ed, Strip *strip, const seq::StripRelation include, VectorSet< Strip * > &targets)
void sequencer_retiming_speed_labels_draw(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static float strip_header_size_get(const TimelineDrawContext &ctx)
static void draw_seq_waveform_overlay(const TimelineDrawContext &ctx, const StripDrawContext &strip_ctx)
static std::optional< BladeSplit > blade_split_get(Scene *scene, const ARegion *region, const wmWindow *win, bToolRef *tref, const int2 &xy)
static void box_blade_draw(Scene *scene, const ARegion *region, wmOperator *op)
bool split_only_selected_get(wmOperator *op)
Vector< Strip * > sequencer_visible_strips_get(const bContext *C)
static void draw_seq_text_get_source(const Strip *strip, char *r_source, size_t source_maxncpy)
static void visible_strips_ordered_get(const TimelineDrawContext &ctx, Vector< StripDrawContext > &r_bottom_layer, Vector< StripDrawContext > &r_top_layer)
static void get_strip_text_color(const StripDrawContext &strip_ctx, uchar r_col[4])
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
bool prefetch_need_redraw(const bContext *C, Scene *scene)
Definition prefetch.cc:711
std::recursive_mutex & text_runtime_mutex_get()
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:463
void source_image_cache_iterate(Scene *scene, void *userdata, void callback_iter(void *userdata, const Strip *strip, int timeline_frame))
void final_image_cache_iterate(Scene *scene, void *userdata, void callback_iter(void *userdata, int timeline_frame))
float give_frame_index(const Scene *scene, const Strip *strip, float timeline_frame)
Definition strip_time.cc:43
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
bool strip_can_have_thumbnail(const Scene *scene, const Strip *strip)
void timeline_boundbox(const Scene *scene, const ListBaseT< Strip > *seqbase, rctf *r_rect)
bool effect_is_transition(StripType type)
Definition effects.cc:381
Vector< Strip * > edit_split_strips_get(Scene *scene, const int frame, const std::optional< int > channel, const bool only_selected)
const char * strip_give_name(const Strip *strip)
void expand_strips(Editing *ed, VectorSet< Strip * > &strips, const StripRelation include)
Definition iterator.cc:70
bool transform_single_image_check(const Strip *strip)
Strip * select_active_get(const Scene *scene)
constexpr int MAX_CHANNELS
int text_effect_font_get(TextVars &text)
void thumbnail_cache_discard_requests_outside(Scene *scene, const rctf &rect)
bool transform_is_locked(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
Definition channels.cc:26
Map< SeqRetimingKey *, Strip * > retiming_selection_get(const Editing *ed)
eSeqOverlapMode tool_settings_overlap_mode_get(Scene *scene)
Definition sequencer.cc:445
bool edit_frame_splits_strip(const Scene *scene, const Strip *strip, const int timeline_frame)
void thumbnail_cache_maintain_capacity(Scene *scene)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_blend_shade_3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
void theme_store(bThemeState *theme_state)
void theme_set(int spacetype, int regionid)
void frame_buffer_clear(int colorid)
void get_color_shade_3ubv(int colorid, int offset, unsigned char col[3])
const bTheme * theme_get()
void theme_restore(const bThemeState *theme_state)
void get_color_shade_alpha_4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4])
void get_color_blend_3ubv(int colorid1, int colorid2, float fac, unsigned char col[3])
void get_color_3ubv(int colorid, unsigned char col[3])
void get_color_shade_4ubv(int colorid, int offset, unsigned char col[4])
char char char char void view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, size_t str_len, const unsigned char col[4])
Definition view2d.cc:2079
void view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1720
void view2d_view_ortho(const View2D *v2d)
Definition view2d.cc:1080
float view2d_pixel_size_get_y(const View2D *v2d)
Definition view2d.cc:1924
void view2d_view_restore(const bContext *C)
Definition view2d.cc:1147
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)
void view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1767
void view2d_text_cache_draw(ARegion *region)
Definition view2d.cc:2139
void view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
Definition view2d.cc:1487
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
ARegion * tooltip_create_from_func(bContext *C, FunctionRef< void(TooltipData &data)> create_fn, const float init_position[2])
void view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const unsigned char col[4])
Definition view2d.cc:2109
float view2d_region_to_view_y(const View2D *v2d, float y)
Definition view2d.cc:1645
float view2d_pixel_size_get_x(const View2D *v2d)
Definition view2d.cc:1920
void tooltip_text_field_add(TooltipData &data, std::string text, std::string suffix, const TooltipStyle style, const TooltipColorID color_id, const bool is_pad=false)
View2D * view2d_fromcontext(const bContext *C)
Definition view2d.cc:1836
void view2d_draw_lines_x_frames(const View2D *v2d, const Scene *scene, bool display_seconds, bool show_fractions, bool draw_minor_lines)
void view2d_view_orthoSpecial(ARegion *region, View2D *v2d, bool xaxis)
Definition view2d.cc:1121
float view2d_view_to_region_x(const View2D *v2d, float x)
Definition view2d.cc:1673
MINLINE float min_ff(float a, float b)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
VecBase< uint8_t, 4 > uchar4
void ED_time_scrub_draw_current_frame(const ARegion *region, const Scene *scene, bool display_seconds, bool display_stalk, bool clamp_playhead)
ScrArea * CTX_wm_area(const bContext *C)
void ED_time_scrub_draw(const ARegion *region, const Scene *scene, bool display_seconds, bool discrete_frames, const int base)
void wmOrtho2_region_pixelspace(const ARegion *region)
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
@ SEQ_TIMELINE_ALL_WAVEFORMS
@ SEQ_TIMELINE_SHOW_STRIP_OFFSETS
@ SEQ_TIMELINE_SHOW_STRIP_DURATION
@ SEQ_TIMELINE_SHOW_STRIP_NAME
@ SEQ_TIMELINE_NO_WAVEFORMS
@ SEQ_TIMELINE_SHOW_FCURVES
@ SEQ_TIMELINE_SHOW_STRIP_SOURCE
@ SEQ_TIMELINE_SHOW_THUMBNAILS
@ SEQ_TIMELINE_WAVEFORMS_HALF
@ SEQ_TIMELINE_SHOW_GRID
@ SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG
void BLF_shadow_offset(int fontid, int x, int y)
Definition blf.cc:979
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
Scene * CTX_data_sequencer_scene(const bContext *C)
void immEnd()
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:835
@ SEQ_EDIT_OVERLAY_FRAME_SHOW
unsigned int uint
Definition BKE_text.h:55
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
Definition blf.cc:967
MINLINE int round_fl_to_int(float a)
wmEventHandler_UI * WM_event_add_ui_handler(const bContext *C, ListBaseT< wmEventHandler > *handlers, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, const eWM_EventHandlerFlag flag)
wmOperator * WM_operator_find_modal_by_type(wmWindow *win, const wmOperatorType *ot)
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void immUniform2f(const char *name, float x, float y)
void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
GPUVertFormat * immVertexFormat()
void ED_markers_draw(const bContext *C, int flag)
bool ED_markers_region_visible(const ScrArea *area, const ARegion *region)
void immBegin(GPUPrimType, uint vertex_len)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
wmWindow * CTX_wm_window(const bContext *C)
MINLINE int max_ii(int a, int b)
@ TH_SEQ_TRANSITION
void immUniformThemeColorAlpha(int color_id, float a)
MINLINE void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
MINLINE float srgb_to_grayscale(const float rgb[3])
void BLF_disable(int fontid, FontFlags flag)
Definition blf.cc:331
void immUnbindProgram()
SpaceSeq * CTX_wm_space_seq(const bContext *C)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
void ED_time_scrub_frame_str_get(const Scene *scene, bool display_seconds, const float frame, char *r_str, uint str_maxncpy)
const Vector< float > * BKE_sound_runtime_get_waveform(const bSound *sound)
Global G
Definition blender.cc:57
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
int BLF_set_default()
void immUniformThemeColor(int color_id)
void BLF_size(int fontid, float size)
Definition blf.cc:445
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
eWM_EventHandlerFlag
Definition WM_api.hh:707
BMesh const char void * data
int BLF_default()
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:580
@ SEQ_CACHE_SHOW_FINAL_OUT
void immUniformColor4f(float r, float g, float b, float a)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
rcti ED_time_scrub_clamp_scroller_mask(const rcti &scroller_mask)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
Definition blf.cc:945
void GPU_framebuffer_bind_no_srgb(gpu::FrameBuffer *fb)
void ANIM_draw_previewrange(const Scene *scene, View2D *v2d, int end_frame_width)
Definition anim_draw.cc:88
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
@ DRAW_MARKERS_MARGIN
Definition ED_markers.hh:35
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:587
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
gpu::FrameBuffer * GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
void immUniform4f(const char *name, float x, float y, float z, float w)
void GPU_matrix_pop_projection()
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
MINLINE float max_ff(float a, float b)
MINLINE void copy_v3_v3_uchar(unsigned char r[3], const unsigned char a[3])
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
void WM_event_remove_ui_handler(ListBaseT< wmEventHandler > *handlers, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, const bool postpone)
void WM_gizmomap_draw(wmGizmoMap *gzmap, const bContext *C, const eWM_GizmoFlagMapDrawStep drawstep)
FCurve * id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven)
@ G_TRANSFORM_SEQ
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
bool BKE_fcurve_is_empty(const FCurve *fcu)
void immUniform1i(const char *name, int x)
size_t BLI_string_join_array(char *result, size_t result_maxncpy, const char *strings[], uint strings_num) ATTR_NONNULL()
bool ED_gizmo_poll_or_unlink_delayed_from_tool(const bContext *C, wmGizmoGroupType *gzgt)
void GPU_matrix_push_projection()
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
Definition wm_draw.cc:954
MINLINE int min_ii(int a, int b)
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:70
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void WM_tooltip_immediate_init(bContext *C, wmWindow *win, ScrArea *area, ARegion *region, wmTooltipInitFn init)
Definition wm_tooltip.cc:31
ARegion * CTX_wm_region(const bContext *C)
void BLF_enable(int fontid, FontFlags flag)
Definition blf.cc:322
@ BLF_SHADOW
Definition BLF_enums.hh:38
@ BLF_CLIPPING
Definition BLF_enums.hh:37
@ BLF_ITALIC
Definition BLF_enums.hh:49
MINLINE int round_db_to_int(double a)
void BLF_color4fv(int fontid, const float rgba[4])
Definition blf.cc:507
@ WM_GIZMOMAP_DRAWSTEP_2D
float evaluate_fcurve(const FCurve *fcu, float evaltime)
MINLINE float clamp_f(float value, float min, float max)
bool WM_paint_cursor_end(wmPaintCursor *handle)
bool BKE_sound_runtime_start_waveform_loading(bSound *sound)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
unsigned char color[4]
ThemeStripColor strip_color[9]
bke::ARegionRuntime * runtime
eEditingOverlayFrameFlag overlay_frame_flag
struct Editing * ed
struct RenderData r
ScrArea_Runtime runtime
eSpaceSeq_SequencerCacheOverlay_Flag flag
eSpaceSeq_SequencerTimelineOverlay_Flag flag
eSpaceSeq_Flag flag
eSpaceSeq_Gizmo_Flag gizmo_flag
struct SequencerTimelineOverlay timeline_overlay
struct SequencerCacheOverlay cache_overlay
eView2D_Scroll scroll
ListBaseT< wmEventHandler > handlers
Map< SeqRetimingKey *, Strip * > retiming_selection
ListBaseT< SeqTimelineChannel > * channels
wmEventType type
Definition WM_types.hh:817
wmGizmoMapType_Params gzmap_params
void(*) customdata_free(void *)
bke::WindowRuntime * runtime
#define ISKEYMODIFIER(event_type)