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