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