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