Blender V5.3
clip_buttons.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10#include <cstring>
11
12#include "MEM_guardedalloc.h"
13
14#include "DNA_scene_types.h"
15#include "DNA_screen_types.h"
16#include "DNA_space_types.h"
17
18#include "BLI_listbase.hh"
19#include "BLI_math_vector_c.hh"
20#include "BLI_path_utils.hh"
21#include "BLI_string.hh"
22#include "BLI_string_utf8.hh"
23#include "BLI_utildefines.hh"
24
25#include "BLT_translation.hh"
26
27#include "BKE_context.hh"
28#include "BKE_movieclip.hh"
29#include "BKE_screen.hh"
30#include "BKE_tracking.hh"
31
32#include "DEG_depsgraph.hh"
33
34#include "ED_clip.hh"
35#include "ED_screen.hh"
36
37#include "UI_interface.hh"
39#include "UI_resources.hh"
40
41#include "RNA_access.hh"
42
43#include "WM_api.hh"
44#include "WM_types.hh"
45
46#include "IMB_imbuf.hh"
47#include "IMB_imbuf_types.hh"
48
49#include "MOV_read.hh"
50
51#include "clip_intern.hh" /* own include */
52
53namespace blender {
54
55/* Panels */
56
57static bool metadata_panel_context_poll(const bContext *C, PanelType * /*pt*/)
58{
59 return ED_space_clip_poll(const_cast<bContext *>(C));
60}
61
62static void metadata_panel_context_draw(const bContext *C, Panel *panel)
63{
64 SpaceClip *space_clip = CTX_wm_space_clip(C);
65 /* NOTE: This might not be exactly the same image buffer as shown in the
66 * clip editor itself, since that might be coming from proxy, or being
67 * postprocessed (stabilized or undistorted).
68 * Ideally we need to query metadata from an original image or movie without
69 * reading actual pixels to speed up the process. */
70 ImBuf *ibuf = ED_space_clip_get_buffer(space_clip);
71 if (ibuf != nullptr) {
73 IMB_freeImBuf(ibuf);
74 }
75}
76
78{
79 PanelType *pt;
80
81 pt = MEM_new_zeroed<PanelType>("spacetype clip panel metadata");
82 STRNCPY_UTF8(pt->idname, "CLIP_PT_metadata");
83 STRNCPY_UTF8(pt->label, N_("Metadata"));
84 STRNCPY_UTF8(pt->category, "Footage");
89 BLI_addtail(&art->paneltypes, pt);
90}
91
92/********************* MovieClip Template ************************/
93
95 ui::Layout *layout, bContext *C, PointerRNA *ptr, const StringRefNull propname, bool compact)
96{
97 if (!*ptr) {
98 return;
99 }
100
101 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
102 if (!prop) {
103 printf("%s: property not found: %s.%s\n",
104 __func__,
106 propname.c_str());
107 return;
108 }
109
110 if (RNA_property_type(prop) != PROP_POINTER) {
111 printf("%s: expected pointer property for %s.%s\n",
112 __func__,
114 propname.c_str());
115 return;
116 }
117
118 PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
119 MovieClip *clip = static_cast<MovieClip *>(clipptr.data);
120
121 layout->context_ptr_set("edit_movieclip", &clipptr);
122
123 if (!compact) {
124 template_id(layout, C, ptr, propname, nullptr, "CLIP_OT_open", nullptr);
125 }
126
127 if (clip) {
128 ui::Layout &row = layout->row(false);
129 ui::Block *block = row.block();
130 uiDefBut(
131 block, ui::ButtonType::Label, IFACE_("File Path:"), 0, 19, 145, 19, nullptr, 0, 0, "");
132
133 ui::Layout &file_row = layout->row(true);
134 file_row.prop(&clipptr, "filepath", UI_ITEM_NONE, "", ICON_NONE);
135 file_row.op("clip.reload", "", ICON_FILE_REFRESH);
136
137 ui::Layout &col = layout->column(true);
138 col.separator();
139 col.prop(&clipptr, "frame_start", UI_ITEM_NONE, IFACE_("Start Frame"), ICON_NONE);
140 col.prop(&clipptr, "frame_offset", UI_ITEM_NONE, IFACE_("Frame Offset"), ICON_NONE);
141 col.separator();
142 template_colorspace_settings(&col, &clipptr, "colorspace_settings");
143 }
144}
145
146/********************* Track Template ************************/
147
148void uiTemplateTrack(ui::Layout *layout, PointerRNA *ptr, const StringRefNull propname)
149{
150 if (!*ptr) {
151 return;
152 }
153
154 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
155 if (!prop) {
156 printf("%s: property not found: %s.%s\n",
157 __func__,
159 propname.c_str());
160 return;
161 }
162
163 if (RNA_property_type(prop) != PROP_POINTER) {
164 printf("%s: expected pointer property for %s.%s\n",
165 __func__,
167 propname.c_str());
168 return;
169 }
170
171 PointerRNA scopesptr = RNA_property_pointer_get(ptr, prop);
172 MovieClipScopes *scopes = static_cast<MovieClipScopes *>(scopesptr.data);
173
174 if (scopes->track_preview_height < UI_UNIT_Y) {
176 }
177 else if (scopes->track_preview_height > UI_UNIT_Y * 20) {
178 scopes->track_preview_height = UI_UNIT_Y * 20;
179 }
180
181 ui::Layout &col = layout->column(true);
182 ui::Block *block = col.block();
183
184 uiDefBut(block,
186 "",
187 0,
188 0,
189 UI_UNIT_X * 10,
190 scopes->track_preview_height,
191 scopes,
192 0,
193 0,
194 "");
195
196 /* Resize grip. */
197 uiDefIconButV(block,
199 ICON_GRIP,
200 0,
201 0,
202 UI_UNIT_X * 10,
203 short(UI_UNIT_Y * 0.8f),
204 &scopes->track_preview_height,
205 UI_UNIT_Y,
206 UI_UNIT_Y * 20.0f,
207 "");
208}
209
210/********************* Marker Template ************************/
211
212#define B_MARKER_POS 3
213#define B_MARKER_OFFSET 4
214#define B_MARKER_PAT_DIM 5
215#define B_MARKER_SEARCH_POS 6
216#define B_MARKER_SEARCH_DIM 7
217#define B_MARKER_FLAG 8
218
242
243static void to_pixel_space(float r[2], const float a[2], int width, int height)
244{
245 copy_v2_v2(r, a);
246 r[0] *= width;
247 r[1] *= height;
248}
249
250static void marker_update_cb(bContext *C, void *arg_cb, void * /*arg*/)
251{
252 MarkerUpdateCb *cb = static_cast<MarkerUpdateCb *>(arg_cb);
253
254 if (!cb->compact) {
255 return;
256 }
257
258 int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
259 MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
260 marker->flag = cb->marker_flag;
261
263}
264
265static void marker_block_handler(bContext *C, void *arg_cb, int event)
266{
267 MarkerUpdateCb *cb = static_cast<MarkerUpdateCb *>(arg_cb);
268 int width, height;
269 bool ok = false;
270
271 BKE_movieclip_get_size(cb->clip, cb->user, &width, &height);
272
273 int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
274 MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
275
276 if (event == B_MARKER_POS) {
277 marker->pos[0] = cb->marker_pos[0] / width;
278 marker->pos[1] = cb->marker_pos[1] / height;
279
280 /* to update position of "parented" objects */
281 DEG_id_tag_update(&cb->clip->id, 0);
283
284 ok = true;
285 }
286 else if (event == B_MARKER_PAT_DIM) {
287 float dim[2], pat_dim[2], pat_min[2], pat_max[2];
288
289 BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
290
291 sub_v2_v2v2(pat_dim, pat_max, pat_min);
292
293 dim[0] = cb->marker_pat[0] / width;
294 dim[1] = cb->marker_pat[1] / height;
295
296 float scale_x = dim[0] / pat_dim[0];
297 float scale_y = dim[1] / pat_dim[1];
298
299 for (int a = 0; a < 4; a++) {
300 cb->marker->pattern_corners[a][0] *= scale_x;
301 cb->marker->pattern_corners[a][1] *= scale_y;
302 }
303
305
306 ok = true;
307 }
308 else if (event == B_MARKER_SEARCH_POS) {
309 float delta[2], side[2];
310
312 mul_v2_fl(side, 0.5f);
313
314 delta[0] = cb->marker_search_pos[0] / width;
315 delta[1] = cb->marker_search_pos[1] / height;
316
317 sub_v2_v2v2(cb->marker->search_min, delta, side);
318 add_v2_v2v2(cb->marker->search_max, delta, side);
319
321
322 ok = true;
323 }
324 else if (event == B_MARKER_SEARCH_DIM) {
325 float dim[2], search_dim[2];
326
327 sub_v2_v2v2(search_dim, cb->marker->search_max, cb->marker->search_min);
328
329 dim[0] = cb->marker_search[0] / width;
330 dim[1] = cb->marker_search[1] / height;
331
332 sub_v2_v2(dim, search_dim);
333 mul_v2_fl(dim, 0.5f);
334
335 cb->marker->search_min[0] -= dim[0];
336 cb->marker->search_min[1] -= dim[1];
337
338 cb->marker->search_max[0] += dim[0];
339 cb->marker->search_max[1] += dim[1];
340
342
343 ok = true;
344 }
345 else if (event == B_MARKER_FLAG) {
346 marker->flag = cb->marker_flag;
347
348 ok = true;
349 }
350 else if (event == B_MARKER_OFFSET) {
351 float offset[2], delta[2];
352
353 offset[0] = cb->track_offset[0] / width;
354 offset[1] = cb->track_offset[1] / height;
355
356 sub_v2_v2v2(delta, offset, cb->track->offset);
357 copy_v2_v2(cb->track->offset, offset);
358
359 for (int i = 0; i < cb->track->markersnr; i++) {
360 sub_v2_v2(cb->track->markers[i].pos, delta);
361 }
362
363 /* to update position of "parented" objects */
364 DEG_id_tag_update(&cb->clip->id, 0);
366
367 ok = true;
368 }
369
370 if (ok) {
372 }
373}
374
376 PointerRNA *ptr,
377 const StringRefNull propname,
378 PointerRNA *userptr,
379 PointerRNA *trackptr,
380 bool compact)
381{
382 if (!*ptr) {
383 return;
384 }
385
386 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
387 if (!prop) {
388 printf("%s: property not found: %s.%s\n",
389 __func__,
391 propname.c_str());
392 return;
393 }
394
395 if (RNA_property_type(prop) != PROP_POINTER) {
396 printf("%s: expected pointer property for %s.%s\n",
397 __func__,
399 propname.c_str());
400 return;
401 }
402
403 PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
404 MovieClip *clip = static_cast<MovieClip *>(clipptr.data);
405 MovieClipUser *user = static_cast<MovieClipUser *>(userptr->data);
406 MovieTrackingTrack *track = static_cast<MovieTrackingTrack *>(trackptr->data);
407
408 int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
409 MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr);
410
411 MarkerUpdateCb *cb = MEM_new_zeroed<MarkerUpdateCb>("uiTemplateMarker update_cb");
412 cb->compact = compact;
413 cb->clip = clip;
414 cb->user = user;
415 cb->track = track;
416 cb->marker = marker;
417 cb->marker_flag = marker->flag;
418 cb->framenr = user->framenr;
419
420 if (compact) {
421 ui::Block *block = layout->block();
422
423 StringRef tip;
424 if (cb->marker_flag & MARKER_DISABLED) {
425 tip = TIP_("Marker is disabled at current frame");
426 }
427 else {
428 tip = TIP_("Marker is enabled at current frame");
429 }
430
431 ui::Button *bt = uiDefIconButBit(block,
434 ICON_HIDE_OFF,
435 0,
436 0,
437 UI_UNIT_X,
438 UI_UNIT_Y,
439 &cb->marker_flag,
440 0,
441 0,
442 tip);
443 button_funcN_set(bt, marker_update_cb, cb, nullptr);
444 button_drawflag_enable(bt, ui::BUT_ICON_REVERSE);
445 }
446 else {
447 int width, height;
448
449 BKE_movieclip_get_size(clip, user, &width, &height);
450
451 if (track->flag & TRACK_LOCKED) {
452 layout->active_set(false);
453 ui::Block *block = layout->absolute().block();
454 uiDefBut(block,
456 IFACE_("Track is locked"),
457 0,
458 0,
459 UI_UNIT_X * 15.0f,
460 UI_UNIT_Y,
461 nullptr,
462 0,
463 0,
464 "");
465 MEM_delete(cb);
466 return;
467 }
468
469 float pat_min[2], pat_max[2];
470 float pat_dim[2], search_dim[2], search_pos[2];
471
472 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
473
474 sub_v2_v2v2(pat_dim, pat_max, pat_min);
475 sub_v2_v2v2(search_dim, marker->search_max, marker->search_min);
476
477 add_v2_v2v2(search_pos, marker->search_max, marker->search_min);
478 mul_v2_fl(search_pos, 0.5);
479
480 to_pixel_space(cb->marker_pos, marker->pos, width, height);
481 to_pixel_space(cb->marker_pat, pat_dim, width, height);
482 to_pixel_space(cb->marker_search, search_dim, width, height);
483 to_pixel_space(cb->marker_search_pos, search_pos, width, height);
484 to_pixel_space(cb->track_offset, track->offset, width, height);
485
486 cb->marker_flag = marker->flag;
487
488 ui::Block *block = layout->absolute().block();
489 block_func_handle_set(block, marker_block_handler, cb);
490 block_funcN_set(block, marker_update_cb, cb, nullptr);
491
492 StringRef tip;
493 int step = 100;
494 int digits = 2;
495
496 if (cb->marker_flag & MARKER_DISABLED) {
497 tip = TIP_("Marker is disabled at current frame");
498 }
499 else {
500 tip = TIP_("Marker is enabled at current frame");
501 }
502
503 ui::Button *but = uiDefButBit(block,
506 IFACE_("Enabled"),
507 0.5 * UI_UNIT_X,
508 9.5 * UI_UNIT_Y,
509 7.25 * UI_UNIT_X,
510 UI_UNIT_Y,
511 &cb->marker_flag,
512 0,
513 0,
514 tip);
515 button_retval_set(but, B_MARKER_FLAG);
516
517 ui::Layout &col = layout->column(true);
518 col.active_set((cb->marker_flag & MARKER_DISABLED) == 0);
519
520 block = col.absolute().block();
521 block_align_begin(block);
522
523 uiDefBut(block,
525 IFACE_("Position:"),
526 0,
527 10 * UI_UNIT_Y,
528 15 * UI_UNIT_X,
529 UI_UNIT_Y,
530 nullptr,
531 0,
532 0,
533 "");
534 ui::Button *bt = uiDefButV(block,
536 IFACE_("X:"),
537 0.5 * UI_UNIT_X,
538 9 * UI_UNIT_Y,
539 7.25 * UI_UNIT_X,
540 UI_UNIT_Y,
541 &cb->marker_pos[0],
542 -10 * width,
543 10.0 * width,
544 TIP_("X-position of marker at frame in screen coordinates"));
545 button_retval_set(bt, B_MARKER_POS);
546 button_number_step_size_set(bt, step);
547 button_number_precision_set(bt, digits);
548 bt = uiDefButV(block,
550 IFACE_("Y:"),
551 8.25 * UI_UNIT_X,
552 9 * UI_UNIT_Y,
553 7.25 * UI_UNIT_X,
554 UI_UNIT_Y,
555 &cb->marker_pos[1],
556 -10 * height,
557 10.0 * height,
558 TIP_("Y-position of marker at frame in screen coordinates"));
559 button_retval_set(bt, B_MARKER_POS);
560 button_number_step_size_set(bt, step);
561 button_number_precision_set(bt, digits);
562
563 uiDefBut(block,
565 IFACE_("Offset:"),
566 0,
567 8 * UI_UNIT_Y,
568 15 * UI_UNIT_X,
569 UI_UNIT_Y,
570 nullptr,
571 0,
572 0,
573 "");
574 bt = uiDefButV(block,
576 IFACE_("X:"),
577 0.5 * UI_UNIT_X,
578 7 * UI_UNIT_Y,
579 7.25 * UI_UNIT_X,
580 UI_UNIT_Y,
581 &cb->track_offset[0],
582 -10 * width,
583 10.0 * width,
584 TIP_("X-offset to parenting point"));
585 button_retval_set(bt, B_MARKER_OFFSET);
586 button_number_step_size_set(bt, step);
587 button_number_precision_set(bt, digits);
588 bt = uiDefButV(block,
590 IFACE_("Y:"),
591 8.25 * UI_UNIT_X,
592 7 * UI_UNIT_Y,
593 7.25 * UI_UNIT_X,
594 UI_UNIT_Y,
595 &cb->track_offset[1],
596 -10 * height,
597 10.0 * height,
598 TIP_("Y-offset to parenting point"));
599 button_retval_set(bt, B_MARKER_OFFSET);
600 button_number_step_size_set(bt, step);
601 button_number_precision_set(bt, digits);
602
603 uiDefBut(block,
605 IFACE_("Pattern Area:"),
606 0,
607 6 * UI_UNIT_Y,
608 15 * UI_UNIT_X,
609 UI_UNIT_Y,
610 nullptr,
611 0,
612 0,
613 "");
614 bt = uiDefButV(block,
616 IFACE_("Width:"),
617 0.5 * UI_UNIT_X,
618 5 * UI_UNIT_Y,
619 15 * UI_UNIT_X,
620 UI_UNIT_Y,
621 &cb->marker_pat[0],
622 3.0f,
623 10.0 * width,
624 TIP_("Width of marker's pattern in screen coordinates"));
625 button_retval_set(bt, B_MARKER_PAT_DIM);
626 button_number_step_size_set(bt, step);
627 button_number_precision_set(bt, digits);
628 bt = uiDefButV(block,
630 IFACE_("Height:"),
631 0.5 * UI_UNIT_X,
632 4 * UI_UNIT_Y,
633 15 * UI_UNIT_X,
634 UI_UNIT_Y,
635 &cb->marker_pat[1],
636 3.0f,
637 10.0 * height,
638 TIP_("Height of marker's pattern in screen coordinates"));
639 button_retval_set(bt, B_MARKER_PAT_DIM);
640 button_number_step_size_set(bt, step);
641 button_number_precision_set(bt, digits);
642
643 uiDefBut(block,
645 IFACE_("Search Area:"),
646 0,
647 3 * UI_UNIT_Y,
648 15 * UI_UNIT_X,
649 UI_UNIT_Y,
650 nullptr,
651 0,
652 0,
653 "");
654 bt = uiDefButV(block,
656 IFACE_("X:"),
657 0.5 * UI_UNIT_X,
658 2 * UI_UNIT_Y,
659 7.25 * UI_UNIT_X,
660 UI_UNIT_Y,
661 &cb->marker_search_pos[0],
662 -width,
663 width,
664 TIP_("X-position of search at frame relative to marker's position"));
665 button_retval_set(bt, B_MARKER_SEARCH_POS);
666 button_number_step_size_set(bt, step);
667 button_number_precision_set(bt, digits);
668 bt = uiDefButV(block,
670 IFACE_("Y:"),
671 8.25 * UI_UNIT_X,
672 2 * UI_UNIT_Y,
673 7.25 * UI_UNIT_X,
674 UI_UNIT_Y,
675 &cb->marker_search_pos[1],
676 -height,
677 height,
678 TIP_("Y-position of search at frame relative to marker's position"));
679 button_retval_set(bt, B_MARKER_SEARCH_POS);
680 button_number_step_size_set(bt, step);
681 button_number_precision_set(bt, digits);
682 bt = uiDefButV(block,
684 IFACE_("Width:"),
685 0.5 * UI_UNIT_X,
686 1 * UI_UNIT_Y,
687 15 * UI_UNIT_X,
688 UI_UNIT_Y,
689 &cb->marker_search[0],
690 3.0f,
691 10.0 * width,
692 TIP_("Width of marker's search in screen coordinates"));
693 button_retval_set(bt, B_MARKER_SEARCH_DIM);
694 button_number_step_size_set(bt, step);
695 button_number_precision_set(bt, digits);
696 bt = uiDefButV(block,
698 IFACE_("Height:"),
699 0.5 * UI_UNIT_X,
700 0 * UI_UNIT_Y,
701 15 * UI_UNIT_X,
702 UI_UNIT_Y,
703 &cb->marker_search[1],
704 3.0f,
705 10.0 * height,
706 TIP_("Height of marker's search in screen coordinates"));
707 button_retval_set(bt, B_MARKER_SEARCH_DIM);
708 button_number_step_size_set(bt, step);
709 button_number_precision_set(bt, digits);
710
711 block_align_end(block);
712 }
713}
714
715/********************* Footage Information Template ************************/
716
718 PointerRNA *ptr,
719 const StringRefNull propname,
720 PointerRNA *userptr)
721{
722 if (!*ptr) {
723 return;
724 }
725
726 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
727 if (!prop) {
728 printf("%s: property not found: %s.%s\n",
729 __func__,
731 propname.c_str());
732 return;
733 }
734
735 if (RNA_property_type(prop) != PROP_POINTER) {
736 printf("%s: expected pointer property for %s.%s\n",
737 __func__,
739 propname.c_str());
740 return;
741 }
742
743 PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
744 MovieClip *clip = static_cast<MovieClip *>(clipptr.data);
745 MovieClipUser *user = static_cast<MovieClipUser *>(userptr->data);
746
747 ui::Layout &col = layout->column(false);
749
750 /* NOTE: Put the frame to cache. If the panel is drawn, the display will also be shown, as well
751 * as metadata panel. So if the cache is skipped here it is not really a memory saver, but
752 * skipping the cache could lead to a performance impact depending on the order in which panels
753 * and the main area is drawn. Basically, if it is this template drawn first and then the main
754 * area it will lead to frame read and processing happening twice. */
755 ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user);
756
757 int width, height;
758 /* Display frame dimensions, channels number and buffer type. */
759 BKE_movieclip_get_size(clip, user, &width, &height);
760
761 char str[1024];
762 size_t ofs = 0;
763 ofs += BLI_snprintf_utf8_rlen(str + ofs, sizeof(str) - ofs, RPT_("%d x %d"), width, height);
764
765 if (ibuf) {
766 if (ibuf->float_data()) {
767 if (ibuf->channels != 4) {
769 str + ofs, sizeof(str) - ofs, RPT_(", %d float channel(s)"), ibuf->channels);
770 }
771 else if (ibuf->color_mode == ImColorMode::RGBA) {
772 ofs += BLI_strncpy_utf8_rlen(str + ofs, RPT_(", RGBA float"), sizeof(str) - ofs);
773 }
774 else {
775 ofs += BLI_strncpy_utf8_rlen(str + ofs, RPT_(", RGB float"), sizeof(str) - ofs);
776 }
777 }
778 else {
779 if (ibuf->color_mode == ImColorMode::RGBA) {
780 ofs += BLI_strncpy_utf8_rlen(str + ofs, RPT_(", RGBA byte"), sizeof(str) - ofs);
781 }
782 else {
783 ofs += BLI_strncpy_utf8_rlen(str + ofs, RPT_(", RGB byte"), sizeof(str) - ofs);
784 }
785 }
786
787 if (clip->anim != nullptr) {
788 float fps = MOV_get_fps(clip->anim);
789 if (fps > 0.0f) {
790 ofs += BLI_snprintf_utf8_rlen(str + ofs, sizeof(str) - ofs, RPT_(", %.2f fps"), fps);
791 }
792 }
793 }
794 else {
795 ofs += BLI_strncpy_utf8_rlen(str + ofs, RPT_(", failed to load"), sizeof(str) - ofs);
796 }
797 UNUSED_VARS(ofs);
798
799 col.label(str, ICON_NONE);
800
801 /* Display current frame number. */
802 int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
803 if (framenr <= clip->len) {
804 SNPRINTF_UTF8(str, RPT_("Frame: %d / %d"), framenr, clip->len);
805 }
806 else {
807 SNPRINTF_UTF8(str, RPT_("Frame: - / %d"), clip->len);
808 }
809 col.label(str, ICON_NONE);
810
811 /* Display current file name if it's a sequence clip. */
812 if (clip->source == MCLIP_SRC_SEQUENCE) {
813 char filepath[FILE_MAX];
814 const char *file;
815
816 if (framenr <= clip->len) {
817 BKE_movieclip_filepath_for_frame(clip, user, filepath);
818 file = BLI_path_basename(filepath);
819 }
820 else {
821 file = "-";
822 }
823
824 SNPRINTF_UTF8(str, RPT_("File: %s"), file);
825
826 col.label(str, ICON_NONE);
827 }
828
829 IMB_freeImBuf(ibuf);
830}
831
832} // namespace blender
#define FILE_MAX
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define RPT_(msgid)
#define TIP_(msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
#define UI_ITEM_NONE
#define NC_MOVIECLIP
Definition WM_types.hh:410
#define NA_EDITED
Definition WM_types.hh:634
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NC_SPACE
Definition WM_types.hh:405
#define UNUSED_VARS(...)
constexpr const char * c_str() const
#define B_MARKER_POS
#define B_MARKER_SEARCH_DIM
#define B_MARKER_SEARCH_POS
#define B_MARKER_OFFSET
#define B_MARKER_PAT_DIM
#define B_MARKER_FLAG
#define str(s)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
BMesh Iterators.
void uiTemplateMovieclipInformation(ui::Layout *layout, PointerRNA *ptr, StringRefNull propname, PointerRNA *userptr)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void BKE_tracking_marker_clamp_search_size(MovieTrackingMarker *marker)
Definition tracking.cc:1332
ImBuf * ED_space_clip_get_buffer(const SpaceClip *sc)
void BKE_movieclip_get_size(MovieClip *clip, const MovieClipUser *user, int *r_width, int *r_height)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static bool metadata_panel_context_poll(const bContext *C, PanelType *)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
void uiTemplateTrack(ui::Layout *layout, PointerRNA *ptr, StringRefNull propname)
MINLINE void mul_v2_fl(float r[2], float f)
static void marker_block_handler(bContext *C, void *arg_cb, int event)
MINLINE void copy_v2_v2(float r[2], const float a[2])
char size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
SpaceClip * CTX_wm_space_clip(const bContext *C)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
static void marker_update_cb(bContext *C, void *arg_cb, void *)
bool ED_space_clip_poll(bContext *C)
PropertyType RNA_property_type(PropertyRNA *prop)
void uiTemplateMarker(ui::Layout *layout, PointerRNA *ptr, StringRefNull propname, PointerRNA *userptr, PointerRNA *trackptr, bool compact)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float min[2], float max[2])
Definition tracking.cc:1500
void IMB_freeImBuf(ImBuf *ibuf)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
@ PROP_POINTER
Definition RNA_types.hh:215
void DEG_id_tag_update(ID *id, unsigned int flags)
MovieTrackingMarker * BKE_tracking_marker_ensure(MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1407
void ED_clip_buttons_register(ARegionType *art)
ImBuf * BKE_movieclip_get_ibuf(MovieClip *clip, const MovieClipUser *user)
void ED_region_image_metadata_panel_draw(ImBuf *ibuf, ui::Layout *layout)
Definition area.cc:4623
void BKE_tracking_marker_clamp_search_position(MovieTrackingMarker *marker)
Definition tracking.cc:1343
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
const char * RNA_struct_identifier(const StructRNA *type)
float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static void to_pixel_space(float r[2], const float a[2], int width, int height)
@ PANEL_TYPE_DEFAULT_CLOSED
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
void uiTemplateMovieClip(ui::Layout *layout, bContext *C, PointerRNA *ptr, StringRefNull propname, bool compact)
float MOV_get_fps(const MovieReader *anim)
MINLINE void sub_v2_v2(float r[2], const float a[2])
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BKE_movieclip_filepath_for_frame(MovieClip *clip, const MovieClipUser *user, char *filepath)
MovieTrackingMarker * BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1363
ListBaseT< PanelType > paneltypes
const float * float_data() const
ImColorMode color_mode
MovieTrackingTrack * track
MovieTrackingMarker * marker
TrackingMarkerFlag marker_flag
struct MovieReader * anim
MovieTrackingMarker * markers
char translation_context[BKE_ST_MAXNAME]
void(*) draw(const bContext *C, Panel *panel)
char category[BKE_ST_MAXNAME]
bool(*) poll(const bContext *C, PanelType *pt)
char idname[BKE_ST_MAXNAME]
char label[BKE_ST_MAXNAME]
ui::Layout * layout
StructRNA * type
Definition RNA_types.hh:63
void alignment_set(LayoutAlign alignment)
void label(StringRef name, int icon)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & absolute(bool align=false)
Layout & row(bool align)
void context_ptr_set(StringRef name, const PointerRNA *ptr)
#define N_(msgid)