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