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