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