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