Propagate Pose Tweaks:
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class VIEW3D_HT_header(bpy.types.Header):
24     bl_space_type = 'VIEW_3D'
25
26     def draw(self, context):
27         layout = self.layout
28
29         view = context.space_data
30         mode_string = context.mode
31         edit_object = context.edit_object
32         obj = context.active_object
33         toolsettings = context.tool_settings
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         # Menus
39         if context.area.show_menus:
40             sub = row.row(align=True)
41
42             sub.menu("VIEW3D_MT_view")
43
44             # Select Menu
45             if mode_string not in {'EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
46                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
47
48             if edit_object:
49                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
50             elif obj:
51                 if mode_string not in {'PAINT_TEXTURE'}:
52                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
53             else:
54                 sub.menu("VIEW3D_MT_object")
55
56         row = layout.row()
57         row.template_header_3D()
58
59         # do in C for now since these buttons cant be both toggle AND exclusive.
60         '''
61         if obj and obj.mode == 'EDIT' and obj.type == 'MESH':
62             row_sub = row.row(align=True)
63             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL')
64             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL')
65             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL')
66         '''
67
68         if obj:
69             # Particle edit
70             if obj.mode == 'PARTICLE_EDIT':
71                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True, toggle=True)
72
73             # Occlude geometry
74             if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
75                 row.prop(view, "use_occlude_geometry", text="")
76
77             # Proportional editing
78             if obj.mode in {'EDIT', 'PARTICLE_EDIT'}:
79                 row = layout.row(align=True)
80                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
81                 if toolsettings.proportional_edit != 'DISABLED':
82                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
83             elif obj.mode == 'OBJECT':
84                 row = layout.row(align=True)
85                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
86                 if toolsettings.use_proportional_edit_objects:
87                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
88
89         # Snap
90         row = layout.row(align=True)
91         row.prop(toolsettings, "use_snap", text="")
92         row.prop(toolsettings, "snap_element", text="", icon_only=True)
93         if toolsettings.snap_element != 'INCREMENT':
94             row.prop(toolsettings, "snap_target", text="")
95             if obj and obj.mode == 'OBJECT':
96                 row.prop(toolsettings, "use_snap_align_rotation", text="")
97         if toolsettings.snap_element == 'VOLUME':
98             row.prop(toolsettings, "use_snap_peel_object", text="")
99         elif toolsettings.snap_element == 'FACE':
100             row.prop(toolsettings, "use_snap_project", text="")
101
102         # OpenGL render
103         row = layout.row(align=True)
104         row.operator("render.opengl", text="", icon='RENDER_STILL')
105         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
106         props.animation = True
107
108         # Pose
109         if obj and obj.mode == 'POSE':
110             row = layout.row(align=True)
111             row.operator("pose.copy", text="", icon='COPYDOWN')
112             row.operator("pose.paste", text="", icon='PASTEDOWN')
113             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
114             props.flipped = 1
115
116
117 # ********** Menu **********
118
119 # ********** Utilities **********
120
121
122 class ShowHideMenu():
123     bl_label = "Show/Hide"
124     _operator_name = ""
125
126     def draw(self, context):
127         layout = self.layout
128
129         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
130         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
131         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
132
133
134 class VIEW3D_MT_transform(bpy.types.Menu):
135     bl_label = "Transform"
136
137     # TODO: get rid of the custom text strings?
138     def draw(self, context):
139         layout = self.layout
140
141         layout.operator("transform.translate", text="Grab/Move")
142         # TODO: sub-menu for grab per axis
143         layout.operator("transform.rotate", text="Rotate")
144         # TODO: sub-menu for rot per axis
145         layout.operator("transform.resize", text="Scale")
146         # TODO: sub-menu for scale per axis
147
148         layout.separator()
149
150         layout.operator("transform.tosphere", text="To Sphere")
151         layout.operator("transform.shear", text="Shear")
152         layout.operator("transform.warp", text="Warp")
153         layout.operator("transform.push_pull", text="Push/Pull")
154
155         layout.separator()
156
157         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
158         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
159
160         layout.separator()
161
162         obj = context.object
163         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}:
164             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
165
166         if context.edit_object and context.edit_object.type == 'ARMATURE':
167             layout.operator("armature.align")
168         else:
169             layout.operator_context = 'EXEC_REGION_WIN'
170             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
171
172         layout.separator()
173
174         layout.operator_context = 'EXEC_AREA'
175
176         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
177         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
178         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
179
180
181 class VIEW3D_MT_mirror(bpy.types.Menu):
182     bl_label = "Mirror"
183
184     def draw(self, context):
185         layout = self.layout
186
187         layout.operator("transform.mirror", text="Interactive Mirror")
188
189         layout.separator()
190
191         layout.operator_context = 'INVOKE_REGION_WIN'
192
193         props = layout.operator("transform.mirror", text="X Global")
194         props.constraint_axis = (True, False, False)
195         props.constraint_orientation = 'GLOBAL'
196         props = layout.operator("transform.mirror", text="Y Global")
197         props.constraint_axis = (False, True, False)
198         props.constraint_orientation = 'GLOBAL'
199         props = layout.operator("transform.mirror", text="Z Global")
200         props.constraint_axis = (False, False, True)
201         props.constraint_orientation = 'GLOBAL'
202
203         if context.edit_object:
204             layout.separator()
205
206             props = layout.operator("transform.mirror", text="X Local")
207             props.constraint_axis = (True, False, False)
208             props.constraint_orientation = 'LOCAL'
209             props = layout.operator("transform.mirror", text="Y Local")
210             props.constraint_axis = (False, True, False)
211             props.constraint_orientation = 'LOCAL'
212             props = layout.operator("transform.mirror", text="Z Local")
213             props.constraint_axis = (False, False, True)
214             props.constraint_orientation = 'LOCAL'
215
216             layout.operator("object.vertex_group_mirror")
217
218
219 class VIEW3D_MT_snap(bpy.types.Menu):
220     bl_label = "Snap"
221
222     def draw(self, context):
223         layout = self.layout
224
225         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
226         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
227
228         layout.separator()
229
230         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
231         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
232         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
233         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
234
235
236 class VIEW3D_MT_uv_map(bpy.types.Menu):
237     bl_label = "UV Mapping"
238
239     def draw(self, context):
240         layout = self.layout
241
242         layout.operator("uv.unwrap")
243         layout.operator("uv.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         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1263
1264
1265 class VIEW3D_MT_pose_library(bpy.types.Menu):
1266     bl_label = "Pose Library"
1267
1268     def draw(self, context):
1269         layout = self.layout
1270
1271         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1272
1273         layout.separator()
1274
1275         layout.operator("poselib.pose_add", text="Add Pose...")
1276         layout.operator("poselib.pose_rename", text="Rename Pose...")
1277         layout.operator("poselib.pose_remove", text="Remove Pose...")
1278
1279
1280 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1281     bl_label = "Motion Paths"
1282
1283     def draw(self, context):
1284         layout = self.layout
1285
1286         layout.operator("pose.paths_calculate", text="Calculate")
1287         layout.operator("pose.paths_clear", text="Clear")
1288
1289
1290 class VIEW3D_MT_pose_group(bpy.types.Menu):
1291     bl_label = "Bone Groups"
1292
1293     def draw(self, context):
1294         layout = self.layout
1295         layout.operator("pose.group_add")
1296         layout.operator("pose.group_remove")
1297
1298         layout.separator()
1299
1300         layout.operator("pose.group_assign")
1301         layout.operator("pose.group_unassign")
1302
1303
1304 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1305     bl_label = "Inverse Kinematics"
1306
1307     def draw(self, context):
1308         layout = self.layout
1309
1310         layout.operator("pose.ik_add")
1311         layout.operator("pose.ik_clear")
1312
1313
1314 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1315     bl_label = "Constraints"
1316
1317     def draw(self, context):
1318         layout = self.layout
1319
1320         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1321         layout.operator("pose.constraints_copy")
1322         layout.operator("pose.constraints_clear")
1323
1324
1325 class VIEW3D_MT_pose_showhide(ShowHideMenu, bpy.types.Menu):
1326     _operator_name = "pose"
1327
1328
1329 class VIEW3D_MT_pose_apply(bpy.types.Menu):
1330     bl_label = "Apply"
1331
1332     def draw(self, context):
1333         layout = self.layout
1334
1335         layout.operator("pose.armature_apply")
1336         layout.operator("pose.visual_transform_apply")
1337
1338
1339 # ********** Edit Menus, suffix from ob.type **********
1340
1341
1342 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1343     bl_label = "Mesh"
1344
1345     def draw(self, context):
1346         layout = self.layout
1347
1348         settings = context.tool_settings
1349
1350         layout.operator("ed.undo")
1351         layout.operator("ed.redo")
1352
1353         layout.separator()
1354
1355         layout.menu("VIEW3D_MT_transform")
1356         layout.menu("VIEW3D_MT_mirror")
1357         layout.menu("VIEW3D_MT_snap")
1358
1359         layout.separator()
1360
1361         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1362
1363         layout.separator()
1364
1365         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1366         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1367         layout.operator("mesh.duplicate_move")
1368         layout.operator("mesh.delete", text="Delete...")
1369
1370         layout.separator()
1371
1372         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1373         layout.menu("VIEW3D_MT_edit_mesh_edges")
1374         layout.menu("VIEW3D_MT_edit_mesh_faces")
1375         layout.menu("VIEW3D_MT_edit_mesh_normals")
1376
1377         layout.separator()
1378
1379         layout.prop(settings, "use_mesh_automerge")
1380         layout.prop_menu_enum(settings, "proportional_edit")
1381         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1382
1383         layout.separator()
1384
1385         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1386
1387
1388 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1389     bl_label = "Specials"
1390
1391     def draw(self, context):
1392         layout = self.layout
1393
1394         layout.operator_context = 'INVOKE_REGION_WIN'
1395
1396         layout.operator("mesh.subdivide", text="Subdivide")
1397         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1398         layout.operator("mesh.merge", text="Merge...")
1399         layout.operator("mesh.remove_doubles")
1400         layout.operator("mesh.hide", text="Hide")
1401         layout.operator("mesh.reveal", text="Reveal")
1402         layout.operator("mesh.select_inverse")
1403         layout.operator("mesh.flip_normals")
1404         layout.operator("mesh.vertices_smooth", text="Smooth")
1405         # layout.operator("mesh.bevel", text="Bevel")
1406         layout.operator("mesh.faces_shade_smooth")
1407         layout.operator("mesh.faces_shade_flat")
1408         layout.operator("mesh.blend_from_shape")
1409         layout.operator("mesh.shape_propagate_to_all")
1410         layout.operator("mesh.select_vertex_path")
1411
1412
1413 class VIEW3D_MT_edit_mesh_select_mode(bpy.types.Menu):
1414     bl_label = "Mesh Select Mode"
1415
1416     def draw(self, context):
1417         layout = self.layout
1418
1419         layout.operator_context = 'INVOKE_REGION_WIN'
1420
1421         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1422         prop.value = "(True, False, False)"
1423         prop.data_path = "tool_settings.mesh_select_mode"
1424
1425         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1426         prop.value = "(False, True, False)"
1427         prop.data_path = "tool_settings.mesh_select_mode"
1428
1429         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1430         prop.value = "(False, False, True)"
1431         prop.data_path = "tool_settings.mesh_select_mode"
1432
1433
1434 class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu):
1435     bl_label = "Extrude"
1436
1437     _extrude_funcs = { \
1438         "VERT": lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1439         "EDGE": lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1440         "FACE": lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1441         "REGION": lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1442     }
1443
1444     @staticmethod
1445     def extrude_options(context):
1446         mesh = context.object.data
1447         select_mode = context.tool_settings.mesh_select_mode
1448
1449         menu = []
1450         if mesh.total_face_sel:
1451             menu += ["REGION", "FACE"]
1452         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1453             menu += ["EDGE"]
1454         if mesh.total_vert_sel and select_mode[0]:
1455             menu += ["VERT"]
1456
1457         # should never get here
1458         return menu
1459
1460     def draw(self, context):
1461         layout = self.layout
1462         layout.operator_context = 'INVOKE_REGION_WIN'
1463
1464         for menu_id in self.extrude_options(context):
1465             self._extrude_funcs[menu_id](layout)
1466
1467
1468 class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator):
1469     "Extrude individual elements and move"
1470     bl_label = "Extrude Individual and Move"
1471     bl_idname = "view3d.edit_mesh_extrude_individual_move"
1472
1473     def execute(self, context):
1474         mesh = context.object.data
1475         select_mode = context.tool_settings.mesh_select_mode
1476
1477         totface = mesh.total_face_sel
1478         totedge = mesh.total_edge_sel
1479         # totvert = mesh.total_vert_sel
1480
1481         if select_mode[2] and totface == 1:
1482             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (False, False, True)})
1483         elif select_mode[2] and totface > 1:
1484             bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
1485         elif select_mode[1] and totedge >= 1:
1486             bpy.ops.mesh.extrude_edges_move('INVOKE_REGION_WIN')
1487         else:
1488             bpy.ops.mesh.extrude_vertices_move('INVOKE_REGION_WIN')
1489
1490         # ignore return from operators above because they are 'RUNNING_MODAL', and cause this one not to be freed. [#24671]
1491         return {'FINISHED'}
1492
1493     def invoke(self, context, event):
1494         return self.execute(context)
1495
1496
1497 class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator):
1498     "Extrude and move along normals"
1499     bl_label = "Extrude and Move on Normals"
1500     bl_idname = "view3d.edit_mesh_extrude_move_normal"
1501
1502     def execute(self, context):
1503         mesh = context.object.data
1504
1505         totface = mesh.total_face_sel
1506         totedge = mesh.total_edge_sel
1507         # totvert = mesh.total_vert_sel
1508
1509         if totface >= 1:
1510             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (False, False, True)})
1511         elif totedge == 1:
1512             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (True, True, False)})
1513         else:
1514             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')
1515
1516         # ignore return from operators above because they are 'RUNNING_MODAL', and cause this one not to be freed. [#24671]
1517         return {'FINISHED'}
1518
1519     def invoke(self, context, event):
1520         return self.execute(context)
1521
1522
1523 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1524     bl_label = "Vertices"
1525
1526     def draw(self, context):
1527         layout = self.layout
1528         layout.operator_context = 'INVOKE_REGION_WIN'
1529
1530         layout.operator("mesh.merge")
1531         layout.operator("mesh.rip_move")
1532         layout.operator("mesh.split")
1533         layout.operator("mesh.separate")
1534
1535         layout.separator()
1536
1537         layout.operator("mesh.vertices_smooth")
1538         layout.operator("mesh.remove_doubles")
1539         layout.operator("mesh.vertices_sort")
1540         layout.operator("mesh.vertices_randomize")
1541
1542         layout.operator("mesh.select_vertex_path")
1543
1544         layout.operator("mesh.blend_from_shape")
1545
1546         layout.operator("object.vertex_group_blend")
1547         layout.operator("mesh.shape_propagate_to_all")
1548
1549         layout.separator()
1550
1551         layout.menu("VIEW3D_MT_vertex_group")
1552         layout.menu("VIEW3D_MT_hook")
1553
1554
1555 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1556     bl_label = "Edges"
1557
1558     def draw(self, context):
1559         layout = self.layout
1560         layout.operator_context = 'INVOKE_REGION_WIN'
1561
1562         layout.operator("mesh.edge_face_add")
1563         layout.operator("mesh.subdivide")
1564
1565         layout.separator()
1566
1567         layout.operator("mesh.mark_seam")
1568         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1569
1570         layout.separator()
1571
1572         layout.operator("mesh.mark_sharp")
1573         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1574
1575         layout.separator()
1576
1577         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1578         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1579
1580         layout.separator()
1581
1582         layout.operator("TRANSFORM_OT_edge_slide")
1583         layout.operator("TRANSFORM_OT_edge_crease")
1584         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1585
1586         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1587         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1588
1589         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1590
1591         layout.operator("mesh.loop_to_region")
1592         layout.operator("mesh.region_to_loop")
1593
1594
1595 class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
1596     bl_label = "Faces"
1597     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1598
1599     def draw(self, context):
1600         layout = self.layout
1601         layout.operator_context = 'INVOKE_REGION_WIN'
1602
1603         layout.operator("mesh.flip_normals")
1604         # layout.operator("mesh.bevel")
1605         # layout.operator("mesh.bevel")
1606         layout.operator("mesh.edge_face_add")
1607         layout.operator("mesh.fill")
1608         layout.operator("mesh.beautify_fill")
1609         layout.operator("mesh.solidify")
1610         layout.operator("mesh.sort_faces")
1611
1612         layout.separator()
1613
1614         layout.operator("mesh.fgon_make")
1615         layout.operator("mesh.fgon_clear")
1616
1617         layout.separator()
1618
1619         layout.operator("mesh.quads_convert_to_tris")
1620         layout.operator("mesh.tris_convert_to_quads")
1621         layout.operator("mesh.edge_flip")
1622
1623         layout.separator()
1624
1625         layout.operator("mesh.faces_shade_smooth")
1626         layout.operator("mesh.faces_shade_flat")
1627
1628         layout.separator()
1629
1630         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1631         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1632
1633         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1634
1635         layout.separator()
1636
1637         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1638         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1639         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1640         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1641
1642
1643 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1644     bl_label = "Normals"
1645
1646     def draw(self, context):
1647         layout = self.layout
1648
1649         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1650         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1651
1652         layout.separator()
1653
1654         layout.operator("mesh.flip_normals")
1655
1656
1657 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, bpy.types.Menu):
1658     _operator_name = "mesh"
1659
1660 # Edit Curve
1661 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1662
1663
1664 def draw_curve(self, context):
1665     layout = self.layout
1666
1667     settings = context.tool_settings
1668
1669     layout.menu("VIEW3D_MT_transform")
1670     layout.menu("VIEW3D_MT_mirror")
1671     layout.menu("VIEW3D_MT_snap")
1672
1673     layout.separator()
1674
1675     layout.operator("curve.extrude")
1676     layout.operator("curve.duplicate")
1677     layout.operator("curve.separate")
1678     layout.operator("curve.make_segment")
1679     layout.operator("curve.cyclic_toggle")
1680     layout.operator("curve.delete", text="Delete...")
1681
1682     layout.separator()
1683
1684     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1685     layout.menu("VIEW3D_MT_edit_curve_segments")
1686
1687     layout.separator()
1688
1689     layout.prop_menu_enum(settings, "proportional_edit")
1690     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1691
1692     layout.separator()
1693
1694     layout.menu("VIEW3D_MT_edit_curve_showhide")
1695
1696
1697 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1698     bl_label = "Curve"
1699
1700     draw = draw_curve
1701
1702
1703 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1704     bl_label = "Control Points"
1705
1706     def draw(self, context):
1707         layout = self.layout
1708
1709         edit_object = context.edit_object
1710
1711         if edit_object.type == 'CURVE':
1712             layout.operator("transform.transform", text="Tilt").mode = 'TILT'
1713             layout.operator("curve.tilt_clear")
1714             layout.operator("curve.separate")
1715
1716             layout.separator()
1717
1718             layout.operator_menu_enum("curve.handle_type_set", "type")
1719
1720             layout.separator()
1721
1722             layout.menu("VIEW3D_MT_hook")
1723
1724
1725 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1726     bl_label = "Segments"
1727
1728     def draw(self, context):
1729         layout = self.layout
1730
1731         layout.operator("curve.subdivide")
1732         layout.operator("curve.switch_direction")
1733
1734
1735 class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
1736     bl_label = "Specials"
1737
1738     def draw(self, context):
1739         layout = self.layout
1740
1741         layout.operator("curve.subdivide")
1742         layout.operator("curve.switch_direction")
1743         layout.operator("curve.spline_weight_set")
1744         layout.operator("curve.radius_set")
1745         layout.operator("curve.smooth")
1746         layout.operator("curve.smooth_radius")
1747
1748
1749 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, bpy.types.Menu):
1750     _operator_name = "curve"
1751
1752
1753 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1754     bl_label = "Surface"
1755
1756     draw = draw_curve
1757
1758
1759 class VIEW3D_MT_edit_font(bpy.types.Menu):
1760     bl_label = "Text"
1761
1762     def draw(self, context):
1763         layout = self.layout
1764
1765         layout.operator("font.file_paste")
1766
1767         layout.separator()
1768
1769         layout.menu("VIEW3D_MT_edit_text_chars")
1770
1771         layout.separator()
1772
1773         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1774         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1775         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1776         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1777
1778
1779 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1780     bl_label = "Special Characters"
1781
1782     def draw(self, context):
1783         layout = self.layout
1784
1785         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1786         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1787
1788         layout.separator()
1789
1790         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1791         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1792         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1793         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1794         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1795         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1796         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1797         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1798         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1799
1800         layout.separator()
1801
1802         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1803         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1804         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1805
1806         layout.separator()
1807
1808         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1809         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1810         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1811
1812
1813 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1814     bl_label = "Metaball"
1815
1816     def draw(self, context):
1817         layout = self.layout
1818
1819         settings = context.tool_settings
1820
1821         layout.operator("ed.undo")
1822         layout.operator("ed.redo")
1823
1824         layout.separator()
1825
1826         layout.menu("VIEW3D_MT_transform")
1827         layout.menu("VIEW3D_MT_mirror")
1828         layout.menu("VIEW3D_MT_snap")
1829
1830         layout.separator()
1831
1832         layout.operator("mball.delete_metaelems", text="Delete...")
1833         layout.operator("mball.duplicate_metaelems")
1834
1835         layout.separator()
1836
1837         layout.prop_menu_enum(settings, "proportional_edit")
1838         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1839
1840         layout.separator()
1841
1842         layout.menu("VIEW3D_MT_edit_meta_showhide")
1843
1844
1845 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1846     bl_label = "Show/Hide"
1847
1848     def draw(self, context):
1849         layout = self.layout
1850
1851         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1852         layout.operator("mball.hide_metaelems", text="Hide Selected")
1853         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1854
1855
1856 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1857     bl_label = "Lattice"
1858
1859     def draw(self, context):
1860         layout = self.layout
1861
1862         settings = context.tool_settings
1863
1864         layout.menu("VIEW3D_MT_transform")
1865         layout.menu("VIEW3D_MT_mirror")
1866         layout.menu("VIEW3D_MT_snap")
1867
1868         layout.separator()
1869
1870         layout.operator("lattice.make_regular")
1871
1872         layout.separator()
1873
1874         layout.prop_menu_enum(settings, "proportional_edit")
1875         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1876
1877
1878 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1879     bl_label = "Armature"
1880
1881     def draw(self, context):
1882         layout = self.layout
1883
1884         edit_object = context.edit_object
1885         arm = edit_object.data
1886
1887         layout.menu("VIEW3D_MT_transform")
1888         layout.menu("VIEW3D_MT_mirror")
1889         layout.menu("VIEW3D_MT_snap")
1890         layout.menu("VIEW3D_MT_edit_armature_roll")
1891
1892         layout.separator()
1893
1894         layout.operator("armature.extrude_move")
1895
1896         if arm.use_mirror_x:
1897             layout.operator("armature.extrude_forked")
1898
1899         layout.operator("armature.duplicate_move")
1900         layout.operator("armature.merge")
1901         layout.operator("armature.fill")
1902         layout.operator("armature.delete")
1903         layout.operator("armature.separate")
1904
1905         layout.separator()
1906
1907         layout.operator("armature.subdivide", text="Subdivide")
1908         layout.operator("armature.switch_direction", text="Switch Direction")
1909
1910         layout.separator()
1911
1912         layout.operator_context = 'EXEC_AREA'
1913         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1914         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1915         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1916         layout.operator("armature.flip_names")
1917
1918         layout.separator()
1919
1920         layout.operator_context = 'INVOKE_DEFAULT'
1921         layout.operator("armature.armature_layers")
1922         layout.operator("armature.bone_layers")
1923
1924         layout.separator()
1925
1926         layout.menu("VIEW3D_MT_edit_armature_parent")
1927
1928         layout.separator()
1929
1930         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1931
1932
1933 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1934     bl_label = "Specials"
1935
1936     def draw(self, context):
1937         layout = self.layout
1938
1939         layout.operator_context = 'INVOKE_REGION_WIN'
1940
1941         layout.operator("armature.subdivide", text="Subdivide")
1942         layout.operator("armature.switch_direction", text="Switch Direction")
1943
1944         layout.separator()
1945
1946         layout.operator_context = 'EXEC_REGION_WIN'
1947         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1948         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1949         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1950         layout.operator("armature.flip_names", text="Flip Names")
1951
1952
1953 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1954     bl_label = "Parent"
1955
1956     def draw(self, context):
1957         layout = self.layout
1958
1959         layout.operator("armature.parent_set", text="Make")
1960         layout.operator("armature.parent_clear", text="Clear")
1961
1962
1963 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1964     bl_label = "Bone Roll"
1965
1966     def draw(self, context):
1967         layout = self.layout
1968
1969         layout.operator_menu_enum("armature.calculate_roll", "type")
1970
1971         layout.separator()
1972
1973         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
1974
1975 # ********** Panel **********
1976
1977
1978 class VIEW3D_PT_view3d_properties(bpy.types.Panel):
1979     bl_space_type = 'VIEW_3D'
1980     bl_region_type = 'UI'
1981     bl_label = "View"
1982
1983     @classmethod
1984     def poll(cls, context):
1985         view = context.space_data
1986         return (view)
1987
1988     def draw(self, context):
1989         layout = self.layout
1990
1991         view = context.space_data
1992
1993         col = layout.column()
1994         col.active = view.region_3d.view_perspective != 'CAMERA'
1995         col.prop(view, "lens")
1996         col.label(text="Lock to Object:")
1997         col.prop(view, "lock_object", text="")
1998         if view.lock_object and view.lock_object.type == 'ARMATURE':
1999             col.prop_search(view, "lock_bone", view.lock_object.data, "bones", text="")
2000         elif not view.lock_object:
2001             col.prop(view, "lock_cursor", text="Lock to Cursor")
2002
2003         col = layout.column(align=True)
2004         col.label(text="Clip:")
2005         col.prop(view, "clip_start", text="Start")
2006         col.prop(view, "clip_end", text="End")
2007
2008         subcol = col.column()
2009         subcol.enabled = not view.lock_camera_and_layers
2010         subcol.label(text="Local Camera:")
2011         subcol.prop(view, "camera", text="")
2012
2013         layout.column().prop(view, "cursor_location")
2014
2015
2016 class VIEW3D_PT_view3d_name(bpy.types.Panel):
2017     bl_space_type = 'VIEW_3D'
2018     bl_region_type = 'UI'
2019     bl_label = "Item"
2020
2021     @classmethod
2022     def poll(cls, context):
2023         return (context.space_data and context.active_object)
2024
2025     def draw(self, context):
2026         layout = self.layout
2027
2028         ob = context.active_object
2029         row = layout.row()
2030         row.label(text="", icon='OBJECT_DATA')
2031         row.prop(ob, "name", text="")
2032
2033         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2034             bone = context.active_bone
2035             if bone:
2036                 row = layout.row()
2037                 row.label(text="", icon='BONE_DATA')
2038                 row.prop(bone, "name", text="")
2039
2040
2041 class VIEW3D_PT_view3d_display(bpy.types.Panel):
2042     bl_space_type = 'VIEW_3D'
2043     bl_region_type = 'UI'
2044     bl_label = "Display"
2045     bl_options = {'DEFAULT_CLOSED'}
2046
2047     @classmethod
2048     def poll(cls, context):
2049         view = context.space_data
2050         return (view)
2051
2052     def draw(self, context):
2053         layout = self.layout
2054
2055         view = context.space_data
2056         scene = context.scene
2057         gs = scene.game_settings
2058         ob = context.object
2059
2060         col = layout.column()
2061         col.prop(view, "show_only_render")
2062
2063         col = layout.column()
2064         display_all = not view.show_only_render
2065         col.active = display_all
2066         col.prop(view, "show_outline_selected")
2067         col.prop(view, "show_all_objects_origin")
2068         col.prop(view, "show_relationship_lines")
2069         if ob and ob.type == 'MESH':
2070             mesh = ob.data
2071             col.prop(mesh, "show_all_edges")
2072
2073         col = layout.column()
2074         col.active = display_all
2075         split = col.split(percentage=0.55)
2076         split.prop(view, "show_floor", text="Grid Floor")
2077
2078         row = split.row(align=True)
2079         row.prop(view, "show_axis_x", text="X", toggle=True)
2080         row.prop(view, "show_axis_y", text="Y", toggle=True)
2081         row.prop(view, "show_axis_z", text="Z", toggle=True)
2082
2083         sub = col.column(align=True)
2084         sub.active = (display_all and view.show_floor)
2085         sub.prop(view, "grid_lines", text="Lines")
2086         sub.prop(view, "grid_scale", text="Scale")
2087         subsub = sub.column(align=True)
2088         subsub.active = scene.unit_settings.system == 'NONE'
2089         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2090
2091         col = layout.column()
2092         col.label(text="Shading:")
2093         col.prop(gs, "material_mode", text="")
2094         col.prop(view, "show_textured_solid")
2095
2096         layout.separator()
2097
2098         region = view.region_quadview
2099
2100         layout.operator("screen.region_quadview", text="Toggle Quad View")
2101
2102         if region:
2103             col = layout.column()
2104             col.prop(region, "lock_rotation")
2105             row = col.row()
2106             row.enabled = region.lock_rotation
2107             row.prop(region, "show_sync_view")
2108             row = col.row()
2109             row.enabled = region.lock_rotation and region.show_sync_view
2110             row.prop(region, "use_box_clip")
2111
2112
2113 class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel):
2114     bl_space_type = 'VIEW_3D'
2115     bl_region_type = 'UI'
2116     bl_label = "Mesh Display"
2117
2118     @classmethod
2119     def poll(cls, context):
2120         # The active object check is needed because of localmode
2121         return (context.active_object and (context.mode == 'EDIT_MESH'))
2122
2123     def draw(self, context):
2124         layout = self.layout
2125
2126         mesh = context.active_object.data
2127
2128         col = layout.column()
2129         col.label(text="Overlays:")
2130         col.prop(mesh, "show_edges", text="Edges")
2131         col.prop(mesh, "show_faces", text="Faces")
2132         col.prop(mesh, "show_edge_crease", text="Creases")
2133         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2134         col.prop(mesh, "show_edge_seams", text="Seams")
2135         col.prop(mesh, "show_edge_sharp", text="Sharp")
2136
2137         col.separator()
2138         col.label(text="Normals:")
2139         col.prop(mesh, "show_normal_face", text="Face")
2140         col.prop(mesh, "show_normal_vertex", text="Vertex")
2141         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2142
2143         col.separator()
2144         col.label(text="Numerics:")
2145         col.prop(mesh, "show_extra_edge_length")
2146         col.prop(mesh, "show_extra_face_angle")
2147         col.prop(mesh, "show_extra_face_area")
2148
2149
2150 class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel):
2151     bl_space_type = 'VIEW_3D'
2152     bl_region_type = 'UI'
2153     bl_label = "Curve Display"
2154
2155     @classmethod
2156     def poll(cls, context):
2157         editmesh = context.mode == 'EDIT_CURVE'
2158         return (editmesh)
2159
2160     def draw(self, context):
2161         layout = self.layout
2162
2163         curve = context.active_object.data
2164
2165         col = layout.column()
2166         col.label(text="Overlays:")
2167         col.prop(curve, "show_handles", text="Handles")
2168         col.prop(curve, "show_normal_face", text="Normals")
2169         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2170
2171
2172 class VIEW3D_PT_background_image(bpy.types.Panel):
2173     bl_space_type = 'VIEW_3D'
2174     bl_region_type = 'UI'
2175     bl_label = "Background Images"
2176     bl_options = {'DEFAULT_CLOSED'}
2177
2178     @classmethod
2179     def poll(cls, context):
2180         view = context.space_data
2181         # bg = context.space_data.background_image
2182         return (view)
2183
2184     def draw_header(self, context):
2185         layout = self.layout
2186         view = context.space_data
2187
2188         layout.prop(view, "show_background_images", text="")
2189
2190     def draw(self, context):
2191         layout = self.layout
2192
2193         view = context.space_data
2194
2195         col = layout.column()
2196         col.operator("view3d.background_image_add", text="Add Image")
2197
2198         for i, bg in enumerate(view.background_images):
2199             layout.active = view.show_background_images
2200             box = layout.box()
2201             row = box.row(align=True)
2202             row.prop(bg, "show_expanded", text="", emboss=False)
2203             if bg.image:
2204                 row.prop(bg.image, "name", text="", emboss=False)
2205             else:
2206                 row.label(text="Not Set")
2207             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2208
2209             box.prop(bg, "view_axis", text="Axis")
2210
2211             if bg.show_expanded:
2212                 row = box.row()
2213                 row.template_ID(bg, "image", open="image.open")
2214                 if (bg.image):
2215                     box.template_image(bg, "image", bg.image_user, compact=True)
2216
2217                     box.prop(bg, "opacity", slider=True)
2218                     if bg.view_axis != 'CAMERA':
2219                         box.prop(bg, "size")
2220                         row = box.row(align=True)
2221                         row.prop(bg, "offset_x", text="X")
2222                         row.prop(bg, "offset_y", text="Y")
2223
2224
2225 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
2226     bl_space_type = 'VIEW_3D'
2227     bl_region_type = 'UI'
2228     bl_label = "Transform Orientations"
2229     bl_options = {'DEFAULT_CLOSED'}
2230
2231     @classmethod
2232     def poll(cls, context):
2233         view = context.space_data
2234         return (view)
2235
2236     def draw(self, context):
2237         layout = self.layout
2238
2239         view = context.space_data
2240
2241         col = layout.column()
2242
2243         col.prop(view, "transform_orientation")
2244         col.operator("transform.create_orientation", text="Create")
2245
2246         orientation = view.current_orientation
2247
2248         if orientation:
2249             col.prop(orientation, "name")
2250             col.operator("transform.delete_orientation", text="Delete")
2251
2252
2253 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
2254     bl_space_type = 'VIEW_3D'
2255     bl_region_type = 'UI'
2256     bl_label = "Skeleton Sketching"
2257     bl_options = {'DEFAULT_CLOSED'}
2258
2259     @classmethod
2260     def poll(cls, context):
2261         scene = context.space_data
2262         ob = context.active_object
2263         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2264
2265     def draw_header(self, context):
2266         layout = self.layout
2267         toolsettings = context.scene.tool_settings
2268
2269         layout.prop(toolsettings, "use_bone_sketching", text="")
2270
2271     def draw(self, context):
2272         layout = self.layout
2273         toolsettings = context.scene.tool_settings
2274
2275         col = layout.column()
2276
2277         col.prop(toolsettings, "use_etch_quick")
2278         col.prop(toolsettings, "use_etch_overdraw")
2279
2280         col.prop(toolsettings, "etch_convert_mode")
2281
2282         if toolsettings.etch_convert_mode == 'LENGTH':
2283             col.prop(toolsettings, "etch_length_limit")
2284         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2285             col.prop(toolsettings, "etch_adaptive_limit")
2286         elif toolsettings.etch_convert_mode == 'FIXED':
2287             col.prop(toolsettings, "etch_subdivision_number")
2288         elif toolsettings.etch_convert_mode == 'RETARGET':
2289             col.prop(toolsettings, "etch_template")
2290             col.prop(toolsettings, "etch_roll_mode")
2291             col.prop(toolsettings, "use_etch_autoname")
2292             col.prop(toolsettings, "etch_number")
2293             col.prop(toolsettings, "etch_side")
2294             col.operator("sketch.convert", text="Convert")
2295
2296
2297 class VIEW3D_PT_context_properties(bpy.types.Panel):
2298     bl_space_type = 'VIEW_3D'
2299     bl_region_type = 'UI'
2300     bl_label = "Properties"
2301     bl_options = {'DEFAULT_CLOSED'}
2302
2303     def _active_context_member(context):
2304         obj = context.object
2305         if obj:
2306             mode = obj.mode
2307             if mode == 'POSE':
2308                 return "active_pose_bone"
2309             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2310                 return "active_bone"
2311             else:
2312                 return "object"
2313
2314         return ""
2315
2316     @classmethod
2317     def poll(cls, context):
2318         member = cls._active_context_member(context)
2319         if member:
2320             context_member = getattr(context, member)
2321             return context_member and context_member.keys()
2322
2323         return False
2324
2325     def draw(self, context):
2326         import rna_prop_ui
2327         member = __class__._active_context_member(context)
2328
2329         if member:
2330             # Draw with no edit button
2331             rna_prop_ui.draw(self.layout, context, member, object, False)
2332
2333
2334 def register():
2335     bpy.utils.register_module(__name__)
2336
2337
2338 def unregister():
2339     bpy.utils.unregister_module(__name__)
2340
2341 if __name__ == "__main__":
2342     register()