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