Add ctrl-click rename to most lists in Blender UI and templates/examples.
[blender.git] / release / scripts / startup / bl_ui / space_clip.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8-80 compliant>
20
21 import bpy
22 from bpy.types import Panel, Header, Menu, UIList
23 from bpy.app.translations import pgettext_iface as iface_
24
25
26 class CLIP_UL_tracking_objects(UIList):
27     def draw_item(self, context, layout, data, item, icon,
28                   active_data, active_propname, index):
29         # assert(isinstance(item, bpy.types.MovieTrackingObject)
30         tobj = item
31         if self.layout_type in {'DEFAULT', 'COMPACT'}:
32             layout.prop(tobj, "name", text="", emboss=False,
33                         icon='CAMERA_DATA' if tobj.is_camera
34                         else 'OBJECT_DATA')
35         elif self.layout_type in {'GRID'}:
36             layout.alignment = 'CENTER'
37             layout.label(text="",
38                          icon='CAMERA_DATA' if tobj.is_camera
39                          else 'OBJECT_DATA')
40
41
42 class CLIP_HT_header(Header):
43     bl_space_type = 'CLIP_EDITOR'
44
45     def _draw_tracking(self, context):
46         layout = self.layout
47
48         sc = context.space_data
49         clip = sc.clip
50
51         row = layout.row(align=True)
52         row.template_header()
53
54         if context.area.show_menus:
55             sub = row.row(align=True)
56             sub.menu("CLIP_MT_view")
57
58             if sc.view == 'CLIP':
59                 if clip:
60                     sub.menu("CLIP_MT_select")
61                     sub.menu("CLIP_MT_clip")
62                     sub.menu("CLIP_MT_track")
63                     sub.menu("CLIP_MT_reconstruction")
64                 else:
65                     sub.menu("CLIP_MT_clip")
66
67         row = layout.row()
68         row.template_ID(sc, "clip", open="clip.open")
69
70         if clip:
71             tracking = clip.tracking
72             active_object = tracking.objects.active
73
74             if sc.view == 'CLIP':
75                 layout.prop(sc, "mode", text="")
76                 layout.prop(sc, "view", text="", expand=True)
77                 layout.prop(sc, "pivot_point", text="", icon_only=True)
78
79                 r = active_object.reconstruction
80
81                 if r.is_valid and sc.view == 'CLIP':
82                     layout.label(text="Solve error: %.4f" %
83                                  (r.average_error))
84             elif sc.view == 'GRAPH':
85                 layout.prop(sc, "view", text="", expand=True)
86
87                 row = layout.row(align=True)
88                 row.prop(sc, "show_graph_only_selected", text="")
89                 row.prop(sc, "show_graph_hidden", text="")
90
91                 row = layout.row(align=True)
92
93                 if sc.show_filters:
94                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN',
95                              text="Filters")
96
97                     sub = row.row(align=True)
98                     sub.active = clip.tracking.reconstruction.is_valid
99                     sub.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
100
101                     row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
102                 else:
103                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
104                              text="Filters")
105             elif sc.view == 'DOPESHEET':
106                 dopesheet = tracking.dopesheet
107                 layout.prop(sc, "view", text="", expand=True)
108
109                 row = layout.row(align=True)
110                 row.prop(dopesheet, "show_only_selected", text="")
111                 row.prop(dopesheet, "show_hidden", text="")
112
113                 row = layout.row(align=True)
114                 row.prop(dopesheet, "sort_method", text="")
115                 row.prop(dopesheet, "use_invert_sort",
116                          text="Invert", toggle=True)
117         else:
118             layout.prop(sc, "view", text="", expand=True)
119
120     def _draw_masking(self, context):
121         layout = self.layout
122
123         toolsettings = context.tool_settings
124         sc = context.space_data
125         clip = sc.clip
126
127         row = layout.row(align=True)
128         row.template_header()
129
130         if context.area.show_menus:
131             sub = row.row(align=True)
132             sub.menu("CLIP_MT_view")
133
134             if clip:
135                 sub.menu("MASK_MT_select")
136                 sub.menu("CLIP_MT_clip")  # XXX - remove?
137                 sub.menu("MASK_MT_mask")
138             else:
139                 sub.menu("CLIP_MT_clip")  # XXX - remove?
140
141         row = layout.row()
142         row.template_ID(sc, "clip", open="clip.open")
143
144         layout.prop(sc, "mode", text="")
145
146         row = layout.row()
147         row.template_ID(sc, "mask", new="mask.new")
148
149         layout.prop(sc, "pivot_point", text="", icon_only=True)
150
151         row = layout.row(align=True)
152         row.prop(toolsettings, "use_proportional_edit_mask",
153                  text="", icon_only=True)
154         if toolsettings.use_proportional_edit_mask:
155             row.prop(toolsettings, "proportional_edit_falloff",
156                      text="", icon_only=True)
157
158     def draw(self, context):
159         layout = self.layout
160
161         sc = context.space_data
162
163         if sc.mode in {'TRACKING', 'RECONSTRUCTION', 'DISTORTION'}:
164             self._draw_tracking(context)
165         else:
166             self._draw_masking(context)
167
168         layout.template_running_jobs()
169
170
171 class CLIP_PT_clip_view_panel:
172
173     @classmethod
174     def poll(cls, context):
175         sc = context.space_data
176         clip = sc.clip
177
178         return clip and sc.view == 'CLIP'
179
180
181 class CLIP_PT_tracking_panel:
182
183     @classmethod
184     def poll(cls, context):
185         sc = context.space_data
186         clip = sc.clip
187
188         return clip and sc.mode == 'TRACKING' and sc.view == 'CLIP'
189
190
191 class CLIP_PT_reconstruction_panel:
192
193     @classmethod
194     def poll(cls, context):
195         sc = context.space_data
196         clip = sc.clip
197
198         return clip and sc.mode == 'RECONSTRUCTION' and sc.view == 'CLIP'
199
200
201 class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
202     bl_space_type = 'CLIP_EDITOR'
203     bl_region_type = 'TOOLS'
204     bl_label = "Marker"
205
206     def draw(self, context):
207         layout = self.layout
208
209         sc = context.space_data
210         clip = sc.clip
211         settings = clip.tracking.settings
212
213         col = layout.column(align=True)
214         col.operator("clip.add_marker_at_click", text="Add Marker")
215         col.operator("clip.detect_features")
216         col.operator("clip.delete_track")
217
218         box = layout.box()
219         row = box.row(align=True)
220         row.prop(settings, "show_default_expanded", text="", emboss=False)
221         row.label(text="Tracking Settings")
222
223         if settings.show_default_expanded:
224             col = box.column()
225             row = col.row(align=True)
226             label = CLIP_MT_tracking_settings_presets.bl_label
227             row.menu('CLIP_MT_tracking_settings_presets', text=label)
228             row.operator("clip.tracking_settings_preset_add",
229                          text="", icon='ZOOMIN')
230             row.operator("clip.tracking_settings_preset_add",
231                          text="", icon='ZOOMOUT').remove_active = True
232
233             col.separator()
234
235             row = col.row(align=True)
236             row.prop(settings, "use_default_red_channel",
237                      text="R", toggle=True)
238             row.prop(settings, "use_default_green_channel",
239                      text="G", toggle=True)
240             row.prop(settings, "use_default_blue_channel",
241                      text="B", toggle=True)
242
243             col.separator()
244
245             sub = col.column(align=True)
246             sub.prop(settings, "default_pattern_size")
247             sub.prop(settings, "default_search_size")
248
249             col.label(text="Tracker:")
250             col.prop(settings, "default_motion_model")
251             col.prop(settings, "use_default_brute")
252             col.prop(settings, "use_default_normalization")
253             col.prop(settings, "use_default_mask")
254             col.prop(settings, "default_correlation_min")
255
256             col.separator()
257
258             sub = col.column(align=True)
259             sub.prop(settings, "default_frames_limit")
260             sub.prop(settings, "default_margin")
261
262             col.label(text="Match:")
263             col.prop(settings, "default_pattern_match", text="")
264
265             col.separator()
266             col.operator("clip.track_settings_as_default",
267                          text="Copy From Active Track")
268
269
270 class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
271     bl_space_type = 'CLIP_EDITOR'
272     bl_region_type = 'TOOLS'
273     bl_label = "Track"
274
275     def draw(self, context):
276         layout = self.layout
277
278         row = layout.row(align=True)
279
280         props = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
281         props.backwards = True
282         props.sequence = False
283         props = row.operator("clip.track_markers", text="",
284                              icon='PLAY_REVERSE')
285         props.backwards = True
286         props.sequence = True
287         props = row.operator("clip.track_markers", text="", icon='PLAY')
288         props.backwards = False
289         props.sequence = True
290         props = row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
291         props.backwards = False
292         props.sequence = False
293
294         col = layout.column()
295         col.label(text="Refine:")
296         row = col.row(align=True)
297         row.operator("clip.refine_markers", text="Backwards").backwards = True
298         row.operator("clip.refine_markers", text="Forwards").backwards = False
299
300         col = layout.column()
301         col.label(text="Clear:")
302         row = col.row(align=True)
303         row.operator("clip.clear_track_path", text="Before").action = 'UPTO'
304         row.operator("clip.clear_track_path", text="After").action = 'REMAINED'
305
306         layout.operator("clip.join_tracks", text="Join")
307
308
309 class CLIP_PT_tools_plane_tracking(CLIP_PT_tracking_panel, Panel):
310     bl_space_type = 'CLIP_EDITOR'
311     bl_region_type = 'TOOLS'
312     bl_label = "Plane Track"
313     bl_options = {'DEFAULT_CLOSED'}
314
315     def draw(self, context):
316         layout = self.layout
317         layout.operator("clip.create_plane_track")
318
319
320 class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
321     bl_space_type = 'CLIP_EDITOR'
322     bl_region_type = 'TOOLS'
323     bl_label = "Solve"
324
325     def draw(self, context):
326         layout = self.layout
327
328         clip = context.space_data.clip
329         tracking = clip.tracking
330         settings = tracking.settings
331         tracking_object = tracking.objects.active
332
333         col = layout.column(align=True)
334
335         col.operator("clip.solve_camera",
336                      text="Camera Motion" if tracking_object.is_camera
337                      else "Object Motion")
338         col.operator("clip.clear_solution")
339
340         col = layout.column()
341         col.prop(settings, "use_tripod_solver")
342         col.prop(settings, "use_keyframe_selection")
343
344         col = layout.column(align=True)
345         col.active = (not settings.use_tripod_solver and
346                       not settings.use_keyframe_selection)
347         col.prop(tracking_object, "keyframe_a")
348         col.prop(tracking_object, "keyframe_b")
349
350         col = layout.column(align=True)
351         col.active = tracking_object.is_camera
352         col.label(text="Refine:")
353         col.prop(settings, "refine_intrinsics", text="")
354
355
356 class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel):
357     bl_space_type = 'CLIP_EDITOR'
358     bl_region_type = 'TOOLS'
359     bl_label = "Clean up"
360
361     def draw(self, context):
362         layout = self.layout
363         clip = context.space_data.clip
364         settings = clip.tracking.settings
365
366         layout.operator("clip.clean_tracks")
367
368         layout.prop(settings, "clean_frames", text="Frames")
369         layout.prop(settings, "clean_error", text="Error")
370         layout.prop(settings, "clean_action", text="")
371
372
373 class CLIP_PT_tools_geometry(CLIP_PT_reconstruction_panel, Panel):
374     bl_space_type = 'CLIP_EDITOR'
375     bl_region_type = 'TOOLS'
376     bl_label = "Geometry"
377
378     def draw(self, context):
379         layout = self.layout
380
381         layout.operator("clip.bundles_to_mesh")
382         layout.operator("clip.track_to_empty")
383
384
385 class CLIP_PT_tools_orientation(CLIP_PT_reconstruction_panel, Panel):
386     bl_space_type = 'CLIP_EDITOR'
387     bl_region_type = 'TOOLS'
388     bl_label = "Orientation"
389
390     def draw(self, context):
391         sc = context.space_data
392         layout = self.layout
393         settings = sc.clip.tracking.settings
394
395         col = layout.column(align=True)
396         row = col.row(align=True)
397         row.operator("clip.set_plane", text="Floor").plane = 'FLOOR'
398         row.operator("clip.set_plane", text="Wall").plane = 'WALL'
399
400         col.operator("clip.set_origin")
401
402         row = col.row(align=True)
403         row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
404         row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
405
406         layout.separator()
407
408         col = layout.column()
409         row = col.row(align=True)
410         row.operator("clip.set_scale")
411         row.operator("clip.apply_solution_scale", text="Apply Scale")
412
413         col.prop(settings, "distance")
414
415
416 class CLIP_PT_tools_object(CLIP_PT_reconstruction_panel, Panel):
417     bl_space_type = 'CLIP_EDITOR'
418     bl_region_type = 'TOOLS'
419     bl_label = "Object"
420
421     @classmethod
422     def poll(cls, context):
423         if CLIP_PT_reconstruction_panel.poll(context):
424             sc = context.space_data
425             clip = sc.clip
426
427             tracking_object = clip.tracking.objects.active
428
429             return not tracking_object.is_camera
430
431         return False
432
433     def draw(self, context):
434         layout = self.layout
435
436         sc = context.space_data
437         clip = sc.clip
438         tracking_object = clip.tracking.objects.active
439         settings = sc.clip.tracking.settings
440
441         col = layout.column()
442
443         col.prop(tracking_object, "scale")
444
445         col.separator()
446
447         col.operator("clip.set_solution_scale", text="Set Scale")
448         col.prop(settings, "object_distance")
449
450
451 class CLIP_PT_tools_grease_pencil(Panel):
452     bl_space_type = 'CLIP_EDITOR'
453     bl_region_type = 'TOOLS'
454     bl_label = "Grease Pencil"
455
456     @classmethod
457     def poll(cls, context):
458         sc = context.space_data
459         clip = sc.clip
460
461         if not clip:
462             return False
463
464         if sc.mode == 'DISTORTION':
465             return sc.view == 'CLIP'
466         elif sc.mode == 'MASK':
467             return True
468
469         return False
470
471     def draw(self, context):
472         layout = self.layout
473
474         col = layout.column(align=True)
475
476         row = col.row(align=True)
477         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
478         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
479
480         row = col.row(align=True)
481         row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
482         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
483
484         row = col.row(align=True)
485         row.prop(context.tool_settings, "use_grease_pencil_sessions")
486
487
488 class CLIP_PT_objects(CLIP_PT_clip_view_panel, Panel):
489     bl_space_type = 'CLIP_EDITOR'
490     bl_region_type = 'UI'
491     bl_label = "Objects"
492     bl_options = {'DEFAULT_CLOSED'}
493
494     def draw(self, context):
495         layout = self.layout
496
497         sc = context.space_data
498         tracking = sc.clip.tracking
499
500         row = layout.row()
501         row.template_list("CLIP_UL_tracking_objects", "", tracking, "objects",
502                           tracking, "active_object_index", rows=1)
503
504         sub = row.column(align=True)
505
506         sub.operator("clip.tracking_object_new", icon='ZOOMIN', text="")
507         sub.operator("clip.tracking_object_remove", icon='ZOOMOUT', text="")
508
509         active = tracking.objects.active
510         if active:
511             layout.prop(active, "name")
512
513
514 class CLIP_PT_track(CLIP_PT_tracking_panel, Panel):
515     bl_space_type = 'CLIP_EDITOR'
516     bl_region_type = 'UI'
517     bl_label = "Track"
518
519     def draw(self, context):
520         layout = self.layout
521
522         sc = context.space_data
523         clip = context.space_data.clip
524         act_track = clip.tracking.tracks.active
525
526         if not act_track:
527             layout.active = False
528             layout.label(text="No active track")
529             return
530
531         row = layout.row()
532         row.prop(act_track, "name", text="")
533
534         sub = row.row(align=True)
535
536         sub.template_marker(sc, "clip", sc.clip_user, act_track, True)
537
538         icon = 'LOCKED' if act_track.lock else 'UNLOCKED'
539         sub.prop(act_track, "lock", text="", icon=icon)
540
541         layout.template_track(sc, "scopes")
542
543         row = layout.row(align=True)
544         sub = row.row(align=True)
545         sub.prop(act_track, "use_red_channel", text="R", toggle=True)
546         sub.prop(act_track, "use_green_channel", text="G", toggle=True)
547         sub.prop(act_track, "use_blue_channel", text="B", toggle=True)
548
549         row.separator()
550
551         row.prop(act_track, "use_grayscale_preview", text="B/W", toggle=True)
552
553         row.separator()
554         row.prop(act_track, "use_alpha_preview",
555                  text="", toggle=True, icon='IMAGE_ALPHA')
556
557         layout.separator()
558
559         row = layout.row(align=True)
560         label = bpy.types.CLIP_MT_track_color_presets.bl_label
561         row.menu('CLIP_MT_track_color_presets', text=label)
562         row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT')
563         row.operator("clip.track_color_preset_add", text="", icon='ZOOMIN')
564         row.operator("clip.track_color_preset_add",
565                      text="", icon='ZOOMOUT').remove_active = True
566
567         row = layout.row()
568         row.prop(act_track, "use_custom_color")
569         if act_track.use_custom_color:
570             row.prop(act_track, "color", text="")
571
572         layout.prop(act_track, "weight")
573
574         if act_track.has_bundle:
575             label_text = "Average Error: %.4f" % (act_track.average_error)
576             layout.label(text=label_text)
577
578
579 class CLIP_PT_plane_track(CLIP_PT_tracking_panel, Panel):
580     bl_space_type = 'CLIP_EDITOR'
581     bl_region_type = 'UI'
582     bl_label = "Plane Track"
583     bl_options = {'DEFAULT_CLOSED'}
584
585     def draw(self, context):
586         layout = self.layout
587
588         sc = context.space_data
589         clip = context.space_data.clip
590         active_track = clip.tracking.plane_tracks.active
591
592         if not active_track:
593             layout.active = False
594             layout.label(text="No active plane track")
595             return
596
597         layout.prop(active_track, "name")
598         layout.prop(active_track, "use_auto_keying")
599
600
601 class CLIP_PT_track_settings(CLIP_PT_tracking_panel, Panel):
602     bl_space_type = 'CLIP_EDITOR'
603     bl_region_type = 'UI'
604     bl_label = "Tracking Settings"
605     bl_options = {'DEFAULT_CLOSED'}
606
607     def draw(self, context):
608         layout = self.layout
609
610         clip = context.space_data.clip
611         settings = clip.tracking.settings
612
613         col = layout.column()
614
615         active = clip.tracking.tracks.active
616         if active:
617             col.prop(active, "motion_model")
618             col.prop(active, "use_brute")
619             col.prop(active, "use_normalization")
620             col.prop(active, "use_mask")
621             col.prop(active, "correlation_min")
622
623             col.separator()
624             col.prop(active, "frames_limit")
625             col.prop(active, "margin")
626             col.prop(active, "pattern_match", text="Match")
627
628         col.prop(settings, "speed")
629
630
631 class CLIP_PT_tracking_camera(Panel):
632     bl_space_type = 'CLIP_EDITOR'
633     bl_region_type = 'UI'
634     bl_label = "Camera Data"
635     bl_options = {'DEFAULT_CLOSED'}
636
637     @classmethod
638     def poll(cls, context):
639         if CLIP_PT_clip_view_panel.poll(context):
640             sc = context.space_data
641
642             return sc.mode in {'TRACKING', 'DISTORTION'} and sc.clip
643
644         return False
645
646     def draw(self, context):
647         layout = self.layout
648
649         sc = context.space_data
650         clip = sc.clip
651
652         row = layout.row(align=True)
653         label = bpy.types.CLIP_MT_camera_presets.bl_label
654         row.menu('CLIP_MT_camera_presets', text=label)
655         row.operator("clip.camera_preset_add", text="", icon='ZOOMIN')
656         row.operator("clip.camera_preset_add", text="",
657                      icon='ZOOMOUT').remove_active = True
658
659         row = layout.row(align=True)
660         sub = row.split(percentage=0.65, align=True)
661         if clip.tracking.camera.units == 'MILLIMETERS':
662             sub.prop(clip.tracking.camera, "focal_length")
663         else:
664             sub.prop(clip.tracking.camera, "focal_length_pixels")
665         sub.prop(clip.tracking.camera, "units", text="")
666
667         col = layout.column(align=True)
668         col.label(text="Sensor:")
669         col.prop(clip.tracking.camera, "sensor_width", text="Width")
670         col.prop(clip.tracking.camera, "pixel_aspect")
671
672         col = layout.column()
673         col.label(text="Optical Center:")
674         row = col.row()
675         row.prop(clip.tracking.camera, "principal", text="")
676         col.operator("clip.set_center_principal", text="Center")
677
678         col = layout.column(align=True)
679         col.label(text="Lens Distortion:")
680         col.prop(clip.tracking.camera, "k1")
681         col.prop(clip.tracking.camera, "k2")
682         col.prop(clip.tracking.camera, "k3")
683
684
685 class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
686     bl_space_type = 'CLIP_EDITOR'
687     bl_region_type = 'UI'
688     bl_label = "Display"
689
690     def draw(self, context):
691         layout = self.layout
692         sc = context.space_data
693
694         row = layout.row(align=True)
695         sub = row.row(align=True)
696         sub.prop(sc, "show_red_channel", text="R", toggle=True)
697         sub.prop(sc, "show_green_channel", text="G", toggle=True)
698         sub.prop(sc, "show_blue_channel", text="B", toggle=True)
699
700         row.separator()
701
702         row.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
703
704         col = layout.column(align=True)
705
706         col.prop(sc, "show_disabled", "Disabled Tracks")
707         col.prop(sc, "show_names", text="Names and Status")
708         if sc.mode != 'MASK':
709             col.prop(sc, "show_bundles", text="3D Markers")
710
711         col.prop(sc, "use_mute_footage", text="Mute Footage")
712         col.prop(sc, "lock_selection")
713
714         if sc.view == 'GRAPH':
715             col.prop(sc, "lock_time_cursor")
716
717         if sc.mode == 'DISTORTION':
718             col.prop(sc, "show_grid", text="Grid")
719             col.prop(sc, "use_manual_calibration")
720         elif sc.mode == 'RECONSTRUCTION':
721             col.prop(sc, "show_stable", text="Stable")
722
723         clip = sc.clip
724         if clip:
725             col.label(text="Display Aspect Ratio:")
726             row = col.row()
727             row.prop(clip, "display_aspect", text="")
728
729
730 class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
731     bl_space_type = 'CLIP_EDITOR'
732     bl_region_type = 'UI'
733     bl_label = "Marker Display"
734
735     @classmethod
736     def poll(cls, context):
737         sc = context.space_data
738
739         return sc.mode != 'MASK'
740
741     def draw(self, context):
742         layout = self.layout
743         sc = context.space_data
744
745         col = layout.column(align=True)
746
747         row = col.row(align=True)
748         row.prop(sc, "show_marker_pattern", text="Pattern")
749         row.prop(sc, "show_marker_search", text="Search")
750
751         col.prop(sc, "show_tiny_markers", text="Thin Markers")
752         col.prop(sc, "show_track_path", text="Path")
753
754         row = col.row(align=True)
755         row.active = sc.show_track_path
756         row.prop(sc, "path_length", text="Length")
757
758
759 class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
760     bl_space_type = 'CLIP_EDITOR'
761     bl_region_type = 'UI'
762     bl_label = "2D Stabilization"
763     bl_options = {'DEFAULT_CLOSED'}
764
765     def draw_header(self, context):
766         stab = context.space_data.clip.tracking.stabilization
767
768         self.layout.prop(stab, "use_2d_stabilization", text="")
769
770     def draw(self, context):
771         layout = self.layout
772
773         tracking = context.space_data.clip.tracking
774         stab = tracking.stabilization
775
776         layout.active = stab.use_2d_stabilization
777
778         row = layout.row()
779         row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks",
780                           stab, "active_track_index", rows=2)
781
782         sub = row.column(align=True)
783
784         sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
785         sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
786
787         sub.menu('CLIP_MT_stabilize_2d_specials', text="",
788                  icon='DOWNARROW_HLT')
789
790         layout.prop(stab, "influence_location")
791
792         layout.prop(stab, "use_autoscale")
793         col = layout.column()
794         col.active = stab.use_autoscale
795         col.prop(stab, "scale_max")
796         col.prop(stab, "influence_scale")
797
798         layout.prop(stab, "use_stabilize_rotation")
799         col = layout.column()
800         col.active = stab.use_stabilize_rotation
801
802         row = col.row(align=True)
803         row.prop_search(stab, "rotation_track", tracking, "tracks", text="")
804         row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN')
805
806         row = col.row()
807         row.active = stab.rotation_track is not None
808         row.prop(stab, "influence_rotation")
809
810         layout.prop(stab, "filter_type")
811
812
813 class CLIP_PT_marker(CLIP_PT_tracking_panel, Panel):
814     bl_space_type = 'CLIP_EDITOR'
815     bl_region_type = 'UI'
816     bl_label = "Marker"
817     bl_options = {'DEFAULT_CLOSED'}
818
819     def draw(self, context):
820         layout = self.layout
821         sc = context.space_data
822         clip = context.space_data.clip
823         act_track = clip.tracking.tracks.active
824
825         if act_track:
826             layout.template_marker(sc, "clip", sc.clip_user, act_track, False)
827         else:
828             layout.active = False
829             layout.label(text="No active track")
830
831
832 class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
833     bl_space_type = 'CLIP_EDITOR'
834     bl_region_type = 'UI'
835     bl_label = "Proxy / Timecode"
836     bl_options = {'DEFAULT_CLOSED'}
837
838     def draw_header(self, context):
839         sc = context.space_data
840
841         self.layout.prop(sc.clip, "use_proxy", text="")
842
843     def draw(self, context):
844         layout = self.layout
845
846         sc = context.space_data
847         clip = sc.clip
848
849         col = layout.column()
850         col.active = clip.use_proxy
851
852         col.label(text="Build Original:")
853
854         row = col.row(align=True)
855         row.prop(clip.proxy, "build_25", toggle=True)
856         row.prop(clip.proxy, "build_50", toggle=True)
857         row.prop(clip.proxy, "build_75", toggle=True)
858         row.prop(clip.proxy, "build_100", toggle=True)
859
860         col.label(text="Build Undistorted:")
861
862         row = col.row(align=True)
863         row.prop(clip.proxy, "build_undistorted_25", toggle=True)
864         row.prop(clip.proxy, "build_undistorted_50", toggle=True)
865         row.prop(clip.proxy, "build_undistorted_75", toggle=True)
866         row.prop(clip.proxy, "build_undistorted_100", toggle=True)
867
868         col.prop(clip.proxy, "quality")
869
870         col.prop(clip, "use_proxy_custom_directory")
871         if clip.use_proxy_custom_directory:
872             col.prop(clip.proxy, "directory")
873
874         col.operator("clip.rebuild_proxy", text="Build Proxy")
875
876         if clip.source == 'MOVIE':
877             col2 = col.column()
878
879             col2.label(text="Use timecode index:")
880             col2.prop(clip.proxy, "timecode", text="")
881
882         col2 = col.column()
883         col2.label(text="Proxy render size:")
884
885         col.prop(sc.clip_user, "proxy_render_size", text="")
886
887         col = layout.column()
888         col.prop(sc.clip_user, "use_render_undistorted")
889
890
891 class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
892     bl_space_type = 'CLIP_EDITOR'
893     bl_region_type = 'UI'
894     bl_label = "Footage Settings"
895     bl_options = {'DEFAULT_CLOSED'}
896
897     def draw(self, context):
898         layout = self.layout
899
900         sc = context.space_data
901         clip = sc.clip
902
903         col = layout.column()
904         col.template_movieclip(sc, "clip", compact=True)
905         col.prop(clip, "frame_start")
906         col.prop(clip, "frame_offset")
907
908
909 class CLIP_PT_footage_info(CLIP_PT_clip_view_panel, Panel):
910     bl_space_type = 'CLIP_EDITOR'
911     bl_region_type = 'UI'
912     bl_label = "Footage Information"
913     bl_options = {'DEFAULT_CLOSED'}
914
915     def draw(self, context):
916         layout = self.layout
917
918         sc = context.space_data
919         clip = sc.clip
920
921         col = layout.column()
922         col.template_movieclip_information(sc, "clip", sc.clip_user)
923
924
925 class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel):
926     bl_space_type = 'CLIP_EDITOR'
927     bl_region_type = 'TOOLS'
928     bl_label = "Clip"
929     bl_translation_context = bpy.app.translations.contexts.id_movieclip
930
931     def draw(self, context):
932         layout = self.layout
933
934         layout.operator("clip.set_viewport_background")
935         layout.operator("clip.setup_tracking_scene")
936         layout.operator("clip.prefetch")
937         layout.operator("clip.set_scene_frames")
938
939
940 class CLIP_MT_view(Menu):
941     bl_label = "View"
942
943     def draw(self, context):
944         layout = self.layout
945
946         sc = context.space_data
947
948         if sc.view == 'CLIP':
949             layout.operator("clip.properties", icon='MENU_PANEL')
950             layout.operator("clip.tools", icon='MENU_PANEL')
951             layout.separator()
952
953             layout.operator("clip.view_selected")
954             layout.operator("clip.view_all")
955
956             layout.separator()
957             layout.operator("clip.view_zoom_in")
958             layout.operator("clip.view_zoom_out")
959
960             layout.separator()
961
962             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
963
964             text = iface_("Zoom %d:%d")
965             for a, b in ratios:
966                 layout.operator("clip.view_zoom_ratio",
967                                 text=text % (a, b),
968                                 translate=False).ratio = a / b
969         else:
970             if sc.view == 'GRAPH':
971                 layout.operator_context = 'INVOKE_REGION_PREVIEW'
972                 layout.operator("clip.graph_center_current_frame")
973                 layout.operator("clip.graph_view_all")
974                 layout.operator_context = 'INVOKE_DEFAULT'
975
976             layout.prop(sc, "show_seconds")
977             layout.separator()
978
979         layout.separator()
980         layout.operator("screen.area_dupli")
981         layout.operator("screen.screen_full_area")
982
983
984 class CLIP_MT_clip(Menu):
985     bl_label = "Clip"
986     bl_translation_context = bpy.app.translations.contexts.id_movieclip
987
988     def draw(self, context):
989         layout = self.layout
990
991         sc = context.space_data
992         clip = sc.clip
993
994         layout.operator("clip.open")
995
996         if clip:
997             layout.operator("clip.prefetch")
998             layout.operator("clip.reload")
999             layout.menu("CLIP_MT_proxy")
1000
1001
1002 class CLIP_MT_proxy(Menu):
1003     bl_label = "Proxy"
1004
1005     def draw(self, context):
1006         layout = self.layout
1007
1008         layout.operator("clip.rebuild_proxy")
1009         layout.operator("clip.delete_proxy")
1010
1011
1012 class CLIP_MT_track(Menu):
1013     bl_label = "Track"
1014
1015     def draw(self, context):
1016         layout = self.layout
1017
1018         layout.operator("clip.clear_solution")
1019         layout.operator("clip.solve_camera")
1020
1021         layout.separator()
1022         layout.operator("clip.clear_track_path",
1023                         text="Clear After").action = 'REMAINED'
1024
1025         layout.operator("clip.clear_track_path",
1026                         text="Clear Before").action = 'UPTO'
1027
1028         layout.operator("clip.clear_track_path",
1029                         text="Clear Track Path").action = 'ALL'
1030
1031         layout.separator()
1032         layout.operator("clip.join_tracks")
1033
1034         layout.separator()
1035         layout.operator("clip.clean_tracks")
1036
1037         layout.separator()
1038         layout.operator("clip.copy_tracks")
1039         layout.operator("clip.paste_tracks")
1040
1041         layout.separator()
1042         layout.operator("clip.track_markers",
1043                         text="Track Frame Backwards").backwards = True
1044
1045         props = layout.operator("clip.track_markers", text="Track Backwards")
1046         props.backwards = True
1047         props.sequence = True
1048
1049         layout.operator("clip.track_markers",
1050                         text="Track Forwards").sequence = True
1051         layout.operator("clip.track_markers", text="Track Frame Forwards")
1052
1053         layout.separator()
1054         layout.operator("clip.delete_track")
1055         layout.operator("clip.delete_marker")
1056
1057         layout.separator()
1058         layout.operator("clip.add_marker_move")
1059
1060         layout.separator()
1061         layout.menu("CLIP_MT_track_visibility")
1062         layout.menu("CLIP_MT_track_transform")
1063
1064
1065 class CLIP_MT_reconstruction(Menu):
1066     bl_label = "Reconstruction"
1067
1068     def draw(self, context):
1069         layout = self.layout
1070
1071         layout.operator("clip.set_origin")
1072         layout.operator("clip.set_plane", text="Set Floor").plane = 'FLOOR'
1073         layout.operator("clip.set_plane", text="Set Wall").plane = 'WALL'
1074
1075         layout.operator("clip.set_axis", text="Set X Axis").axis = "X"
1076         layout.operator("clip.set_axis", text="Set Y Axis").axis = "Y"
1077
1078         layout.operator("clip.set_scale")
1079
1080         layout.separator()
1081
1082         layout.operator("clip.track_to_empty")
1083         layout.operator("clip.bundles_to_mesh")
1084
1085
1086 class CLIP_MT_track_visibility(Menu):
1087     bl_label = "Show/Hide"
1088
1089     def draw(self, context):
1090         layout = self.layout
1091
1092         layout.operator("clip.hide_tracks_clear", text="Show Hidden")
1093         layout.operator("clip.hide_tracks", text="Hide Selected")
1094
1095         layout.operator("clip.hide_tracks",
1096                         text="Hide Unselected").unselected = True
1097
1098
1099 class CLIP_MT_track_transform(Menu):
1100     bl_label = "Transform"
1101
1102     def draw(self, context):
1103         layout = self.layout
1104
1105         layout.operator("transform.translate")
1106         layout.operator("transform.resize")
1107
1108
1109 class CLIP_MT_select(Menu):
1110     bl_label = "Select"
1111
1112     def draw(self, context):
1113         layout = self.layout
1114
1115         layout.operator("clip.select_border")
1116         layout.operator("clip.select_circle")
1117
1118         layout.separator()
1119
1120         layout.operator("clip.select_all"
1121                         ).action = 'TOGGLE'
1122         layout.operator("clip.select_all",
1123                         text="Inverse").action = 'INVERT'
1124
1125         layout.menu("CLIP_MT_select_grouped")
1126
1127
1128 class CLIP_MT_select_grouped(Menu):
1129     bl_label = "Select Grouped"
1130
1131     def draw(self, context):
1132         layout = self.layout
1133
1134         layout.operator_enum("clip.select_grouped", "group")
1135
1136
1137 class CLIP_MT_tracking_specials(Menu):
1138     bl_label = "Specials"
1139
1140     @classmethod
1141     def poll(cls, context):
1142         return context.space_data.clip
1143
1144     def draw(self, context):
1145         layout = self.layout
1146
1147         layout.operator("clip.disable_markers",
1148                         text="Enable Markers").action = 'ENABLE'
1149
1150         layout.operator("clip.disable_markers",
1151                         text="Disable markers").action = 'DISABLE'
1152
1153         layout.separator()
1154         layout.operator("clip.set_origin")
1155
1156         layout.separator()
1157         layout.operator("clip.hide_tracks")
1158         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
1159
1160         layout.separator()
1161         layout.operator("clip.lock_tracks", text="Lock Tracks").action = 'LOCK'
1162
1163         layout.operator("clip.lock_tracks",
1164                         text="Unlock Tracks").action = 'UNLOCK'
1165
1166
1167 class CLIP_MT_select_mode(Menu):
1168     bl_label = "Select Mode"
1169
1170     def draw(self, context):
1171         layout = self.layout
1172
1173         layout.operator_context = 'INVOKE_REGION_WIN'
1174
1175         layout.operator_enum("clip.mode_set", "mode")
1176
1177
1178 class CLIP_MT_camera_presets(Menu):
1179     """Predefined tracking camera intrinsics"""
1180     bl_label = "Camera Presets"
1181     preset_subdir = "tracking_camera"
1182     preset_operator = "script.execute_preset"
1183     draw = Menu.draw_preset
1184
1185
1186 class CLIP_MT_track_color_presets(Menu):
1187     """Predefined track color"""
1188     bl_label = "Color Presets"
1189     preset_subdir = "tracking_track_color"
1190     preset_operator = "script.execute_preset"
1191     draw = Menu.draw_preset
1192
1193
1194 class CLIP_MT_tracking_settings_presets(Menu):
1195     """Predefined tracking settings"""
1196     bl_label = "Tracking Presets"
1197     preset_subdir = "tracking_settings"
1198     preset_operator = "script.execute_preset"
1199     draw = Menu.draw_preset
1200
1201
1202 class CLIP_MT_track_color_specials(Menu):
1203     bl_label = "Track Color Specials"
1204
1205     def draw(self, context):
1206         layout = self.layout
1207
1208         layout.operator("clip.track_copy_color", icon='COPY_ID')
1209
1210
1211 class CLIP_MT_stabilize_2d_specials(Menu):
1212     bl_label = "Track Color Specials"
1213
1214     def draw(self, context):
1215         layout = self.layout
1216
1217         layout.operator("clip.stabilize_2d_select")
1218
1219
1220 # -----------------------------------------------------------------------------
1221 # Mask (similar code in space_image.py, keep in sync)
1222
1223
1224 from bl_ui.properties_mask_common import (MASK_PT_mask,
1225                                           MASK_PT_layers,
1226                                           MASK_PT_spline,
1227                                           MASK_PT_point,
1228                                           MASK_PT_display,
1229                                           MASK_PT_tools)
1230
1231
1232 class CLIP_PT_mask(MASK_PT_mask, Panel):
1233     bl_space_type = 'CLIP_EDITOR'
1234     bl_region_type = 'UI'
1235
1236
1237 class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
1238     bl_space_type = 'CLIP_EDITOR'
1239     bl_region_type = 'UI'
1240
1241
1242 class CLIP_PT_mask_display(MASK_PT_display, Panel):
1243     bl_space_type = 'CLIP_EDITOR'
1244     bl_region_type = 'UI'
1245
1246
1247 class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
1248     bl_space_type = 'CLIP_EDITOR'
1249     bl_region_type = 'UI'
1250
1251
1252 class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
1253     bl_space_type = 'CLIP_EDITOR'
1254     bl_region_type = 'UI'
1255
1256
1257 class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
1258     bl_space_type = 'CLIP_EDITOR'
1259     bl_region_type = 'TOOLS'
1260
1261 # --- end mask ---
1262
1263 if __name__ == "__main__":  # only for live edit.
1264     bpy.utils.register_module(__name__)