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