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