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