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