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