Movie Clip Editor: cleanup of display panels
[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 clip:
42                 sub.menu("CLIP_MT_select")
43
44             sub.menu("CLIP_MT_clip")
45
46             if clip:
47                 sub.menu("CLIP_MT_track")
48                 sub.menu("CLIP_MT_reconstruction")
49
50         if clip:
51             layout.prop(sc, "mode", text="")
52             layout.prop(sc, "view", text="", expand=True)
53
54             if sc.view == 'GRAPH':
55                 row = layout.row(align=True)
56
57                 if sc.show_filters:
58                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN',
59                         text="Filters")
60
61                     sub = row.column()
62                     sub.active = clip.tracking.reconstruction.is_valid
63                     sub.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
64
65                     row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
66                 else:
67                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
68                         text="Filters")
69
70         row = layout.row()
71         row.template_ID(sc, "clip", open='clip.open')
72
73         if clip:
74             tracking = clip.tracking
75             active = tracking.objects.active
76
77             if active and not active.is_camera:
78                 r = active.reconstruction
79             else:
80                 r = tracking.reconstruction
81
82             if r.is_valid:
83                 layout.label(text="Average solve error: %.4f" %
84                     (r.average_error))
85
86         layout.template_running_jobs()
87
88
89 class CLIP_PT_tools_marker(Panel):
90     bl_space_type = 'CLIP_EDITOR'
91     bl_region_type = 'TOOLS'
92     bl_label = "Marker"
93
94     @classmethod
95     def poll(cls, context):
96         sc = context.space_data
97         clip = sc.clip
98
99         return clip and sc.mode == 'TRACKING'
100
101     def draw(self, context):
102         sc = context.space_data
103         clip = sc.clip
104         settings = clip.tracking.settings
105         layout = self.layout
106
107         col = layout.column(align=True)
108         col.operator("clip.add_marker_move")
109         col.operator("clip.detect_features")
110         col.operator("clip.delete_track")
111
112         box = layout.box()
113         row = box.row(align=True)
114         row.prop(settings, "show_default_expanded", text="", emboss=False)
115         row.label(text="Tracking Settings")
116
117         if settings.show_default_expanded:
118             col = box.column()
119             row = col.row(align=True)
120             label = CLIP_MT_tracking_settings_presets.bl_label
121             row.menu('CLIP_MT_tracking_settings_presets', text=label)
122             row.operator("clip.tracking_settings_preset_add",
123                          text="", icon='ZOOMIN')
124             props = row.operator("clip.tracking_settings_preset_add",
125                                  text="", icon='ZOOMOUT')
126             props.remove_active = True
127
128             col.separator()
129
130             row = col.row(align=True)
131             row.prop(settings, "use_default_red_channel",
132                      text="R", toggle=True)
133             row.prop(settings, "use_default_green_channel",
134                      text="G", toggle=True)
135             row.prop(settings, "use_default_blue_channel",
136                      text="B", toggle=True)
137
138             col.separator()
139
140             sub = col.column(align=True)
141             sub.prop(settings, "default_pattern_size")
142             sub.prop(settings, "default_search_size")
143
144             col.label(text="Tracker:")
145             col.prop(settings, "default_tracker", text="")
146
147             if settings.default_tracker == 'KLT':
148                 col.prop(settings, "default_pyramid_levels")
149             col.prop(settings, "default_correlation_min")
150
151             col.separator()
152
153             sub = col.column(align=True)
154             sub.prop(settings, "default_frames_limit")
155             sub.prop(settings, "default_margin")
156
157             col.label(text="Match:")
158             col.prop(settings, "default_pattern_match", text="")
159
160             col.separator()
161             col.operator('clip.track_settings_as_default',
162                          text="Copy From Active Track")
163
164
165 class CLIP_PT_tools_tracking(Panel):
166     bl_space_type = 'CLIP_EDITOR'
167     bl_region_type = 'TOOLS'
168     bl_label = "Track"
169
170     @classmethod
171     def poll(cls, context):
172         sc = context.space_data
173         clip = sc.clip
174
175         return clip and sc.mode == 'TRACKING'
176
177     def draw(self, context):
178         layout = self.layout
179
180         row = layout.row(align=True)
181
182         props = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
183         props.backwards = True
184         props = row.operator("clip.track_markers", text="",
185                              icon='PLAY_REVERSE')
186         props.backwards = True
187         props.sequence = True
188         props = row.operator("clip.track_markers", text="", icon='PLAY')
189         props.backwards = False
190         props.sequence = True
191         row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
192
193         col = layout.column(align=True)
194         props = col.operator("clip.clear_track_path", text="Clear After")
195         props.action = 'REMAINED'
196
197         props = col.operator("clip.clear_track_path", text="Clear Before")
198         props.action = 'UPTO'
199         col.operator("clip.clear_track_path", text="Clear").action = 'ALL'
200
201         layout.operator("clip.join_tracks", text="Join")
202
203
204 class CLIP_PT_tools_solve(Panel):
205     bl_space_type = 'CLIP_EDITOR'
206     bl_region_type = 'TOOLS'
207     bl_label = "Solve"
208
209     @classmethod
210     def poll(cls, context):
211         sc = context.space_data
212         clip = sc.clip
213
214         return clip and sc.mode == 'TRACKING'
215
216     def draw(self, context):
217         layout = self.layout
218         clip = context.space_data.clip
219         tracking = clip.tracking
220         settings = tracking.settings
221         tracking_object = tracking.objects.active
222
223         col = layout.column(align=True)
224
225         col.operator("clip.solve_camera",
226                      text="Camera Motion" if tracking_object.is_camera
227                      else "Object Motion")
228         col.operator("clip.clear_solution")
229
230         col = layout.column(align=True)
231         col.prop(settings, "keyframe_a")
232         col.prop(settings, "keyframe_b")
233
234         col = layout.column(align=True)
235         col.active = tracking_object.is_camera
236         col.label(text="Refine:")
237         col.prop(settings, "refine_intrinsics", text="")
238
239
240 class CLIP_PT_tools_cleanup(Panel):
241     bl_space_type = 'CLIP_EDITOR'
242     bl_region_type = 'TOOLS'
243     bl_label = "Clean up"
244
245     @classmethod
246     def poll(cls, context):
247         sc = context.space_data
248         clip = sc.clip
249
250         return clip and sc.mode == 'TRACKING'
251
252     def draw(self, context):
253         layout = self.layout
254         clip = context.space_data.clip
255         settings = clip.tracking.settings
256
257         layout.operator("clip.clean_tracks")
258
259         layout.prop(settings, 'clean_frames', text="Frames")
260         layout.prop(settings, 'clean_error', text="Error")
261         layout.prop(settings, 'clean_action', text="")
262
263
264 class CLIP_PT_tools_geometry(Panel):
265     bl_space_type = 'CLIP_EDITOR'
266     bl_region_type = 'TOOLS'
267     bl_label = "Geometry"
268
269     @classmethod
270     def poll(cls, context):
271         sc = context.space_data
272         clip = sc.clip
273
274         return clip and sc.mode == 'RECONSTRUCTION'
275
276     def draw(self, context):
277         layout = self.layout
278
279         layout.operator("clip.bundles_to_mesh")
280         layout.operator("clip.track_to_empty")
281
282
283 class CLIP_PT_tools_orientation(Panel):
284     bl_space_type = 'CLIP_EDITOR'
285     bl_region_type = 'TOOLS'
286     bl_label = "Orientation"
287
288     @classmethod
289     def poll(cls, context):
290         sc = context.space_data
291         clip = sc.clip
292
293         return clip and sc.mode == 'RECONSTRUCTION'
294
295     def draw(self, context):
296         sc = context.space_data
297         layout = self.layout
298         settings = sc.clip.tracking.settings
299
300         col = layout.column(align=True)
301         col.operator("clip.set_floor")
302         col.operator("clip.set_origin")
303
304         row = col.row()
305         row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
306         row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
307
308         layout.separator()
309
310         col = layout.column()
311         col.operator("clip.set_scale")
312         col.prop(settings, "distance")
313
314
315 class CLIP_PT_tools_object(Panel):
316     bl_space_type = 'CLIP_EDITOR'
317     bl_region_type = 'TOOLS'
318     bl_label = "Object"
319
320     @classmethod
321     def poll(cls, context):
322         sc = context.space_data
323         clip = sc.clip
324
325         if clip and sc.mode == 'RECONSTRUCTION':
326             tracking_object = clip.tracking.objects.active
327             return not tracking_object.is_camera
328
329         return False
330
331     def draw(self, context):
332         layout = self.layout
333
334         sc = context.space_data
335         clip = sc.clip
336         tracking_object = clip.tracking.objects.active
337         settings = sc.clip.tracking.settings
338
339         col = layout.column()
340
341         col.prop(tracking_object, "scale")
342
343         col.separator()
344
345         col.operator("clip.set_solution_scale", text="Set Scale")
346         col.prop(settings, "object_distance")
347
348
349 class CLIP_PT_tools_grease_pencil(Panel):
350     bl_space_type = 'CLIP_EDITOR'
351     bl_region_type = 'TOOLS'
352     bl_label = "Grease Pencil"
353
354     @classmethod
355     def poll(cls, context):
356         sc = context.space_data
357         clip = sc.clip
358
359         return clip and sc.mode == 'DISTORTION'
360
361     def draw(self, context):
362         layout = self.layout
363
364         col = layout.column(align=True)
365
366         row = col.row(align=True)
367         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
368         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
369
370         row = col.row(align=True)
371         row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
372         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
373
374         row = col.row()
375         row.prop(context.tool_settings, "use_grease_pencil_sessions")
376
377
378 class CLIP_PT_objects(Panel):
379     bl_space_type = 'CLIP_EDITOR'
380     bl_region_type = 'UI'
381     bl_label = "Objects"
382     bl_options = {'DEFAULT_CLOSED'}
383
384     @classmethod
385     def poll(cls, context):
386         sc = context.space_data
387
388         return sc.clip
389
390     def draw(self, context):
391         layout = self.layout
392
393         sc = context.space_data
394         tracking = sc.clip.tracking
395
396         row = layout.row()
397         row.template_list(tracking, "objects",
398                           tracking, "active_object_index", rows=3)
399
400         sub = row.column(align=True)
401
402         sub.operator("clip.tracking_object_new", icon='ZOOMIN', text="")
403         sub.operator("clip.tracking_object_remove", icon='ZOOMOUT', text="")
404
405         active = tracking.objects.active
406         if active:
407             layout.prop(active, "name")
408
409
410 class CLIP_PT_track(Panel):
411     bl_space_type = 'CLIP_EDITOR'
412     bl_region_type = 'UI'
413     bl_label = "Track"
414
415     @classmethod
416     def poll(cls, context):
417         sc = context.space_data
418         clip = sc.clip
419
420         return sc.mode == 'TRACKING' and clip
421
422     def draw(self, context):
423         layout = self.layout
424         sc = context.space_data
425         clip = context.space_data.clip
426         act_track = clip.tracking.tracks.active
427
428         if not act_track:
429             layout.active = False
430             layout.label(text="No active track")
431             return
432
433         row = layout.row()
434         row.prop(act_track, "name", text="")
435
436         sub = row.row(align=True)
437
438         sub.template_marker(sc, "clip", sc.clip_user, act_track, True)
439
440         icon = 'LOCKED' if act_track.lock else 'UNLOCKED'
441         sub.prop(act_track, "lock", text="", icon=icon)
442
443         layout.template_track(sc, "scopes")
444
445         row = layout.row(align=True)
446         sub = row.row()
447         sub.prop(act_track, "use_red_channel", text="R", toggle=True)
448         sub.prop(act_track, "use_green_channel", text="G", toggle=True)
449         sub.prop(act_track, "use_blue_channel", text="B", toggle=True)
450
451         row.separator()
452
453         sub = row.row()
454         sub.prop(act_track, "use_grayscale_preview", text="B/W", toggle=True)
455
456         layout.separator()
457
458         row = layout.row(align=True)
459         label = bpy.types.CLIP_MT_track_color_presets.bl_label
460         row.menu('CLIP_MT_track_color_presets', text=label)
461         row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT')
462         row.operator("clip.track_color_preset_add", text="", icon='ZOOMIN')
463         props = row.operator("clip.track_color_preset_add",
464                              text="", icon='ZOOMOUT')
465         props.remove_active = True
466
467         row = layout.row()
468         row.prop(act_track, "use_custom_color")
469         if act_track.use_custom_color:
470             row.prop(act_track, "color", text="")
471
472         if act_track.has_bundle:
473             label_text = "Average Error: %.4f" % (act_track.average_error)
474             layout.label(text=label_text)
475
476
477 class CLIP_PT_tracking_camera(Panel):
478     bl_space_type = 'CLIP_EDITOR'
479     bl_region_type = 'UI'
480     bl_label = "Camera Data"
481     bl_options = {'DEFAULT_CLOSED'}
482
483     @classmethod
484     def poll(cls, context):
485         sc = context.space_data
486
487         return sc.mode in {'TRACKING', 'DISTORTION'} and sc.clip
488
489     def draw(self, context):
490         layout = self.layout
491
492         sc = context.space_data
493         clip = sc.clip
494
495         row = layout.row(align=True)
496         label = bpy.types.CLIP_MT_camera_presets.bl_label
497         row.menu('CLIP_MT_camera_presets', text=label)
498         row.operator("clip.camera_preset_add", text="", icon='ZOOMIN')
499         props = row.operator("clip.camera_preset_add", text="", icon='ZOOMOUT')
500         props.remove_active = True
501
502         row = layout.row(align=True)
503         sub = row.split(percentage=0.65)
504         if clip.tracking.camera.units == 'MILLIMETERS':
505             sub.prop(clip.tracking.camera, "focal_length")
506         else:
507             sub.prop(clip.tracking.camera, "focal_length_pixels")
508         sub.prop(clip.tracking.camera, "units", text="")
509
510         col = layout.column(align=True)
511         col.label(text="Sensor:")
512         col.prop(clip.tracking.camera, "sensor_width", text="Width")
513         col.prop(clip.tracking.camera, "pixel_aspect")
514
515         col = layout.column()
516         col.label(text="Optical Center:")
517         row = col.row()
518         row.prop(clip.tracking.camera, "principal", text="")
519         col.operator("clip.set_center_principal", text="Center")
520
521         col = layout.column(align=True)
522         col.label(text="Lens Distortion:")
523         col.prop(clip.tracking.camera, "k1")
524         col.prop(clip.tracking.camera, "k2")
525         col.prop(clip.tracking.camera, "k3")
526
527
528 class CLIP_PT_display(Panel):
529     bl_space_type = 'CLIP_EDITOR'
530     bl_region_type = 'UI'
531     bl_label = "Display"
532
533     def draw(self, context):
534         layout = self.layout
535         sc = context.space_data
536
537         row = layout.row(align=True)
538         sub = row.row()
539         sub.prop(sc, "show_red_channel", text="R", toggle=True)
540         sub.prop(sc, "show_green_channel", text="G", toggle=True)
541         sub.prop(sc, "show_blue_channel", text="B", toggle=True)
542
543         row.separator()
544
545         sub = row.row()
546         sub.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
547
548         col = layout.column(align=True)
549
550         col.prop(sc, "show_disabled", "Disabled Tracks")
551         col.prop(sc, "show_names", text="Names and Status")
552         col.prop(sc, "show_bundles", text="3D Markers")
553
554         col.prop(sc, "use_mute_footage", text="Mute Footage")
555         col.prop(sc, "lock_selection")
556
557         if sc.view == 'GRAPH':
558             col.prop(sc, "lock_time_cursor")
559
560         if sc.mode == 'DISTORTION':
561             col.prop(sc, "show_grid", text="Grid")
562             col.prop(sc, "use_manual_calibration")
563         elif sc.mode == 'RECONSTRUCTION':
564             col.prop(sc, "show_stable", text="Stable")
565
566         clip = sc.clip
567         if clip:
568             col.label(text="Display Aspect Ratio:")
569             row = col.row()
570             row.prop(clip, "display_aspect", text="")
571
572
573 class CLIP_PT_marker_display(Panel):
574     bl_space_type = 'CLIP_EDITOR'
575     bl_region_type = 'UI'
576     bl_label = "Marker Display"
577
578     def draw(self, context):
579         layout = self.layout
580         sc = context.space_data
581
582         col = layout.column(align=True)
583
584         row = col.row()
585         row.prop(sc, "show_marker_pattern", text="Pattern")
586         row.prop(sc, "show_marker_search", text="Search")
587
588         col.prop(sc, "show_tiny_markers", text="Thin Markers")
589         col.prop(sc, "show_track_path", text="Path")
590
591         row = col.row()
592         row.active = sc.show_track_path
593         row.prop(sc, "path_length", text="Length")
594
595
596 class CLIP_PT_track_settings(Panel):
597     bl_space_type = 'CLIP_EDITOR'
598     bl_region_type = 'UI'
599     bl_label = "Tracking Settings"
600     bl_options = {'DEFAULT_CLOSED'}
601
602     @classmethod
603     def poll(cls, context):
604         sc = context.space_data
605
606         return sc.mode == 'TRACKING' and sc.clip
607
608     def draw(self, context):
609         layout = self.layout
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, "tracker")
618
619             if active.tracker == 'KLT':
620                 col.prop(active, "pyramid_levels")
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_stabilization(Panel):
632     bl_space_type = 'CLIP_EDITOR'
633     bl_region_type = 'UI'
634     bl_label = "2D Stabilization"
635     bl_options = {'DEFAULT_CLOSED'}
636
637     @classmethod
638     def poll(cls, context):
639         sc = context.space_data
640
641         return sc.mode == 'RECONSTRUCTION' and sc.clip
642
643     def draw_header(self, context):
644         stab = context.space_data.clip.tracking.stabilization
645
646         self.layout.prop(stab, "use_2d_stabilization", text="")
647
648     def draw(self, context):
649         layout = self.layout
650
651         tracking = context.space_data.clip.tracking
652         stab = tracking.stabilization
653
654         layout.active = stab.use_2d_stabilization
655
656         row = layout.row()
657         row.template_list(stab, "tracks", stab, "active_track_index", rows=3)
658
659         sub = row.column(align=True)
660
661         sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
662         sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
663
664         sub.menu('CLIP_MT_stabilize_2d_specials', text="",
665                  icon='DOWNARROW_HLT')
666
667         layout.prop(stab, "influence_location")
668
669         layout.prop(stab, "use_autoscale")
670         col = layout.column()
671         col.active = stab.use_autoscale
672         col.prop(stab, "scale_max")
673         col.prop(stab, "influence_scale")
674
675         layout.prop(stab, "use_stabilize_rotation")
676         col = layout.column()
677         col.active = stab.use_stabilize_rotation
678
679         row = col.row(align=True)
680         row.prop_search(stab, "rotation_track", tracking, "tracks", text="")
681         row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN')
682
683         row = col.row()
684         row.active = stab.rotation_track is not None
685         row.prop(stab, "influence_rotation")
686
687
688 class CLIP_PT_marker(Panel):
689     bl_space_type = 'CLIP_EDITOR'
690     bl_region_type = 'UI'
691     bl_label = "Marker"
692     bl_options = {'DEFAULT_CLOSED'}
693
694     @classmethod
695     def poll(cls, context):
696         sc = context.space_data
697         clip = sc.clip
698
699         return sc.mode == 'TRACKING' and clip
700
701     def draw(self, context):
702         layout = self.layout
703         sc = context.space_data
704         clip = context.space_data.clip
705         act_track = clip.tracking.tracks.active
706
707         if act_track:
708             layout.template_marker(sc, "clip", sc.clip_user, act_track, False)
709         else:
710             layout.active = False
711             layout.label(text="No active track")
712
713
714 class CLIP_PT_proxy(Panel):
715     bl_space_type = 'CLIP_EDITOR'
716     bl_region_type = 'UI'
717     bl_label = "Proxy / Timecode"
718     bl_options = {'DEFAULT_CLOSED'}
719
720     @classmethod
721     def poll(cls, context):
722         sc = context.space_data
723
724         return sc.clip
725
726     def draw_header(self, context):
727         sc = context.space_data
728
729         self.layout.prop(sc.clip, "use_proxy", text="")
730
731     def draw(self, context):
732         layout = self.layout
733         sc = context.space_data
734         clip = sc.clip
735
736         layout.active = clip.use_proxy
737
738         layout.label(text="Build Original:")
739
740         row = layout.row(align=True)
741         row.prop(clip.proxy, "build_25", toggle=True)
742         row.prop(clip.proxy, "build_50", toggle=True)
743         row.prop(clip.proxy, "build_75", toggle=True)
744         row.prop(clip.proxy, "build_100", toggle=True)
745
746         layout.label(text="Build Undistorted:")
747
748         row = layout.row(align=True)
749         row.prop(clip.proxy, "build_undistorted_25", toggle=True)
750         row.prop(clip.proxy, "build_undistorted_50", toggle=True)
751         row.prop(clip.proxy, "build_undistorted_75", toggle=True)
752         row.prop(clip.proxy, "build_undistorted_100", toggle=True)
753
754         layout.prop(clip.proxy, "quality")
755
756         layout.prop(clip, 'use_proxy_custom_directory')
757         if clip.use_proxy_custom_directory:
758             layout.prop(clip.proxy, "directory")
759
760         layout.operator("clip.rebuild_proxy", text="Build Proxy")
761
762         if clip.source == 'MOVIE':
763             col = layout.column()
764
765             col.label(text="Use timecode index:")
766             col.prop(clip.proxy, "timecode", text="")
767
768         col = layout.column()
769         col.label(text="Proxy render size:")
770
771         col.prop(sc.clip_user, "proxy_render_size", text="")
772         col.prop(sc.clip_user, "use_render_undistorted")
773
774
775 class CLIP_PT_footage(Panel):
776     bl_space_type = 'CLIP_EDITOR'
777     bl_region_type = 'UI'
778     bl_label = "Footage Settings"
779     bl_options = {'DEFAULT_CLOSED'}
780
781     @classmethod
782     def poll(cls, context):
783         sc = context.space_data
784
785         return sc.clip
786
787     def draw(self, context):
788         layout = self.layout
789
790         sc = context.space_data
791         clip = sc.clip
792
793         if clip:
794             layout.template_movieclip(sc, "clip", compact=True)
795         else:
796             layout.operator("clip.open", icon='FILESEL')
797
798
799 class CLIP_PT_tools_clip(Panel):
800     bl_space_type = 'CLIP_EDITOR'
801     bl_region_type = 'TOOLS'
802     bl_label = "Clip"
803
804     @classmethod
805     def poll(cls, context):
806         sc = context.space_data
807
808         return sc.clip
809
810     def draw(self, context):
811         layout = self.layout
812
813         layout.operator("clip.set_viewport_background")
814         layout.operator("clip.setup_tracking_scene")
815
816
817 class CLIP_MT_view(Menu):
818     bl_label = "View"
819
820     def draw(self, context):
821         layout = self.layout
822
823         layout.operator("clip.properties", icon='MENU_PANEL')
824         layout.operator("clip.tools", icon='MENU_PANEL')
825         layout.separator()
826
827         layout.operator("clip.view_selected")
828         layout.operator("clip.view_all")
829
830         layout.separator()
831         layout.operator("clip.view_zoom_in")
832         layout.operator("clip.view_zoom_out")
833
834         layout.separator()
835
836         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
837
838         for a, b in ratios:
839             text = "Zoom %d:%d" % (a, b)
840             layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b
841
842         layout.separator()
843         layout.operator("screen.area_dupli")
844         layout.operator("screen.screen_full_area")
845
846
847 class CLIP_MT_clip(Menu):
848     bl_label = "Clip"
849
850     def draw(self, context):
851         layout = self.layout
852
853         sc = context.space_data
854         clip = sc.clip
855
856         layout.operator("clip.open")
857
858         if clip:
859             layout.operator("clip.reload")
860             layout.menu("CLIP_MT_proxy")
861
862
863 class CLIP_MT_proxy(Menu):
864     bl_label = "Proxy"
865
866     def draw(self, context):
867         layout = self.layout
868
869         layout.operator("clip.rebuild_proxy")
870         layout.operator("clip.delete_proxy")
871
872
873 class CLIP_MT_track(Menu):
874     bl_label = "Track"
875
876     def draw(self, context):
877         layout = self.layout
878
879         layout.operator("clip.clear_solution")
880         layout.operator("clip.solve_camera")
881
882         layout.separator()
883         props = layout.operator("clip.clear_track_path", text="Clear After")
884         props.action = 'REMAINED'
885
886         props = layout.operator("clip.clear_track_path", text="Clear Before")
887         props.action = 'UPTO'
888
889         props = layout.operator("clip.clear_track_path",
890             text="Clear Track Path")
891         props.action = 'ALL'
892
893         layout.separator()
894         layout.operator("clip.join_tracks")
895
896         layout.separator()
897         layout.operator("clip.clean_tracks")
898
899         layout.separator()
900         layout.operator("clip.copy_tracks")
901         layout.operator("clip.paste_tracks")
902
903         layout.separator()
904         props = layout.operator("clip.track_markers",
905             text="Track Frame Backwards")
906         props.backwards = True
907
908         props = layout.operator("clip.track_markers", text="Track Backwards")
909         props.backwards = True
910         props.sequence = True
911
912         props = layout.operator("clip.track_markers", text="Track Forwards")
913         props.sequence = True
914         layout.operator("clip.track_markers", text="Track Frame Forwards")
915
916         layout.separator()
917         layout.operator("clip.delete_track")
918         layout.operator("clip.delete_marker")
919
920         layout.separator()
921         layout.operator("clip.add_marker_move")
922
923         layout.separator()
924         layout.menu("CLIP_MT_track_visibility")
925         layout.menu("CLIP_MT_track_transform")
926
927
928 class CLIP_MT_reconstruction(Menu):
929     bl_label = "Reconstruction"
930
931     def draw(self, context):
932         layout = self.layout
933
934         layout.operator("clip.set_origin")
935         layout.operator("clip.set_floor")
936
937         layout.operator("clip.set_axis", text="Set X Axis").axis = "X"
938         layout.operator("clip.set_axis", text="Set Y Axis").axis = "Y"
939
940         layout.operator("clip.set_scale")
941
942         layout.separator()
943
944         layout.operator("clip.track_to_empty")
945         layout.operator("clip.bundles_to_mesh")
946
947
948 class CLIP_MT_track_visibility(Menu):
949     bl_label = "Show/Hide"
950
951     def draw(self, context):
952         layout = self.layout
953
954         layout.operator("clip.hide_tracks_clear", text="Show Hidden")
955         layout.operator("clip.hide_tracks", text="Hide Selected")
956
957         props = layout.operator("clip.hide_tracks", text="Hide Unselected")
958         props.unselected = True
959
960
961 class CLIP_MT_track_transform(Menu):
962     bl_label = "Transform"
963
964     def draw(self, context):
965         layout = self.layout
966
967         layout.operator("transform.translate")
968         layout.operator("transform.resize")
969
970
971 class CLIP_MT_select(Menu):
972     bl_label = "Select"
973
974     def draw(self, context):
975         layout = self.layout
976
977         layout.operator("clip.select_border")
978         layout.operator("clip.select_circle")
979
980         layout.separator()
981
982         props = layout.operator("clip.select_all", text="Select/Deselect all")
983         props.action = 'TOGGLE'
984         layout.operator("clip.select_all", text="Inverse").action = 'INVERT'
985
986         layout.menu("CLIP_MT_select_grouped")
987
988
989 class CLIP_MT_select_grouped(Menu):
990     bl_label = "Select Grouped"
991
992     def draw(self, context):
993         layout = self.layout
994
995         layout.operator_enum("clip.select_grouped", "group")
996
997
998 class CLIP_MT_tracking_specials(Menu):
999     bl_label = "Specials"
1000
1001     @classmethod
1002     def poll(cls, context):
1003         return context.space_data.clip
1004
1005     def draw(self, context):
1006         layout = self.layout
1007
1008         props = layout.operator("clip.disable_markers",
1009                                 text="Enable Markers")
1010         props.action = 'ENABLE'
1011
1012         props = layout.operator("clip.disable_markers", text="Disable markers")
1013         props.action = 'DISABLE'
1014
1015         layout.separator()
1016         layout.operator("clip.set_origin")
1017
1018         layout.separator()
1019         layout.operator("clip.hide_tracks")
1020         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
1021
1022         layout.separator()
1023         props = layout.operator("clip.lock_tracks", text="Lock Tracks")
1024         props.action = 'LOCK'
1025
1026         props = layout.operator("clip.lock_tracks", text="Unlock Tracks")
1027         props.action = 'UNLOCK'
1028
1029
1030 class CLIP_MT_camera_presets(Menu):
1031     """Predefined tracking camera intrinsics"""
1032     bl_label = "Camera Presets"
1033     preset_subdir = "tracking_camera"
1034     preset_operator = "script.execute_preset"
1035     draw = Menu.draw_preset
1036
1037
1038 class CLIP_MT_track_color_presets(Menu):
1039     """Predefined track color"""
1040     bl_label = "Color Presets"
1041     preset_subdir = "tracking_track_color"
1042     preset_operator = "script.execute_preset"
1043     draw = Menu.draw_preset
1044
1045
1046 class CLIP_MT_tracking_settings_presets(Menu):
1047     """Predefined tracking settings"""
1048     bl_label = "Tracking Presets"
1049     preset_subdir = "tracking_settings"
1050     preset_operator = "script.execute_preset"
1051     draw = Menu.draw_preset
1052
1053
1054 class CLIP_MT_track_color_specials(Menu):
1055     bl_label = "Track Color Specials"
1056
1057     def draw(self, context):
1058         layout = self.layout
1059
1060         layout.operator('clip.track_copy_color', icon='COPY_ID')
1061
1062
1063 class CLIP_MT_stabilize_2d_specials(Menu):
1064     bl_label = "Track Color Specials"
1065
1066     def draw(self, context):
1067         layout = self.layout
1068
1069         layout.operator('clip.stabilize_2d_select')
1070
1071 if __name__ == "__main__":  # only for live edit.
1072     bpy.utils.register_module(__name__)