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