Blender  V2.93
clip_buttons.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2011 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "DNA_scene_types.h"
30 #include "DNA_screen_types.h"
31 #include "DNA_space_types.h"
32 
33 #include "BLI_listbase.h"
34 #include "BLI_math.h"
35 #include "BLI_path_util.h"
36 #include "BLI_string.h"
37 #include "BLI_utildefines.h"
38 
39 #include "BLT_translation.h"
40 
41 #include "BKE_context.h"
42 #include "BKE_movieclip.h"
43 #include "BKE_screen.h"
44 #include "BKE_tracking.h"
45 
46 #include "DEG_depsgraph.h"
47 
48 #include "ED_clip.h"
49 #include "ED_screen.h"
50 
51 #include "UI_interface.h"
52 #include "UI_resources.h"
53 
54 #include "RNA_access.h"
55 
56 #include "WM_api.h"
57 #include "WM_types.h"
58 
59 #include "IMB_imbuf.h"
60 #include "IMB_imbuf_types.h"
61 
62 #include "clip_intern.h" /* own include */
63 
64 /* Panels */
65 
67 {
68  return ED_space_clip_poll((bContext *)C);
69 }
70 
71 static void metadata_panel_context_draw(const bContext *C, Panel *panel)
72 {
73  SpaceClip *space_clip = CTX_wm_space_clip(C);
74  /* NOTE: This might not be exactly the same image buffer as shown in the
75  * clip editor itself, since that might be coming from proxy, or being
76  * postprocessed (stabilized or undistored).
77  * Ideally we need to query metadata from an original image or movie without
78  * reading actual pixels to speed up the process. */
79  ImBuf *ibuf = ED_space_clip_get_buffer(space_clip);
80  if (ibuf != NULL) {
82  IMB_freeImBuf(ibuf);
83  }
84 }
85 
87 {
88  PanelType *pt;
89 
90  pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel metadata");
91  strcpy(pt->idname, "CLIP_PT_metadata");
92  strcpy(pt->label, N_("Metadata"));
93  strcpy(pt->category, "Footage");
98  BLI_addtail(&art->paneltypes, pt);
99 }
100 
101 /********************* MovieClip Template ************************/
102 
104  uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
105 {
106  if (!ptr->data) {
107  return;
108  }
109 
110  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
111  if (!prop) {
112  printf(
113  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
114  return;
115  }
116 
117  if (RNA_property_type(prop) != PROP_POINTER) {
118  printf("%s: expected pointer property for %s.%s\n",
119  __func__,
121  propname);
122  return;
123  }
124 
125  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
126  MovieClip *clip = clipptr.data;
127 
128  uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
129 
130  if (!compact) {
131  uiTemplateID(layout,
132  C,
133  ptr,
134  propname,
135  NULL,
136  "CLIP_OT_open",
137  NULL,
139  false,
140  NULL);
141  }
142 
143  if (clip) {
144  uiLayout *row = uiLayoutRow(layout, false);
145  uiBlock *block = uiLayoutGetBlock(row);
146  uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("File Path:"), 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
147 
148  row = uiLayoutRow(layout, false);
149  uiLayout *split = uiLayoutSplit(row, 0.0f, false);
150  row = uiLayoutRow(split, true);
151 
152  uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
153  uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
154 
155  uiLayout *col = uiLayoutColumn(layout, false);
156  uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
157  }
158 }
159 
160 /********************* Track Template ************************/
161 
162 void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
163 {
164  if (!ptr->data) {
165  return;
166  }
167 
168  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
169  if (!prop) {
170  printf(
171  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
172  return;
173  }
174 
175  if (RNA_property_type(prop) != PROP_POINTER) {
176  printf("%s: expected pointer property for %s.%s\n",
177  __func__,
179  propname);
180  return;
181  }
182 
183  PointerRNA scopesptr = RNA_property_pointer_get(ptr, prop);
184  MovieClipScopes *scopes = (MovieClipScopes *)scopesptr.data;
185 
186  if (scopes->track_preview_height < UI_UNIT_Y) {
188  }
189  else if (scopes->track_preview_height > UI_UNIT_Y * 20) {
190  scopes->track_preview_height = UI_UNIT_Y * 20;
191  }
192 
193  uiLayout *col = uiLayoutColumn(layout, true);
194  uiBlock *block = uiLayoutGetBlock(col);
195 
196  uiDefBut(block,
198  0,
199  "",
200  0,
201  0,
202  UI_UNIT_X * 10,
203  scopes->track_preview_height,
204  scopes,
205  0,
206  0,
207  0,
208  0,
209  "");
210 
211  /* Resize grip. */
212  uiDefIconButI(block,
214  0,
215  ICON_GRIP,
216  0,
217  0,
218  UI_UNIT_X * 10,
219  (short)(UI_UNIT_Y * 0.8f),
220  &scopes->track_preview_height,
221  UI_UNIT_Y,
222  UI_UNIT_Y * 20.0f,
223  0.0f,
224  0.0f,
225  "");
226 }
227 
228 /********************* Marker Template ************************/
229 
230 #define B_MARKER_POS 3
231 #define B_MARKER_OFFSET 4
232 #define B_MARKER_PAT_DIM 5
233 #define B_MARKER_SEARCH_POS 6
234 #define B_MARKER_SEARCH_DIM 7
235 #define B_MARKER_FLAG 8
236 
237 typedef struct {
239  int compact;
240 
246 
248  int framenr;
250  float marker_pos[2];
252  float marker_pat[2];
254  float track_offset[2];
256  float marker_search_pos[2], marker_search[2];
260 
261 static void to_pixel_space(float r[2], const float a[2], int width, int height)
262 {
263  copy_v2_v2(r, a);
264  r[0] *= width;
265  r[1] *= height;
266 }
267 
268 static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
269 {
270  MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
271 
272  if (!cb->compact) {
273  return;
274  }
275 
276  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
277  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
278  marker->flag = cb->marker_flag;
279 
281 }
282 
283 static void marker_block_handler(bContext *C, void *arg_cb, int event)
284 {
285  MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
286  int width, height;
287  bool ok = false;
288 
290 
291  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
292  MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
293 
294  if (event == B_MARKER_POS) {
295  marker->pos[0] = cb->marker_pos[0] / width;
296  marker->pos[1] = cb->marker_pos[1] / height;
297 
298  /* to update position of "parented" objects */
299  DEG_id_tag_update(&cb->clip->id, 0);
301 
302  ok = true;
303  }
304  else if (event == B_MARKER_PAT_DIM) {
305  float dim[2], pat_dim[2], pat_min[2], pat_max[2];
306 
307  BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
308 
309  sub_v2_v2v2(pat_dim, pat_max, pat_min);
310 
311  dim[0] = cb->marker_pat[0] / width;
312  dim[1] = cb->marker_pat[1] / height;
313 
314  float scale_x = dim[0] / pat_dim[0];
315  float scale_y = dim[1] / pat_dim[1];
316 
317  for (int a = 0; a < 4; a++) {
318  cb->marker->pattern_corners[a][0] *= scale_x;
319  cb->marker->pattern_corners[a][1] *= scale_y;
320  }
321 
323 
324  ok = true;
325  }
326  else if (event == B_MARKER_SEARCH_POS) {
327  float delta[2], side[2];
328 
329  sub_v2_v2v2(side, cb->marker->search_max, cb->marker->search_min);
330  mul_v2_fl(side, 0.5f);
331 
332  delta[0] = cb->marker_search_pos[0] / width;
333  delta[1] = cb->marker_search_pos[1] / height;
334 
335  sub_v2_v2v2(cb->marker->search_min, delta, side);
336  add_v2_v2v2(cb->marker->search_max, delta, side);
337 
339 
340  ok = true;
341  }
342  else if (event == B_MARKER_SEARCH_DIM) {
343  float dim[2], search_dim[2];
344 
345  sub_v2_v2v2(search_dim, cb->marker->search_max, cb->marker->search_min);
346 
347  dim[0] = cb->marker_search[0] / width;
348  dim[1] = cb->marker_search[1] / height;
349 
350  sub_v2_v2(dim, search_dim);
351  mul_v2_fl(dim, 0.5f);
352 
353  cb->marker->search_min[0] -= dim[0];
354  cb->marker->search_min[1] -= dim[1];
355 
356  cb->marker->search_max[0] += dim[0];
357  cb->marker->search_max[1] += dim[1];
358 
360 
361  ok = true;
362  }
363  else if (event == B_MARKER_FLAG) {
364  marker->flag = cb->marker_flag;
365 
366  ok = true;
367  }
368  else if (event == B_MARKER_OFFSET) {
369  float offset[2], delta[2];
370 
371  offset[0] = cb->track_offset[0] / width;
372  offset[1] = cb->track_offset[1] / height;
373 
374  sub_v2_v2v2(delta, offset, cb->track->offset);
375  copy_v2_v2(cb->track->offset, offset);
376 
377  for (int i = 0; i < cb->track->markersnr; i++) {
378  sub_v2_v2(cb->track->markers[i].pos, delta);
379  }
380 
381  /* to update position of "parented" objects */
382  DEG_id_tag_update(&cb->clip->id, 0);
384 
385  ok = true;
386  }
387 
388  if (ok) {
390  }
391 }
392 
394  PointerRNA *ptr,
395  const char *propname,
396  PointerRNA *userptr,
397  PointerRNA *trackptr,
398  bool compact)
399 {
400  if (!ptr->data) {
401  return;
402  }
403 
404  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
405  if (!prop) {
406  printf(
407  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
408  return;
409  }
410 
411  if (RNA_property_type(prop) != PROP_POINTER) {
412  printf("%s: expected pointer property for %s.%s\n",
413  __func__,
415  propname);
416  return;
417  }
418 
419  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
420  MovieClip *clip = (MovieClip *)clipptr.data;
421  MovieClipUser *user = userptr->data;
422  MovieTrackingTrack *track = trackptr->data;
423 
424  int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
425  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr);
426 
427  MarkerUpdateCb *cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
428  cb->compact = compact;
429  cb->clip = clip;
430  cb->user = user;
431  cb->track = track;
432  cb->marker = marker;
433  cb->marker_flag = marker->flag;
434  cb->framenr = user->framenr;
435 
436  if (compact) {
437  const char *tip;
438  uiBlock *block = uiLayoutGetBlock(layout);
439 
440  if (cb->marker_flag & MARKER_DISABLED) {
441  tip = TIP_("Marker is disabled at current frame");
442  }
443  else {
444  tip = TIP_("Marker is enabled at current frame");
445  }
446 
447  uiBut *bt = uiDefIconButBitI(block,
450  0,
451  ICON_HIDE_OFF,
452  0,
453  0,
454  UI_UNIT_X,
455  UI_UNIT_Y,
456  &cb->marker_flag,
457  0,
458  0,
459  1,
460  0,
461  tip);
464  }
465  else {
466  int width, height;
467 
468  BKE_movieclip_get_size(clip, user, &width, &height);
469 
470  if (track->flag & TRACK_LOCKED) {
471  uiLayoutSetActive(layout, false);
472  uiBlock *block = uiLayoutAbsoluteBlock(layout);
473  uiDefBut(block,
475  0,
476  IFACE_("Track is locked"),
477  0,
478  0,
479  UI_UNIT_X * 15.0f,
480  UI_UNIT_Y,
481  NULL,
482  0,
483  0,
484  0,
485  0,
486  "");
487 
488  return;
489  }
490 
491  float pat_min[2], pat_max[2];
492  float pat_dim[2], search_dim[2], search_pos[2];
493 
494  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
495 
496  sub_v2_v2v2(pat_dim, pat_max, pat_min);
497  sub_v2_v2v2(search_dim, marker->search_max, marker->search_min);
498 
499  add_v2_v2v2(search_pos, marker->search_max, marker->search_min);
500  mul_v2_fl(search_pos, 0.5);
501 
502  to_pixel_space(cb->marker_pos, marker->pos, width, height);
503  to_pixel_space(cb->marker_pat, pat_dim, width, height);
504  to_pixel_space(cb->marker_search, search_dim, width, height);
505  to_pixel_space(cb->marker_search_pos, search_pos, width, height);
506  to_pixel_space(cb->track_offset, track->offset, width, height);
507 
508  cb->marker_flag = marker->flag;
509 
510  uiBlock *block = uiLayoutAbsoluteBlock(layout);
513 
514  const char *tip;
515  int step = 100;
516  int digits = 2;
517 
518  if (cb->marker_flag & MARKER_DISABLED) {
519  tip = TIP_("Marker is disabled at current frame");
520  }
521  else {
522  tip = TIP_("Marker is enabled at current frame");
523  }
524 
525  uiDefButBitI(block,
529  IFACE_("Enabled"),
530  0.5 * UI_UNIT_X,
531  9.5 * UI_UNIT_Y,
532  7.25 * UI_UNIT_X,
533  UI_UNIT_Y,
534  &cb->marker_flag,
535  0,
536  0,
537  0,
538  0,
539  tip);
540 
541  uiLayout *col = uiLayoutColumn(layout, true);
543 
544  block = uiLayoutAbsoluteBlock(col);
545  UI_block_align_begin(block);
546 
547  uiDefBut(block,
549  0,
550  IFACE_("Position:"),
551  0,
552  10 * UI_UNIT_Y,
553  15 * UI_UNIT_X,
554  UI_UNIT_Y,
555  NULL,
556  0,
557  0,
558  0,
559  0,
560  "");
561  uiBut *bt = uiDefButF(block,
562  UI_BTYPE_NUM,
563  B_MARKER_POS,
564  IFACE_("X:"),
565  0.5 * UI_UNIT_X,
566  9 * UI_UNIT_Y,
567  7.25 * UI_UNIT_X,
568  UI_UNIT_Y,
569  &cb->marker_pos[0],
570  -10 * width,
571  10.0 * width,
572  0,
573  0,
574  TIP_("X-position of marker at frame in screen coordinates"));
575  UI_but_number_step_size_set(bt, step);
576  UI_but_number_precision_set(bt, digits);
577  bt = uiDefButF(block,
578  UI_BTYPE_NUM,
579  B_MARKER_POS,
580  IFACE_("Y:"),
581  8.25 * UI_UNIT_X,
582  9 * UI_UNIT_Y,
583  7.25 * UI_UNIT_X,
584  UI_UNIT_Y,
585  &cb->marker_pos[1],
586  -10 * height,
587  10.0 * height,
588  0,
589  0,
590  TIP_("Y-position of marker at frame in screen coordinates"));
591  UI_but_number_step_size_set(bt, step);
592  UI_but_number_precision_set(bt, digits);
593 
594  uiDefBut(block,
596  0,
597  IFACE_("Offset:"),
598  0,
599  8 * UI_UNIT_Y,
600  15 * UI_UNIT_X,
601  UI_UNIT_Y,
602  NULL,
603  0,
604  0,
605  0,
606  0,
607  "");
608  bt = uiDefButF(block,
609  UI_BTYPE_NUM,
611  IFACE_("X:"),
612  0.5 * UI_UNIT_X,
613  7 * UI_UNIT_Y,
614  7.25 * UI_UNIT_X,
615  UI_UNIT_Y,
616  &cb->track_offset[0],
617  -10 * width,
618  10.0 * width,
619  0,
620  0,
621  TIP_("X-offset to parenting point"));
622  UI_but_number_step_size_set(bt, step);
623  UI_but_number_precision_set(bt, digits);
624  bt = uiDefButF(block,
625  UI_BTYPE_NUM,
627  IFACE_("Y:"),
628  8.25 * UI_UNIT_X,
629  7 * UI_UNIT_Y,
630  7.25 * UI_UNIT_X,
631  UI_UNIT_Y,
632  &cb->track_offset[1],
633  -10 * height,
634  10.0 * height,
635  0,
636  0,
637  TIP_("Y-offset to parenting point"));
638  UI_but_number_step_size_set(bt, step);
639  UI_but_number_precision_set(bt, digits);
640 
641  uiDefBut(block,
643  0,
644  IFACE_("Pattern Area:"),
645  0,
646  6 * UI_UNIT_Y,
647  15 * UI_UNIT_X,
648  UI_UNIT_Y,
649  NULL,
650  0,
651  0,
652  0,
653  0,
654  "");
655  bt = uiDefButF(block,
656  UI_BTYPE_NUM,
658  IFACE_("Width:"),
659  0.5 * UI_UNIT_X,
660  5 * UI_UNIT_Y,
661  15 * UI_UNIT_X,
662  UI_UNIT_Y,
663  &cb->marker_pat[0],
664  3.0f,
665  10.0 * width,
666  0,
667  0,
668  TIP_("Width of marker's pattern in screen coordinates"));
669  UI_but_number_step_size_set(bt, step);
670  UI_but_number_precision_set(bt, digits);
671  bt = uiDefButF(block,
672  UI_BTYPE_NUM,
674  IFACE_("Height:"),
675  0.5 * UI_UNIT_X,
676  4 * UI_UNIT_Y,
677  15 * UI_UNIT_X,
678  UI_UNIT_Y,
679  &cb->marker_pat[1],
680  3.0f,
681  10.0 * height,
682  0,
683  0,
684  TIP_("Height of marker's pattern in screen coordinates"));
685  UI_but_number_step_size_set(bt, step);
686  UI_but_number_precision_set(bt, digits);
687 
688  uiDefBut(block,
690  0,
691  IFACE_("Search Area:"),
692  0,
693  3 * UI_UNIT_Y,
694  15 * UI_UNIT_X,
695  UI_UNIT_Y,
696  NULL,
697  0,
698  0,
699  0,
700  0,
701  "");
702  bt = uiDefButF(block,
703  UI_BTYPE_NUM,
705  IFACE_("X:"),
706  0.5 * UI_UNIT_X,
707  2 * UI_UNIT_Y,
708  7.25 * UI_UNIT_X,
709  UI_UNIT_Y,
710  &cb->marker_search_pos[0],
711  -width,
712  width,
713  0,
714  0,
715  TIP_("X-position of search at frame relative to marker's position"));
716  UI_but_number_step_size_set(bt, step);
717  UI_but_number_precision_set(bt, digits);
718  bt = uiDefButF(block,
719  UI_BTYPE_NUM,
721  IFACE_("Y:"),
722  8.25 * UI_UNIT_X,
723  2 * UI_UNIT_Y,
724  7.25 * UI_UNIT_X,
725  UI_UNIT_Y,
726  &cb->marker_search_pos[1],
727  -height,
728  height,
729  0,
730  0,
731  TIP_("Y-position of search at frame relative to marker's position"));
732  UI_but_number_step_size_set(bt, step);
733  UI_but_number_precision_set(bt, digits);
734  bt = uiDefButF(block,
735  UI_BTYPE_NUM,
737  IFACE_("Width:"),
738  0.5 * UI_UNIT_X,
739  1 * UI_UNIT_Y,
740  15 * UI_UNIT_X,
741  UI_UNIT_Y,
742  &cb->marker_search[0],
743  3.0f,
744  10.0 * width,
745  0,
746  0,
747  TIP_("Width of marker's search in screen coordinates"));
748  UI_but_number_step_size_set(bt, step);
749  UI_but_number_precision_set(bt, digits);
750  bt = uiDefButF(block,
751  UI_BTYPE_NUM,
753  IFACE_("Height:"),
754  0.5 * UI_UNIT_X,
755  0 * UI_UNIT_Y,
756  15 * UI_UNIT_X,
757  UI_UNIT_Y,
758  &cb->marker_search[1],
759  3.0f,
760  10.0 * height,
761  0,
762  0,
763  TIP_("Height of marker's search in screen coordinates"));
764  UI_but_number_step_size_set(bt, step);
765  UI_but_number_precision_set(bt, digits);
766 
767  UI_block_align_end(block);
768  }
769 }
770 
771 /********************* Footage Information Template ************************/
772 
774  PointerRNA *ptr,
775  const char *propname,
776  PointerRNA *userptr)
777 {
778  if (!ptr->data) {
779  return;
780  }
781 
782  PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
783  if (!prop) {
784  printf(
785  "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
786  return;
787  }
788 
789  if (RNA_property_type(prop) != PROP_POINTER) {
790  printf("%s: expected pointer property for %s.%s\n",
791  __func__,
793  propname);
794  return;
795  }
796 
797  PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
798  MovieClip *clip = (MovieClip *)clipptr.data;
799  MovieClipUser *user = userptr->data;
800 
801  uiLayout *col = uiLayoutColumn(layout, false);
803 
804  ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, user, clip->flag, MOVIECLIP_CACHE_SKIP);
805 
806  int width, height;
807  /* Display frame dimensions, channels number and buffer type. */
808  BKE_movieclip_get_size(clip, user, &width, &height);
809 
810  char str[1024];
811  size_t ofs = 0;
812  ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, TIP_("%d x %d"), width, height);
813 
814  if (ibuf) {
815  if (ibuf->rect_float) {
816  if (ibuf->channels != 4) {
817  ofs += BLI_snprintf(
818  str + ofs, sizeof(str) - ofs, TIP_(", %d float channel(s)"), ibuf->channels);
819  }
820  else if (ibuf->planes == R_IMF_PLANES_RGBA) {
821  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGBA float"), sizeof(str) - ofs);
822  }
823  else {
824  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGB float"), sizeof(str) - ofs);
825  }
826  }
827  else {
828  if (ibuf->planes == R_IMF_PLANES_RGBA) {
829  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGBA byte"), sizeof(str) - ofs);
830  }
831  else {
832  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", RGB byte"), sizeof(str) - ofs);
833  }
834  }
835 
836  if (clip->anim != NULL) {
837  short frs_sec;
838  float frs_sec_base;
839  if (IMB_anim_get_fps(clip->anim, &frs_sec, &frs_sec_base, true)) {
840  ofs += BLI_snprintf(
841  str + ofs, sizeof(str) - ofs, TIP_(", %.2f fps"), (float)frs_sec / frs_sec_base);
842  }
843  }
844  }
845  else {
846  ofs += BLI_strncpy_rlen(str + ofs, TIP_(", failed to load"), sizeof(str) - ofs);
847  }
848 
849  uiItemL(col, str, ICON_NONE);
850 
851  /* Display current frame number. */
852  int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
853  if (framenr <= clip->len) {
854  BLI_snprintf(str, sizeof(str), TIP_("Frame: %d / %d"), framenr, clip->len);
855  }
856  else {
857  BLI_snprintf(str, sizeof(str), TIP_("Frame: - / %d"), clip->len);
858  }
859  uiItemL(col, str, ICON_NONE);
860 
861  /* Display current file name if it's a sequence clip. */
862  if (clip->source == MCLIP_SRC_SEQUENCE) {
863  char filepath[FILE_MAX];
864  const char *file;
865 
866  if (framenr <= clip->len) {
867  BKE_movieclip_filename_for_frame(clip, user, filepath);
868  file = BLI_path_slash_rfind(filepath);
869  }
870  else {
871  file = "-";
872  }
873 
874  BLI_snprintf(str, sizeof(str), TIP_("File: %s"), file);
875 
876  uiItemL(col, str, ICON_NONE);
877  }
878 
879  IMB_freeImBuf(ibuf);
880 }
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:899
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
#define MOVIECLIP_CACHE_SKIP
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag, int cache_flag)
Definition: movieclip.c:1354
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
Definition: movieclip.c:1540
void BKE_movieclip_filename_for_frame(struct MovieClip *clip, struct MovieClipUser *user, char *name)
Definition: movieclip.c:1939
@ PANEL_TYPE_DEFAULT_CLOSED
Definition: BKE_screen.h:297
#define CLAMP_SEARCH_POS
Definition: BKE_tracking.h:517
#define CLAMP_SEARCH_DIM
Definition: BKE_tracking.h:516
struct MovieTrackingMarker * BKE_tracking_marker_ensure(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1567
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2])
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1523
#define CLAMP_PAT_DIM
Definition: BKE_tracking.h:514
void BKE_tracking_marker_clamp(struct MovieTrackingMarker *marker, int event)
Definition: tracking.c:1455
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
#define FILE_MAX
const char * BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1962
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:187
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define UNUSED(x)
#define TIP_(msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
#define N_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ MCLIP_SRC_SEQUENCE
#define R_IMF_PLANES_RGBA
@ TRACK_LOCKED
@ MARKER_DISABLED
bool ED_space_clip_poll(struct bContext *C)
Definition: clip_editor.c:76
struct ImBuf * ED_space_clip_get_buffer(struct SpaceClip *sc)
Definition: clip_editor.c:235
void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout)
Definition: area.c:3531
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
Definition: anim_movie.c:1691
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
@ PROP_POINTER
Definition: RNA_types.h:78
#define C
Definition: RandGen.cpp:39
#define UI_UNIT_Y
uiBut * uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:4988
void uiLayoutSetActive(uiLayout *layout, bool active)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
@ UI_BUT_ICON_REVERSE
Definition: UI_interface.h:298
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
uiBut * uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:4687
uiBut * uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:4896
uiBut * uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:5341
void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiTemplateID(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter, const bool live_icon, const char *text)
void UI_but_drawflag_enable(uiBut *but, int flag)
Definition: interface.c:6092
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
uiBlock * uiLayoutAbsoluteBlock(uiLayout *layout)
void UI_but_number_step_size_set(uiBut *but, float step_size)
Definition: interface.c:6827
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
Definition: interface.c:6247
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
@ UI_LAYOUT_ALIGN_RIGHT
@ UI_TEMPLATE_ID_FILTER_ALL
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void UI_block_align_begin(uiBlock *block)
Definition: interface.c:3821
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr)
uiLayout * uiLayoutSplit(uiLayout *layout, float percentage, bool align)
void UI_but_number_precision_set(uiBut *but, float precision)
Definition: interface.c:6836
void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
Definition: interface.c:6301
#define UI_UNIT_X
uiBut * uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:5371
@ UI_BTYPE_TOGGLE_N
Definition: UI_interface.h:345
@ UI_BTYPE_LABEL
Definition: UI_interface.h:358
@ UI_BTYPE_CHECKBOX_N
Definition: UI_interface.h:352
@ UI_BTYPE_NUM
Definition: UI_interface.h:341
@ UI_BTYPE_TRACK_PREVIEW
Definition: UI_interface.h:373
@ UI_BTYPE_GRIP
Definition: UI_interface.h:391
void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2)
Definition: interface.c:6266
void UI_block_align_end(uiBlock *block)
Definition: interface.c:3834
#define NC_MOVIECLIP
Definition: WM_types.h:298
#define NA_EDITED
Definition: WM_types.h:462
#define ND_SPACE_VIEW3D
Definition: WM_types.h:423
#define NC_SPACE
Definition: WM_types.h:293
#define B_MARKER_POS
Definition: clip_buttons.c:230
#define B_MARKER_SEARCH_DIM
Definition: clip_buttons.c:234
static void marker_block_handler(bContext *C, void *arg_cb, int event)
Definition: clip_buttons.c:283
void ED_clip_buttons_register(ARegionType *art)
Definition: clip_buttons.c:86
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
Definition: clip_buttons.c:162
#define B_MARKER_SEARCH_POS
Definition: clip_buttons.c:233
void uiTemplateMovieclipInformation(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr)
Definition: clip_buttons.c:773
void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, bool compact)
Definition: clip_buttons.c:393
#define B_MARKER_OFFSET
Definition: clip_buttons.c:231
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
Definition: clip_buttons.c:66
#define B_MARKER_PAT_DIM
Definition: clip_buttons.c:232
#define B_MARKER_FLAG
Definition: clip_buttons.c:235
static void to_pixel_space(float r[2], const float a[2], int width, int height)
Definition: clip_buttons.c:261
static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
Definition: clip_buttons.c:268
void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
Definition: clip_buttons.c:103
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
Definition: clip_buttons.c:71
FILE * file
#define str(s)
uint col
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition: abc_util.cc:115
const char * RNA_struct_identifier(const StructRNA *type)
Definition: rna_access.c:723
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3641
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
ListBase paneltypes
Definition: BKE_screen.h:216
int channels
unsigned char planes
float * rect_float
MovieTrackingMarker * marker
Definition: clip_buttons.c:245
MovieTrackingTrack * track
Definition: clip_buttons.c:244
float track_offset[2]
Definition: clip_buttons.c:254
float marker_search_pos[2]
Definition: clip_buttons.c:256
MovieClip * clip
Definition: clip_buttons.c:241
float marker_search[2]
Definition: clip_buttons.c:256
float marker_pat[2]
Definition: clip_buttons.c:252
float marker_pos[2]
Definition: clip_buttons.c:250
MovieClipUser * user
Definition: clip_buttons.c:243
struct anim * anim
MovieTrackingMarker * markers
void(* draw)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:266
bool(* poll)(const struct bContext *C, struct PanelType *pt)
Definition: BKE_screen.h:260
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:241
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:244
char category[BKE_ST_MAXNAME]
Definition: BKE_screen.h:246
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:242
struct uiLayout * layout
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
uint len
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157