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