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