- UV header sync selection vert/edge/face buttons were displayed as 3 tickboxes
[blender.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class VIEW3D_HT_header(bpy.types.Header):
24     bl_space_type = 'VIEW_3D'
25
26     def draw(self, context):
27         layout = self.layout
28
29         view = context.space_data
30         mode_string = context.mode
31         edit_object = context.edit_object
32         obj = context.active_object
33         toolsettings = context.tool_settings
34
35         row = layout.row()
36         row.template_header()
37
38         sub = row.row(align=True)
39
40         # Menus
41         if context.area.show_menus:
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_WEIGHT', 'PAINT_TEXTURE'):
53                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
54             else:
55                 sub.menu("VIEW3D_MT_object")
56
57         row.template_header_3D()
58
59         if obj and obj.mode == 'EDIT' and obj.type == 'MESH':
60             row_sub = row.row(align=True)
61             row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=0, icon='VERTEXSEL')
62             row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=1, icon='EDGESEL')
63             row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=2, icon='FACESEL')
64
65         # Particle edit
66         if obj and obj.mode == 'PARTICLE_EDIT':
67             row.prop(toolsettings.particle_edit, "selection_mode", text="", expand=True, toggle=True)
68
69         # Occlude geometry
70         if obj and view.viewport_shading in ('SOLID', 'SHADED', 'TEXTURED') and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
71             row.prop(view, "occlude_geometry", text="")
72
73         # Proportional editing
74         if obj and obj.mode in ('OBJECT', 'EDIT', 'PARTICLE_EDIT'):
75             row = layout.row(align=True)
76             row.prop(toolsettings, "proportional_editing", text="", icon_only=True)
77             if toolsettings.proportional_editing != 'DISABLED':
78                 row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True)
79
80         # Snap
81         row = layout.row(align=True)
82         row.prop(toolsettings, "snap", text="")
83         row.prop(toolsettings, "snap_element", text="", icon_only=True)
84         if toolsettings.snap_element != 'INCREMENT':
85             row.prop(toolsettings, "snap_target", text="")
86             if obj and obj.mode == 'OBJECT':
87                 row.prop(toolsettings, "snap_align_rotation", text="")
88         if toolsettings.snap_element == 'VOLUME':
89             row.prop(toolsettings, "snap_peel_object", text="")
90         elif toolsettings.snap_element == 'FACE':
91             row.prop(toolsettings, "snap_project", text="")
92
93         # OpenGL render
94         row = layout.row(align=True)
95         row.operator("screen.opengl_render", text="", icon='RENDER_STILL')
96         props = row.operator("screen.opengl_render", text="", icon='RENDER_ANIMATION')
97         props.animation = True
98
99         # Pose
100         if obj and obj.mode == 'POSE':
101             row = layout.row(align=True)
102             row.operator("pose.copy", text="", icon='COPYDOWN')
103             row.operator("pose.paste", text="", icon='PASTEDOWN')
104             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
105             props.flipped = 1
106
107
108 # ********** Menu **********
109
110 # ********** Utilities **********
111
112
113 class VIEW3D_MT_showhide(bpy.types.Menu):
114     bl_label = "Show/Hide"
115     _operator_name = ""
116
117     def draw(self, context):
118         layout = self.layout
119
120         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
121         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
122         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
123
124
125 class VIEW3D_MT_transform(bpy.types.Menu):
126     bl_label = "Transform"
127
128     # TODO: get rid of the custom text strings?
129     def draw(self, context):
130         layout = self.layout
131
132         layout.operator("transform.translate", text="Grab/Move")
133         # TODO: sub-menu for grab per axis
134         layout.operator("transform.rotate", text="Rotate")
135         # TODO: sub-menu for rot per axis
136         layout.operator("transform.resize", text="Scale")
137         # TODO: sub-menu for scale per axis
138
139         layout.separator()
140
141         layout.operator("transform.tosphere", text="To Sphere")
142         layout.operator("transform.shear", text="Shear")
143         layout.operator("transform.warp", text="Warp")
144         layout.operator("transform.transform", text="Push/Pull").mode = 'PUSHPULL'
145         if context.edit_object and context.edit_object.type == 'ARMATURE':
146             layout.operator("armature.align")
147         else:
148             layout.operator_context = 'EXEC_REGION_WIN'
149             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working
150
151         layout.separator()
152
153         layout.operator_context = 'EXEC_AREA'
154
155         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
156         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
157         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
158
159
160 class VIEW3D_MT_mirror(bpy.types.Menu):
161     bl_label = "Mirror"
162
163     def draw(self, context):
164         layout = self.layout
165
166         layout.operator("transform.mirror", text="Interactive Mirror")
167
168         layout.separator()
169
170         layout.operator_context = 'INVOKE_REGION_WIN'
171
172         props = layout.operator("transform.mirror", text="X Global")
173         props.constraint_axis = (True, False, False)
174         props.constraint_orientation = 'GLOBAL'
175         props = layout.operator("transform.mirror", text="Y Global")
176         props.constraint_axis = (False, True, False)
177         props.constraint_orientation = 'GLOBAL'
178         props = layout.operator("transform.mirror", text="Z Global")
179         props.constraint_axis = (False, False, True)
180         props.constraint_orientation = 'GLOBAL'
181
182         if context.edit_object:
183             layout.separator()
184
185             props = layout.operator("transform.mirror", text="X Local")
186             props.constraint_axis = (True, False, False)
187             props.constraint_orientation = 'LOCAL'
188             props = layout.operator("transform.mirror", text="Y Local")
189             props.constraint_axis = (False, True, False)
190             props.constraint_orientation = 'LOCAL'
191             props = layout.operator("transform.mirror", text="Z Local")
192             props.constraint_axis = (False, False, True)
193             props.constraint_orientation = 'LOCAL'
194
195             layout.operator("object.vertex_group_mirror")
196
197
198 class VIEW3D_MT_snap(bpy.types.Menu):
199     bl_label = "Snap"
200
201     def draw(self, context):
202         layout = self.layout
203
204         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
205         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
206         layout.operator("view3d.snap_selected_to_center", text="Selection to Origin")
207
208         layout.separator()
209
210         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
211         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
212         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
213         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
214
215
216 class VIEW3D_MT_uv_map(bpy.types.Menu):
217     bl_label = "UV Mapping"
218
219     def draw(self, context):
220         layout = self.layout
221
222         layout.operator("uv.unwrap")
223         layout.operator("uv.cube_project")
224         layout.operator("uv.cylinder_project")
225         layout.operator("uv.sphere_project")
226         layout.operator("uv.project_from_view")
227         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
228
229         layout.separator()
230
231         layout.operator("uv.reset")
232
233 # ********** View menus **********
234
235
236 class VIEW3D_MT_view(bpy.types.Menu):
237     bl_label = "View"
238
239     def draw(self, context):
240         layout = self.layout
241
242         layout.operator("view3d.properties", icon='MENU_PANEL')
243         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
244
245         layout.separator()
246
247         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
248         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
249         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
250         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
251
252         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
253
254         layout.separator()
255
256         layout.operator("view3d.view_persportho")
257
258         layout.separator()
259
260         layout.menu("VIEW3D_MT_view_navigation")
261         layout.menu("VIEW3D_MT_view_align")
262
263         layout.separator()
264
265         layout.operator_context = 'INVOKE_REGION_WIN'
266
267         layout.operator("view3d.clip_border", text="Clipping Border...")
268         layout.operator("view3d.zoom_border", text="Zoom Border...")
269
270         layout.separator()
271
272         layout.operator("view3d.layers", text="Show All Layers").nr = 0
273
274         layout.separator()
275
276         layout.operator("view3d.localview", text="View Global/Local")
277         layout.operator("view3d.view_selected")
278         layout.operator("view3d.view_all")
279
280         layout.separator()
281
282         layout.operator("screen.animation_play", text="Playback Animation")
283
284         layout.separator()
285
286         layout.operator("screen.area_dupli")
287         layout.operator("screen.region_quadview")
288         layout.operator("screen.screen_full_area")
289
290
291 class VIEW3D_MT_view_navigation(bpy.types.Menu):
292     bl_label = "Navigation"
293
294     def draw(self, context):
295         layout = self.layout
296
297         layout.operator_enums("view3d.view_orbit", "type")
298
299         layout.separator()
300
301         layout.operator_enums("view3d.view_pan", "type")
302
303         layout.separator()
304
305         layout.operator("view3d.zoom", text="Zoom In").delta = 1
306         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
307
308         layout.separator()
309
310         layout.operator("view3d.fly")
311
312
313 class VIEW3D_MT_view_align(bpy.types.Menu):
314     bl_label = "Align View"
315
316     def draw(self, context):
317         layout = self.layout
318
319         layout.menu("VIEW3D_MT_view_align_selected")
320
321         layout.separator()
322
323         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
324         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
325         layout.operator("view3d.view_selected")
326         layout.operator("view3d.view_center_cursor")
327
328
329 class VIEW3D_MT_view_align_selected(bpy.types.Menu):
330     bl_label = "Align View to Selected"
331
332     def draw(self, context):
333         layout = self.layout
334
335         props = layout.operator("view3d.viewnumpad", text="Top")
336         props.align_active = True
337         props.type = 'TOP'
338         props = layout.operator("view3d.viewnumpad", text="Bottom")
339         props.align_active = True
340         props.type = 'BOTTOM'
341         props = layout.operator("view3d.viewnumpad", text="Front")
342         props.align_active = True
343         props.type = 'FRONT'
344         props = layout.operator("view3d.viewnumpad", text="Back")
345         props.align_active = True
346         props.type = 'BACK'
347         props = layout.operator("view3d.viewnumpad", text="Right")
348         props.align_active = True
349         props.type = 'RIGHT'
350         props = layout.operator("view3d.viewnumpad", text="Left")
351         props.align_active = True
352         props.type = 'LEFT'
353
354
355 class VIEW3D_MT_view_cameras(bpy.types.Menu):
356     bl_label = "Cameras"
357
358     def draw(self, context):
359         layout = self.layout
360
361         layout.operator("view3d.object_as_camera")
362         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
363
364 # ********** Select menus, suffix from context.mode **********
365
366
367 class VIEW3D_MT_select_object(bpy.types.Menu):
368     bl_label = "Select"
369
370     def draw(self, context):
371         layout = self.layout
372
373         layout.operator("view3d.select_border")
374         layout.operator("view3d.select_circle")
375
376         layout.separator()
377
378         layout.operator("object.select_all", text="Select/Deselect All")
379         layout.operator("object.select_inverse", text="Inverse")
380         layout.operator("object.select_random", text="Random")
381         layout.operator("object.select_mirror", text="Mirror")
382         layout.operator("object.select_by_layer", text="Select All by Layer")
383         layout.operator_menu_enum("object.select_by_type", "type", "", text="Select All by Type...")
384
385         layout.separator()
386
387         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
388         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
389         layout.operator("object.select_pattern", text="Select Pattern...")
390
391
392 class VIEW3D_MT_select_pose(bpy.types.Menu):
393     bl_label = "Select"
394
395     def draw(self, context):
396         layout = self.layout
397
398         layout.operator("view3d.select_border")
399
400         layout.separator()
401
402         layout.operator("pose.select_all", text="Select/Deselect All")
403         layout.operator("pose.select_inverse", text="Inverse")
404         layout.operator("pose.select_constraint_target", text="Constraint Target")
405         layout.operator("pose.select_linked", text="Linked")
406
407         layout.separator()
408
409         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
410         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
411
412         layout.separator()
413
414         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
415         props.extend = True
416         props.direction = 'PARENT'
417
418         props = layout.operator("pose.select_hierarchy", text="Extend Child")
419         props.extend = True
420         props.direction = 'CHILD'
421
422         layout.operator("object.select_pattern", text="Select Pattern...")
423
424
425 class VIEW3D_MT_select_particle(bpy.types.Menu):
426     bl_label = "Select"
427
428     def draw(self, context):
429         layout = self.layout
430
431         layout.operator("view3d.select_border")
432
433         layout.separator()
434
435         layout.operator("particle.select_all", text="Select/Deselect All")
436         layout.operator("particle.select_linked")
437         layout.operator("particle.select_inverse")
438
439         layout.separator()
440
441         layout.operator("particle.select_more")
442         layout.operator("particle.select_less")
443
444         layout.separator()
445
446         layout.operator("particle.select_first", text="Roots")
447         layout.operator("particle.select_last", text="Tips")
448
449
450 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
451     bl_label = "Select"
452
453     def draw(self, context):
454         layout = self.layout
455
456         layout.operator("view3d.select_border")
457         layout.operator("view3d.select_circle")
458
459         layout.separator()
460
461         layout.operator("mesh.select_all", text="Select/Deselect All")
462         layout.operator("mesh.select_inverse", text="Inverse")
463
464         layout.separator()
465
466         layout.operator("mesh.select_random", text="Random...")
467         layout.operator("mesh.select_nth", text="Select Nth...")
468         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
469         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
470         layout.operator("mesh.faces_select_interior", text="Interior Faces")
471         layout.operator("mesh.select_axis", text="Side of Active")
472
473         layout.separator()
474
475         layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
476         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
477         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
478         layout.operator("mesh.select_similar", text="Similar...")
479
480         layout.separator()
481
482         layout.operator("mesh.select_less", text="Less")
483         layout.operator("mesh.select_more", text="More")
484
485         layout.separator()
486
487         layout.operator("mesh.select_mirror", text="Mirror")
488
489         layout.operator("mesh.select_linked", text="Linked")
490         layout.operator("mesh.select_vertex_path", text="Vertex Path")
491         layout.operator("mesh.loop_multi_select", text="Edge Loop")
492         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
493
494         layout.separator()
495
496         layout.operator("mesh.loop_to_region")
497         layout.operator("mesh.region_to_loop")
498
499
500 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
501     bl_label = "Select"
502
503     def draw(self, context):
504         layout = self.layout
505
506         layout.operator("view3d.select_border")
507         layout.operator("view3d.select_circle")
508
509         layout.separator()
510
511         layout.operator("curve.select_all", text="Select/Deselect All")
512         layout.operator("curve.select_inverse")
513         layout.operator("curve.select_random")
514         layout.operator("curve.select_every_nth")
515
516         layout.separator()
517
518         layout.operator("curve.de_select_first")
519         layout.operator("curve.de_select_last")
520         layout.operator("curve.select_next")
521         layout.operator("curve.select_previous")
522
523         layout.separator()
524
525         layout.operator("curve.select_more")
526         layout.operator("curve.select_less")
527
528
529 class VIEW3D_MT_select_edit_surface(bpy.types.Menu):
530     bl_label = "Select"
531
532     def draw(self, context):
533         layout = self.layout
534
535         layout.operator("view3d.select_border")
536         layout.operator("view3d.select_circle")
537
538         layout.separator()
539
540         layout.operator("curve.select_all", text="Select/Deselect All")
541         layout.operator("curve.select_inverse")
542         layout.operator("curve.select_random")
543         layout.operator("curve.select_every_nth")
544
545         layout.separator()
546
547         layout.operator("curve.select_row")
548
549         layout.separator()
550
551         layout.operator("curve.select_more")
552         layout.operator("curve.select_less")
553
554
555 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
556     bl_label = "Select"
557
558     def draw(self, context):
559         layout = self.layout
560
561         layout.operator("view3d.select_border")
562
563         layout.separator()
564
565         layout.operator("mball.select_deselect_all_metaelems")
566         layout.operator("mball.select_inverse_metaelems")
567
568         layout.separator()
569
570         layout.operator("mball.select_random_metaelems")
571
572
573 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
574     bl_label = "Select"
575
576     def draw(self, context):
577         layout = self.layout
578
579         layout.operator("view3d.select_border")
580
581         layout.separator()
582
583         layout.operator("lattice.select_all", text="Select/Deselect All")
584
585
586 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
587     bl_label = "Select"
588
589     def draw(self, context):
590         layout = self.layout
591
592         layout.operator("view3d.select_border")
593
594
595         layout.separator()
596
597         layout.operator("armature.select_all", text="Select/Deselect All")
598         layout.operator("armature.select_inverse", text="Inverse")
599
600         layout.separator()
601
602         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
603         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
604
605         layout.separator()
606
607         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
608         props.extend = True
609         props.direction = 'PARENT'
610
611         props = layout.operator("armature.select_hierarchy", text="Extend Child")
612         props.extend = True
613         props.direction = 'CHILD'
614
615         layout.operator("object.select_pattern", text="Select Pattern...")
616
617
618 class VIEW3D_MT_select_face(bpy.types.Menu):# XXX no matching enum
619     bl_label = "Select"
620
621     def draw(self, context):
622         layout = self.layout
623
624         # TODO
625         # see view3d_select_faceselmenu
626
627 # ********** Object menu **********
628
629
630 class VIEW3D_MT_object(bpy.types.Menu):
631     bl_context = "objectmode"
632     bl_label = "Object"
633
634     def draw(self, context):
635         layout = self.layout
636
637         layout.menu("VIEW3D_MT_transform")
638         layout.menu("VIEW3D_MT_mirror")
639         layout.menu("VIEW3D_MT_object_clear")
640         layout.menu("VIEW3D_MT_object_apply")
641         layout.menu("VIEW3D_MT_snap")
642
643         layout.separator()
644
645         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
646         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
647
648         layout.separator()
649
650         layout.operator("object.duplicate_move")
651         layout.operator("object.duplicate_move_linked")
652         layout.operator("object.delete", text="Delete...")
653         layout.operator("object.proxy_make", text="Make Proxy...")
654         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
655         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
656         layout.menu("VIEW3D_MT_make_single_user")
657
658         layout.separator()
659
660         layout.menu("VIEW3D_MT_object_parent")
661         layout.menu("VIEW3D_MT_object_track")
662         layout.menu("VIEW3D_MT_object_group")
663         layout.menu("VIEW3D_MT_object_constraints")
664
665         layout.separator()
666
667         layout.operator("object.join_shapes")
668         layout.operator("object.join_uvs")
669         layout.operator("object.join")
670
671         layout.separator()
672
673         layout.operator("object.move_to_layer", text="Move to Layer...")
674         layout.menu("VIEW3D_MT_object_showhide")
675
676         layout.operator_menu_enum("object.convert", "target")
677
678
679 class VIEW3D_MT_object_clear(bpy.types.Menu):
680     bl_label = "Clear"
681
682     def draw(self, context):
683         layout = self.layout
684
685         layout.operator("object.location_clear", text="Location")
686         layout.operator("object.rotation_clear", text="Rotation")
687         layout.operator("object.scale_clear", text="Scale")
688         layout.operator("object.origin_clear", text="Origin")
689
690
691 class VIEW3D_MT_object_apply(bpy.types.Menu):
692     bl_label = "Apply"
693
694     def draw(self, context):
695         layout = self.layout
696
697         layout.operator("object.location_apply", text="Location")
698         layout.operator("object.rotation_apply", text="Rotation")
699         layout.operator("object.scale_apply", text="Scale")
700         layout.separator()
701         layout.operator("object.visual_transform_apply", text="Visual Transform")
702         layout.operator("object.duplicates_make_real")
703
704
705 class VIEW3D_MT_object_parent(bpy.types.Menu):
706     bl_label = "Parent"
707
708     def draw(self, context):
709         layout = self.layout
710
711         layout.operator("object.parent_set", text="Set")
712         layout.operator("object.parent_clear", text="Clear")
713
714
715 class VIEW3D_MT_object_track(bpy.types.Menu):
716     bl_label = "Track"
717
718     def draw(self, context):
719         layout = self.layout
720
721         layout.operator("object.track_set", text="Set")
722         layout.operator("object.track_clear", text="Clear")
723
724
725 class VIEW3D_MT_object_group(bpy.types.Menu):
726     bl_label = "Group"
727
728     def draw(self, context):
729         layout = self.layout
730
731         layout.operator("group.create")
732         layout.operator("group.objects_remove")
733
734         layout.separator()
735
736         layout.operator("group.objects_add_active")
737         layout.operator("group.objects_remove_active")
738
739
740 class VIEW3D_MT_object_constraints(bpy.types.Menu):
741     bl_label = "Constraints"
742
743     def draw(self, context):
744         layout = self.layout
745
746         layout.operator("object.constraint_add_with_targets")
747         layout.operator("object.constraints_clear")
748
749
750 class VIEW3D_MT_object_showhide(bpy.types.Menu):
751     bl_label = "Show/Hide"
752
753     def draw(self, context):
754         layout = self.layout
755
756         layout.operator("object.restrictview_clear", text="Show Hidden")
757         layout.operator("object.restrictview_set", text="Hide Selected")
758         layout.operator("object.restrictview_set", text="Hide Unselected").unselected = True
759
760
761 class VIEW3D_MT_make_single_user(bpy.types.Menu):
762     bl_label = "Make Single User"
763
764     def draw(self, context):
765         layout = self.layout
766
767         props = layout.operator("object.make_single_user", text="Object")
768         props.object = True
769
770         props = layout.operator("object.make_single_user", text="Object & ObData")
771         props.object = props.obdata = True
772
773         props = layout.operator("object.make_single_user", text="Object & ObData & Materials+Tex")
774         props.object = props.obdata = props.material = props.texture = True
775
776         props = layout.operator("object.make_single_user", text="Materials+Tex")
777         props.material = props.texture = True
778
779         props = layout.operator("object.make_single_user", text="Animation")
780         props.animation = True
781
782
783 class VIEW3D_MT_make_links(bpy.types.Menu):
784     bl_label = "Make Links"
785
786     def draw(self, context):
787         layout = self.layout
788
789         layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...")
790         layout.operator_menu_enum("marker.make_links_scene", "type", text="Markers to Scene...")
791         layout.operator_enums("object.make_links_data", property="type") # inline
792
793
794 # ********** Vertex paint menu **********
795
796
797 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
798     bl_label = "Paint"
799
800     def draw(self, context):
801         layout = self.layout
802
803         layout.operator("paint.vertex_color_set")
804         layout.operator("paint.vertex_color_set", text="Set Selected Vertex Colors").selected = True
805
806
807 class VIEW3D_MT_hook(bpy.types.Menu):
808     bl_label = "Hooks"
809
810     def draw(self, context):
811         layout = self.layout
812         layout.operator_context = 'EXEC_AREA'
813         layout.operator("object.hook_add_newob")
814         layout.operator("object.hook_add_selob")
815
816         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
817             layout.separator()
818             layout.operator_menu_enum("object.hook_assign", "modifier")
819             layout.operator_menu_enum("object.hook_remove", "modifier")
820             layout.separator()
821             layout.operator_menu_enum("object.hook_select", "modifier")
822             layout.operator_menu_enum("object.hook_reset", "modifier")
823             layout.operator_menu_enum("object.hook_recenter", "modifier")
824
825
826 class VIEW3D_MT_vertex_group(bpy.types.Menu):
827     bl_label = "Vertex Groups"
828
829     def draw(self, context):
830         layout = self.layout
831         layout.operator_context = 'EXEC_AREA'
832         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
833
834         ob = context.active_object
835         if ob.mode == 'EDIT':
836             if ob.vertex_groups and ob.active_vertex_group:
837                 layout.separator()
838                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
839                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
840                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
841                 layout.separator()
842
843         if ob.vertex_groups and ob.active_vertex_group:
844             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
845             layout.operator("object.vertex_group_remove", text="Remove Active Group")
846             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
847
848
849 # ********** Sculpt menu **********
850
851
852 class VIEW3D_MT_sculpt(bpy.types.Menu):
853     bl_label = "Sculpt"
854
855     def draw(self, context):
856         layout = self.layout
857
858         sculpt = context.tool_settings.sculpt
859         brush = context.tool_settings.sculpt.brush
860
861         layout.prop(sculpt, "symmetry_x")
862         layout.prop(sculpt, "symmetry_y")
863         layout.prop(sculpt, "symmetry_z")
864         layout.separator()
865         layout.prop(sculpt, "lock_x")
866         layout.prop(sculpt, "lock_y")
867         layout.prop(sculpt, "lock_z")
868         layout.separator()
869         layout.operator_menu_enum("brush.curve_preset", property="shape")
870         layout.separator()
871
872         sculpt_tool = brush.sculpt_tool
873
874         if sculpt_tool != 'GRAB':
875             layout.prop(brush, "use_airbrush")
876
877             if sculpt_tool != 'LAYER':
878                 layout.prop(brush, "use_anchor")
879
880             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
881                 layout.prop(brush, "flip_direction")
882
883             if sculpt_tool == 'LAYER':
884                 layout.prop(brush, "use_persistent")
885                 layout.operator("sculpt.set_persistent_base")
886
887 # ********** Particle menu **********
888
889
890 class VIEW3D_MT_particle(bpy.types.Menu):
891     bl_label = "Particle"
892
893     def draw(self, context):
894         layout = self.layout
895
896         particle_edit = context.tool_settings.particle_edit
897
898         layout.operator("particle.mirror")
899
900         layout.separator()
901
902         layout.operator("particle.remove_doubles")
903         layout.operator("particle.delete")
904
905         if particle_edit.selection_mode == 'POINT':
906             layout.operator("particle.subdivide")
907
908         layout.operator("particle.rekey")
909         layout.operator("particle.weight_set")
910
911         layout.separator()
912
913         layout.menu("VIEW3D_MT_particle_showhide")
914
915
916 class VIEW3D_MT_particle_specials(bpy.types.Menu):
917     bl_label = "Specials"
918
919     def draw(self, context):
920         layout = self.layout
921         particle_edit = context.tool_settings.particle_edit
922
923         layout.operator("particle.rekey")
924
925         layout.separator()
926         if particle_edit.selection_mode == 'POINT':
927             layout.operator("particle.subdivide")
928             layout.operator("particle.select_first")
929             layout.operator("particle.select_last")
930
931         layout.operator("particle.remove_doubles")
932
933
934 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
935     _operator_name = "particle"
936
937 # ********** Pose Menu **********
938
939
940 class VIEW3D_MT_pose(bpy.types.Menu):
941     bl_label = "Pose"
942
943     def draw(self, context):
944         layout = self.layout
945
946         arm = context.active_object.data
947
948         layout.menu("VIEW3D_MT_transform")
949         layout.menu("VIEW3D_MT_snap")
950         if arm.drawtype in ('BBONE', 'ENVELOPE'):
951             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
952
953         layout.menu("VIEW3D_MT_pose_transform")
954
955         layout.separator()
956
957         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
958         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
959
960         layout.separator()
961
962         layout.operator("pose.apply")
963         layout.operator("pose.relax")
964
965         layout.separator()
966
967         layout.operator("pose.copy")
968         layout.operator("pose.paste")
969         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
970
971         layout.separator()
972
973         layout.menu("VIEW3D_MT_pose_pose")
974         layout.menu("VIEW3D_MT_pose_motion")
975         layout.menu("VIEW3D_MT_pose_group")
976
977         layout.separator()
978
979         layout.menu("VIEW3D_MT_pose_ik")
980         layout.menu("VIEW3D_MT_pose_constraints")
981
982         layout.separator()
983
984         layout.operator_context = 'EXEC_AREA'
985         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
986         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
987         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
988
989         layout.operator("pose.flip_names")
990
991         layout.separator()
992
993         layout.operator_context = 'INVOKE_AREA'
994         layout.operator("pose.armature_layers", text="Change Armature Layers...")
995         layout.operator("pose.bone_layers", text="Change Bone Layers...")
996
997         layout.separator()
998
999         layout.menu("VIEW3D_MT_pose_showhide")
1000         layout.operator_menu_enum("pose.flags_set", 'mode', text="Bone Settings")
1001
1002
1003 class VIEW3D_MT_pose_transform(bpy.types.Menu):
1004     bl_label = "Clear Transform"
1005
1006     def draw(self, context):
1007         layout = self.layout
1008
1009         layout.label(text="User Transform")
1010
1011         layout.operator("pose.loc_clear", text="Location")
1012         layout.operator("pose.rot_clear", text="Rotation")
1013         layout.operator("pose.scale_clear", text="Scale")
1014
1015         layout.label(text="Origin")
1016
1017
1018 class VIEW3D_MT_pose_pose(bpy.types.Menu):
1019     bl_label = "Pose Library"
1020
1021     def draw(self, context):
1022         layout = self.layout
1023
1024         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1025
1026         layout.separator()
1027
1028         layout.operator("poselib.pose_add", text="Add Pose...")
1029         layout.operator("poselib.pose_rename", text="Rename Pose...")
1030         layout.operator("poselib.pose_remove", text="Remove Pose...")
1031
1032
1033 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1034     bl_label = "Motion Paths"
1035
1036     def draw(self, context):
1037         layout = self.layout
1038
1039         layout.operator("pose.paths_calculate", text="Calculate")
1040         layout.operator("pose.paths_clear", text="Clear")
1041
1042
1043 class VIEW3D_MT_pose_group(bpy.types.Menu):
1044     bl_label = "Bone Groups"
1045
1046     def draw(self, context):
1047         layout = self.layout
1048         layout.operator("pose.group_add")
1049         layout.operator("pose.group_remove")
1050
1051         layout.separator()
1052
1053         layout.operator("pose.group_assign")
1054         layout.operator("pose.group_unassign")
1055
1056
1057 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1058     bl_label = "Inverse Kinematics"
1059
1060     def draw(self, context):
1061         layout = self.layout
1062
1063         layout.operator("pose.ik_add")
1064         layout.operator("pose.ik_clear")
1065
1066
1067 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1068     bl_label = "Constraints"
1069
1070     def draw(self, context):
1071         layout = self.layout
1072
1073         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1074         layout.operator("pose.constraints_clear")
1075
1076
1077 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
1078     _operator_name = "pose"
1079
1080 # ********** Edit Menus, suffix from ob.type **********
1081
1082
1083 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1084     bl_label = "Mesh"
1085
1086     def draw(self, context):
1087         layout = self.layout
1088
1089         settings = context.tool_settings
1090
1091         layout.operator("ed.undo")
1092         layout.operator("ed.redo")
1093
1094         layout.separator()
1095
1096         layout.menu("VIEW3D_MT_transform")
1097         layout.menu("VIEW3D_MT_mirror")
1098         layout.menu("VIEW3D_MT_snap")
1099
1100         layout.separator()
1101
1102         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1103
1104         layout.separator()
1105
1106         layout.operator("mesh.extrude_move")
1107         layout.operator("mesh.duplicate_move")
1108         layout.operator("mesh.delete", text="Delete...")
1109
1110         layout.separator()
1111
1112         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1113         layout.menu("VIEW3D_MT_edit_mesh_edges")
1114         layout.menu("VIEW3D_MT_edit_mesh_faces")
1115         layout.menu("VIEW3D_MT_edit_mesh_normals")
1116
1117         layout.separator()
1118
1119         layout.prop(settings, "automerge_editing")
1120         layout.prop_menu_enum(settings, "proportional_editing")
1121         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1122
1123         layout.separator()
1124
1125         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1126
1127
1128 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1129     bl_label = "Specials"
1130
1131     def draw(self, context):
1132         layout = self.layout
1133
1134         layout.operator_context = 'INVOKE_REGION_WIN'
1135
1136         layout.operator("mesh.subdivide", text="Subdivide")
1137         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1138         layout.operator("mesh.merge", text="Merge...")
1139         layout.operator("mesh.remove_doubles")
1140         layout.operator("mesh.hide", text="Hide")
1141         layout.operator("mesh.reveal", text="Reveal")
1142         layout.operator("mesh.select_inverse")
1143         layout.operator("mesh.flip_normals")
1144         layout.operator("mesh.vertices_smooth", text="Smooth")
1145         # layout.operator("mesh.bevel", text="Bevel")
1146         layout.operator("mesh.faces_shade_smooth")
1147         layout.operator("mesh.faces_shade_flat")
1148         layout.operator("mesh.blend_from_shape")
1149         layout.operator("mesh.shape_propagate_to_all")
1150         layout.operator("mesh.select_vertex_path")
1151
1152
1153 class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu):
1154     bl_label = "Mesh Select Mode"
1155
1156     def draw(self, context):
1157         layout = self.layout
1158
1159         layout.operator_context = 'INVOKE_REGION_WIN'
1160
1161         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1162         prop.value = "(True, False, False)"
1163         prop.path = "tool_settings.mesh_selection_mode"
1164
1165         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1166         prop.value = "(False, True, False)"
1167         prop.path = "tool_settings.mesh_selection_mode"
1168
1169         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1170         prop.value = "(False, False, True)"
1171         prop.path = "tool_settings.mesh_selection_mode"
1172
1173
1174 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1175     bl_label = "Vertices"
1176
1177     def draw(self, context):
1178         layout = self.layout
1179         layout.operator_context = 'INVOKE_REGION_WIN'
1180
1181         layout.operator("mesh.merge")
1182         layout.operator("mesh.rip")
1183         layout.operator("mesh.split")
1184         layout.operator("mesh.separate")
1185
1186         layout.separator()
1187
1188         layout.operator("mesh.vertices_smooth")
1189         layout.operator("mesh.remove_doubles")
1190
1191         layout.operator("mesh.select_vertex_path")
1192
1193         layout.operator("mesh.blend_from_shape")
1194
1195         layout.operator("object.vertex_group_blend")
1196         layout.operator("mesh.shape_propagate_to_all")
1197
1198         layout.separator()
1199
1200         layout.menu("VIEW3D_MT_vertex_group")
1201         layout.menu("VIEW3D_MT_hook")
1202
1203
1204 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1205     bl_label = "Edges"
1206
1207     def draw(self, context):
1208         layout = self.layout
1209         layout.operator_context = 'INVOKE_REGION_WIN'
1210
1211         layout.operator("mesh.edge_face_add")
1212         layout.operator("mesh.subdivide")
1213
1214         layout.separator()
1215
1216         layout.operator("mesh.mark_seam")
1217         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1218
1219         layout.separator()
1220
1221         layout.operator("mesh.mark_sharp")
1222         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1223
1224         layout.separator()
1225
1226         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1227         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1228
1229         layout.separator()
1230
1231         layout.operator("TRANSFORM_OT_edge_slide")
1232         layout.operator("TRANSFORM_OT_edge_crease")
1233         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1234
1235         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1236         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1237
1238         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1239
1240         layout.operator("mesh.loop_to_region")
1241         layout.operator("mesh.region_to_loop")
1242
1243
1244 class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
1245     bl_label = "Faces"
1246     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1247
1248     def draw(self, context):
1249         layout = self.layout
1250         layout.operator_context = 'INVOKE_REGION_WIN'
1251
1252         # layout.operator("mesh.bevel")
1253         # layout.operator("mesh.bevel")
1254         layout.operator("mesh.edge_face_add")
1255         layout.operator("mesh.fill")
1256         layout.operator("mesh.beauty_fill")
1257         layout.operator("mesh.solidify")
1258
1259         layout.separator()
1260
1261         layout.operator("mesh.quads_convert_to_tris")
1262         layout.operator("mesh.tris_convert_to_quads")
1263         layout.operator("mesh.edge_flip")
1264
1265         layout.separator()
1266
1267         layout.operator("mesh.faces_shade_smooth")
1268         layout.operator("mesh.faces_shade_flat")
1269
1270         layout.separator()
1271
1272         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1273         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1274
1275         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1276
1277         layout.separator()
1278
1279         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1280         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1281         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1282         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1283
1284
1285 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1286     bl_label = "Normals"
1287
1288     def draw(self, context):
1289         layout = self.layout
1290
1291         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1292         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1293
1294         layout.separator()
1295
1296         layout.operator("mesh.flip_normals")
1297
1298
1299 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1300     _operator_name = "mesh"
1301
1302 # Edit Curve
1303 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1304
1305
1306 def draw_curve(self, context):
1307     layout = self.layout
1308
1309     settings = context.tool_settings
1310
1311     layout.menu("VIEW3D_MT_transform")
1312     layout.menu("VIEW3D_MT_mirror")
1313     layout.menu("VIEW3D_MT_snap")
1314
1315     layout.separator()
1316
1317     layout.operator("curve.extrude")
1318     layout.operator("curve.duplicate")
1319     layout.operator("curve.separate")
1320     layout.operator("curve.make_segment")
1321     layout.operator("curve.cyclic_toggle")
1322     layout.operator("curve.delete", text="Delete...")
1323
1324     layout.separator()
1325
1326     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1327     layout.menu("VIEW3D_MT_edit_curve_segments")
1328
1329     layout.separator()
1330
1331     layout.prop_menu_enum(settings, "proportional_editing")
1332     layout.prop_menu_enum(settings, "proportional_editing_falloff")
1333
1334     layout.separator()
1335
1336     layout.menu("VIEW3D_MT_edit_curve_showhide")
1337
1338
1339 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1340     bl_label = "Curve"
1341
1342     draw = draw_curve
1343
1344
1345 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1346     bl_label = "Control Points"
1347
1348     def draw(self, context):
1349         layout = self.layout
1350
1351         edit_object = context.edit_object
1352
1353         if edit_object.type == 'CURVE':
1354             layout.operator("transform.transform").mode = 'TILT'
1355             layout.operator("curve.tilt_clear")
1356             layout.operator("curve.separate")
1357
1358             layout.separator()
1359
1360             layout.operator_menu_enum("curve.handle_type_set", "type")
1361
1362             layout.separator()
1363
1364             layout.menu("VIEW3D_MT_hook")
1365
1366
1367 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1368     bl_label = "Segments"
1369
1370     def draw(self, context):
1371         layout = self.layout
1372
1373         layout.operator("curve.subdivide")
1374         layout.operator("curve.switch_direction")
1375
1376
1377 class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
1378     bl_label = "Specials"
1379
1380     def draw(self, context):
1381         layout = self.layout
1382
1383         layout.operator("curve.subdivide")
1384         layout.operator("curve.switch_direction")
1385         layout.operator("curve.spline_weight_set")
1386         layout.operator("curve.radius_set")
1387         layout.operator("curve.smooth")
1388         layout.operator("curve.smooth_radius")
1389
1390
1391 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1392     _operator_name = "curve"
1393
1394
1395 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1396     bl_label = "Surface"
1397
1398     draw = draw_curve
1399
1400
1401 class VIEW3D_MT_edit_text(bpy.types.Menu):
1402     bl_label = "Text"
1403
1404     def draw(self, context):
1405         layout = self.layout
1406
1407         layout.operator("font.file_paste")
1408
1409         layout.separator()
1410
1411         layout.menu("VIEW3D_MT_edit_text_chars")
1412
1413
1414 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1415     bl_label = "Special Characters"
1416
1417     def draw(self, context):
1418         layout = self.layout
1419
1420         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1421         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1422
1423         layout.separator()
1424
1425         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1426         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1427         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1428         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1429         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1430         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1431         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1432         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1433         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1434
1435         layout.separator()
1436
1437         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1438         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1439         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1440
1441         layout.separator()
1442
1443         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1444         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1445         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1446
1447
1448 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1449     bl_label = "Metaball"
1450
1451     def draw(self, context):
1452         layout = self.layout
1453
1454         settings = context.tool_settings
1455
1456         layout.operator("ed.undo")
1457         layout.operator("ed.redo")
1458
1459         layout.separator()
1460
1461         layout.menu("VIEW3D_MT_transform")
1462         layout.menu("VIEW3D_MT_mirror")
1463         layout.menu("VIEW3D_MT_snap")
1464
1465         layout.separator()
1466
1467         layout.operator("mball.delete_metaelems", text="Delete...")
1468         layout.operator("mball.duplicate_metaelems")
1469
1470         layout.separator()
1471
1472         layout.prop_menu_enum(settings, "proportional_editing")
1473         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1474
1475         layout.separator()
1476
1477         layout.menu("VIEW3D_MT_edit_meta_showhide")
1478
1479
1480 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1481     bl_label = "Show/Hide"
1482
1483     def draw(self, context):
1484         layout = self.layout
1485
1486         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1487         layout.operator("mball.hide_metaelems", text="Hide Selected")
1488         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1489
1490
1491 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1492     bl_label = "Lattice"
1493
1494     def draw(self, context):
1495         layout = self.layout
1496
1497         settings = context.tool_settings
1498
1499         layout.menu("VIEW3D_MT_transform")
1500         layout.menu("VIEW3D_MT_mirror")
1501         layout.menu("VIEW3D_MT_snap")
1502
1503         layout.separator()
1504
1505         layout.operator("lattice.make_regular")
1506
1507         layout.separator()
1508
1509         layout.prop_menu_enum(settings, "proportional_editing")
1510         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1511
1512
1513 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1514     bl_label = "Armature"
1515
1516     def draw(self, context):
1517         layout = self.layout
1518
1519         edit_object = context.edit_object
1520         arm = edit_object.data
1521
1522         layout.menu("VIEW3D_MT_transform")
1523         layout.menu("VIEW3D_MT_mirror")
1524         layout.menu("VIEW3D_MT_snap")
1525         layout.menu("VIEW3D_MT_edit_armature_roll")
1526
1527         if arm.drawtype == 'ENVELOPE':
1528             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1529         else:
1530             layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
1531
1532         layout.separator()
1533
1534         layout.operator("armature.extrude_move")
1535
1536         if arm.x_axis_mirror:
1537             layout.operator("armature.extrude_forked")
1538
1539         layout.operator("armature.duplicate_move")
1540         layout.operator("armature.merge")
1541         layout.operator("armature.fill")
1542         layout.operator("armature.delete")
1543         layout.operator("armature.separate")
1544
1545         layout.separator()
1546
1547         layout.operator("armature.subdivide_multi", text="Subdivide")
1548         layout.operator("armature.switch_direction", text="Switch Direction")
1549
1550         layout.separator()
1551
1552         layout.operator_context = 'EXEC_AREA'
1553         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1554         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1555         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1556         layout.operator("armature.flip_names")
1557
1558         layout.separator()
1559
1560         layout.operator_context = 'INVOKE_DEFAULT'
1561         layout.operator("armature.armature_layers")
1562         layout.operator("armature.bone_layers")
1563
1564         layout.separator()
1565
1566         layout.menu("VIEW3D_MT_edit_armature_parent")
1567
1568         layout.separator()
1569
1570         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1571
1572
1573 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1574     bl_label = "Specials"
1575
1576     def draw(self, context):
1577         layout = self.layout
1578
1579         layout.operator_context = 'INVOKE_REGION_WIN'
1580
1581         layout.operator("armature.subdivide_multi", text="Subdivide")
1582         layout.operator("armature.switch_direction", text="Switch Direction")
1583
1584         layout.separator()
1585
1586         layout.operator_context = 'EXEC_REGION_WIN'
1587         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1588         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1589         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1590         layout.operator("armature.flip_names", text="Flip Names")
1591
1592
1593 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1594     bl_label = "Parent"
1595
1596     def draw(self, context):
1597         layout = self.layout
1598
1599         layout.operator("armature.parent_set", text="Make")
1600         layout.operator("armature.parent_clear", text="Clear")
1601
1602
1603 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1604     bl_label = "Bone Roll"
1605
1606     def draw(self, context):
1607         layout = self.layout
1608
1609         layout.operator("armature.calculate_roll", text="Clear Roll (Z-Axis Up)").type = 'GLOBALUP'
1610         layout.operator("armature.calculate_roll", text="Roll to Cursor").type = 'CURSOR'
1611
1612         layout.separator()
1613
1614         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
1615
1616 # ********** Panel **********
1617
1618
1619 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1620     bl_space_type = 'VIEW_3D'
1621     bl_region_type = 'UI'
1622     bl_label = "View"
1623
1624     def poll(self, context):
1625         view = context.space_data
1626         return (view)
1627
1628     def draw(self, context):
1629         layout = self.layout
1630
1631         view = context.space_data
1632         scene = context.scene
1633
1634         col = layout.column()
1635         col.label(text="Camera:")
1636         col.prop(view, "camera", text="")
1637         col.prop(view, "lens")
1638         col.label(text="Lock to Object:")
1639         col.prop(view, "lock_object", text="")
1640         if view.lock_object and view.lock_object.type == 'ARMATURE':
1641             col.prop_object(view, "lock_bone", view.lock_object.data, "bones", text="")
1642
1643         col = layout.column(align=True)
1644         col.label(text="Clip:")
1645         col.prop(view, "clip_start", text="Start")
1646         col.prop(view, "clip_end", text="End")
1647
1648         layout.column().prop(scene, "cursor_location", text="3D Cursor:")
1649
1650
1651 class VIEW3D_PT_3dview_name(bpy.types.Panel):
1652     bl_space_type = 'VIEW_3D'
1653     bl_region_type = 'UI'
1654     bl_label = "Item"
1655
1656     def poll(self, context):
1657         return (context.space_data and context.active_object)
1658
1659     def draw(self, context):
1660         layout = self.layout
1661
1662         ob = context.active_object
1663         row = layout.row()
1664         row.label(text="", icon='OBJECT_DATA')
1665         row.prop(ob, "name", text="")
1666
1667         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1668             bone = context.active_bone
1669             if bone:
1670                 row = layout.row()
1671                 row.label(text="", icon='BONE_DATA')
1672                 row.prop(bone, "name", text="")
1673
1674
1675 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1676     bl_space_type = 'VIEW_3D'
1677     bl_region_type = 'UI'
1678     bl_label = "Display"
1679     bl_default_closed = True
1680
1681     def poll(self, context):
1682         view = context.space_data
1683         return (view)
1684
1685     def draw(self, context):
1686         layout = self.layout
1687
1688         view = context.space_data
1689         gs = context.scene.game_data
1690         ob = context.object
1691
1692         col = layout.column()
1693         col.prop(view, "display_x_axis", text="X Axis")
1694         col.prop(view, "display_y_axis", text="Y Axis")
1695         col.prop(view, "display_z_axis", text="Z Axis")
1696         col.prop(view, "outline_selected")
1697         col.prop(view, "all_object_origins")
1698         col.prop(view, "relationship_lines")
1699         if ob and ob.type == 'MESH':
1700             mesh = ob.data
1701             col.prop(mesh, "all_edges")
1702
1703         col = layout.column()
1704         col.prop(view, "display_floor", text="Grid Floor")
1705         sub = col.column(align=True)
1706         sub.active = view.display_floor
1707         sub.prop(view, "grid_lines", text="Lines")
1708         sub.prop(view, "grid_spacing", text="Spacing")
1709         sub.prop(view, "grid_subdivisions", text="Subdivisions")
1710
1711         col = layout.column()
1712         col.label(text="Shading:")
1713         col.prop(gs, "material_mode", text="")
1714         col.prop(view, "textured_solid")
1715
1716 # XXX - the Quad View options don't work yet
1717 #               layout.separator()
1718 #
1719 #               layout.operator("screen.region_foursplit", text="Toggle Quad View")
1720 #               col = layout.column()
1721 #               col.prop(view, "lock_rotation")
1722 #               col.prop(view, "box_preview")
1723 #               col.prop(view, "box_clip")
1724
1725
1726 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1727     bl_space_type = 'VIEW_3D'
1728     bl_region_type = 'UI'
1729     bl_label = "Mesh Display"
1730
1731     def poll(self, context):
1732         # The active object check is needed because of localmode
1733         return (context.active_object and (context.mode == 'EDIT_MESH'))
1734
1735     def draw(self, context):
1736         layout = self.layout
1737
1738         mesh = context.active_object.data
1739
1740         col = layout.column()
1741         col.label(text="Overlays:")
1742         col.prop(mesh, "draw_edges", text="Edges")
1743         col.prop(mesh, "draw_faces", text="Faces")
1744         col.prop(mesh, "draw_creases", text="Creases")
1745         col.prop(mesh, "draw_bevel_weights", text="Bevel Weights")
1746         col.prop(mesh, "draw_seams", text="Seams")
1747         col.prop(mesh, "draw_sharp", text="Sharp")
1748
1749         col.separator()
1750         col.label(text="Normals:")
1751         col.prop(mesh, "draw_normals", text="Face")
1752         col.prop(mesh, "draw_vertex_normals", text="Vertex")
1753         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1754
1755         col.separator()
1756         col.label(text="Numerics:")
1757         col.prop(mesh, "draw_edge_lenght")
1758         col.prop(mesh, "draw_edge_angle")
1759         col.prop(mesh, "draw_face_area")
1760
1761
1762 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1763     bl_space_type = 'VIEW_3D'
1764     bl_region_type = 'UI'
1765     bl_label = "Curve Display"
1766
1767     def poll(self, context):
1768         editmesh = context.mode == 'EDIT_CURVE'
1769         return (editmesh)
1770
1771     def draw(self, context):
1772         layout = self.layout
1773
1774         curve = context.active_object.data
1775
1776         col = layout.column()
1777         col.label(text="Overlays:")
1778         col.prop(curve, "draw_handles", text="Handles")
1779         col.prop(curve, "draw_normals", text="Normals")
1780         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1781
1782
1783 class VIEW3D_PT_background_image(bpy.types.Panel):
1784     bl_space_type = 'VIEW_3D'
1785     bl_region_type = 'UI'
1786     bl_label = "Background Image"
1787     bl_default_closed = True
1788
1789     def poll(self, context):
1790         view = context.space_data
1791         # bg = context.space_data.background_image
1792         return (view)
1793
1794     def draw_header(self, context):
1795         layout = self.layout
1796         view = context.space_data
1797
1798         layout.prop(view, "display_background_image", text="")
1799
1800     def draw(self, context):
1801         layout = self.layout
1802
1803         view = context.space_data
1804         bg = view.background_image
1805
1806         if bg:
1807             layout.active = view.display_background_image
1808             box = layout.box()
1809             if (bg.image):
1810                 box.template_ID(bg, "image", open="image.open")
1811                 box.template_image(bg, "image", bg.image_user, compact=True)
1812             else:
1813                 box.template_ID(bg, "image", open="image.open")
1814             
1815             col = layout.column()
1816             col.label(text="Display Settings")
1817             
1818             col = layout.column()
1819             col.prop(bg, "size")
1820             col.prop(bg, "transparency", slider=True)
1821
1822             col = layout.column()
1823             col.label(text="Offset")
1824             col.prop(bg, "offset_x", text="X")
1825             col.prop(bg, "offset_y", text="Y")
1826
1827 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1828     bl_space_type = 'VIEW_3D'
1829     bl_region_type = 'UI'
1830     bl_label = "Transform Orientations"
1831     bl_default_closed = True
1832
1833     def poll(self, context):
1834         view = context.space_data
1835         return (view)
1836
1837     def draw(self, context):
1838         layout = self.layout
1839
1840         view = context.space_data
1841
1842         col = layout.column()
1843
1844         col.prop(view, "transform_orientation")
1845         col.operator("transform.create_orientation", text="Create")
1846
1847         orientation = view.current_orientation
1848
1849         if orientation:
1850             col.prop(orientation, "name")
1851             col.operator("transform.delete_orientation", text="Delete")
1852
1853
1854 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1855     bl_space_type = 'VIEW_3D'
1856     bl_region_type = 'UI'
1857     bl_label = "Skeleton Sketching"
1858     bl_default_closed = True
1859
1860     def poll(self, context):
1861         scene = context.space_data
1862         ob = context.active_object
1863         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1864
1865     def draw_header(self, context):
1866         layout = self.layout
1867         toolsettings = context.scene.tool_settings
1868
1869         layout.prop(toolsettings, "bone_sketching", text="")
1870
1871     def draw(self, context):
1872         layout = self.layout
1873         toolsettings = context.scene.tool_settings
1874
1875         col = layout.column()
1876
1877         col.prop(toolsettings, "etch_quick")
1878         col.prop(toolsettings, "etch_overdraw")
1879
1880         col.prop(toolsettings, "etch_convert_mode")
1881
1882         if toolsettings.etch_convert_mode == 'LENGTH':
1883             col.prop(toolsettings, "etch_length_limit")
1884         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
1885             col.prop(toolsettings, "etch_adaptive_limit")
1886         elif toolsettings.etch_convert_mode == 'FIXED':
1887             col.prop(toolsettings, "etch_subdivision_number")
1888         elif toolsettings.etch_convert_mode == 'RETARGET':
1889             col.prop(toolsettings, "etch_template")
1890             col.prop(toolsettings, "etch_roll_mode")
1891             col.prop(toolsettings, "etch_autoname")
1892             col.prop(toolsettings, "etch_number")
1893             col.prop(toolsettings, "etch_side")
1894
1895
1896 class VIEW3D_PT_context_properties(bpy.types.Panel):
1897     bl_space_type = 'VIEW_3D'
1898     bl_region_type = 'UI'
1899     bl_label = "Properties"
1900     bl_default_closed = True
1901
1902     def _active_context_member(self, context):
1903         obj = context.object
1904         if obj:
1905             mode = obj.mode
1906             if mode == 'POSE':
1907                 return "active_pose_bone"
1908             elif mode == 'EDIT' and obj.type == 'ARMATURE':
1909                 return "active_bone"
1910             else:
1911                 return "object"
1912
1913         return ""
1914
1915     def poll(self, context):
1916         member = self._active_context_member(context)
1917         if member:
1918             context_member = getattr(context, member)
1919             return context_member and context_member.keys()
1920
1921         return False
1922
1923     def draw(self, context):
1924         import rna_prop_ui
1925         # reload(rna_prop_ui)
1926         member = self._active_context_member(context)
1927
1928         if member:
1929             # Draw with no edit button
1930             rna_prop_ui.draw(self.layout, context, member, False)
1931
1932
1933 bpy.types.register(VIEW3D_HT_header) # Header
1934
1935 bpy.types.register(VIEW3D_MT_view) #View Menus
1936 bpy.types.register(VIEW3D_MT_view_navigation)
1937 bpy.types.register(VIEW3D_MT_view_align)
1938 bpy.types.register(VIEW3D_MT_view_align_selected)
1939 bpy.types.register(VIEW3D_MT_view_cameras)
1940
1941 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1942 bpy.types.register(VIEW3D_MT_select_pose)
1943 bpy.types.register(VIEW3D_MT_select_particle)
1944 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1945 bpy.types.register(VIEW3D_MT_select_edit_curve)
1946 bpy.types.register(VIEW3D_MT_select_edit_surface)
1947 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1948 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1949 bpy.types.register(VIEW3D_MT_select_edit_armature)
1950 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1951
1952 bpy.types.register(VIEW3D_MT_transform) # Object/Edit Menus
1953 bpy.types.register(VIEW3D_MT_mirror) # Object/Edit Menus
1954 bpy.types.register(VIEW3D_MT_snap) # Object/Edit Menus
1955 bpy.types.register(VIEW3D_MT_uv_map) # Edit Menus
1956
1957 bpy.types.register(VIEW3D_MT_object) # Object Menu
1958 bpy.types.register(VIEW3D_MT_object_apply)
1959 bpy.types.register(VIEW3D_MT_object_clear)
1960 bpy.types.register(VIEW3D_MT_object_parent)
1961 bpy.types.register(VIEW3D_MT_object_track)
1962 bpy.types.register(VIEW3D_MT_object_group)
1963 bpy.types.register(VIEW3D_MT_object_constraints)
1964 bpy.types.register(VIEW3D_MT_object_showhide)
1965 bpy.types.register(VIEW3D_MT_make_single_user)
1966 bpy.types.register(VIEW3D_MT_make_links)
1967
1968 bpy.types.register(VIEW3D_MT_hook)
1969 bpy.types.register(VIEW3D_MT_vertex_group)
1970
1971 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1972
1973 bpy.types.register(VIEW3D_MT_paint_vertex)
1974
1975 bpy.types.register(VIEW3D_MT_particle)# Particle Menu
1976 bpy.types.register(VIEW3D_MT_particle_specials)
1977 bpy.types.register(VIEW3D_MT_particle_showhide)
1978
1979 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1980 bpy.types.register(VIEW3D_MT_pose_transform)
1981 bpy.types.register(VIEW3D_MT_pose_pose)
1982 bpy.types.register(VIEW3D_MT_pose_motion)
1983 bpy.types.register(VIEW3D_MT_pose_group)
1984 bpy.types.register(VIEW3D_MT_pose_ik)
1985 bpy.types.register(VIEW3D_MT_pose_constraints)
1986 bpy.types.register(VIEW3D_MT_pose_showhide)
1987
1988 bpy.types.register(VIEW3D_MT_edit_mesh)
1989 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1990 bpy.types.register(VIEW3D_MT_edit_mesh_selection_mode) # Only as a menu for keybindings
1991 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1992 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1993 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1994 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1995 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1996
1997 bpy.types.register(VIEW3D_MT_edit_curve)
1998 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1999 bpy.types.register(VIEW3D_MT_edit_curve_segments)
2000 bpy.types.register(VIEW3D_MT_edit_curve_specials)
2001 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
2002
2003 bpy.types.register(VIEW3D_MT_edit_surface)
2004
2005 bpy.types.register(VIEW3D_MT_edit_text)
2006 bpy.types.register(VIEW3D_MT_edit_text_chars)
2007
2008 bpy.types.register(VIEW3D_MT_edit_meta)
2009 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
2010
2011 bpy.types.register(VIEW3D_MT_edit_lattice)
2012
2013 bpy.types.register(VIEW3D_MT_edit_armature)
2014 bpy.types.register(VIEW3D_MT_edit_armature_parent)
2015 bpy.types.register(VIEW3D_MT_edit_armature_roll)
2016
2017 bpy.types.register(VIEW3D_MT_armature_specials) # Only as a menu for keybindings
2018
2019  # Panels
2020 bpy.types.register(VIEW3D_PT_3dview_properties)
2021 bpy.types.register(VIEW3D_PT_3dview_display)
2022 bpy.types.register(VIEW3D_PT_3dview_name)
2023 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
2024 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
2025 bpy.types.register(VIEW3D_PT_background_image)
2026 bpy.types.register(VIEW3D_PT_transform_orientations)
2027 bpy.types.register(VIEW3D_PT_etch_a_ton)
2028
2029 bpy.types.register(VIEW3D_PT_context_properties)