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