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