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