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