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