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