Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / space_view3d.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 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_grease_pencil_common import GreasePencilDataPanel
23 from bl_ui.properties_paint_common import UnifiedPaintPanel
24 from bpy.app.translations import contexts as i18n_contexts
25
26
27 class VIEW3D_HT_header(Header):
28     bl_space_type = 'VIEW_3D'
29
30     def draw(self, context):
31         layout = self.layout
32
33         view = context.space_data
34         # mode_string = context.mode
35         obj = context.active_object
36         toolsettings = context.tool_settings
37
38         row = layout.row(align=True)
39         row.template_header()
40         sub = row.row(align=True)
41
42         VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
43
44         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
45         row = layout
46         layout.template_header_3D()
47
48         if obj:
49             mode = obj.mode
50
51             # Occlude geometry
52             if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'EDIT' and obj.type == 'MESH')) or
53                     (mode == 'WEIGHT_PAINT')):
54                 row.prop(view, "use_occlude_geometry", text="")
55
56             # Proportional editing
57             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
58                 row = layout.row(align=True)
59                 row.prop(toolsettings, "proportional_edit", icon_only=True)
60                 if toolsettings.proportional_edit != 'DISABLED':
61                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
62             elif mode == 'EDIT':
63                 row = layout.row(align=True)
64                 row.prop(toolsettings, "proportional_edit", icon_only=True)
65                 if toolsettings.proportional_edit != 'DISABLED':
66                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
67             elif mode == 'OBJECT':
68                 row = layout.row(align=True)
69                 row.prop(toolsettings, "use_proportional_edit_objects", icon_only=True)
70                 if toolsettings.use_proportional_edit_objects:
71                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
72         else:
73             # Proportional editing
74             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
75                 row = layout.row(align=True)
76                 row.prop(toolsettings, "proportional_edit", icon_only=True)
77                 if toolsettings.proportional_edit != 'DISABLED':
78                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
79
80         # Snap
81         show_snap = False
82         if obj is None:
83             show_snap = True
84         else:
85             if mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
86                 show_snap = True
87             else:
88                 paint_settings = UnifiedPaintPanel.paint_settings(context)
89                 if paint_settings:
90                     brush = paint_settings.brush
91                     if brush and brush.stroke_method == 'CURVE':
92                         show_snap = True
93
94         if show_snap:
95             snap_element = toolsettings.snap_element
96             row = layout.row(align=True)
97             row.prop(toolsettings, "use_snap", text="")
98             row.prop(toolsettings, "snap_element", icon_only=True)
99             if snap_element == 'INCREMENT':
100                 row.prop(toolsettings, "use_snap_grid_absolute", text="")
101             else:
102                 row.prop(toolsettings, "snap_target", text="")
103                 if obj:
104                     if mode in {'OBJECT', 'POSE'} and snap_element != 'VOLUME':
105                         row.prop(toolsettings, "use_snap_align_rotation", text="")
106                     elif mode == 'EDIT':
107                         row.prop(toolsettings, "use_snap_self", text="")
108
109             if snap_element == 'VOLUME':
110                 row.prop(toolsettings, "use_snap_peel_object", text="")
111             elif snap_element == 'FACE':
112                 row.prop(toolsettings, "use_snap_project", text="")
113
114         # AutoMerge editing
115         if obj:
116             if (mode == 'EDIT' and obj.type == 'MESH'):
117                 layout.prop(toolsettings, "use_mesh_automerge", text="", icon='AUTOMERGE_ON')
118
119         # OpenGL render
120         row = layout.row(align=True)
121         row.operator("render.opengl", text="", icon='RENDER_STILL')
122         row.operator("render.opengl", text="", icon='RENDER_ANIMATION').animation = True
123
124         # Pose
125         if obj and mode == 'POSE':
126             row = layout.row(align=True)
127             row.operator("pose.copy", text="", icon='COPYDOWN')
128             row.operator("pose.paste", text="", icon='PASTEDOWN').flipped = False
129             row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = True
130
131         # GPencil
132         if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
133             row = layout.row(align=True)
134             row.operator("gpencil.copy", text="", icon='COPYDOWN')
135             row.operator("gpencil.paste", text="", icon='PASTEDOWN')
136
137             layout.prop(context.gpencil_data, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH') # XXX: icon
138
139             layout.prop(context.tool_settings.gpencil_sculpt, "use_select_mask")
140
141
142
143
144 class VIEW3D_MT_editor_menus(Menu):
145     bl_space_type = 'VIEW3D_MT_editor_menus'
146     bl_label = ""
147
148     def draw(self, context):
149         self.draw_menus(self.layout, context)
150
151     @staticmethod
152     def draw_menus(layout, context):
153         obj = context.active_object
154         mode_string = context.mode
155         edit_object = context.edit_object
156         gp_edit = context.gpencil_data and context.gpencil_data.use_stroke_edit_mode
157
158         layout.menu("VIEW3D_MT_view")
159
160         # Select Menu
161         if gp_edit:
162             layout.menu("VIEW3D_MT_select_gpencil")
163         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
164             mesh = obj.data
165             if mesh.use_paint_mask:
166                 layout.menu("VIEW3D_MT_select_paint_mask")
167             elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
168                 layout.menu("VIEW3D_MT_select_paint_mask_vertex")
169         elif mode_string != 'SCULPT':
170             layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
171
172         if gp_edit:
173             pass
174         elif mode_string == 'OBJECT':
175             layout.menu("INFO_MT_add", text="Add")
176         elif mode_string == 'EDIT_MESH':
177             layout.menu("INFO_MT_mesh_add", text="Add")
178         elif mode_string == 'EDIT_CURVE':
179             layout.menu("INFO_MT_curve_add", text="Add")
180         elif mode_string == 'EDIT_SURFACE':
181             layout.menu("INFO_MT_surface_add", text="Add")
182         elif mode_string == 'EDIT_METABALL':
183             layout.menu("INFO_MT_metaball_add", text="Add")
184         elif mode_string == 'EDIT_ARMATURE':
185             layout.menu("INFO_MT_edit_armature_add", text="Add")
186
187         if gp_edit:
188             layout.menu("VIEW3D_MT_edit_gpencil")
189         elif edit_object:
190             layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
191         elif obj:
192             if mode_string != 'PAINT_TEXTURE':
193                 layout.menu("VIEW3D_MT_%s" % mode_string.lower())
194             if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
195                 layout.menu("VIEW3D_MT_brush")
196             if mode_string == 'SCULPT':
197                 layout.menu("VIEW3D_MT_hide_mask")
198         else:
199             layout.menu("VIEW3D_MT_object")
200
201
202 # ********** Menu **********
203
204
205 # ********** Utilities **********
206
207
208 class ShowHideMenu:
209     bl_label = "Show/Hide"
210     _operator_name = ""
211
212     def draw(self, context):
213         layout = self.layout
214
215         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
216         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
217         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
218
219
220 # Standard transforms which apply to all cases
221 # NOTE: this doesn't seem to be able to be used directly
222 class VIEW3D_MT_transform_base(Menu):
223     bl_label = "Transform"
224
225     # TODO: get rid of the custom text strings?
226     def draw(self, context):
227         layout = self.layout
228
229         layout.operator("transform.translate", text="Grab/Move")
230         # TODO: sub-menu for grab per axis
231         layout.operator("transform.rotate", text="Rotate")
232         # TODO: sub-menu for rot per axis
233         layout.operator("transform.resize", text="Scale")
234         # TODO: sub-menu for scale per axis
235
236         layout.separator()
237
238         layout.operator("transform.tosphere", text="To Sphere")
239         layout.operator("transform.shear", text="Shear")
240         layout.operator("transform.bend", text="Bend")
241         layout.operator("transform.push_pull", text="Push/Pull")
242
243         if context.mode != 'OBJECT':
244             layout.operator("transform.vertex_warp", text="Warp")
245             layout.operator("transform.vertex_random", text="Randomize")
246
247
248 # Generic transform menu - geometry types
249 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
250     def draw(self, context):
251         # base menu
252         VIEW3D_MT_transform_base.draw(self, context)
253
254         # generic...
255         layout = self.layout
256         layout.operator("transform.shrink_fatten", text="Shrink Fatten")
257
258         layout.separator()
259
260         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
261         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
262
263
264 # Object-specific extensions to Transform menu
265 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
266     def draw(self, context):
267         layout = self.layout
268
269         # base menu
270         VIEW3D_MT_transform_base.draw(self, context)
271
272         # object-specific option follow...
273         layout.separator()
274
275         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
276         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
277
278         layout.separator()
279
280         layout.operator_context = 'EXEC_REGION_WIN'
281         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
282
283         layout.separator()
284
285         layout.operator_context = 'EXEC_AREA'
286
287         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
288         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
289         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
290         layout.operator("object.origin_set", text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
291         layout.separator()
292
293         layout.operator("object.randomize_transform")
294         layout.operator("object.align")
295
296
297 # Armature EditMode extensions to Transform menu
298 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
299     def draw(self, context):
300         layout = self.layout
301
302         # base menu
303         VIEW3D_MT_transform_base.draw(self, context)
304
305         # armature specific extensions follow...
306         layout.separator()
307
308         obj = context.object
309         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
310             if obj.data.draw_type == 'BBONE':
311                 layout.operator("transform.transform", text="Scale BBone").mode = 'BONE_SIZE'
312             elif obj.data.draw_type == 'ENVELOPE':
313                 layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONE_SIZE'
314                 layout.operator("transform.transform", text="Scale Radius").mode = 'BONE_ENVELOPE'
315
316         if context.edit_object and context.edit_object.type == 'ARMATURE':
317             layout.operator("armature.align")
318
319
320 class VIEW3D_MT_mirror(Menu):
321     bl_label = "Mirror"
322
323     def draw(self, context):
324         layout = self.layout
325
326         layout.operator("transform.mirror", text="Interactive Mirror")
327
328         layout.separator()
329
330         layout.operator_context = 'INVOKE_REGION_WIN'
331
332         props = layout.operator("transform.mirror", text="X Global")
333         props.constraint_axis = (True, False, False)
334         props.constraint_orientation = 'GLOBAL'
335         props = layout.operator("transform.mirror", text="Y Global")
336         props.constraint_axis = (False, True, False)
337         props.constraint_orientation = 'GLOBAL'
338         props = layout.operator("transform.mirror", text="Z Global")
339         props.constraint_axis = (False, False, True)
340         props.constraint_orientation = 'GLOBAL'
341
342         if context.edit_object:
343             layout.separator()
344
345             props = layout.operator("transform.mirror", text="X Local")
346             props.constraint_axis = (True, False, False)
347             props.constraint_orientation = 'LOCAL'
348             props = layout.operator("transform.mirror", text="Y Local")
349             props.constraint_axis = (False, True, False)
350             props.constraint_orientation = 'LOCAL'
351             props = layout.operator("transform.mirror", text="Z Local")
352             props.constraint_axis = (False, False, True)
353             props.constraint_orientation = 'LOCAL'
354
355             layout.operator("object.vertex_group_mirror")
356
357
358 class VIEW3D_MT_snap(Menu):
359     bl_label = "Snap"
360
361     def draw(self, context):
362         layout = self.layout
363
364         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
365         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
366         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)").use_offset = True
367
368         layout.separator()
369
370         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
371         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
372         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
373         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
374
375
376 class VIEW3D_MT_uv_map(Menu):
377     bl_label = "UV Mapping"
378
379     def draw(self, context):
380         layout = self.layout
381
382         layout.operator("uv.unwrap")
383
384         layout.operator_context = 'INVOKE_DEFAULT'
385         layout.operator("uv.smart_project")
386         layout.operator("uv.lightmap_pack")
387         layout.operator("uv.follow_active_quads")
388
389         layout.separator()
390
391         layout.operator_context = 'EXEC_REGION_WIN'
392         layout.operator("uv.cube_project")
393         layout.operator("uv.cylinder_project")
394         layout.operator("uv.sphere_project")
395
396         layout.separator()
397
398         layout.operator_context = 'INVOKE_REGION_WIN'
399         layout.operator("uv.project_from_view").scale_to_bounds = False
400         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
401
402         layout.separator()
403
404         layout.operator("uv.reset")
405
406
407 # ********** View menus **********
408
409
410 class VIEW3D_MT_view(Menu):
411     bl_label = "View"
412
413     def draw(self, context):
414         layout = self.layout
415
416         layout.operator("view3d.properties", icon='MENU_PANEL')
417         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
418
419         layout.separator()
420
421         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
422         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
423         layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
424         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
425         layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
426         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
427         layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
428
429         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
430
431         layout.separator()
432
433         layout.operator("view3d.view_persportho")
434
435         layout.separator()
436
437         layout.menu("VIEW3D_MT_view_navigation")
438         layout.menu("VIEW3D_MT_view_align")
439
440         layout.separator()
441
442         layout.operator_context = 'INVOKE_REGION_WIN'
443
444         layout.operator("view3d.clip_border", text="Clipping Border...")
445         layout.operator("view3d.zoom_border", text="Zoom Border...")
446         layout.operator("view3d.render_border", text="Render Border...").camera_only = False
447         layout.operator("view3d.clear_render_border")
448
449         layout.separator()
450
451         layout.operator("view3d.layers", text="Show All Layers").nr = 0
452
453         layout.separator()
454
455         layout.operator("view3d.localview", text="View Global/Local")
456         layout.operator("view3d.view_selected").use_all_regions = False
457         layout.operator("view3d.view_all").center = False
458
459         layout.separator()
460
461         layout.operator("screen.animation_play", text="Playback Animation")
462
463         layout.separator()
464
465         layout.operator("screen.area_dupli")
466         layout.operator("screen.region_quadview")
467         layout.operator("screen.screen_full_area")
468         layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
469
470
471 class VIEW3D_MT_view_navigation(Menu):
472     bl_label = "Navigation"
473
474     def draw(self, context):
475         from math import pi
476         layout = self.layout
477
478         layout.operator_enum("view3d.view_orbit", "type")
479         props = layout.operator("view3d.view_orbit", "Orbit Opposite")
480         props.type = 'ORBITRIGHT'
481         props.angle = pi
482
483         layout.separator()
484
485         layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
486         layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
487
488         layout.separator()
489
490         layout.operator_enum("view3d.view_pan", "type")
491
492         layout.separator()
493
494         layout.operator("view3d.zoom", text="Zoom In").delta = 1
495         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
496         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
497
498         layout.separator()
499
500         layout.operator("view3d.fly")
501         layout.operator("view3d.walk")
502
503
504 class VIEW3D_MT_view_align(Menu):
505     bl_label = "Align View"
506
507     def draw(self, context):
508         layout = self.layout
509
510         layout.menu("VIEW3D_MT_view_align_selected")
511
512         layout.separator()
513
514         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
515         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
516         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
517         layout.operator("view3d.view_selected")
518         layout.operator("view3d.view_center_cursor")
519
520         layout.separator()
521
522         layout.operator("view3d.view_lock_to_active")
523         layout.operator("view3d.view_lock_clear")
524
525
526 class VIEW3D_MT_view_align_selected(Menu):
527     bl_label = "Align View to Active"
528
529     def draw(self, context):
530         layout = self.layout
531
532         props = layout.operator("view3d.viewnumpad", text="Top")
533         props.align_active = True
534         props.type = 'TOP'
535
536         props = layout.operator("view3d.viewnumpad", text="Bottom")
537         props.align_active = True
538         props.type = 'BOTTOM'
539
540         props = layout.operator("view3d.viewnumpad", text="Front")
541         props.align_active = True
542         props.type = 'FRONT'
543
544         props = layout.operator("view3d.viewnumpad", text="Back")
545         props.align_active = True
546         props.type = 'BACK'
547
548         props = layout.operator("view3d.viewnumpad", text="Right")
549         props.align_active = True
550         props.type = 'RIGHT'
551
552         props = layout.operator("view3d.viewnumpad", text="Left")
553         props.align_active = True
554         props.type = 'LEFT'
555
556
557 class VIEW3D_MT_view_cameras(Menu):
558     bl_label = "Cameras"
559
560     def draw(self, context):
561         layout = self.layout
562
563         layout.operator("view3d.object_as_camera")
564         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
565
566
567 # ********** Select menus, suffix from context.mode **********
568
569 class VIEW3D_MT_select_object_more_less(Menu):
570     bl_label = "Select More/Less"
571
572     def draw(self, context):
573         layout = self.layout
574
575         layout = self.layout
576
577         layout.operator("object.select_more", text="More")
578         layout.operator("object.select_less", text="Less")
579
580         layout.separator()
581
582         props = layout.operator("object.select_hierarchy", text="Parent")
583         props.extend = False
584         props.direction = 'PARENT'
585
586         props = layout.operator("object.select_hierarchy", text="Child")
587         props.extend = False
588         props.direction = 'CHILD'
589
590         layout.separator()
591
592         props = layout.operator("object.select_hierarchy", text="Extend Parent")
593         props.extend = True
594         props.direction = 'PARENT'
595
596         props = layout.operator("object.select_hierarchy", text="Extend Child")
597         props.extend = True
598         props.direction = 'CHILD'
599
600
601 class VIEW3D_MT_select_object(Menu):
602     bl_label = "Select"
603
604     def draw(self, context):
605         layout = self.layout
606
607         layout.operator("view3d.select_border")
608         layout.operator("view3d.select_circle")
609
610         layout.separator()
611
612         layout.operator("object.select_all").action = 'TOGGLE'
613         layout.operator("object.select_all", text="Inverse").action = 'INVERT'
614         layout.operator("object.select_random", text="Random")
615         layout.operator("object.select_mirror", text="Mirror")
616         layout.operator("object.select_by_layer", text="Select All by Layer")
617         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
618         layout.operator("object.select_camera", text="Select Camera")
619
620         layout.separator()
621
622         layout.menu("VIEW3D_MT_select_object_more_less")
623
624         layout.separator()
625
626         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
627         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
628         layout.operator("object.select_pattern", text="Select Pattern...")
629
630
631 class VIEW3D_MT_select_pose_more_less(Menu):
632     bl_label = "Select More/Less"
633
634     def draw(self, context):
635         layout = self.layout
636
637         layout = self.layout
638
639         props = layout.operator("pose.select_hierarchy", text="Parent")
640         props.extend = False
641         props.direction = 'PARENT'
642
643         props = layout.operator("pose.select_hierarchy", text="Child")
644         props.extend = False
645         props.direction = 'CHILD'
646
647         layout.separator()
648
649         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
650         props.extend = True
651         props.direction = 'PARENT'
652
653         props = layout.operator("pose.select_hierarchy", text="Extend Child")
654         props.extend = True
655         props.direction = 'CHILD'
656
657
658 class VIEW3D_MT_select_pose(Menu):
659     bl_label = "Select"
660
661     def draw(self, context):
662         layout = self.layout
663
664         layout.operator("view3d.select_border")
665         layout.operator("view3d.select_circle")
666
667         layout.separator()
668
669         layout.operator("pose.select_all").action = 'TOGGLE'
670         layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
671         layout.operator("pose.select_mirror", text="Flip Active")
672         layout.operator("pose.select_constraint_target", text="Constraint Target")
673         layout.operator("pose.select_linked", text="Linked")
674
675         layout.separator()
676
677         layout.menu("VIEW3D_MT_select_pose_more_less")
678
679         layout.separator()
680
681         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
682         layout.operator("object.select_pattern", text="Select Pattern...")
683
684
685 class VIEW3D_MT_edit_mesh_select_similar(Menu):
686     bl_label = "Select Similar"
687
688     def draw(self, context):
689         layout = self.layout
690
691         layout.operator_enum("mesh.select_similar", "type")
692
693         layout.separator()
694
695         layout.operator("mesh.select_similar_region", text="Face Regions")
696
697
698 class VIEW3D_MT_edit_mesh_select_by_trait(Menu):
699     bl_label = "Select All by Trait"
700
701     def draw(self, context):
702         layout = self.layout
703         if context.scene.tool_settings.mesh_select_mode[2] is False:
704             layout.operator("mesh.select_non_manifold", text="Non Manifold")
705         layout.operator("mesh.select_loose", text="Loose Geometry")
706         layout.operator("mesh.select_interior_faces", text="Interior Faces")
707         layout.operator("mesh.select_face_by_sides")
708
709         layout.separator()
710
711         layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")
712
713
714 class VIEW3D_MT_edit_mesh_select_more_less(Menu):
715     bl_label = "Select More/Less"
716
717     def draw(self, context):
718         layout = self.layout
719
720         layout.operator("mesh.select_more", text="More")
721         layout.operator("mesh.select_less", text="Less")
722
723         layout.separator()
724
725         layout.operator("mesh.select_next_item", text="Next Active")
726         layout.operator("mesh.select_prev_item", text="Previous Active")
727
728
729 class VIEW3D_MT_select_edit_mesh(Menu):
730     bl_label = "Select"
731
732     def draw(self, context):
733         layout = self.layout
734
735         layout.operator("view3d.select_border")
736         layout.operator("view3d.select_circle")
737
738         layout.separator()
739
740         # primitive
741         layout.operator("mesh.select_all").action = 'TOGGLE'
742         layout.operator("mesh.select_all", text="Inverse").action = 'INVERT'
743
744         layout.separator()
745
746         # numeric
747         layout.operator("mesh.select_random", text="Random")
748         layout.operator("mesh.select_nth")
749
750         layout.separator()
751
752         # geometric
753         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
754         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
755
756         layout.separator()
757
758         # other ...
759         layout.menu("VIEW3D_MT_edit_mesh_select_similar")
760
761         layout.separator()
762
763         layout.menu("VIEW3D_MT_edit_mesh_select_by_trait")
764
765         layout.separator()
766
767         layout.menu("VIEW3D_MT_edit_mesh_select_more_less")
768
769         layout.separator()
770
771         layout.operator("mesh.select_mirror", text="Mirror")
772         layout.operator("mesh.select_axis", text="Side of Active")
773
774         layout.operator("mesh.select_linked", text="Linked")
775         layout.operator("mesh.shortest_path_select", text="Shortest Path")
776         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
777         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
778
779         layout.separator()
780
781         layout.operator("mesh.loop_to_region")
782         layout.operator("mesh.region_to_loop")
783
784
785 class VIEW3D_MT_select_edit_curve(Menu):
786     bl_label = "Select"
787
788     def draw(self, context):
789         layout = self.layout
790
791         layout.operator("view3d.select_border")
792         layout.operator("view3d.select_circle")
793
794         layout.separator()
795
796         layout.operator("curve.select_all").action = 'TOGGLE'
797         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
798         layout.operator("curve.select_random")
799         layout.operator("curve.select_nth")
800         layout.operator("curve.select_linked", text="Select Linked")
801         layout.operator("curve.select_similar", text="Select Similar")
802
803         layout.separator()
804
805         layout.operator("curve.de_select_first")
806         layout.operator("curve.de_select_last")
807         layout.operator("curve.select_next")
808         layout.operator("curve.select_previous")
809
810         layout.separator()
811
812         layout.operator("curve.select_more")
813         layout.operator("curve.select_less")
814
815
816 class VIEW3D_MT_select_edit_surface(Menu):
817     bl_label = "Select"
818
819     def draw(self, context):
820         layout = self.layout
821
822         layout.operator("view3d.select_border")
823         layout.operator("view3d.select_circle")
824
825         layout.separator()
826
827         layout.operator("curve.select_all").action = 'TOGGLE'
828         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
829         layout.operator("curve.select_random")
830         layout.operator("curve.select_nth")
831         layout.operator("curve.select_linked", text="Select Linked")
832         layout.operator("curve.select_similar", text="Select Similar")
833
834         layout.separator()
835
836         layout.operator("curve.select_row")
837
838         layout.separator()
839
840         layout.operator("curve.select_more")
841         layout.operator("curve.select_less")
842
843
844 class VIEW3D_MT_select_edit_text(Menu):
845     # intentional name mis-match
846     # select menu for 3d-text doesn't make sense
847     bl_label = "Edit"
848
849     def draw(self, context):
850         layout = self.layout
851
852         layout.operator("font.text_copy", text="Copy")
853         layout.operator("font.text_cut", text="Cut")
854         layout.operator("font.text_paste", text="Paste")
855
856         layout.separator()
857
858         layout.operator("font.text_paste_from_file")
859
860         layout.separator()
861
862         layout.operator("font.select_all")
863
864
865 class VIEW3D_MT_select_edit_metaball(Menu):
866     bl_label = "Select"
867
868     def draw(self, context):
869         layout = self.layout
870
871         layout.operator("view3d.select_border")
872         layout.operator("view3d.select_circle")
873
874         layout.separator()
875
876         layout.operator("mball.select_all").action = 'TOGGLE'
877         layout.operator("mball.select_all", text="Inverse").action = 'INVERT'
878
879         layout.separator()
880
881         layout.operator("mball.select_random_metaelems")
882
883         layout.separator()
884
885         layout.operator_menu_enum("mball.select_similar", "type", text="Similar")
886
887
888 class VIEW3D_MT_select_edit_lattice(Menu):
889     bl_label = "Select"
890
891     def draw(self, context):
892         layout = self.layout
893
894         layout.operator("view3d.select_border")
895         layout.operator("view3d.select_circle")
896
897         layout.separator()
898
899         layout.operator("lattice.select_mirror")
900         layout.operator("lattice.select_random")
901         layout.operator("lattice.select_all").action = 'TOGGLE'
902         layout.operator("lattice.select_all", text="Inverse").action = 'INVERT'
903
904         layout.separator()
905
906         layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")
907
908
909 class VIEW3D_MT_select_edit_armature(Menu):
910     bl_label = "Select"
911
912     def draw(self, context):
913         layout = self.layout
914
915         layout.operator("view3d.select_border")
916         layout.operator("view3d.select_circle")
917
918         layout.separator()
919
920         layout.operator("armature.select_all").action = 'TOGGLE'
921         layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
922         layout.operator("armature.select_mirror", text="Mirror").extend = False
923
924         layout.separator()
925
926         layout.operator("armature.select_more", text="More")
927         layout.operator("armature.select_less", text="Less")
928
929         layout.separator()
930
931         props = layout.operator("armature.select_hierarchy", text="Parent")
932         props.extend = False
933         props.direction = 'PARENT'
934
935         props = layout.operator("armature.select_hierarchy", text="Child")
936         props.extend = False
937         props.direction = 'CHILD'
938
939         layout.separator()
940
941         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
942         props.extend = True
943         props.direction = 'PARENT'
944
945         props = layout.operator("armature.select_hierarchy", text="Extend Child")
946         props.extend = True
947         props.direction = 'CHILD'
948
949         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
950         layout.operator("object.select_pattern", text="Select Pattern...")
951
952
953 class VIEW3D_MT_select_gpencil(Menu):
954     bl_label = "Select"
955
956     def draw(self, context):
957         layout = self.layout
958
959         layout.operator("gpencil.select_border")
960         layout.operator("gpencil.select_circle")
961
962         layout.separator()
963
964         layout.operator("gpencil.select_all", text="(De)select All").action = 'TOGGLE'
965         layout.operator("gpencil.select_all", text="Inverse").action = 'INVERT'
966         layout.operator("gpencil.select_linked", text="Linked")
967         #layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
968         layout.operator("gpencil.select_grouped", text="Grouped")
969
970         layout.separator()
971
972         layout.operator("gpencil.select_first")
973         layout.operator("gpencil.select_last")
974
975         layout.separator()
976
977         layout.operator("gpencil.select_more")
978         layout.operator("gpencil.select_less")
979
980
981 class VIEW3D_MT_select_paint_mask(Menu):
982     bl_label = "Select"
983
984     def draw(self, context):
985         layout = self.layout
986
987         layout.operator("view3d.select_border")
988         layout.operator("view3d.select_circle")
989
990         layout.separator()
991
992         layout.operator("paint.face_select_all").action = 'TOGGLE'
993         layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT'
994
995         layout.separator()
996
997         layout.operator("paint.face_select_linked", text="Linked")
998
999
1000 class VIEW3D_MT_select_paint_mask_vertex(Menu):
1001     bl_label = "Select"
1002
1003     def draw(self, context):
1004         layout = self.layout
1005
1006         layout.operator("view3d.select_border")
1007         layout.operator("view3d.select_circle")
1008
1009         layout.separator()
1010
1011         layout.operator("paint.vert_select_all").action = 'TOGGLE'
1012         layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT'
1013
1014         layout.separator()
1015
1016         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
1017
1018
1019 class VIEW3D_MT_angle_control(Menu):
1020     bl_label = "Angle Control"
1021
1022     @classmethod
1023     def poll(cls, context):
1024         settings = UnifiedPaintPanel.paint_settings(context)
1025         if not settings:
1026             return False
1027
1028         brush = settings.brush
1029         tex_slot = brush.texture_slot
1030
1031         return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
1032
1033     def draw(self, context):
1034         layout = self.layout
1035
1036         settings = UnifiedPaintPanel.paint_settings(context)
1037         brush = settings.brush
1038
1039         sculpt = (context.sculpt_object is not None)
1040
1041         tex_slot = brush.texture_slot
1042
1043         layout.prop(tex_slot, "use_rake", text="Rake")
1044
1045         if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
1046             if sculpt:
1047                 if brush.sculpt_capabilities.has_random_texture_angle:
1048                     layout.prop(tex_slot, "use_random", text="Random")
1049             else:
1050                 layout.prop(tex_slot, "use_random", text="Random")
1051
1052
1053 # ********** Add menu **********
1054
1055 # XXX: INFO_MT_ names used to keep backwards compatibility (Addons etc that hook into the menu)
1056
1057
1058 class INFO_MT_mesh_add(Menu):
1059     bl_idname = "INFO_MT_mesh_add"
1060     bl_label = "Mesh"
1061
1062     def draw(self, context):
1063         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1064
1065         layout = self.layout
1066
1067         layout.operator_context = 'INVOKE_REGION_WIN'
1068
1069         VIEW3D_PT_tools_add_object.draw_add_mesh(layout)
1070
1071
1072 class INFO_MT_curve_add(Menu):
1073     bl_idname = "INFO_MT_curve_add"
1074     bl_label = "Curve"
1075
1076     def draw(self, context):
1077         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1078         layout = self.layout
1079
1080         layout.operator_context = 'INVOKE_REGION_WIN'
1081
1082         VIEW3D_PT_tools_add_object.draw_add_curve(layout)
1083
1084
1085 class INFO_MT_surface_add(Menu):
1086     bl_idname = "INFO_MT_surface_add"
1087     bl_label = "Surface"
1088
1089     def draw(self, context):
1090         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1091         layout = self.layout
1092
1093         layout.operator_context = 'INVOKE_REGION_WIN'
1094
1095         VIEW3D_PT_tools_add_object.draw_add_surface(layout)
1096
1097
1098 class INFO_MT_metaball_add(Menu):
1099     bl_idname = "INFO_MT_metaball_add"
1100     bl_label = "Metaball"
1101
1102     def draw(self, context):
1103         layout = self.layout
1104
1105         layout.operator_context = 'INVOKE_REGION_WIN'
1106         layout.operator_enum("object.metaball_add", "type")
1107
1108
1109 class INFO_MT_edit_curve_add(Menu):
1110     bl_idname = "INFO_MT_edit_curve_add"
1111     bl_label = "Add"
1112
1113     def draw(self, context):
1114         is_surf = context.active_object.type == 'SURFACE'
1115
1116         layout = self.layout
1117         layout.operator_context = 'EXEC_REGION_WIN'
1118
1119         if is_surf:
1120             INFO_MT_surface_add.draw(self, context)
1121         else:
1122             INFO_MT_curve_add.draw(self, context)
1123
1124
1125 class INFO_MT_edit_armature_add(Menu):
1126     bl_idname = "INFO_MT_edit_armature_add"
1127     bl_label = "Armature"
1128
1129     def draw(self, context):
1130         layout = self.layout
1131
1132         layout.operator_context = 'EXEC_REGION_WIN'
1133         layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA')
1134
1135
1136 class INFO_MT_armature_add(Menu):
1137     bl_idname = "INFO_MT_armature_add"
1138     bl_label = "Armature"
1139
1140     def draw(self, context):
1141         layout = self.layout
1142
1143         layout.operator_context = 'EXEC_REGION_WIN'
1144         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
1145
1146
1147 class INFO_MT_lamp_add(Menu):
1148     bl_idname = "INFO_MT_lamp_add"
1149     bl_label = "Lamp"
1150
1151     def draw(self, context):
1152         layout = self.layout
1153
1154         layout.operator_context = 'INVOKE_REGION_WIN'
1155         layout.operator_enum("object.lamp_add", "type")
1156
1157
1158 class INFO_MT_add(Menu):
1159     bl_label = "Add"
1160
1161     def draw(self, context):
1162         layout = self.layout
1163
1164         # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
1165
1166         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
1167         #       "align_view" to work on first call (see [#32719]).
1168         layout.operator_context = 'EXEC_REGION_WIN'
1169
1170         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
1171         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
1172
1173         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
1174         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
1175         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
1176         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
1177         layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
1178         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
1179         layout.separator()
1180
1181         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
1182         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
1183         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
1184         layout.separator()
1185
1186         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
1187         layout.separator()
1188
1189         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
1190         layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
1191         layout.separator()
1192
1193         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
1194         layout.separator()
1195
1196         if len(bpy.data.groups) > 10:
1197             layout.operator_context = 'INVOKE_REGION_WIN'
1198             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
1199         else:
1200             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
1201
1202
1203 # ********** Object menu **********
1204
1205
1206 class VIEW3D_MT_object(Menu):
1207     bl_context = "objectmode"
1208     bl_label = "Object"
1209
1210     def draw(self, context):
1211         layout = self.layout
1212         view = context.space_data
1213         is_local_view = (view.local_view is not None)
1214
1215         layout.operator("ed.undo")
1216         layout.operator("ed.redo")
1217         layout.operator("ed.undo_history")
1218
1219         layout.separator()
1220
1221         layout.menu("VIEW3D_MT_transform_object")
1222         layout.menu("VIEW3D_MT_mirror")
1223         layout.menu("VIEW3D_MT_object_clear")
1224         layout.menu("VIEW3D_MT_object_apply")
1225         layout.menu("VIEW3D_MT_snap")
1226
1227         layout.separator()
1228
1229         layout.menu("VIEW3D_MT_object_animation")
1230
1231         layout.separator()
1232
1233         layout.operator("object.duplicate_move")
1234         layout.operator("object.duplicate_move_linked")
1235         layout.operator("object.delete", text="Delete...").use_global = False
1236         layout.operator("object.proxy_make", text="Make Proxy...")
1237         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
1238         layout.operator("object.make_dupli_face")
1239         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
1240         layout.menu("VIEW3D_MT_make_single_user")
1241
1242         layout.separator()
1243
1244         layout.menu("VIEW3D_MT_object_parent")
1245         layout.menu("VIEW3D_MT_object_track")
1246         layout.menu("VIEW3D_MT_object_group")
1247         layout.menu("VIEW3D_MT_object_constraints")
1248
1249         layout.separator()
1250
1251         layout.menu("VIEW3D_MT_object_quick_effects")
1252
1253         layout.separator()
1254
1255         layout.menu("VIEW3D_MT_object_game")
1256
1257         layout.separator()
1258
1259         layout.operator("object.join")
1260         layout.operator("object.data_transfer")
1261         layout.operator("object.datalayout_transfer")
1262
1263         layout.separator()
1264
1265         if is_local_view:
1266             layout.operator_context = 'EXEC_REGION_WIN'
1267             layout.operator("object.move_to_layer", text="Move out of Local View")
1268             layout.operator_context = 'INVOKE_REGION_WIN'
1269         else:
1270             layout.operator("object.move_to_layer", text="Move to Layer...")
1271
1272         layout.menu("VIEW3D_MT_object_showhide")
1273
1274         layout.operator_menu_enum("object.convert", "target")
1275
1276
1277 class VIEW3D_MT_object_animation(Menu):
1278     bl_label = "Animation"
1279
1280     def draw(self, context):
1281         layout = self.layout
1282
1283         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1284         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
1285         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
1286         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1287
1288         layout.separator()
1289
1290         layout.operator("nla.bake", text="Bake Action...")
1291
1292
1293 class VIEW3D_MT_object_clear(Menu):
1294     bl_label = "Clear"
1295
1296     def draw(self, context):
1297         layout = self.layout
1298
1299         layout.operator("object.location_clear", text="Location")
1300         layout.operator("object.rotation_clear", text="Rotation")
1301         layout.operator("object.scale_clear", text="Scale")
1302         layout.operator("object.origin_clear", text="Origin")
1303
1304
1305 class VIEW3D_MT_object_specials(Menu):
1306     bl_label = "Specials"
1307
1308     @classmethod
1309     def poll(cls, context):
1310         # add more special types
1311         return context.object
1312
1313     def draw(self, context):
1314         layout = self.layout
1315
1316         scene = context.scene
1317         obj = context.object
1318
1319         if obj.type == 'CAMERA':
1320             layout.operator_context = 'INVOKE_REGION_WIN'
1321
1322             if obj.data.type == 'PERSP':
1323                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1324                 props.data_path_iter = "selected_editable_objects"
1325                 props.data_path_item = "data.lens"
1326                 props.input_scale = 0.1
1327                 if obj.data.lens_unit == 'MILLIMETERS':
1328                     props.header_text = "Camera Lens Angle: %.1fmm"
1329                 else:
1330                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1331
1332             else:
1333                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1334                 props.data_path_iter = "selected_editable_objects"
1335                 props.data_path_item = "data.ortho_scale"
1336                 props.input_scale = 0.01
1337                 props.header_text = "Camera Lens Scale: %.3f"
1338
1339             if not obj.data.dof_object:
1340                 view = context.space_data
1341                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1342                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1343                 else:
1344                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1345                     props.data_path_iter = "selected_editable_objects"
1346                     props.data_path_item = "data.dof_distance"
1347                     props.input_scale = 0.02
1348                     props.header_text = "DOF Distance: %.3f"
1349                 del view
1350
1351         if obj.type in {'CURVE', 'FONT'}:
1352             layout.operator_context = 'INVOKE_REGION_WIN'
1353
1354             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1355             props.data_path_iter = "selected_editable_objects"
1356             props.data_path_item = "data.extrude"
1357             props.input_scale = 0.01
1358             props.header_text = "Extrude Size: %.3f"
1359
1360             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1361             props.data_path_iter = "selected_editable_objects"
1362             props.data_path_item = "data.offset"
1363             props.input_scale = 0.01
1364             props.header_text = "Width Size: %.3f"
1365
1366         if obj.type == 'EMPTY':
1367             layout.operator_context = 'INVOKE_REGION_WIN'
1368
1369             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
1370             props.data_path_iter = "selected_editable_objects"
1371             props.data_path_item = "empty_draw_size"
1372             props.input_scale = 0.01
1373             props.header_text = "Empty Draw Size: %.3f"
1374
1375         if obj.type == 'LAMP':
1376             lamp = obj.data
1377
1378             layout.operator_context = 'INVOKE_REGION_WIN'
1379
1380             if scene.render.use_shading_nodes:
1381                 try:
1382                     value = lamp.node_tree.nodes["Emission"].inputs["Strength"].default_value
1383                 except AttributeError:
1384                     value = None
1385
1386                 if value is not None:
1387                     props = layout.operator("wm.context_modal_mouse", text="Strength")
1388                     props.data_path_iter = "selected_editable_objects"
1389                     props.data_path_item = "data.node_tree.nodes[\"Emission\"].inputs[\"Strength\"].default_value"
1390                     props.header_text = "Lamp Strength: %.3f"
1391                     props.input_scale = 0.1
1392                 del value
1393
1394                 if lamp.type == 'AREA':
1395                     props = layout.operator("wm.context_modal_mouse", text="Size X")
1396                     props.data_path_iter = "selected_editable_objects"
1397                     props.data_path_item = "data.size"
1398                     props.header_text = "Lamp Size X: %.3f"
1399
1400                     if lamp.shape == 'RECTANGLE':
1401                         props = layout.operator("wm.context_modal_mouse", text="Size Y")
1402                         props.data_path_iter = "selected_editable_objects"
1403                         props.data_path_item = "data.size_y"
1404                         props.header_text = "Lamp Size Y: %.3f"
1405
1406                 elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
1407                     props = layout.operator("wm.context_modal_mouse", text="Size")
1408                     props.data_path_iter = "selected_editable_objects"
1409                     props.data_path_item = "data.shadow_soft_size"
1410                     props.header_text = "Lamp Size: %.3f"
1411             else:
1412                 props = layout.operator("wm.context_modal_mouse", text="Energy")
1413                 props.data_path_iter = "selected_editable_objects"
1414                 props.data_path_item = "data.energy"
1415                 props.header_text = "Lamp Energy: %.3f"
1416
1417                 if lamp.type in {'SPOT', 'AREA', 'POINT'}:
1418                     props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
1419                     props.data_path_iter = "selected_editable_objects"
1420                     props.data_path_item = "data.distance"
1421                     props.input_scale = 0.1
1422                     props.header_text = "Lamp Falloff Distance: %.1f"
1423
1424             if lamp.type == 'SPOT':
1425                 layout.separator()
1426                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
1427                 props.data_path_iter = "selected_editable_objects"
1428                 props.data_path_item = "data.spot_size"
1429                 props.input_scale = 0.01
1430                 props.header_text = "Spot Size: %.2f"
1431
1432                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
1433                 props.data_path_iter = "selected_editable_objects"
1434                 props.data_path_item = "data.spot_blend"
1435                 props.input_scale = -0.01
1436                 props.header_text = "Spot Blend: %.2f"
1437
1438                 if not scene.render.use_shading_nodes:
1439                     props = layout.operator("wm.context_modal_mouse", text="Clip Start")
1440                     props.data_path_iter = "selected_editable_objects"
1441                     props.data_path_item = "data.shadow_buffer_clip_start"
1442                     props.input_scale = 0.05
1443                     props.header_text = "Clip Start: %.2f"
1444
1445                     props = layout.operator("wm.context_modal_mouse", text="Clip End")
1446                     props.data_path_iter = "selected_editable_objects"
1447                     props.data_path_item = "data.shadow_buffer_clip_end"
1448                     props.input_scale = 0.05
1449                     props.header_text = "Clip End: %.2f"
1450
1451         layout.separator()
1452
1453         props = layout.operator("object.isolate_type_render")
1454         props = layout.operator("object.hide_render_clear_all")
1455
1456
1457 class VIEW3D_MT_object_apply(Menu):
1458     bl_label = "Apply"
1459
1460     def draw(self, context):
1461         layout = self.layout
1462
1463         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1464         props.location, props.rotation, props.scale = True, False, False
1465
1466         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1467         props.location, props.rotation, props.scale = False, True, False
1468
1469         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1470         props.location, props.rotation, props.scale = False, False, True
1471         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1472         props.location, props.rotation, props.scale = False, True, True
1473
1474         layout.separator()
1475         
1476         layout.operator("object.transforms_to_deltas", text="Location to Deltas", text_ctxt=i18n_contexts.default).mode = 'LOC'
1477         layout.operator("object.transforms_to_deltas", text="Rotation to Deltas", text_ctxt=i18n_contexts.default).mode = 'ROT'
1478         layout.operator("object.transforms_to_deltas", text="Scale to Deltas", text_ctxt=i18n_contexts.default).mode = 'SCALE'
1479         
1480         layout.operator("object.transforms_to_deltas", text="All Transforms to Deltas", text_ctxt=i18n_contexts.default).mode = 'ALL'
1481         layout.operator("object.anim_transforms_to_deltas")
1482         
1483         layout.separator()
1484
1485         layout.operator("object.visual_transform_apply", text="Visual Transform", text_ctxt=i18n_contexts.default)
1486         layout.operator("object.duplicates_make_real")
1487
1488
1489 class VIEW3D_MT_object_parent(Menu):
1490     bl_label = "Parent"
1491
1492     def draw(self, context):
1493         layout = self.layout
1494
1495         layout.operator_enum("object.parent_set", "type")
1496         layout.separator()
1497         layout.operator_enum("object.parent_clear", "type")
1498
1499
1500 class VIEW3D_MT_object_track(Menu):
1501     bl_label = "Track"
1502
1503     def draw(self, context):
1504         layout = self.layout
1505
1506         layout.operator_enum("object.track_set", "type")
1507         layout.separator()
1508         layout.operator_enum("object.track_clear", "type")
1509
1510
1511 class VIEW3D_MT_object_group(Menu):
1512     bl_label = "Group"
1513
1514     def draw(self, context):
1515         layout = self.layout
1516
1517         layout.operator("group.create")
1518         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
1519         layout.operator("group.objects_remove")
1520         layout.operator("group.objects_remove_all")
1521
1522         layout.separator()
1523
1524         layout.operator("group.objects_add_active")
1525         layout.operator("group.objects_remove_active")
1526
1527
1528 class VIEW3D_MT_object_constraints(Menu):
1529     bl_label = "Constraints"
1530
1531     def draw(self, context):
1532         layout = self.layout
1533
1534         layout.operator("object.constraint_add_with_targets")
1535         layout.operator("object.constraints_copy")
1536         layout.operator("object.constraints_clear")
1537
1538
1539 class VIEW3D_MT_object_quick_effects(Menu):
1540     bl_label = "Quick Effects"
1541
1542     def draw(self, context):
1543         layout = self.layout
1544
1545         layout.operator("object.quick_fur")
1546         layout.operator("object.quick_explode")
1547         layout.operator("object.quick_smoke")
1548         layout.operator("object.quick_fluid")
1549
1550
1551 class VIEW3D_MT_object_showhide(Menu):
1552     bl_label = "Show/Hide"
1553
1554     def draw(self, context):
1555         layout = self.layout
1556
1557         layout.operator("object.hide_view_clear", text="Show Hidden")
1558         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1559         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1560
1561
1562 class VIEW3D_MT_make_single_user(Menu):
1563     bl_label = "Make Single User"
1564
1565     def draw(self, context):
1566         layout = self.layout
1567
1568         props = layout.operator("object.make_single_user", text="Object")
1569         props.object = True
1570         props.obdata = props.material = props.texture = props.animation = False
1571
1572         props = layout.operator("object.make_single_user", text="Object & Data")
1573         props.object = props.obdata = True
1574         props.material = props.texture = props.animation = False
1575
1576         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1577         props.object = props.obdata = props.material = props.texture = True
1578         props.animation = False
1579
1580         props = layout.operator("object.make_single_user", text="Materials+Tex")
1581         props.material = props.texture = True
1582         props.object = props.obdata = props.animation = False
1583
1584         props = layout.operator("object.make_single_user", text="Object Animation")
1585         props.animation = True
1586         props.object = props.obdata = props.material = props.texture = False
1587
1588
1589 class VIEW3D_MT_make_links(Menu):
1590     bl_label = "Make Links"
1591
1592     def draw(self, context):
1593         layout = self.layout
1594         operator_context_default = layout.operator_context
1595         if len(bpy.data.scenes) > 10:
1596             layout.operator_context = 'INVOKE_REGION_WIN'
1597             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1598         else:
1599             layout.operator_context = 'EXEC_REGION_WIN'
1600             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1601         layout.operator_context = operator_context_default
1602
1603         layout.operator_enum("object.make_links_data", "type")  # inline
1604
1605         layout.operator("object.join_uvs")  # stupid place to add this!
1606
1607
1608 class VIEW3D_MT_object_game(Menu):
1609     bl_label = "Game"
1610
1611     def draw(self, context):
1612         layout = self.layout
1613
1614         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1615         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1616
1617         layout.separator()
1618
1619         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1620         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1621         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1622
1623         layout.separator()
1624
1625         layout.operator("object.game_property_clear")
1626
1627
1628 # ********** Brush menu **********
1629 class VIEW3D_MT_brush(Menu):
1630     bl_label = "Brush"
1631
1632     def draw(self, context):
1633         layout = self.layout
1634
1635         settings = UnifiedPaintPanel.paint_settings(context)
1636         brush = settings.brush
1637
1638         ups = context.tool_settings.unified_paint_settings
1639         layout.prop(ups, "use_unified_size", text="Unified Size")
1640         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1641         if context.image_paint_object or context.vertex_paint_object:
1642             layout.prop(ups, "use_unified_color", text="Unified Color")
1643         layout.separator()
1644
1645         # brush paint modes
1646         layout.menu("VIEW3D_MT_brush_paint_modes")
1647
1648         # brush tool
1649         if context.sculpt_object:
1650             layout.operator("brush.reset")
1651             layout.prop_menu_enum(brush, "sculpt_tool")
1652         elif context.image_paint_object:
1653             layout.prop_menu_enum(brush, "image_tool")
1654         elif context.vertex_paint_object or context.weight_paint_object:
1655             layout.prop_menu_enum(brush, "vertex_tool")
1656
1657         # skip if no active brush
1658         if not brush:
1659             return
1660
1661         # TODO: still missing a lot of brush options here
1662
1663         # sculpt options
1664         if context.sculpt_object:
1665
1666             sculpt_tool = brush.sculpt_tool
1667
1668             layout.separator()
1669             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1670             layout.separator()
1671
1672             if sculpt_tool != 'GRAB':
1673                 layout.prop_menu_enum(brush, "stroke_method")
1674
1675                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1676                     layout.prop_menu_enum(brush, "direction")
1677
1678                 if sculpt_tool == 'LAYER':
1679                     layout.prop(brush, "use_persistent")
1680                     layout.operator("sculpt.set_persistent_base")
1681
1682
1683 class VIEW3D_MT_brush_paint_modes(Menu):
1684     bl_label = "Enabled Modes"
1685
1686     def draw(self, context):
1687         layout = self.layout
1688
1689         settings = UnifiedPaintPanel.paint_settings(context)
1690         brush = settings.brush
1691
1692         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1693         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1694         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1695         layout.prop(brush, "use_paint_image", text="Texture Paint")
1696
1697 # ********** Vertex paint menu **********
1698
1699
1700 class VIEW3D_MT_paint_vertex(Menu):
1701     bl_label = "Paint"
1702
1703     def draw(self, context):
1704         layout = self.layout
1705
1706         layout.operator("ed.undo")
1707         layout.operator("ed.redo")
1708
1709         layout.separator()
1710
1711         layout.operator("paint.vertex_color_set")
1712         layout.operator("paint.vertex_color_smooth")
1713         layout.operator("paint.vertex_color_dirt")
1714
1715         layout.separator()
1716
1717         layout.operator("paint.vertex_color_invert", text="Invert")
1718         layout.operator("paint.vertex_color_levels", text="Levels")
1719         layout.operator("paint.vertex_color_hsv", text="Hue Saturation Value")
1720         layout.operator("paint.vertex_color_brightness_contrast", text="Bright/Contrast")
1721
1722
1723 class VIEW3D_MT_hook(Menu):
1724     bl_label = "Hooks"
1725
1726     def draw(self, context):
1727         layout = self.layout
1728         layout.operator_context = 'EXEC_AREA'
1729         layout.operator("object.hook_add_newob")
1730         layout.operator("object.hook_add_selob").use_bone = False
1731         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1732
1733         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1734             layout.separator()
1735             layout.operator_menu_enum("object.hook_assign", "modifier")
1736             layout.operator_menu_enum("object.hook_remove", "modifier")
1737             layout.separator()
1738             layout.operator_menu_enum("object.hook_select", "modifier")
1739             layout.operator_menu_enum("object.hook_reset", "modifier")
1740             layout.operator_menu_enum("object.hook_recenter", "modifier")
1741
1742
1743 class VIEW3D_MT_vertex_group(Menu):
1744     bl_label = "Vertex Groups"
1745
1746     def draw(self, context):
1747         layout = self.layout
1748
1749         layout.operator_context = 'EXEC_AREA'
1750         layout.operator("object.vertex_group_assign_new")
1751
1752         ob = context.active_object
1753         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1754             if ob.vertex_groups.active:
1755                 layout.separator()
1756                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1757                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").use_all_groups = False
1758                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
1759                 layout.separator()
1760
1761         if ob.vertex_groups.active:
1762             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1763             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1764             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1765
1766 # ********** Weight paint menu **********
1767
1768
1769 class VIEW3D_MT_paint_weight(Menu):
1770     bl_label = "Weights"
1771
1772     def draw(self, context):
1773         layout = self.layout
1774
1775         layout.operator("ed.undo")
1776         layout.operator("ed.redo")
1777         layout.operator("ed.undo_history")
1778
1779         layout.separator()
1780
1781         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1782         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1783
1784         layout.separator()
1785
1786         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1787         layout.operator("object.vertex_group_normalize", text="Normalize")
1788         layout.operator("object.vertex_group_mirror", text="Mirror")
1789         layout.operator("object.vertex_group_invert", text="Invert")
1790         layout.operator("object.vertex_group_clean", text="Clean")
1791         layout.operator("object.vertex_group_quantize", text="Quantize")
1792         layout.operator("object.vertex_group_levels", text="Levels")
1793         layout.operator("object.vertex_group_smooth", text="Smooth")
1794         props = layout.operator("object.data_transfer", text="Transfer Weights")
1795         props.use_reverse_transfer = True
1796         props.data_type = 'VGROUP_WEIGHTS'
1797         layout.operator("object.vertex_group_limit_total", text="Limit Total")
1798         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1799
1800         layout.separator()
1801
1802         layout.operator("paint.weight_set")
1803
1804 # ********** Sculpt menu **********
1805
1806
1807 class VIEW3D_MT_sculpt(Menu):
1808     bl_label = "Sculpt"
1809
1810     def draw(self, context):
1811         layout = self.layout
1812
1813         toolsettings = context.tool_settings
1814         sculpt = toolsettings.sculpt
1815
1816         layout.operator("ed.undo")
1817         layout.operator("ed.redo")
1818
1819         layout.separator()
1820
1821         layout.prop(sculpt, "use_symmetry_x")
1822         layout.prop(sculpt, "use_symmetry_y")
1823         layout.prop(sculpt, "use_symmetry_z")
1824         layout.separator()
1825         layout.prop(sculpt, "lock_x")
1826         layout.prop(sculpt, "lock_y")
1827         layout.prop(sculpt, "lock_z")
1828
1829         layout.separator()
1830         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1831         layout.prop(sculpt, "show_low_resolution")
1832         layout.prop(sculpt, "show_brush")
1833         layout.prop(sculpt, "use_deform_only")
1834         layout.prop(sculpt, "show_diffuse_color")
1835
1836
1837 class VIEW3D_MT_hide_mask(Menu):
1838     bl_label = "Hide/Mask"
1839
1840     def draw(self, context):
1841         layout = self.layout
1842
1843         props = layout.operator("paint.hide_show", text="Show All")
1844         props.action = 'SHOW'
1845         props.area = 'ALL'
1846
1847         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
1848         props.action = 'HIDE'
1849         props.area = 'INSIDE'
1850
1851         props = layout.operator("paint.hide_show", text="Show Bounding Box")
1852         props.action = 'SHOW'
1853         props.area = 'INSIDE'
1854
1855         props = layout.operator("paint.hide_show", text="Hide Masked")
1856         props.area = 'MASKED'
1857         props.action = 'HIDE'
1858
1859         layout.separator()
1860
1861         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1862         props.mode = 'INVERT'
1863
1864         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1865         props.mode = 'VALUE'
1866         props.value = 1
1867
1868         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1869         props.mode = 'VALUE'
1870         props.value = 0
1871
1872         props = layout.operator("view3d.select_border", text="Box Mask")
1873         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
1874
1875
1876         layout.operator("particle.unify_length")
1877         layout.operator("particle.unify_length")
1878 # ********** Pose Menu **********
1879
1880
1881 class VIEW3D_MT_pose(Menu):
1882     bl_label = "Pose"
1883
1884     def draw(self, context):
1885         layout = self.layout
1886
1887         layout.operator("ed.undo")
1888         layout.operator("ed.redo")
1889         layout.operator("ed.undo_history")
1890
1891         layout.separator()
1892
1893         layout.menu("VIEW3D_MT_transform_armature")
1894
1895         layout.menu("VIEW3D_MT_pose_transform")
1896         layout.menu("VIEW3D_MT_pose_apply")
1897
1898         layout.menu("VIEW3D_MT_snap")
1899
1900         layout.separator()
1901
1902         layout.menu("VIEW3D_MT_object_animation")
1903
1904         layout.separator()
1905
1906         layout.menu("VIEW3D_MT_pose_slide")
1907         layout.menu("VIEW3D_MT_pose_propagate")
1908
1909         layout.separator()
1910
1911         layout.operator("pose.copy")
1912         layout.operator("pose.paste").flipped = False
1913         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1914
1915         layout.separator()
1916
1917         layout.menu("VIEW3D_MT_pose_library")
1918         layout.menu("VIEW3D_MT_pose_motion")
1919         layout.menu("VIEW3D_MT_pose_group")
1920
1921         layout.separator()
1922
1923         layout.menu("VIEW3D_MT_object_parent")
1924         layout.menu("VIEW3D_MT_pose_ik")
1925         layout.menu("VIEW3D_MT_pose_constraints")
1926
1927         layout.separator()
1928
1929         layout.operator_context = 'EXEC_AREA'
1930         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1931         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1932         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1933
1934         layout.operator("pose.flip_names")
1935
1936         layout.operator("pose.quaternions_flip")
1937
1938         layout.separator()
1939
1940         layout.operator_context = 'INVOKE_AREA'
1941         layout.operator("armature.armature_layers", text="Change Armature Layers...")
1942         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1943
1944         layout.separator()
1945
1946         layout.menu("VIEW3D_MT_pose_showhide")
1947         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1948
1949
1950 class VIEW3D_MT_pose_transform(Menu):
1951     bl_label = "Clear Transform"
1952
1953     def draw(self, context):
1954         layout = self.layout
1955
1956         layout.operator("pose.transforms_clear", text="All")
1957
1958         layout.separator()
1959
1960         layout.operator("pose.loc_clear", text="Location")
1961         layout.operator("pose.rot_clear", text="Rotation")
1962         layout.operator("pose.scale_clear", text="Scale")
1963
1964         layout.separator()
1965
1966         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1967
1968
1969 class VIEW3D_MT_pose_slide(Menu):
1970     bl_label = "In-Betweens"
1971
1972     def draw(self, context):
1973         layout = self.layout
1974
1975         layout.operator("pose.push")
1976         layout.operator("pose.relax")
1977         layout.operator("pose.breakdown")
1978
1979
1980 class VIEW3D_MT_pose_propagate(Menu):
1981     bl_label = "Propagate"
1982
1983     def draw(self, context):
1984         layout = self.layout
1985
1986         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1987
1988         layout.separator()
1989
1990         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1991         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1992
1993         layout.separator()
1994
1995         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
1996
1997         layout.separator()
1998
1999         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
2000
2001
2002 class VIEW3D_MT_pose_library(Menu):
2003     bl_label = "Pose Library"
2004
2005     def draw(self, context):
2006         layout = self.layout
2007
2008         layout.operator("poselib.browse_interactive", text="Browse Poses...")
2009
2010         layout.separator()
2011
2012         layout.operator("poselib.pose_add", text="Add Pose...")
2013         layout.operator("poselib.pose_rename", text="Rename Pose...")
2014         layout.operator("poselib.pose_remove", text="Remove Pose...")
2015
2016
2017 class VIEW3D_MT_pose_motion(Menu):
2018     bl_label = "Motion Paths"
2019
2020     def draw(self, context):
2021         layout = self.layout
2022
2023         layout.operator("pose.paths_calculate", text="Calculate")
2024         layout.operator("pose.paths_clear", text="Clear")
2025
2026
2027 class VIEW3D_MT_pose_group(Menu):
2028     bl_label = "Bone Groups"
2029
2030     def draw(self, context):
2031         layout = self.layout
2032
2033         pose = context.active_object.pose
2034
2035         layout.operator_context = 'EXEC_AREA'
2036         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
2037         if pose.bone_groups:
2038             active_group = pose.bone_groups.active_index + 1
2039             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
2040
2041             layout.separator()
2042
2043             # layout.operator_context = 'INVOKE_AREA'
2044             layout.operator("pose.group_unassign")
2045             layout.operator("pose.group_remove")
2046
2047
2048 class VIEW3D_MT_pose_ik(Menu):
2049     bl_label = "Inverse Kinematics"
2050
2051     def draw(self, context):
2052         layout = self.layout
2053
2054         layout.operator("pose.ik_add")
2055         layout.operator("pose.ik_clear")
2056
2057
2058 class VIEW3D_MT_pose_constraints(Menu):
2059     bl_label = "Constraints"
2060
2061     def draw(self, context):
2062         layout = self.layout
2063
2064         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
2065         layout.operator("pose.constraints_copy")
2066         layout.operator("pose.constraints_clear")
2067
2068
2069 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
2070     _operator_name = "pose"
2071
2072
2073 class VIEW3D_MT_pose_apply(Menu):
2074     bl_label = "Apply"
2075
2076     def draw(self, context):
2077         layout = self.layout
2078
2079         layout.operator("pose.armature_apply")
2080         layout.operator("pose.visual_transform_apply")
2081
2082
2083 class VIEW3D_MT_pose_specials(Menu):
2084     bl_label = "Specials"
2085
2086     def draw(self, context):
2087         layout = self.layout
2088
2089         layout.operator("paint.weight_from_bones", text="Assign Automatic from Bones").type = 'AUTOMATIC'
2090         layout.operator("paint.weight_from_bones", text="Assign from Bone Envelopes").type = 'ENVELOPES'
2091
2092         layout.separator()
2093
2094         layout.operator("pose.select_constraint_target")
2095         layout.operator("pose.flip_names")
2096         layout.operator("pose.paths_calculate")
2097         layout.operator("pose.paths_clear")
2098         layout.operator("pose.user_transforms_clear")
2099         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
2100         layout.operator("pose.relax")
2101
2102         layout.separator()
2103
2104         layout.operator_menu_enum("pose.autoside_names", "axis")
2105
2106
2107 class BoneOptions:
2108     def draw(self, context):
2109         layout = self.layout
2110
2111         options = [
2112             "show_wire",
2113             "use_deform",
2114             "use_envelope_multiply",
2115             "use_inherit_rotation",
2116             "use_inherit_scale",
2117         ]
2118
2119         if context.mode == 'EDIT_ARMATURE':
2120             bone_props = bpy.types.EditBone.bl_rna.properties
2121             data_path_iter = "selected_bones"
2122             opt_suffix = ""
2123             options.append("lock")
2124         else:  # pose-mode
2125             bone_props = bpy.types.Bone.bl_rna.properties
2126             data_path_iter = "selected_pose_bones"
2127             opt_suffix = "bone."
2128
2129         for opt in options:
2130             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
2131                                     text_ctxt=i18n_contexts.default)
2132             props.data_path_iter = data_path_iter
2133             props.data_path_item = opt_suffix + opt
2134             props.type = self.type
2135
2136
2137 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
2138     bl_label = "Toggle Bone Options"
2139     type = 'TOGGLE'
2140
2141
2142 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
2143     bl_label = "Enable Bone Options"
2144     type = 'ENABLE'
2145
2146
2147 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
2148     bl_label = "Disable Bone Options"
2149     type = 'DISABLE'
2150
2151 # ********** Edit Menus, suffix from ob.type **********
2152
2153
2154 class VIEW3D_MT_edit_mesh(Menu):
2155     bl_label = "Mesh"
2156
2157     def draw(self, context):
2158         layout = self.layout
2159
2160         toolsettings = context.tool_settings
2161
2162         layout.operator("ed.undo")
2163         layout.operator("ed.redo")
2164         layout.operator("ed.undo_history")
2165
2166         layout.separator()
2167
2168         layout.menu("VIEW3D_MT_transform")
2169         layout.menu("VIEW3D_MT_mirror")
2170         layout.menu("VIEW3D_MT_snap")
2171
2172         layout.separator()
2173
2174         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
2175
2176         layout.separator()
2177
2178         layout.operator("mesh.duplicate_move")
2179         layout.menu("VIEW3D_MT_edit_mesh_extrude")
2180         layout.menu("VIEW3D_MT_edit_mesh_delete")
2181
2182         layout.separator()
2183
2184         layout.menu("VIEW3D_MT_edit_mesh_vertices")
2185         layout.menu("VIEW3D_MT_edit_mesh_edges")
2186         layout.menu("VIEW3D_MT_edit_mesh_faces")
2187         layout.menu("VIEW3D_MT_edit_mesh_normals")
2188         layout.menu("VIEW3D_MT_edit_mesh_clean")
2189
2190         layout.separator()
2191
2192         layout.operator("mesh.symmetrize")
2193         layout.operator("mesh.symmetry_snap")
2194         layout.operator("mesh.bisect")
2195         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
2196
2197         layout.separator()
2198
2199         layout.prop(toolsettings, "use_mesh_automerge")
2200         layout.prop_menu_enum(toolsettings, "proportional_edit")
2201         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2202
2203         layout.separator()
2204
2205         layout.menu("VIEW3D_MT_edit_mesh_showhide")
2206
2207
2208 class VIEW3D_MT_edit_mesh_specials(Menu):
2209     bl_label = "Specials"
2210
2211     def draw(self, context):
2212         layout = self.layout
2213
2214         layout.operator_context = 'INVOKE_REGION_WIN'
2215
2216         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
2217         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
2218
2219         layout.separator()
2220
2221         layout.operator("mesh.merge", text="Merge...")
2222         layout.operator("mesh.remove_doubles")
2223
2224         layout.separator()
2225
2226         layout.operator("mesh.hide", text="Hide").unselected = False
2227         layout.operator("mesh.reveal", text="Reveal")
2228         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
2229
2230         layout.separator()
2231
2232         layout.operator("mesh.flip_normals")
2233         layout.operator("mesh.vertices_smooth", text="Smooth")
2234         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
2235
2236         layout.separator()
2237
2238         layout.operator("mesh.inset")
2239         layout.operator("mesh.bevel", text="Bevel")
2240         layout.operator("mesh.bridge_edge_loops")
2241
2242         layout.separator()
2243
2244         layout.operator("mesh.faces_shade_smooth")
2245         layout.operator("mesh.faces_shade_flat")
2246
2247         layout.separator()
2248
2249         layout.operator("mesh.blend_from_shape")
2250         layout.operator("mesh.shape_propagate_to_all")
2251         layout.operator("mesh.shortest_path_select")
2252         layout.operator("mesh.sort_elements")
2253         layout.operator("mesh.symmetrize")
2254         layout.operator("mesh.symmetry_snap")
2255
2256
2257 class VIEW3D_MT_edit_mesh_select_mode(Menu):
2258     bl_label = "Mesh Select Mode"
2259
2260     def draw(self, context):
2261         layout = self.layout
2262
2263         layout.operator_context = 'INVOKE_REGION_WIN'
2264         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
2265         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
2266         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
2267
2268
2269 class VIEW3D_MT_edit_mesh_extrude(Menu):
2270     bl_label = "Extrude"
2271
2272     _extrude_funcs = {
2273         'VERT': lambda layout:
2274             layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
2275         'EDGE': lambda layout:
2276             layout.operator("mesh.extrude_edges_move", text="Edges Only"),
2277         'FACE': lambda layout:
2278             layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
2279         'REGION': lambda layout:
2280             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
2281         'REGION_VERT_NORMAL': lambda layout:
2282             layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"),
2283     }
2284
2285     @staticmethod
2286     def extrude_options(context):
2287         mesh = context.object.data
2288         select_mode = context.tool_settings.mesh_select_mode
2289
2290         menu = []
2291         if mesh.total_face_sel:
2292             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
2293         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
2294             menu += ['EDGE']
2295         if mesh.total_vert_sel and select_mode[0]:
2296             menu += ['VERT']
2297
2298         # should never get here
2299         return menu
2300
2301     def draw(self, context):
2302         layout = self.layout
2303         layout.operator_context = 'INVOKE_REGION_WIN'
2304
2305         for menu_id in self.extrude_options(context):
2306             self._extrude_funcs[menu_id](layout)
2307
2308
2309 class VIEW3D_MT_edit_mesh_vertices(Menu):
2310     bl_label = "Vertices"
2311
2312     def draw(self, context):
2313         layout = self.layout
2314         layout.operator_context = 'INVOKE_REGION_WIN'
2315
2316         layout.operator("mesh.merge")
2317         layout.operator("mesh.rip_move")
2318         layout.operator("mesh.rip_move_fill")
2319         layout.operator("mesh.rip_edge_move")
2320         layout.operator("mesh.split")
2321         layout.operator_menu_enum("mesh.separate", "type")
2322         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2323         layout.operator("mesh.vert_connect", text="Connect Vertices")
2324         layout.operator("transform.vert_slide", text="Slide")
2325
2326         layout.separator()
2327
2328         layout.operator("mesh.mark_sharp", text="Mark Sharp Edges").use_verts = True
2329         props = layout.operator("mesh.mark_sharp", text="Clear Sharp Edges")
2330         props.use_verts = True
2331         props.clear = True
2332
2333         layout.separator()
2334
2335         layout.operator("mesh.bevel").vertex_only = True
2336         layout.operator("mesh.convex_hull")
2337         layout.operator("mesh.vertices_smooth")
2338         layout.operator("mesh.remove_doubles")
2339
2340         layout.operator("mesh.blend_from_shape")
2341
2342         layout.operator("object.vertex_group_smooth")
2343         layout.operator("mesh.shape_propagate_to_all")
2344
2345         layout.separator()
2346
2347         layout.menu("VIEW3D_MT_vertex_group")
2348         layout.menu("VIEW3D_MT_hook")
2349
2350
2351 class VIEW3D_MT_edit_mesh_edges(Menu):
2352     bl_label = "Edges"
2353
2354     def draw(self, context):
2355         layout = self.layout
2356
2357         with_freestyle = bpy.app.build_options.freestyle
2358
2359         layout.operator_context = 'INVOKE_REGION_WIN'
2360
2361         layout.operator("mesh.edge_face_add")
2362         layout.operator("mesh.subdivide")
2363         layout.operator("mesh.unsubdivide")
2364
2365         layout.separator()
2366
2367         layout.operator("transform.edge_crease")
2368         layout.operator("transform.edge_bevelweight")
2369
2370         layout.separator()
2371
2372         layout.operator("mesh.mark_seam").clear = False
2373         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
2374
2375         layout.separator()
2376
2377         layout.operator("mesh.mark_sharp")
2378         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
2379
2380         layout.separator()
2381
2382         if with_freestyle:
2383             layout.operator("mesh.mark_freestyle_edge").clear = False
2384             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
2385             layout.separator()
2386
2387         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2388         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
2389
2390         layout.separator()
2391
2392         layout.operator("mesh.bevel").vertex_only = False
2393         layout.operator("mesh.edge_split")
2394         layout.operator("mesh.bridge_edge_loops")
2395
2396         layout.separator()
2397
2398         layout.operator("transform.edge_slide")
2399         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
2400         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
2401         layout.operator("mesh.loop_to_region")
2402         layout.operator("mesh.region_to_loop")
2403
2404
2405 class VIEW3D_MT_edit_mesh_faces(Menu):
2406     bl_label = "Faces"
2407     bl_idname = "VIEW3D_MT_edit_mesh_faces"
2408
2409     def draw(self, context):
2410         layout = self.layout
2411
2412         with_freestyle = bpy.app.build_options.freestyle
2413
2414         layout.operator_context = 'INVOKE_REGION_WIN'
2415
2416         layout.operator("mesh.flip_normals")
2417         layout.operator("mesh.edge_face_add")
2418         layout.operator("mesh.fill")
2419         layout.operator("mesh.fill_grid")
2420         layout.operator("mesh.beautify_fill")
2421         layout.operator("mesh.inset")
2422         layout.operator("mesh.bevel").vertex_only = False
2423         layout.operator("mesh.solidify")
2424         layout.operator("mesh.intersect")
2425         layout.operator("mesh.intersect_boolean")
2426         layout.operator("mesh.wireframe")
2427
2428         layout.separator()
2429
2430         if with_freestyle:
2431             layout.operator("mesh.mark_freestyle_face").clear = False
2432             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
2433             layout.separator()
2434
2435         layout.operator("mesh.poke")
2436         props = layout.operator("mesh.quads_convert_to_tris")
2437         props.quad_method = props.ngon_method = 'BEAUTY'
2438         layout.operator("mesh.tris_convert_to_quads")
2439         layout.operator("mesh.face_split_by_edges")
2440
2441         layout.separator()
2442
2443         layout.operator("mesh.faces_shade_smooth")
2444         layout.operator("mesh.faces_shade_flat")
2445
2446         layout.operator("mesh.normals_make_consistent", text="Recalculate Normals").inside = False
2447
2448         layout.separator()
2449
2450         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2451
2452         layout.separator()
2453
2454         layout.operator("mesh.uvs_rotate")
2455         layout.operator("mesh.uvs_reverse")
2456         layout.operator("mesh.colors_rotate")
2457         layout.operator("mesh.colors_reverse")
2458
2459
2460 class VIEW3D_MT_edit_mesh_normals(Menu):
2461     bl_label = "Normals"
2462
2463     def draw(self, context):
2464         layout = self.layout
2465
2466         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
2467         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
2468
2469         layout.separator()
2470
2471         layout.operator("mesh.flip_normals")
2472
2473
2474 class VIEW3D_MT_edit_mesh_clean(Menu):
2475     bl_label = "Clean up"
2476
2477     def draw(self, context):
2478         layout = self.layout
2479
2480         layout.operator("mesh.delete_loose")
2481
2482         layout.separator()
2483
2484         layout.operator("mesh.decimate")
2485         layout.operator("mesh.dissolve_degenerate")
2486         layout.operator("mesh.dissolve_limited")
2487         layout.operator("mesh.face_make_planar")
2488         layout.operator("mesh.vert_connect_nonplanar")
2489         layout.operator("mesh.vert_connect_concave")
2490         layout.operator("mesh.fill_holes")
2491
2492
2493 class VIEW3D_MT_edit_mesh_delete(Menu):
2494     bl_label = "Delete"
2495
2496     def draw(self, context):
2497         layout = self.layout
2498
2499         layout.operator_enum("mesh.delete", "type")
2500
2501         layout.separator()
2502
2503         layout.operator("mesh.dissolve_verts")
2504         layout.operator("mesh.dissolve_edges")
2505         layout.operator("mesh.dissolve_faces")
2506
2507         layout.separator()
2508
2509         layout.operator("mesh.dissolve_limited")
2510
2511         layout.separator()
2512
2513         layout.operator("mesh.edge_collapse")
2514         layout.operator("mesh.delete_edgeloop", text="Edge Loops")
2515
2516
2517 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2518     _operator_name = "mesh"
2519
2520
2521 class VIEW3D_MT_edit_gpencil_delete(Menu):
2522     bl_label = "Delete"
2523
2524     def draw(self, context):
2525         layout = self.layout
2526
2527         layout.operator_enum("gpencil.delete", "type")
2528
2529         layout.separator()
2530
2531         layout.operator("gpencil.dissolve")
2532
2533         layout.separator()
2534
2535         layout.operator("gpencil.active_frames_delete_all")
2536
2537
2538 # Edit Curve
2539 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2540
2541
2542 def draw_curve(self, context):
2543     layout = self.layout
2544
2545     toolsettings = context.tool_settings
2546
2547     layout.menu("VIEW3D_MT_transform")
2548     layout.menu("VIEW3D_MT_mirror")
2549     layout.menu("VIEW3D_MT_snap")
2550
2551     layout.separator()
2552
2553     layout.operator("curve.extrude_move")
2554     layout.operator("curve.spin")
2555     layout.operator("curve.duplicate_move")
2556     layout.operator("curve.split")
2557     layout.operator("curve.separate")
2558     layout.operator("curve.make_segment")
2559     layout.operator("curve.cyclic_toggle")
2560     layout.menu("VIEW3D_MT_edit_curve_delete")
2561
2562     layout.separator()
2563
2564     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2565     layout.menu("VIEW3D_MT_edit_curve_segments")
2566
2567     layout.separator()
2568
2569     layout.prop_menu_enum(toolsettings, "proportional_edit")
2570     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2571
2572     layout.separator()
2573
2574     layout.menu("VIEW3D_MT_edit_curve_showhide")
2575
2576
2577 class VIEW3D_MT_edit_curve(Menu):
2578     bl_label = "Curve"
2579
2580     draw = draw_curve
2581
2582
2583 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2584     bl_label = "Control Points"
2585
2586     def draw(self, context):
2587         layout = self.layout
2588
2589         edit_object = context.edit_object
2590
2591         if edit_object.type == 'CURVE':
2592             layout.operator("transform.tilt")
2593             layout.operator("curve.tilt_clear")
2594
2595             layout.separator()
2596
2597             layout.operator_menu_enum("curve.handle_type_set", "type")
2598             layout.operator("curve.normals_make_consistent")
2599
2600             layout.separator()
2601
2602         layout.menu("VIEW3D_MT_hook")
2603
2604
2605 class VIEW3D_MT_edit_curve_segments(Menu):
2606     bl_label = "Segments"
2607
2608     def draw(self, context):
2609         layout = self.layout
2610
2611         layout.operator("curve.subdivide")
2612         layout.operator("curve.switch_direction")
2613
2614
2615 class VIEW3D_MT_edit_curve_specials(Menu):
2616     bl_label = "Specials"
2617
2618     def draw(self, context):
2619         layout = self.layout
2620
2621         layout.operator("curve.subdivide")
2622         layout.operator("curve.switch_direction")
2623         layout.operator("curve.spline_weight_set")
2624         layout.operator("curve.radius_set")
2625         layout.operator("curve.smooth")
2626         layout.operator("curve.smooth_weight")
2627         layout.operator("curve.smooth_radius")
2628         layout.operator("curve.smooth_tilt")
2629
2630
2631 class VIEW3D_MT_edit_curve_delete(Menu):
2632     bl_label = "Delete"
2633
2634     def draw(self, context):
2635         layout = self.layout
2636
2637         layout.operator_enum("curve.delete", "type")
2638
2639         layout.separator()
2640
2641         layout.operator("curve.dissolve_verts")
2642
2643
2644 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2645     _operator_name = "curve"
2646
2647
2648 class VIEW3D_MT_edit_surface(Menu):
2649     bl_label = "Surface"
2650
2651     draw = draw_curve
2652
2653
2654 class VIEW3D_MT_edit_font(Menu):
2655     bl_label = "Text"
2656
2657     def draw(self, context):
2658         layout = self.layout
2659
2660         layout.menu("VIEW3D_MT_edit_text_chars")
2661
2662         layout.separator()
2663
2664         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2665         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2666         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2667         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2668
2669
2670 class VIEW3D_MT_edit_text_chars(Menu):
2671     bl_label = "Special Characters"
2672
2673     def draw(self, context):
2674         layout = self.layout
2675
2676         layout.operator("font.text_insert", text="Copyright").text = "\u00A9"
2677         layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE"
2678
2679         layout.separator()
2680
2681         layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0"
2682         layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7"
2683         layout.operator("font.text_insert", text="Circle").text = "\u008A"
2684         layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9"
2685         layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2"
2686         layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3"
2687         layout.operator("font.text_insert", text="Double >>").text = "\u00BB"
2688         layout.operator("font.text_insert", text="Double <<").text = "\u00AB"
2689         layout.operator("font.text_insert", text="Promillage").text = "\u2030"
2690
2691         layout.separator()
2692
2693         layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4"
2694         layout.operator("font.text_insert", text="British Pound").text = "\u00A3"
2695         layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5"
2696
2697         layout.separator()
2698
2699         layout.operator("font.text_insert", text="German S").text = "\u00DF"
2700         layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF"
2701         layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1"
2702
2703
2704 class VIEW3D_MT_edit_meta(Menu):
2705     bl_label = "Metaball"
2706
2707     def draw(self, context):
2708         layout = self.layout
2709
2710         toolsettings = context.tool_settings
2711
2712         layout.operator("ed.undo")
2713         layout.operator("ed.redo")
2714         layout.operator("ed.undo_history")
2715
2716         layout.separator()
2717
2718         layout.menu("VIEW3D_MT_transform")
2719         layout.menu("VIEW3D_MT_mirror")
2720         layout.menu("VIEW3D_MT_snap")
2721
2722         layout.separator()
2723
2724         layout.operator("mball.delete_metaelems", text="Delete...")
2725         layout.operator("mball.duplicate_metaelems")
2726
2727         layout.separator()
2728
2729         layout.prop_menu_enum(toolsettings, "proportional_edit")
2730         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2731
2732         layout.separator()
2733
2734         layout.menu("VIEW3D_MT_edit_meta_showhide")
2735
2736
2737 class VIEW3D_MT_edit_meta_showhide(Menu):
2738     bl_label = "Show/Hide"
2739
2740     def draw(self, context):
2741         layout = self.layout
2742
2743         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2744         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2745         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2746
2747
2748 class VIEW3D_MT_edit_lattice(Menu):
2749     bl_label = "Lattice"
2750
2751     def draw(self, context):
2752         layout = self.layout
2753
2754         toolsettings = context.tool_settings
2755
2756         layout.menu("VIEW3D_MT_transform")
2757         layout.menu("VIEW3D_MT_mirror")
2758         layout.menu("VIEW3D_MT_snap")
2759         layout.operator_menu_enum("lattice.flip", "axis")
2760
2761         layout.separator()
2762
2763         layout.operator("lattice.make_regular")
2764
2765         layout.separator()
2766
2767         layout.prop_menu_enum(toolsettings, "proportional_edit")
2768         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2769
2770
2771 class VIEW3D_MT_edit_armature(Menu):
2772     bl_label = "Armature"
2773
2774     def draw(self, context):
2775         layout = self.layout
2776
2777         edit_object = context.edit_object
2778         arm = edit_object.data
2779
2780         layout.menu("VIEW3D_MT_transform_armature")
2781         layout.menu("VIEW3D_MT_mirror")
2782         layout.menu("VIEW3D_MT_snap")
2783         layout.menu("VIEW3D_MT_edit_armature_roll")
2784
2785         layout.separator()
2786
2787         layout.operator("armature.extrude_move")
2788
2789         if arm.use_mirror_x:
2790             layout.operator("armature.extrude_forked")
2791
2792         layout.operator("armature.duplicate_move")
2793         layout.operator("armature.merge")
2794         layout.operator("armature.fill")
2795         layout.operator("armature.delete")
2796         layout.operator("armature.split")
2797         layout.operator("armature.separate")
2798
2799         layout.separator()
2800
2801         layout.operator("armature.subdivide", text="Subdivide")
2802         layout.operator("armature.switch_direction", text="Switch Direction")
2803
2804         layout.separator()
2805
2806         layout.operator_context = 'EXEC_AREA'
2807         layout.operator("armature.symmetrize")
2808         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2809         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2810         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2811         layout.operator("armature.flip_names")
2812
2813         layout.separator()
2814
2815         layout.operator_context = 'INVOKE_DEFAULT'
2816         layout.operator("armature.armature_layers")
2817         layout.operator("armature.bone_layers")
2818
2819         layout.separator()
2820
2821         layout.menu("VIEW3D_MT_edit_armature_parent")
2822
2823         layout.separator()
2824
2825         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2826
2827
2828 class VIEW3D_MT_armature_specials(Menu):
2829     bl_label = "Specials"
2830
2831     def draw(self, context):
2832         layout = self.layout
2833
2834         layout.operator_context = 'INVOKE_REGION_WIN'
2835
2836         layout.operator("armature.subdivide", text="Subdivide")
2837         layout.operator("armature.switch_direction", text="Switch Direction")
2838
2839         layout.separator()
2840
2841         layout.operator_context = 'EXEC_REGION_WIN'
2842         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2843         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2844         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2845         layout.operator("armature.flip_names", text="Flip Names")
2846         layout.operator("armature.symmetrize")
2847
2848
2849 class VIEW3D_MT_edit_armature_parent(Menu):
2850     bl_label = "Parent"
2851
2852     def draw(self, context):
2853         layout = self.layout
2854
2855         layout.operator("armature.parent_set", text="Make")
2856         layout.operator("armature.parent_clear", text="Clear")
2857
2858
2859 class VIEW3D_MT_edit_armature_roll(Menu):
2860     bl_label = "Bone Roll"
2861
2862     def draw(self, context):
2863         layout = self.layout
2864
2865         layout.operator_menu_enum("armature.calculate_roll", "type")
2866
2867         layout.separator()
2868
2869         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2870         layout.operator("armature.roll_clear")
2871
2872
2873 class VIEW3D_MT_edit_armature_delete(Menu):
2874     bl_label = "Delete"
2875
2876     def draw(self, context):
2877         layout = self.layout
2878
2879         layout.operator("armature.delete", text="Delete Bones")
2880
2881         layout.separator()
2882
2883         layout.operator("armature.dissolve", text="Dissolve")
2884
2885
2886 # ********** GPencil Stroke Edit menu **********
2887
2888
2889 class VIEW3D_MT_edit_gpencil(Menu):
2890     bl_label = "GPencil"
2891
2892     def draw(self, context):
2893         toolsettings = context.tool_settings
2894
2895         layout = self.layout
2896
2897         layout.operator("ed.undo")
2898         layout.operator("ed.redo")
2899         layout.operator("ed.undo_history")
2900
2901         layout.separator()
2902
2903         layout.operator("gpencil.brush_paint", text="Sculpt Strokes").wait_for_input = True
2904         layout.prop_menu_enum(toolsettings.gpencil_sculpt, "tool", text="Sculpt Brush")
2905
2906         layout.separator()
2907
2908         layout.menu("VIEW3D_MT_edit_gpencil_transform")
2909         layout.operator("transform.mirror", text="Mirror")
2910         layout.menu("GPENCIL_MT_snap")
2911
2912         layout.separator()
2913
2914         layout.menu("VIEW3D_MT_object_animation")   # NOTE: provides keyingset access...
2915
2916         layout.separator()
2917
2918         layout.menu("VIEW3D_MT_edit_gpencil_delete")
2919         layout.operator("gpencil.duplicate_move", text="Duplicate")
2920
2921         layout.separator()
2922
2923         layout.operator("gpencil.copy", text="Copy")
2924         layout.operator("gpencil.paste", text="Paste")
2925
2926         layout.separator()
2927
2928         layout.prop_menu_enum(toolsettings, "proportional_edit")
2929         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2930
2931         layout.separator()
2932
2933         layout.operator("gpencil.reveal")
2934         layout.operator("gpencil.hide", text="Show Active Layer Only").unselected = True
2935         layout.operator("gpencil.hide", text="Hide Active Layer").unselected = False
2936
2937         layout.separator()
2938
2939         layout.operator_menu_enum("gpencil.move_to_layer", "layer", text="Move to Layer")
2940         layout.operator_menu_enum("gpencil.convert", "type", text="Convert to Geometry...")
2941
2942
2943 class VIEW3D_MT_edit_gpencil_transform(Menu):
2944     bl_label = "Transform"
2945
2946     def draw(self, context):
2947         layout = self.layout
2948
2949         layout.operator("transform.translate")
2950         layout.operator("transform.rotate")
2951         layout.operator("transform.resize", text="Scale")
2952
2953         layout.separator()
2954
2955         layout.operator("transform.bend", text="Bend")
2956         layout.operator("transform.shear", text="Shear")
2957         layout.operator("transform.tosphere", text="To Sphere")
2958         layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN'
2959
2960
2961 # ********** Panel **********
2962
2963
2964 class VIEW3D_PT_grease_pencil(GreasePencilDataPanel, Panel):
2965     bl_space_type = 'VIEW_3D'
2966     bl_region_type = 'UI'
2967
2968     # NOTE: this is just a wrapper around the generic GP Panel
2969
2970
2971 class VIEW3D_PT_view3d_properties(Panel):
2972     bl_space_type = 'VIEW_3D'
2973     bl_region_type = 'UI'
2974     bl_label = "View"
2975
2976     @classmethod
2977     def poll(cls, context):
2978         view = context.space_data
2979         return (view)
2980
2981     def draw(self, context):
2982         layout = self.layout
2983
2984         view = context.space_data
2985
2986         col = layout.column()
2987         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
2988         col.prop(view, "lens")
2989         col.label(text="Lock to Object:")
2990         col.prop(view, "lock_object", text="")
2991         lock_object = view.lock_object
2992         if lock_object:
2993             if lock_object.type == 'ARMATURE':
2994                 col.prop_search(view, "lock_bone", lock_object.data,
2995                                 "edit_bones" if lock_object.mode == 'EDIT'
2996                                 else "bones",
2997                                 text="")
2998         else:
2999             col.prop(view, "lock_cursor", text="Lock to Cursor")
3000
3001         col = layout.column()
3002         col.prop(view, "lock_camera")
3003
3004         col = layout.column(align=True)
3005         col.label(text="Clip:")
3006         col.prop(view, "clip_start", text="Start")
3007         col.prop(view, "clip_end", text="End")
3008
3009         subcol = col.column(align=True)
3010         subcol.enabled = not view.lock_camera_and_layers
3011         subcol.label(text="Local Camera:")
3012         subcol.prop(view, "camera", text="")
3013
3014         col = layout.column(align=True)
3015         col.prop(view, "use_render_border")
3016         col.active = view.region_3d.view_perspective != 'CAMERA'
3017
3018
3019 class VIEW3D_PT_view3d_cursor(Panel):
3020     bl_space_type = 'VIEW_3D'
3021     bl_region_type = 'UI'
3022     bl_label = "3D Cursor"
3023
3024     @classmethod
3025     def poll(cls, context):
3026         view = context.space_data
3027         return (view is not None)
3028
3029     def draw(self, context):
3030         layout = self.layout
3031
3032         view = context.space_data
3033         layout.column().prop(view, "cursor_location", text="Location")
3034
3035
3036 class VIEW3D_PT_view3d_name(Panel):
3037     bl_space_type = 'VIEW_3D'
3038     bl_region_type = 'UI'
3039     bl_label = "Item"
3040
3041     @classmethod
3042     def poll(cls, context):
3043         return (context.space_data and context.active_object)
3044
3045     def draw(self, context):
3046         layout = self.layout
3047
3048         ob = context.active_object
3049         row = layout.row()
3050         row.label(text="", icon='OBJECT_DATA')
3051         row.prop(ob, "name", text="")
3052
3053         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
3054             bone = context.active_bone
3055             if bone:
3056                 row = layout.row()
3057                 row.label(text="", icon='BONE_DATA')
3058                 row.prop(bone, "name", text="")
3059
3060
3061 class VIEW3D_PT_view3d_display(Panel):
3062     bl_space_type = 'VIEW_3D'
3063     bl_region_type = 'UI'
3064     bl_label = "Display"
3065     bl_options = {'DEFAULT_CLOSED'}
3066
3067     @classmethod
3068     def poll(cls, context):
3069         view = context.space_data
3070         return (view)
3071
3072     def draw(self, context):
3073         layout = self.layout
3074
3075         view = context.space_data
3076         scene = context.scene
3077
3078         col = layout.column()
3079         col.prop(view, "show_only_render")
3080         col.prop(view, "show_world")
3081
3082         col = layout.column()
3083         display_all = not view.show_only_render
3084         col.active = display_all
3085         col.prop(view, "show_outline_selected")
3086         col.prop(view, "show_all_objects_origin")
3087         col.prop(view, "show_relationship_lines")
3088
3089         col = layout.column()
3090         col.active = display_all
3091         split = col.split(percentage=0.55)
3092         split.prop(view, "show_floor", text="Grid Floor")
3093
3094         row = split.row(align=True)
3095         row.prop(view, "show_axis_x", text="X", toggle=True)
3096         row.prop(view, "show_axis_y", text="Y", toggle=True)
3097         row.prop(view, "show_axis_z", text="Z", toggle=True)
3098
3099         sub = col.column(align=True)
3100         sub.active = (display_all and view.show_floor)
3101         sub.prop(view, "grid_lines", text="Lines")
3102         sub.prop(view, "grid_scale", text="Scale")
3103         subsub = sub.column(align=True)
3104         subsub.active = scene.unit_settings.system == 'NONE'
3105         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
3106
3107         layout.separator()
3108
3109         layout.operator("screen.region_quadview", text="Toggle Quad View")
3110
3111         if view.region_quadviews:
3112             region = view.region_quadviews[2]
3113             col = layout.column()
3114             col.prop(region, "lock_rotation")
3115             row = col.row()
3116             row.enabled = region.lock_rotation
3117             row.prop(region, "show_sync_view")
3118             row = col.row()
3119             row.enabled = region.lock_rotation and region.show_sync_view
3120             row.prop(region, "use_box_clip")
3121
3122
3123 class VIEW3D_PT_view3d_stereo(Panel):
3124     bl_space_type = 'VIEW_3D'
3125     bl_region_type = 'UI'
3126     bl_label = "Stereoscopy"
3127     bl_options = {'DEFAULT_CLOSED'}
3128
3129     @classmethod
3130     def poll(cls, context):
3131         scene = context.scene
3132
3133         multiview = scene.render.use_multiview
3134         return context.space_data and multiview
3135
3136     def draw(self, context):
3137         layout = self.layout
3138         view = context.space_data
3139
3140         basic_stereo = context.scene.render.views_format == 'STEREO_3D'
3141
3142         col = layout.column()
3143         col.row().prop(view, "stereo_3d_camera", expand=True)
3144
3145         col.label(text="Display:")
3146         row = col.row()
3147         row.active = basic_stereo
3148         row.prop(view, "show_stereo_3d_cameras")
3149         row = col.row()
3150         row.active = basic_stereo
3151         split = row.split()
3152         split.prop(view, "show_stereo_3d_convergence_plane")
3153         split = row.split()
3154         split.prop(view, "stereo_3d_convergence_plane_alpha", text="Alpha")
3155         split.active = view.show_stereo_3d_convergence_plane
3156         row = col.row()
3157         split = row.split()
3158         split.prop(view, "show_stereo_3d_volume")
3159         split = row.split()
3160         split.prop(view, "stereo_3d_volume_alpha", text="Alpha")
3161
3162
3163 class VIEW3D_PT_view3d_shading(Panel):
3164     bl_space_type = 'VIEW_3D'
3165     bl_region_type = 'UI'
3166     bl_label = "Shading"
3167
3168     def draw(self, context):
3169         layout = self.layout
3170
3171         view = context.space_data
3172         scene = context.scene
3173         gs = scene.game_settings
3174         obj = context.object
3175
3176         col = layout.column()
3177
3178         if not scene.render.use_shading_nodes:
3179             col.prop(gs, "material_mode", text="")
3180
3181         if view.viewport_shade == 'SOLID':
3182             col.prop(view, "show_textured_solid")
3183             col.prop(view, "use_matcap")
3184             if view.use_matcap:
3185                 col.template_icon_view(view, "matcap_icon")
3186         if view.viewport_shade == 'TEXTURED' or context.mode == 'PAINT_TEXTURE':
3187             if scene.render.use_shading_nodes or gs.material_mode != 'GLSL':
3188                 col.prop(view, "show_textured_shadeless")
3189
3190         col.prop(view, "show_backface_culling")
3191
3192         if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
3193             if obj and obj.mode == 'EDIT':
3194                 col.prop(view, "show_occlude_wire")
3195
3196         fx_settings = view.fx_settings
3197
3198         if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
3199             sub = col.column()
3200             sub.active = view.region_3d.view_perspective == 'CAMERA'
3201             sub.prop(fx_settings, "use_dof")
3202             col.prop(fx_settings, "use_ssao", text="Ambient Occlusion")
3203             if fx_settings.use_ssao:
3204                 ssao_settings = fx_settings.ssao
3205                 subcol = col.column(align=True)
3206                 subcol.prop(ssao_settings, "factor")
3207                 subcol.prop(ssao_settings, "distance_max")
3208                 subcol.prop(ssao_settings, "attenuation")
3209                 subcol.prop(ssao_settings, "samples")
3210                 subcol.prop(ssao_settings, "color")
3211
3212
3213 class VIEW3D_PT_view3d_motion_tracking(Panel):
3214     bl_space_type = 'VIEW_3D'
3215     bl_region_type = 'UI'
3216     bl_label = "Motion Tracking"
3217     bl_options = {'DEFAULT_CLOSED'}
3218
3219     @classmethod
3220     def poll(cls, context):
3221         view = context.space_data
3222         return (view)
3223
3224     def draw_header(self, context):
3225         view = context.space_data
3226
3227         self.layout.prop(view, "show_reconstruction", text="")
3228
3229     def draw(self, context):
3230         layout = self.layout
3231
3232         view = context.space_data
3233
3234         col = layout.column()
3235         col.active = view.show_reconstruction
3236         col.prop(view, "show_camera_path", text="Camera Path")
3237         col.prop(view, "show_bundle_names", text="3D Marker Names")
3238         col.label(text="Track Type and Size:")
3239         row = col.row(align=True)
3240         row.prop(view, "tracks_draw_type", text="")
3241         row.prop(view, "tracks_draw_size", text="")
3242
3243
3244 class VIEW3D_PT_view3d_meshdisplay(Panel):
3245     bl_space_type = 'VIEW_3D'
3246     bl_region_type = 'UI'
3247     bl_label = "Mesh Display"
3248
3249     @classmethod
3250     def poll(cls, context):
3251         # The active object check is needed because of local-mode
3252         return (context.active_object and (context.mode == 'EDIT_MESH'))
3253
3254     def draw(self, context):
3255         layout = self.layout
3256         with_freestyle = bpy.app.build_options.freestyle
3257
3258         mesh = context.active_object.data
3259         scene = context.scene
3260
3261         split = layout.split()
3262
3263         col = split.column()
3264         col.label(text="Overlays:")
3265         col.prop(mesh, "show_faces", text="Faces")
3266         col.prop(mesh, "show_edges", text="Edges")
3267         col.prop(mesh, "show_edge_crease", text="Creases")
3268         if with_freestyle:
3269             col.prop(mesh, "show_edge_seams", text="Seams")
3270
3271         layout.prop(mesh, "show_weight")
3272
3273         col = split.column()
3274         col.label()
3275         if not with_freestyle:
3276             col.prop(mesh, "show_edge_seams", text="Seams")
3277         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
3278         col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
3279         if with_freestyle:
3280             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
3281             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
3282
3283         col = layout.column()
3284
3285         col.separator()
3286         col.label(text="Normals:")
3287         row = col.row(align=True)
3288
3289         row.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
3290         row.prop(mesh, "show_normal_loop", text="", icon='LOOPSEL')
3291         row.prop(mesh, "show_normal_face", text="", icon='FACESEL')
3292
3293         sub = row.row(align=True)
3294         sub.active = mesh.show_normal_vertex or mesh.show_normal_face or mesh.show_normal_loop
3295         sub.prop(scene.tool_settings, "normal_size", text="Size")
3296
3297         col.separator()
3298         split = layout.split()
3299         col = split.column()
3300         col.label(text="Edge Info:")
3301         col.prop(mesh, "show_extra_edge_length", text="Length")
3302         col.prop(mesh, "show_extra_edge_angle", text="Angle")
3303         col = split.column()
3304         col.label(text="Face Info:")
3305         col.prop(mesh, "show_extra_face_area", text="Area")
3306         col.prop(mesh, "show_extra_face_angle", text="Angle")
3307         if bpy.app.debug:
3308             layout.prop(mesh, "show_extra_indices")
3309
3310
3311 class VIEW3D_PT_view3d_meshstatvis(Panel):
3312     bl_space_type = 'VIEW_3D'
3313     bl_region_type = 'UI'
3314     bl_label = "Mesh Analysis"
3315
3316     @classmethod
3317     def poll(cls, context):
3318         # The active object check is needed because of local-mode
3319         return (context.active_object and (context.mode == 'EDIT_MESH'))
3320
3321     def draw_header(self, context):
3322         mesh = context.active_object.data
3323
3324         self.layout.prop(mesh, "show_statvis", text="")
3325
3326     def draw(self, context):
3327         layout = self.layout
3328
3329         mesh = context.active_object.data
3330         statvis = context.tool_settings.statvis
3331         layout.active = mesh.show_statvis
3332
3333         layout.prop(statvis, "type")
3334         statvis_type = statvis.type
3335         if statvis_type == 'OVERHANG':
3336             row = layout.row(align=True)
3337             row.prop(statvis, "overhang_min", text="")
3338             row.prop(statvis, "overhang_max", text="")
3339             layout.prop(statvis, "overhang_axis", expand=True)
3340         elif statvis_type == 'THICKNESS':
3341             row = layout.row(align=True)
3342             row.prop(statvis, "thickness_min", text="")
3343             row.prop(statvis, "thickness_max", text="")
3344             layout.prop(statvis, "thickness_samples")
3345         elif statvis_type == 'INTERSECT':
3346             pass
3347         elif statvis_type == 'DISTORT':
3348             row = layout.row(align=True)
3349             row.prop(statvis, "distort_min", text="")
3350             row.prop(statvis, "distort_max", text="")
3351         elif statvis_type == 'SHARP':
3352             row = layout.row(align=True)
3353             row.prop(statvis, "sharp_min", text="")
3354             row.prop(statvis, "sharp_max", text="")
3355
3356
3357 class VIEW3D_PT_view3d_curvedisplay(Panel):
3358     bl_space_type = 'VIEW_3D'
3359     bl_region_type = 'UI'
3360     bl_label = "Curve Display"
3361
3362     @classmethod
3363     def poll(cls, context):
3364         editmesh = context.mode == 'EDIT_CURVE'
3365         return (editmesh)
3366
3367     def draw(self, context):
3368         layout = self.layout
3369
3370         curve = context.active_object.data
3371
3372         col = layout.column()
3373         row = col.row()
3374         row.prop(curve, "show_handles", text="Handles")
3375         row.prop(curve, "show_normal_face", text="Normals")
3376         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
3377
3378
3379 class VIEW3D_PT_background_image(Panel):
3380     bl_space_type = 'VIEW_3D'
3381     bl_region_type = 'UI'
3382     bl_label = "Background Images"
3383     bl_options = {'DEFAULT_CLOSED'}
3384
3385     def draw_header(self, context):
3386         view = context.space_data
3387
3388         self.layout.prop(view, "show_background_images", text="")
3389
3390     def draw(self, context):
3391         layout = self.layout
3392
3393         view = context.space_data
3394         use_multiview = context.scene.render.use_multiview
3395
3396         col = layout.column()
3397         col.operator("view3d.background_image_add", text="Add Image")
3398
3399         for i, bg in enumerate(view.background_images):
3400             layout.active = view.show_background_images
3401             box = layout.box()
3402             row = box.row(align=True)
3403             row.prop(bg, "show_expanded", text="", emboss=False)
3404             if bg.source == 'IMAGE' and bg.image:
3405                 row.prop(bg.image, "name", text="", emboss=False)
3406             elif bg.source == 'MOVIE_CLIP' and bg.clip:
3407                 row.prop(bg.clip, "name", text="", emboss=False)
3408             else:
3409                 row.label(text="Not Set")
3410
3411             if bg.show_background_image:
3412                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
3413             else:
3414                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
3415
3416             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
3417
3418             box.prop(bg, "view_axis", text="Axis")
3419
3420             if bg.show_expanded:
3421                 row = box.row()
3422                 row.prop(bg, "source", expand=True)
3423
3424                 has_bg = False
3425                 if bg.source == 'IMAGE':
3426                     row = box.row()
3427                     row.template_ID(bg, "image", open="image.open")
3428                     if bg.image is not None:
3429                         box.template_image(bg, "image", bg.image_user, compact=True)
3430                         has_bg = True
3431
3432                         if use_multiview and bg.view_axis in {'CAMERA', 'ALL'}:
3433                             box.prop(bg.image, "use_multiview")
3434
3435                             column = box.column()
3436                             column.active = bg.image.use_multiview
3437
3438                             column.label(text="Views Format:")
3439                             column.row().prop(bg.image, "views_format", expand=True)
3440
3441                             sub = column.box()
3442                             sub.active = bg.image.views_format == 'STEREO_3D'
3443                             sub.template_image_stereo_3d(bg.image.stereo_3d_format)
3444
3445                 elif bg.source == 'MOVIE_CLIP':
3446                     box.prop(bg, "use_camera_clip")
3447
3448                     column = box.column()
3449                     column.active = not bg.use_camera_clip
3450                     column.template_ID(bg, "clip", open="clip.open")
3451
3452                     if bg.clip:
3453                         column.template_movieclip(bg, "clip", compact=True)
3454
3455                     if bg.use_camera_clip or bg.clip:
3456                         has_bg = True
3457
3458                     column = box.column()
3459                     column.active = has_bg
3460                     column.prop(bg.clip_user, "proxy_render_size", text="")
3461                     column.prop(bg.clip_user, "use_render_undistorted")
3462
3463                 if has_bg:
3464                     col = box.column()
3465                     col.prop(bg, "opacity", slider=True)
3466                     col.row().prop(bg, "draw_depth", expand=True)
3467
3468                     if bg.view_axis in {'CAMERA', 'ALL'}:
3469                         col.row().prop(bg, "frame_method", expand=True)
3470
3471                     box = col.box()
3472                     row = box.row()
3473                     row.prop(bg, "offset_x", text="X")
3474                     row.prop(bg, "offset_y", text="Y")
3475
3476                     row = box.row()
3477                     row.prop(bg, "use_flip_x")
3478                     row.prop(bg, "use_flip_y")
3479
3480                     row = box.row()
3481                     if bg.view_axis != 'CAMERA':
3482                         row.prop(bg, "rotation")
3483                         row.prop(bg, "size")
3484
3485
3486 class VIEW3D_PT_transform_orientations(Panel):
3487     bl_space_type = 'VIEW_3D'
3488     bl_region_type = 'UI'
3489     bl_label = "Transform Orientations"
3490     bl_options = {'DEFAULT_CLOSED'}
3491
3492     @classmethod
3493     def poll(cls, context):
3494         view = context.space_data
3495         return (view)
3496
3497     def draw(self, context):
3498         layout = self.layout
3499
3500         view = context.space_data
3501         orientation = view.current_orientation
3502
3503         row = layout.row(align=True)
3504         row.prop(view, "transform_orientation", text="")
3505         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
3506
3507         if orientation:
3508             row = layout.row(align=True)
3509             row.prop(orientation, "name", text="")
3510             row.operator("transform.delete_orientation", text="", icon='X')
3511
3512
3513 class VIEW3D_PT_etch_a_ton(Panel):
3514     bl_space_type = 'VIEW_3D'
3515     bl_region_type = 'UI'
3516     bl_label = "Skeleton Sketching"
3517     bl_options = {'DEFAULT_CLOSED'}
3518
3519     @classmethod
3520     def poll(cls, context):
3521         scene = context.space_data
3522         ob = context.active_object
3523         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
3524
3525     def draw_header(self, context):
3526         layout = self.layout
3527         toolsettings = context.scene.tool_settings
3528
3529         layout.prop(toolsettings, "use_bone_sketching", text="")
3530
3531     def draw(self, context):
3532         layout = self.layout
3533
3534         toolsettings = context.scene.tool_settings
3535
3536         col = layout.column()
3537
3538         col.prop(toolsettings, "use_etch_quick")
3539         col.prop(toolsettings, "use_etch_overdraw")
3540
3541         col.separator()
3542
3543         col.prop(toolsettings, "etch_convert_mode")
3544
3545         if toolsettings.etch_convert_mode == 'LENGTH':
3546             col.prop(toolsettings, "etch_length_limit")
3547         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
3548             col.prop(toolsettings, "etch_adaptive_limit")
3549         elif toolsettings.etch_convert_mode == 'FIXED':
3550             col.prop(toolsettings, "etch_subdivision_number")
3551         elif toolsett