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