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