ef658b65ddbef0e16a977d53ca215917cd608710
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_paint_common import UnifiedPaintPanel
23 from bpy.app.translations import contexts as i18n_contexts
24
25
26 class VIEW3D_HT_header(Header):
27     bl_space_type = 'VIEW_3D'
28
29     def draw(self, context):
30         layout = self.layout
31
32         view = context.space_data
33         mode_string = context.mode
34         edit_object = context.edit_object
35         obj = context.active_object
36         toolsettings = context.tool_settings
37
38         row = layout.row(align=True)
39         row.template_header()
40
41         # Menus
42         if context.area.show_menus:
43             sub = row.row(align=True)
44
45             sub.menu("VIEW3D_MT_view")
46
47             # Select Menu
48             if mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
49                 mesh = obj.data
50                 if mesh.use_paint_mask:
51                     sub.menu("VIEW3D_MT_select_paint_mask")
52                 elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
53                     sub.menu("VIEW3D_MT_select_paint_mask_vertex")
54             elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
55                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
56
57             if edit_object:
58                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
59             elif obj:
60                 if mode_string not in {'PAINT_TEXTURE'}:
61                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
62                 if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
63                     sub.menu("VIEW3D_MT_brush")
64                 if mode_string == 'SCULPT':
65                     sub.menu("VIEW3D_MT_hide_mask")
66             else:
67                 sub.menu("VIEW3D_MT_object")
68
69         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
70         row = layout
71         layout.template_header_3D()
72
73         if obj:
74             mode = obj.mode
75             # Particle edit
76             if mode == 'PARTICLE_EDIT':
77                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
78
79             # Occlude geometry
80             if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
81                     (mode == 'WEIGHT_PAINT')):
82                 row.prop(view, "use_occlude_geometry", text="")
83
84             # Proportional editing
85             if mode in {'EDIT', 'PARTICLE_EDIT'}:
86                 row = layout.row(align=True)
87                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
88                 if toolsettings.proportional_edit != 'DISABLED':
89                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
90             elif mode == 'OBJECT':
91                 row = layout.row(align=True)
92                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
93                 if toolsettings.use_proportional_edit_objects:
94                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
95
96         # Snap
97         if not obj or mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
98             snap_element = toolsettings.snap_element
99             row = layout.row(align=True)
100             row.prop(toolsettings, "use_snap", text="")
101             row.prop(toolsettings, "snap_element", text="", icon_only=True)
102             if snap_element != 'INCREMENT':
103                 row.prop(toolsettings, "snap_target", text="")
104                 if obj:
105                     if mode in {'OBJECT', 'POSE'} and snap_element != 'VOLUME':
106                         row.prop(toolsettings, "use_snap_align_rotation", text="")
107                     elif mode == 'EDIT':
108                         row.prop(toolsettings, "use_snap_self", text="")
109
110             if snap_element == 'VOLUME':
111                 row.prop(toolsettings, "use_snap_peel_object", text="")
112             elif snap_element == 'FACE':
113                 row.prop(toolsettings, "use_snap_project", text="")
114
115         # AutoMerge editing
116         if obj:
117             if (mode == 'EDIT' and obj.type == 'MESH'):
118                 layout.prop(toolsettings, "use_mesh_automerge", text="", icon='AUTOMERGE_ON')
119
120         # OpenGL render
121         row = layout.row(align=True)
122         row.operator("render.opengl", text="", icon='RENDER_STILL')
123         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
124         props.animation = True
125
126         # Pose
127         if obj and mode == 'POSE':
128             row = layout.row(align=True)
129             row.operator("pose.copy", text="", icon='COPYDOWN')
130             row.operator("pose.paste", text="", icon='PASTEDOWN')
131             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
132             props.flipped = 1
133
134
135 # ********** Menu **********
136
137 # ********** Utilities **********
138
139
140 class ShowHideMenu():
141     bl_label = "Show/Hide"
142     _operator_name = ""
143
144     def draw(self, context):
145         layout = self.layout
146
147         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
148         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
149         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
150
151
152 # Standard transforms which apply to all cases
153 # NOTE: this doesn't seem to be able to be used directly
154 class VIEW3D_MT_transform_base(Menu):
155     bl_label = "Transform"
156
157     # TODO: get rid of the custom text strings?
158     def draw(self, context):
159         layout = self.layout
160
161         layout.operator("transform.translate", text="Grab/Move")
162         # TODO: sub-menu for grab per axis
163         layout.operator("transform.rotate", text="Rotate")
164         # TODO: sub-menu for rot per axis
165         layout.operator("transform.resize", text="Scale")
166         # TODO: sub-menu for scale per axis
167
168         layout.separator()
169
170         layout.operator("transform.tosphere", text="To Sphere")
171         layout.operator("transform.shear", text="Shear")
172         layout.operator("transform.warp", text="Warp")
173         layout.operator("transform.push_pull", text="Push/Pull")
174
175
176 # Generic transform menu - geometry types
177 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
178     def draw(self, context):
179         # base menu
180         VIEW3D_MT_transform_base.draw(self, context)
181
182         # generic...
183         layout = self.layout
184         layout.operator("transform.shrink_fatten", text="Shrink Fatten")
185
186         layout.separator()
187
188         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
189         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
190
191
192 # Object-specific extensions to Transform menu
193 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
194     def draw(self, context):
195         layout = self.layout
196
197         # base menu
198         VIEW3D_MT_transform_base.draw(self, context)
199
200         # object-specific option follow...
201         layout.separator()
202
203         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
204         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
205
206         layout.separator()
207
208         layout.operator_context = 'EXEC_REGION_WIN'
209         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
210
211         layout.separator()
212
213         layout.operator_context = 'EXEC_AREA'
214
215         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
216         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
217         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
218         layout.operator("object.origin_set", text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
219         layout.separator()
220
221         layout.operator("object.randomize_transform")
222         layout.operator("object.align")
223
224         layout.separator()
225
226         layout.operator("object.anim_transforms_to_deltas")
227
228
229 # Armature EditMode extensions to Transform menu
230 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
231     def draw(self, context):
232         layout = self.layout
233
234         # base menu
235         VIEW3D_MT_transform_base.draw(self, context)
236
237         # armature specific extensions follow...
238         layout.separator()
239
240         obj = context.object
241         if     (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
242                 obj.data.draw_type in {'BBONE', 'ENVELOPE'}):
243             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
244
245         if context.edit_object and context.edit_object.type == 'ARMATURE':
246             layout.operator("armature.align")
247
248
249 class VIEW3D_MT_mirror(Menu):
250     bl_label = "Mirror"
251
252     def draw(self, context):
253         layout = self.layout
254
255         layout.operator("transform.mirror", text="Interactive Mirror")
256
257         layout.separator()
258
259         layout.operator_context = 'INVOKE_REGION_WIN'
260
261         props = layout.operator("transform.mirror", text="X Global")
262         props.constraint_axis = (True, False, False)
263         props.constraint_orientation = 'GLOBAL'
264         props = layout.operator("transform.mirror", text="Y Global")
265         props.constraint_axis = (False, True, False)
266         props.constraint_orientation = 'GLOBAL'
267         props = layout.operator("transform.mirror", text="Z Global")
268         props.constraint_axis = (False, False, True)
269         props.constraint_orientation = 'GLOBAL'
270
271         if context.edit_object:
272             layout.separator()
273
274             props = layout.operator("transform.mirror", text="X Local")
275             props.constraint_axis = (True, False, False)
276             props.constraint_orientation = 'LOCAL'
277             props = layout.operator("transform.mirror", text="Y Local")
278             props.constraint_axis = (False, True, False)
279             props.constraint_orientation = 'LOCAL'
280             props = layout.operator("transform.mirror", text="Z Local")
281             props.constraint_axis = (False, False, True)
282             props.constraint_orientation = 'LOCAL'
283
284             layout.operator("object.vertex_group_mirror")
285
286
287 class VIEW3D_MT_snap(Menu):
288     bl_label = "Snap"
289
290     def draw(self, context):
291         layout = self.layout
292
293         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
294         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
295
296         layout.separator()
297
298         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
299         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
300         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
301         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
302
303
304 class VIEW3D_MT_uv_map(Menu):
305     bl_label = "UV Mapping"
306
307     def draw(self, context):
308         layout = self.layout
309
310         layout.operator("uv.unwrap")
311
312         layout.operator_context = 'INVOKE_DEFAULT'
313         layout.operator("uv.smart_project")
314         layout.operator("uv.lightmap_pack")
315         layout.operator("uv.follow_active_quads")
316
317         layout.separator()
318
319         layout.operator_context = 'EXEC_REGION_WIN'
320         layout.operator("uv.cube_project")
321         layout.operator("uv.cylinder_project")
322         layout.operator("uv.sphere_project")
323
324         layout.separator()
325
326         layout.operator_context = 'EXEC_REGION_WIN'
327         layout.operator("uv.project_from_view").scale_to_bounds = False
328         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
329
330         layout.separator()
331
332         layout.operator("uv.reset")
333
334
335 # ********** View menus **********
336
337
338 class VIEW3D_MT_view(Menu):
339     bl_label = "View"
340
341     def draw(self, context):
342         layout = self.layout
343
344         layout.operator("view3d.properties", icon='MENU_PANEL')
345         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
346
347         layout.separator()
348
349         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
350         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
351         layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
352         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
353         layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
354         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
355         layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
356
357         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
358
359         layout.separator()
360
361         layout.operator("view3d.view_persportho")
362
363         layout.separator()
364
365         layout.menu("VIEW3D_MT_view_navigation")
366         layout.menu("VIEW3D_MT_view_align")
367
368         layout.separator()
369
370         layout.operator_context = 'INVOKE_REGION_WIN'
371
372         layout.operator("view3d.clip_border", text="Clipping Border...")
373         layout.operator("view3d.zoom_border", text="Zoom Border...")
374         layout.operator("view3d.render_border", text="Render Border...")
375
376         layout.separator()
377
378         layout.operator("view3d.layers", text="Show All Layers").nr = 0
379
380         layout.separator()
381
382         layout.operator("view3d.localview", text="View Global/Local")
383         layout.operator("view3d.view_selected")
384         layout.operator("view3d.view_all")
385
386         layout.separator()
387
388         layout.operator("screen.animation_play", text="Playback Animation")
389
390         layout.separator()
391
392         layout.operator("screen.area_dupli")
393         layout.operator("screen.region_quadview")
394         layout.operator("screen.screen_full_area")
395
396
397 class VIEW3D_MT_view_navigation(Menu):
398     bl_label = "Navigation"
399
400     def draw(self, context):
401         layout = self.layout
402
403         layout.operator_enum("view3d.view_orbit", "type")
404
405         layout.separator()
406
407         layout.operator_enum("view3d.view_pan", "type")
408
409         layout.separator()
410
411         layout.operator("view3d.zoom", text="Zoom In").delta = 1
412         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
413         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
414
415         layout.separator()
416
417         layout.operator("view3d.fly")
418
419
420 class VIEW3D_MT_view_align(Menu):
421     bl_label = "Align View"
422
423     def draw(self, context):
424         layout = self.layout
425
426         layout.menu("VIEW3D_MT_view_align_selected")
427
428         layout.separator()
429
430         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
431         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
432         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
433         layout.operator("view3d.view_selected")
434         layout.operator("view3d.view_center_cursor")
435
436         layout.separator()
437
438         layout.operator("view3d.view_lock_to_active")
439         layout.operator("view3d.view_lock_clear")
440
441
442 class VIEW3D_MT_view_align_selected(Menu):
443     bl_label = "Align View to Selected"
444
445     def draw(self, context):
446         layout = self.layout
447
448         props = layout.operator("view3d.viewnumpad", text="Top")
449         props.align_active = True
450         props.type = 'TOP'
451
452         props = layout.operator("view3d.viewnumpad", text="Bottom")
453         props.align_active = True
454         props.type = 'BOTTOM'
455
456         props = layout.operator("view3d.viewnumpad", text="Front")
457         props.align_active = True
458         props.type = 'FRONT'
459
460         props = layout.operator("view3d.viewnumpad", text="Back")
461         props.align_active = True
462         props.type = 'BACK'
463
464         props = layout.operator("view3d.viewnumpad", text="Right")
465         props.align_active = True
466         props.type = 'RIGHT'
467
468         props = layout.operator("view3d.viewnumpad", text="Left")
469         props.align_active = True
470         props.type = 'LEFT'
471
472
473 class VIEW3D_MT_view_cameras(Menu):
474     bl_label = "Cameras"
475
476     def draw(self, context):
477         layout = self.layout
478
479         layout.operator("view3d.object_as_camera")
480         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
481
482 # ********** Select menus, suffix from context.mode **********
483
484
485 class VIEW3D_MT_select_object(Menu):
486     bl_label = "Select"
487
488     def draw(self, context):
489         layout = self.layout
490
491         layout.operator("view3d.select_border")
492         layout.operator("view3d.select_circle")
493
494         layout.separator()
495
496         layout.operator("object.select_all").action = 'TOGGLE'
497         layout.operator("object.select_all", text="Inverse").action = 'INVERT'
498         layout.operator("object.select_random", text="Random")
499         layout.operator("object.select_mirror", text="Mirror")
500         layout.operator("object.select_by_layer", text="Select All by Layer")
501         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
502         layout.operator("object.select_camera", text="Select Camera")
503
504         layout.separator()
505
506         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
507         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
508         layout.operator("object.select_pattern", text="Select Pattern...")
509
510
511 class VIEW3D_MT_select_pose(Menu):
512     bl_label = "Select"
513
514     def draw(self, context):
515         layout = self.layout
516
517         layout.operator("view3d.select_border")
518         layout.operator("view3d.select_circle")
519
520         layout.separator()
521
522         layout.operator("pose.select_all").action = 'TOGGLE'
523         layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
524         layout.operator("pose.select_flip_active", text="Flip Active")
525         layout.operator("pose.select_constraint_target", text="Constraint Target")
526         layout.operator("pose.select_linked", text="Linked")
527
528         layout.separator()
529
530         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
531         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
532
533         layout.separator()
534
535         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
536         props.extend = True
537         props.direction = 'PARENT'
538
539         props = layout.operator("pose.select_hierarchy", text="Extend Child")
540         props.extend = True
541         props.direction = 'CHILD'
542
543         layout.separator()
544
545         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
546         layout.operator("object.select_pattern", text="Select Pattern...")
547
548
549 class VIEW3D_MT_select_particle(Menu):
550     bl_label = "Select"
551
552     def draw(self, context):
553         layout = self.layout
554
555         layout.operator("view3d.select_border")
556
557         layout.separator()
558
559         layout.operator("particle.select_all").action = 'TOGGLE'
560         layout.operator("particle.select_linked")
561         layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
562
563         layout.separator()
564
565         layout.operator("particle.select_more")
566         layout.operator("particle.select_less")
567
568         layout.separator()
569
570         layout.operator("particle.select_roots", text="Roots")
571         layout.operator("particle.select_tips", text="Tips")
572
573
574 class VIEW3D_MT_select_edit_mesh(Menu):
575     bl_label = "Select"
576
577     def draw(self, context):
578         layout = self.layout
579
580         layout.operator("view3d.select_border")
581         layout.operator("view3d.select_circle")
582
583         layout.separator()
584
585         layout.operator("mesh.select_all").action = 'TOGGLE'
586         layout.operator("mesh.select_all", text="Inverse").action = 'INVERT'
587
588         layout.separator()
589
590         layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")
591         layout.operator("mesh.select_random", text="Random")
592         layout.operator("mesh.select_nth")
593         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
594         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
595         layout.operator("mesh.select_interior_faces", text="Interior Faces")
596         layout.operator("mesh.select_axis", text="Side of Active")
597
598         layout.separator()
599
600         layout.operator("mesh.select_face_by_sides")
601         if context.scene.tool_settings.mesh_select_mode[2] is False:
602             layout.operator("mesh.select_non_manifold", text="Non Manifold")
603         layout.operator("mesh.select_loose_verts", text="Loose Verts/Edges")
604         layout.operator_menu_enum("mesh.select_similar", "type", text="Similar")
605
606         layout.separator()
607
608         layout.operator("mesh.select_less", text="Less")
609         layout.operator("mesh.select_more", text="More")
610
611         layout.separator()
612
613         layout.operator("mesh.select_mirror", text="Mirror")
614
615         layout.operator("mesh.select_linked", text="Linked")
616         layout.operator("mesh.select_vertex_path", text="Vertex Path")
617         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
618         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
619
620         layout.separator()
621
622         layout.operator("mesh.loop_to_region")
623         layout.operator("mesh.region_to_loop")
624
625
626 class VIEW3D_MT_select_edit_curve(Menu):
627     bl_label = "Select"
628
629     def draw(self, context):
630         layout = self.layout
631
632         layout.operator("view3d.select_border")
633         layout.operator("view3d.select_circle")
634
635         layout.separator()
636
637         layout.operator("curve.select_all").action = 'TOGGLE'
638         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
639         layout.operator("curve.select_random")
640         layout.operator("curve.select_nth")
641         layout.operator("curve.select_linked", text="Select Linked")
642
643         layout.separator()
644
645         layout.operator("curve.de_select_first")
646         layout.operator("curve.de_select_last")
647         layout.operator("curve.select_next")
648         layout.operator("curve.select_previous")
649
650         layout.separator()
651
652         layout.operator("curve.select_more")
653         layout.operator("curve.select_less")
654
655
656 class VIEW3D_MT_select_edit_surface(Menu):
657     bl_label = "Select"
658
659     def draw(self, context):
660         layout = self.layout
661
662         layout.operator("view3d.select_border")
663         layout.operator("view3d.select_circle")
664
665         layout.separator()
666
667         layout.operator("curve.select_all").action = 'TOGGLE'
668         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
669         layout.operator("curve.select_random")
670         layout.operator("curve.select_nth")
671         layout.operator("curve.select_linked", text="Select Linked")
672
673         layout.separator()
674
675         layout.operator("curve.select_row")
676
677         layout.separator()
678
679         layout.operator("curve.select_more")
680         layout.operator("curve.select_less")
681
682
683 class VIEW3D_MT_select_edit_metaball(Menu):
684     bl_label = "Select"
685
686     def draw(self, context):
687         layout = self.layout
688
689         layout.operator("view3d.select_border")
690         layout.operator("view3d.select_circle")
691
692         layout.separator()
693
694         layout.operator("mball.select_all").action = 'TOGGLE'
695         layout.operator("mball.select_all", text="Inverse").action = 'INVERT'
696
697         layout.separator()
698
699         layout.operator("mball.select_random_metaelems")
700
701
702 class VIEW3D_MT_select_edit_lattice(Menu):
703     bl_label = "Select"
704
705     def draw(self, context):
706         layout = self.layout
707
708         layout.operator("view3d.select_border")
709         layout.operator("view3d.select_circle")
710
711         layout.separator()
712
713         layout.operator("lattice.select_all").action = 'TOGGLE'
714         layout.operator("lattice.select_all", text="Inverse").action = 'INVERT'
715
716         layout.separator()
717
718         layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")
719
720
721 class VIEW3D_MT_select_edit_armature(Menu):
722     bl_label = "Select"
723
724     def draw(self, context):
725         layout = self.layout
726
727         layout.operator("view3d.select_border")
728         layout.operator("view3d.select_circle")
729
730         layout.separator()
731
732         layout.operator("armature.select_all").action = 'TOGGLE'
733         layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
734
735         layout.separator()
736
737         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
738         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
739
740         layout.separator()
741
742         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
743         props.extend = True
744         props.direction = 'PARENT'
745
746         props = layout.operator("armature.select_hierarchy", text="Extend Child")
747         props.extend = True
748         props.direction = 'CHILD'
749
750         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
751         layout.operator("object.select_pattern", text="Select Pattern...")
752
753
754 class VIEW3D_MT_select_paint_mask(Menu):
755     bl_label = "Select"
756
757     def draw(self, context):
758         layout = self.layout
759
760         layout.operator("view3d.select_border")
761         layout.operator("view3d.select_circle")
762
763         layout.separator()
764
765         layout.operator("paint.face_select_all").action = 'TOGGLE'
766         layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT'
767
768         layout.separator()
769
770         layout.operator("paint.face_select_linked", text="Linked")
771
772
773 class VIEW3D_MT_select_paint_mask_vertex(Menu):
774     bl_label = "Select"
775
776     def draw(self, context):
777         layout = self.layout
778
779         layout.operator("view3d.select_border")
780         layout.operator("view3d.select_circle")
781
782         layout.separator()
783
784         layout.operator("paint.vert_select_all").action = 'TOGGLE'
785         layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT'
786
787         layout.separator()
788
789         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
790
791
792 # ********** Object menu **********
793
794
795 class VIEW3D_MT_object(Menu):
796     bl_context = "objectmode"
797     bl_label = "Object"
798
799     def draw(self, context):
800         layout = self.layout
801
802         layout.operator("ed.undo")
803         layout.operator("ed.redo")
804         layout.operator("ed.undo_history")
805
806         layout.separator()
807
808         layout.menu("VIEW3D_MT_transform_object")
809         layout.menu("VIEW3D_MT_mirror")
810         layout.menu("VIEW3D_MT_object_clear")
811         layout.menu("VIEW3D_MT_object_apply")
812         layout.menu("VIEW3D_MT_snap")
813
814         layout.separator()
815
816         layout.menu("VIEW3D_MT_object_animation")
817
818         layout.separator()
819
820         layout.operator("object.duplicate_move")
821         layout.operator("object.duplicate_move_linked")
822         layout.operator("object.delete", text="Delete...")
823         layout.operator("object.proxy_make", text="Make Proxy...")
824         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
825         layout.operator("object.make_dupli_face")
826         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
827         layout.menu("VIEW3D_MT_make_single_user")
828
829         layout.separator()
830
831         layout.menu("VIEW3D_MT_object_parent")
832         layout.menu("VIEW3D_MT_object_track")
833         layout.menu("VIEW3D_MT_object_group")
834         layout.menu("VIEW3D_MT_object_constraints")
835
836         layout.separator()
837
838         layout.menu("VIEW3D_MT_object_quick_effects")
839
840         layout.separator()
841
842         layout.menu("VIEW3D_MT_object_game")
843
844         layout.separator()
845
846         layout.operator("object.join")
847
848         layout.separator()
849
850         layout.operator("object.move_to_layer", text="Move to Layer...")
851         layout.menu("VIEW3D_MT_object_showhide")
852
853         layout.operator_menu_enum("object.convert", "target")
854
855
856 class VIEW3D_MT_object_animation(Menu):
857     bl_label = "Animation"
858
859     def draw(self, context):
860         layout = self.layout
861
862         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
863         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
864         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
865         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
866
867         layout.separator()
868
869         layout.operator("nla.bake", text="Bake Action...")
870
871
872 class VIEW3D_MT_object_clear(Menu):
873     bl_label = "Clear"
874
875     def draw(self, context):
876         layout = self.layout
877
878         layout.operator("object.location_clear", text="Location")
879         layout.operator("object.rotation_clear", text="Rotation")
880         layout.operator("object.scale_clear", text="Scale")
881         layout.operator("object.origin_clear", text="Origin")
882
883
884 class VIEW3D_MT_object_specials(Menu):
885     bl_label = "Specials"
886
887     @classmethod
888     def poll(cls, context):
889         # add more special types
890         return context.object
891
892     def draw(self, context):
893         layout = self.layout
894
895         obj = context.object
896         if obj.type == 'CAMERA':
897             layout.operator_context = 'INVOKE_REGION_WIN'
898
899             if obj.data.type == 'PERSP':
900                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
901                 props.data_path_iter = "selected_editable_objects"
902                 props.data_path_item = "data.lens"
903                 props.input_scale = 0.1
904                 if obj.data.lens_unit == 'MILLIMETERS':
905                     props.header_text = "Camera Lens Angle: %.1fmm"
906                 else:
907                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
908
909             else:
910                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
911                 props.data_path_iter = "selected_editable_objects"
912                 props.data_path_item = "data.ortho_scale"
913                 props.input_scale = 0.01
914                 props.header_text = "Camera Lens Scale: %.3f"
915
916             if not obj.data.dof_object:
917                 #layout.label(text="Test Has DOF obj");
918                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
919                 props.data_path_iter = "selected_editable_objects"
920                 props.data_path_item = "data.dof_distance"
921                 props.input_scale = 0.02
922                 props.header_text = "DOF Distance: %.3f"
923
924         if obj.type in {'CURVE', 'FONT'}:
925             layout.operator_context = 'INVOKE_REGION_WIN'
926
927             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
928             props.data_path_iter = "selected_editable_objects"
929             props.data_path_item = "data.extrude"
930             props.input_scale = 0.01
931             props.header_text = "Extrude Size: %.3f"
932
933             props = layout.operator("wm.context_modal_mouse", text="Width Size")
934             props.data_path_iter = "selected_editable_objects"
935             props.data_path_item = "data.offset"
936             props.input_scale = 0.01
937             props.header_text = "Width Size: %.3f"
938
939         if obj.type == 'EMPTY':
940             layout.operator_context = 'INVOKE_REGION_WIN'
941
942             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
943             props.data_path_iter = "selected_editable_objects"
944             props.data_path_item = "empty_draw_size"
945             props.input_scale = 0.01
946             props.header_text = "Empty Draw Size: %.3f"
947
948         if obj.type == 'LAMP':
949             layout.operator_context = 'INVOKE_REGION_WIN'
950
951             props = layout.operator("wm.context_modal_mouse", text="Energy")
952             props.data_path_iter = "selected_editable_objects"
953             props.data_path_item = "data.energy"
954             props.header_text = "Lamp Energy: %.3f"
955
956             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
957                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
958                 props.data_path_iter = "selected_editable_objects"
959                 props.data_path_item = "data.distance"
960                 props.input_scale = 0.1
961                 props.header_text = "Lamp Falloff Distance: %.1f"
962
963             if obj.data.type == 'SPOT':
964                 layout.separator()
965                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
966                 props.data_path_iter = "selected_editable_objects"
967                 props.data_path_item = "data.spot_size"
968                 props.input_scale = 0.01
969                 props.header_text = "Spot Size: %.2f"
970
971                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
972                 props.data_path_iter = "selected_editable_objects"
973                 props.data_path_item = "data.spot_blend"
974                 props.input_scale = -0.01
975                 props.header_text = "Spot Blend: %.2f"
976
977                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
978                 props.data_path_iter = "selected_editable_objects"
979                 props.data_path_item = "data.shadow_buffer_clip_start"
980                 props.input_scale = 0.05
981                 props.header_text = "Clip Start: %.2f"
982
983                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
984                 props.data_path_iter = "selected_editable_objects"
985                 props.data_path_item = "data.shadow_buffer_clip_end"
986                 props.input_scale = 0.05
987                 props.header_text = "Clip End: %.2f"
988
989         layout.separator()
990
991         props = layout.operator("object.isolate_type_render")
992         props = layout.operator("object.hide_render_clear_all")
993
994
995 class VIEW3D_MT_object_apply(Menu):
996     bl_label = "Apply"
997
998     def draw(self, context):
999         layout = self.layout
1000
1001         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1002         props.location, props.rotation, props.scale = True, False, False
1003
1004         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1005         props.location, props.rotation, props.scale = False, True, False
1006
1007         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1008         props.location, props.rotation, props.scale = False, False, True
1009         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1010         props.location, props.rotation, props.scale = False, True, True
1011
1012         layout.separator()
1013
1014         layout.operator("object.visual_transform_apply", text="Visual Transform", text_ctxt=i18n_contexts.default)
1015         layout.operator("object.duplicates_make_real")
1016
1017
1018 class VIEW3D_MT_object_parent(Menu):
1019     bl_label = "Parent"
1020
1021     def draw(self, context):
1022         layout = self.layout
1023
1024         layout.operator_enum("object.parent_set", "type")
1025         layout.separator()
1026         layout.operator_enum("object.parent_clear", "type")
1027
1028
1029 class VIEW3D_MT_object_track(Menu):
1030     bl_label = "Track"
1031
1032     def draw(self, context):
1033         layout = self.layout
1034
1035         layout.operator_enum("object.track_set", "type")
1036         layout.separator()
1037         layout.operator_enum("object.track_clear", "type")
1038
1039
1040 class VIEW3D_MT_object_group(Menu):
1041     bl_label = "Group"
1042
1043     def draw(self, context):
1044         layout = self.layout
1045
1046         layout.operator("group.create")
1047         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
1048         layout.operator("group.objects_remove")
1049         layout.operator("group.objects_remove_all")
1050
1051         layout.separator()
1052
1053         layout.operator("group.objects_add_active")
1054         layout.operator("group.objects_remove_active")
1055
1056
1057 class VIEW3D_MT_object_constraints(Menu):
1058     bl_label = "Constraints"
1059
1060     def draw(self, context):
1061         layout = self.layout
1062
1063         layout.operator("object.constraint_add_with_targets")
1064         layout.operator("object.constraints_copy")
1065         layout.operator("object.constraints_clear")
1066
1067
1068 class VIEW3D_MT_object_quick_effects(Menu):
1069     bl_label = "Quick Effects"
1070
1071     def draw(self, context):
1072         layout = self.layout
1073
1074         layout.operator("object.quick_fur")
1075         layout.operator("object.quick_explode")
1076         layout.operator("object.quick_smoke")
1077         layout.operator("object.quick_fluid")
1078
1079
1080 class VIEW3D_MT_object_showhide(Menu):
1081     bl_label = "Show/Hide"
1082
1083     def draw(self, context):
1084         layout = self.layout
1085
1086         layout.operator("object.hide_view_clear", text="Show Hidden")
1087         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1088         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1089
1090
1091 class VIEW3D_MT_make_single_user(Menu):
1092     bl_label = "Make Single User"
1093
1094     def draw(self, context):
1095         layout = self.layout
1096
1097         props = layout.operator("object.make_single_user", text="Object")
1098         props.object = True
1099
1100         props = layout.operator("object.make_single_user", text="Object & Data")
1101         props.object = props.obdata = True
1102
1103         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1104         props.object = props.obdata = props.material = props.texture = True
1105
1106         props = layout.operator("object.make_single_user", text="Materials+Tex")
1107         props.material = props.texture = True
1108
1109         props = layout.operator("object.make_single_user", text="Object Animation")
1110         props.animation = True
1111
1112
1113 class VIEW3D_MT_make_links(Menu):
1114     bl_label = "Make Links"
1115
1116     def draw(self, context):
1117         layout = self.layout
1118         operator_context_default = layout.operator_context
1119         if len(bpy.data.scenes) > 10:
1120             layout.operator_context = 'INVOKE_REGION_WIN'
1121             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1122         else:
1123             layout.operator_context = 'EXEC_REGION_WIN'
1124             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1125         layout.operator_context = operator_context_default
1126
1127         layout.operator_enum("object.make_links_data", "type")  # inline
1128
1129         layout.operator("object.join_uvs")  # stupid place to add this!
1130
1131
1132 class VIEW3D_MT_object_game(Menu):
1133     bl_label = "Game"
1134
1135     def draw(self, context):
1136         layout = self.layout
1137
1138         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1139         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1140
1141         layout.separator()
1142
1143         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1144         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1145         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1146
1147         layout.separator()
1148
1149         layout.operator("object.game_property_clear")
1150
1151
1152 # ********** Brush menu **********
1153 class VIEW3D_MT_brush(Menu):
1154     bl_label = "Brush"
1155
1156     def draw(self, context):
1157         layout = self.layout
1158
1159         settings = UnifiedPaintPanel.paint_settings(context)
1160         brush = settings.brush
1161
1162         ups = context.tool_settings.unified_paint_settings
1163         layout.prop(ups, "use_unified_size", text="Unified Size")
1164         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1165         layout.separator()
1166
1167         # brush paint modes
1168         layout.menu("VIEW3D_MT_brush_paint_modes")
1169
1170         # brush tool
1171         if context.sculpt_object:
1172             layout.operator("brush.reset")
1173             layout.prop_menu_enum(brush, "sculpt_tool")
1174         elif context.image_paint_object:
1175             layout.prop_menu_enum(brush, "image_tool")
1176         elif context.vertex_paint_object or context.weight_paint_object:
1177             layout.prop_menu_enum(brush, "vertex_tool")
1178
1179         # skip if no active brush
1180         if not brush:
1181             return
1182
1183         # TODO: still missing a lot of brush options here
1184
1185         # sculpt options
1186         if context.sculpt_object:
1187
1188             sculpt_tool = brush.sculpt_tool
1189
1190             layout.separator()
1191             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1192             layout.separator()
1193
1194             if sculpt_tool != 'GRAB':
1195                 layout.prop_menu_enum(brush, "stroke_method")
1196
1197                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1198                     layout.prop_menu_enum(brush, "direction")
1199
1200                 if sculpt_tool == 'LAYER':
1201                     layout.prop(brush, "use_persistent")
1202                     layout.operator("sculpt.set_persistent_base")
1203
1204
1205 class VIEW3D_MT_brush_paint_modes(Menu):
1206     bl_label = "Enabled Modes"
1207
1208     def draw(self, context):
1209         layout = self.layout
1210
1211         settings = UnifiedPaintPanel.paint_settings(context)
1212         brush = settings.brush
1213
1214         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1215         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1216         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1217         layout.prop(brush, "use_paint_image", text="Texture Paint")
1218
1219 # ********** Vertex paint menu **********
1220
1221
1222 class VIEW3D_MT_paint_vertex(Menu):
1223     bl_label = "Paint"
1224
1225     def draw(self, context):
1226         layout = self.layout
1227
1228         layout.operator("ed.undo")
1229         layout.operator("ed.redo")
1230
1231         layout.separator()
1232
1233         layout.operator("paint.vertex_color_set")
1234         layout.operator("paint.vertex_color_dirt")
1235
1236
1237 class VIEW3D_MT_hook(Menu):
1238     bl_label = "Hooks"
1239
1240     def draw(self, context):
1241         layout = self.layout
1242         layout.operator_context = 'EXEC_AREA'
1243         layout.operator("object.hook_add_newob")
1244         layout.operator("object.hook_add_selob").use_bone = False
1245         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1246
1247         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1248             layout.separator()
1249             layout.operator_menu_enum("object.hook_assign", "modifier")
1250             layout.operator_menu_enum("object.hook_remove", "modifier")
1251             layout.separator()
1252             layout.operator_menu_enum("object.hook_select", "modifier")
1253             layout.operator_menu_enum("object.hook_reset", "modifier")
1254             layout.operator_menu_enum("object.hook_recenter", "modifier")
1255
1256
1257 class VIEW3D_MT_vertex_group(Menu):
1258     bl_label = "Vertex Groups"
1259
1260     def draw(self, context):
1261         layout = self.layout
1262
1263         layout.operator_context = 'EXEC_AREA'
1264         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1265
1266         ob = context.active_object
1267         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1268             if ob.vertex_groups.active:
1269                 layout.separator()
1270                 layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
1271                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1272                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1273                 layout.separator()
1274
1275         if ob.vertex_groups.active:
1276             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1277             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1278             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1279
1280 # ********** Weight paint menu **********
1281
1282
1283 class VIEW3D_MT_paint_weight(Menu):
1284     bl_label = "Weights"
1285
1286     def draw(self, context):
1287         layout = self.layout
1288
1289         layout.operator("ed.undo")
1290         layout.operator("ed.redo")
1291         layout.operator("ed.undo_history")
1292
1293         layout.separator()
1294
1295         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1296         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1297
1298         layout.separator()
1299
1300         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1301         layout.operator("object.vertex_group_normalize", text="Normalize")
1302         layout.operator("object.vertex_group_mirror", text="Mirror")
1303         layout.operator("object.vertex_group_invert", text="Invert")
1304         layout.operator("object.vertex_group_clean", text="Clean")
1305         layout.operator("object.vertex_group_levels", text="Levels")
1306         layout.operator("object.vertex_group_blend", text="Blend")
1307         layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1308         layout.operator("object.vertex_group_limit_total", text="Limit Total")
1309         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1310
1311         layout.separator()
1312
1313         layout.operator("paint.weight_set")
1314
1315 # ********** Sculpt menu **********
1316
1317
1318 class VIEW3D_MT_sculpt(Menu):
1319     bl_label = "Sculpt"
1320
1321     def draw(self, context):
1322         layout = self.layout
1323
1324         toolsettings = context.tool_settings
1325         sculpt = toolsettings.sculpt
1326
1327         layout.operator("ed.undo")
1328         layout.operator("ed.redo")
1329
1330         layout.separator()
1331
1332         layout.prop(sculpt, "use_symmetry_x")
1333         layout.prop(sculpt, "use_symmetry_y")
1334         layout.prop(sculpt, "use_symmetry_z")
1335         layout.separator()
1336         layout.prop(sculpt, "lock_x")
1337         layout.prop(sculpt, "lock_y")
1338         layout.prop(sculpt, "lock_z")
1339
1340         layout.separator()
1341         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1342         layout.prop(sculpt, "show_low_resolution")
1343         layout.prop(sculpt, "show_brush")
1344         layout.prop(sculpt, "use_deform_only")
1345         layout.prop(sculpt, "show_diffuse_color")
1346
1347
1348 class VIEW3D_MT_hide_mask(Menu):
1349     bl_label = "Hide/Mask"
1350
1351     def draw(self, context):
1352         layout = self.layout
1353
1354         op = layout.operator("paint.hide_show", text="Show All")
1355         op.action = 'SHOW'
1356         op.area = 'ALL'
1357
1358         op = layout.operator("paint.hide_show", text="Hide Bounding Box")
1359         op.action = 'HIDE'
1360         op.area = 'INSIDE'
1361
1362         op = layout.operator("paint.hide_show", text="Show Bounding Box")
1363         op.action = 'SHOW'
1364         op.area = 'INSIDE'
1365
1366         op = layout.operator("paint.hide_show", text="Hide Masked")
1367         op.area = 'MASKED'
1368         op.action = 'HIDE'
1369
1370         layout.separator()
1371
1372         op = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1373         op.mode = 'INVERT'
1374
1375         op = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1376         op.mode = 'VALUE'
1377         op.value = 1
1378
1379         op = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1380         op.mode = 'VALUE'
1381         op.value = 0
1382
1383
1384 # ********** Particle menu **********
1385
1386
1387 class VIEW3D_MT_particle(Menu):
1388     bl_label = "Particle"
1389
1390     def draw(self, context):
1391         layout = self.layout
1392
1393         particle_edit = context.tool_settings.particle_edit
1394
1395         layout.operator("ed.undo")
1396         layout.operator("ed.redo")
1397         layout.operator("ed.undo_history")
1398
1399         layout.separator()
1400
1401         layout.operator("particle.mirror")
1402
1403         layout.separator()
1404
1405         layout.operator("particle.remove_doubles")
1406         layout.operator("particle.delete")
1407
1408         if particle_edit.select_mode == 'POINT':
1409             layout.operator("particle.subdivide")
1410
1411         layout.operator("particle.rekey")
1412         layout.operator("particle.weight_set")
1413
1414         layout.separator()
1415
1416         layout.menu("VIEW3D_MT_particle_showhide")
1417
1418
1419 class VIEW3D_MT_particle_specials(Menu):
1420     bl_label = "Specials"
1421
1422     def draw(self, context):
1423         layout = self.layout
1424
1425         particle_edit = context.tool_settings.particle_edit
1426
1427         layout.operator("particle.rekey")
1428
1429         layout.separator()
1430         if particle_edit.select_mode == 'POINT':
1431             layout.operator("particle.subdivide")
1432             layout.operator("particle.select_roots")
1433             layout.operator("particle.select_tips")
1434
1435         layout.operator("particle.remove_doubles")
1436
1437
1438 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1439     _operator_name = "particle"
1440
1441 # ********** Pose Menu **********
1442
1443
1444 class VIEW3D_MT_pose(Menu):
1445     bl_label = "Pose"
1446
1447     def draw(self, context):
1448         layout = self.layout
1449
1450         layout.operator("ed.undo")
1451         layout.operator("ed.redo")
1452         layout.operator("ed.undo_history")
1453
1454         layout.separator()
1455
1456         layout.menu("VIEW3D_MT_transform_armature")
1457
1458         layout.menu("VIEW3D_MT_pose_transform")
1459         layout.menu("VIEW3D_MT_pose_apply")
1460
1461         layout.menu("VIEW3D_MT_snap")
1462
1463         layout.separator()
1464
1465         layout.menu("VIEW3D_MT_object_animation")
1466
1467         layout.separator()
1468
1469         layout.menu("VIEW3D_MT_pose_slide")
1470         layout.menu("VIEW3D_MT_pose_propagate")
1471
1472         layout.separator()
1473
1474         layout.operator("pose.copy")
1475         layout.operator("pose.paste")
1476         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1477
1478         layout.separator()
1479
1480         layout.menu("VIEW3D_MT_pose_library")
1481         layout.menu("VIEW3D_MT_pose_motion")
1482         layout.menu("VIEW3D_MT_pose_group")
1483
1484         layout.separator()
1485
1486         layout.menu("VIEW3D_MT_object_parent")
1487         layout.menu("VIEW3D_MT_pose_ik")
1488         layout.menu("VIEW3D_MT_pose_constraints")
1489
1490         layout.separator()
1491
1492         layout.operator_context = 'EXEC_AREA'
1493         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1494         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1495         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1496
1497         layout.operator("pose.flip_names")
1498
1499         layout.operator("pose.quaternions_flip")
1500
1501         layout.separator()
1502
1503         layout.operator_context = 'INVOKE_AREA'
1504         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1505         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1506
1507         layout.separator()
1508
1509         layout.menu("VIEW3D_MT_pose_showhide")
1510         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1511
1512
1513 class VIEW3D_MT_pose_transform(Menu):
1514     bl_label = "Clear Transform"
1515
1516     def draw(self, context):
1517         layout = self.layout
1518
1519         layout.operator("pose.transforms_clear", text="All")
1520
1521         layout.separator()
1522
1523         layout.operator("pose.loc_clear", text="Location")
1524         layout.operator("pose.rot_clear", text="Rotation")
1525         layout.operator("pose.scale_clear", text="Scale")
1526
1527         layout.separator()
1528
1529         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1530
1531
1532 class VIEW3D_MT_pose_slide(Menu):
1533     bl_label = "In-Betweens"
1534
1535     def draw(self, context):
1536         layout = self.layout
1537
1538         layout.operator("pose.push")
1539         layout.operator("pose.relax")
1540         layout.operator("pose.breakdown")
1541
1542
1543 class VIEW3D_MT_pose_propagate(Menu):
1544     bl_label = "Propagate"
1545
1546     def draw(self, context):
1547         layout = self.layout
1548
1549         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1550
1551         layout.separator()
1552
1553         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1554         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1555
1556         layout.separator()
1557
1558         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1559
1560
1561 class VIEW3D_MT_pose_library(Menu):
1562     bl_label = "Pose Library"
1563
1564     def draw(self, context):
1565         layout = self.layout
1566
1567         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1568
1569         layout.separator()
1570
1571         layout.operator("poselib.pose_add", text="Add Pose...")
1572         layout.operator("poselib.pose_rename", text="Rename Pose...")
1573         layout.operator("poselib.pose_remove", text="Remove Pose...")
1574
1575
1576 class VIEW3D_MT_pose_motion(Menu):
1577     bl_label = "Motion Paths"
1578
1579     def draw(self, context):
1580         layout = self.layout
1581
1582         layout.operator("pose.paths_calculate", text="Calculate")
1583         layout.operator("pose.paths_clear", text="Clear")
1584
1585
1586 class VIEW3D_MT_pose_group(Menu):
1587     bl_label = "Bone Groups"
1588
1589     def draw(self, context):
1590         layout = self.layout
1591
1592         pose = context.active_object.pose
1593
1594         layout.operator_context = 'EXEC_AREA'
1595         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
1596         if pose.bone_groups:
1597             active_group = pose.bone_groups.active_index + 1
1598             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
1599
1600             layout.separator()
1601
1602             #layout.operator_context = 'INVOKE_AREA'
1603             layout.operator("pose.group_unassign")
1604             layout.operator("pose.group_remove")
1605
1606
1607 class VIEW3D_MT_pose_ik(Menu):
1608     bl_label = "Inverse Kinematics"
1609
1610     def draw(self, context):
1611         layout = self.layout
1612
1613         layout.operator("pose.ik_add")
1614         layout.operator("pose.ik_clear")
1615
1616
1617 class VIEW3D_MT_pose_constraints(Menu):
1618     bl_label = "Constraints"
1619
1620     def draw(self, context):
1621         layout = self.layout
1622
1623         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1624         layout.operator("pose.constraints_copy")
1625         layout.operator("pose.constraints_clear")
1626
1627
1628 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1629     _operator_name = "pose"
1630
1631
1632 class VIEW3D_MT_pose_apply(Menu):
1633     bl_label = "Apply"
1634
1635     def draw(self, context):
1636         layout = self.layout
1637
1638         layout.operator("pose.armature_apply")
1639         layout.operator("pose.visual_transform_apply")
1640
1641
1642 class VIEW3D_MT_pose_specials(Menu):
1643     bl_label = "Specials"
1644
1645     def draw(self, context):
1646         layout = self.layout
1647
1648         layout.operator("paint.weight_from_bones", text="Assign Automatic from Bones").type = 'AUTOMATIC'
1649         layout.operator("paint.weight_from_bones", text="Assign from Bone Envelopes").type = 'ENVELOPES'
1650
1651         layout.separator()
1652
1653         layout.operator("pose.select_constraint_target")
1654         layout.operator("pose.flip_names")
1655         layout.operator("pose.paths_calculate")
1656         layout.operator("pose.paths_clear")
1657         layout.operator("pose.user_transforms_clear")
1658         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
1659         layout.operator("pose.relax")
1660
1661         layout.separator()
1662
1663         layout.operator_menu_enum("pose.autoside_names", "axis")
1664
1665
1666 class BoneOptions:
1667     def draw(self, context):
1668         layout = self.layout
1669
1670         options = [
1671             "show_wire",
1672             "use_deform",
1673             "use_envelope_multiply",
1674             "use_inherit_rotation",
1675             "use_inherit_scale",
1676         ]
1677
1678         if context.mode == 'EDIT_ARMATURE':
1679             bone_props = bpy.types.EditBone.bl_rna.properties
1680             data_path_iter = "selected_bones"
1681             opt_suffix = ""
1682             options.append("lock")
1683         else:  # pose-mode
1684             bone_props = bpy.types.Bone.bl_rna.properties
1685             data_path_iter = "selected_pose_bones"
1686             opt_suffix = "bone."
1687
1688         for opt in options:
1689             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
1690                                     text_ctxt=i18n_contexts.default)
1691             props.data_path_iter = data_path_iter
1692             props.data_path_item = opt_suffix + opt
1693             props.type = self.type
1694
1695
1696 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1697     bl_label = "Toggle Bone Options"
1698     type = 'TOGGLE'
1699
1700
1701 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1702     bl_label = "Enable Bone Options"
1703     type = 'ENABLE'
1704
1705
1706 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1707     bl_label = "Disable Bone Options"
1708     type = 'DISABLE'
1709
1710 # ********** Edit Menus, suffix from ob.type **********
1711
1712
1713 class VIEW3D_MT_edit_mesh(Menu):
1714     bl_label = "Mesh"
1715
1716     def draw(self, context):
1717         layout = self.layout
1718
1719         toolsettings = context.tool_settings
1720
1721         layout.operator("ed.undo")
1722         layout.operator("ed.redo")
1723         layout.operator("ed.undo_history")
1724
1725         layout.separator()
1726
1727         layout.menu("VIEW3D_MT_transform")
1728         layout.menu("VIEW3D_MT_mirror")
1729         layout.menu("VIEW3D_MT_snap")
1730
1731         layout.separator()
1732
1733         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1734
1735         layout.separator()
1736         layout.operator("mesh.symmetrize")
1737         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1738         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1739         layout.operator("mesh.duplicate_move")
1740         layout.menu("VIEW3D_MT_edit_mesh_delete")
1741
1742         layout.separator()
1743
1744         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1745         layout.menu("VIEW3D_MT_edit_mesh_edges")
1746         layout.menu("VIEW3D_MT_edit_mesh_faces")
1747         layout.menu("VIEW3D_MT_edit_mesh_normals")
1748
1749         layout.separator()
1750
1751         layout.prop(toolsettings, "use_mesh_automerge")
1752         layout.prop_menu_enum(toolsettings, "proportional_edit")
1753         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1754
1755         layout.separator()
1756
1757         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1758
1759
1760 class VIEW3D_MT_edit_mesh_specials(Menu):
1761     bl_label = "Specials"
1762
1763     def draw(self, context):
1764         layout = self.layout
1765
1766         layout.operator_context = 'INVOKE_REGION_WIN'
1767
1768         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1769         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1770
1771         layout.separator()
1772
1773         layout.operator("mesh.merge", text="Merge...")
1774         layout.operator("mesh.remove_doubles")
1775
1776         layout.separator()
1777
1778         layout.operator("mesh.hide", text="Hide").unselected = False
1779         layout.operator("mesh.reveal", text="Reveal")
1780         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
1781
1782         layout.separator()
1783
1784         layout.operator("mesh.flip_normals")
1785         layout.operator("mesh.vertices_smooth", text="Smooth")
1786         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
1787
1788         layout.separator()
1789
1790         layout.operator("mesh.inset")
1791         layout.operator("mesh.bevel", text="Bevel")
1792         layout.operator("mesh.bridge_edge_loops")
1793
1794         layout.separator()
1795
1796         layout.operator("mesh.faces_shade_smooth")
1797         layout.operator("mesh.faces_shade_flat")
1798
1799         layout.separator()
1800
1801         layout.operator("mesh.blend_from_shape")
1802         layout.operator("mesh.shape_propagate_to_all")
1803         layout.operator("mesh.select_vertex_path")
1804         layout.operator("mesh.sort_elements")
1805         layout.operator("mesh.symmetrize")
1806
1807
1808 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1809     bl_label = "Mesh Select Mode"
1810
1811     def draw(self, context):
1812         layout = self.layout
1813
1814         layout.operator_context = 'INVOKE_REGION_WIN'
1815         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
1816         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
1817         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
1818
1819
1820 class VIEW3D_MT_edit_mesh_extrude(Menu):
1821     bl_label = "Extrude"
1822
1823     _extrude_funcs = {
1824         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1825         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1826         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1827         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1828     }
1829
1830     @staticmethod
1831     def extrude_options(context):
1832         mesh = context.object.data
1833         select_mode = context.tool_settings.mesh_select_mode
1834
1835         menu = []
1836         if mesh.total_face_sel:
1837             menu += ['REGION', 'FACE']
1838         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1839             menu += ['EDGE']
1840         if mesh.total_vert_sel and select_mode[0]:
1841             menu += ['VERT']
1842
1843         # should never get here
1844         return menu
1845
1846     def draw(self, context):
1847         layout = self.layout
1848         layout.operator_context = 'INVOKE_REGION_WIN'
1849
1850         for menu_id in self.extrude_options(context):
1851             self._extrude_funcs[menu_id](layout)
1852
1853
1854 class VIEW3D_MT_edit_mesh_vertices(Menu):
1855     bl_label = "Vertices"
1856
1857     def draw(self, context):
1858         layout = self.layout
1859         layout.operator_context = 'INVOKE_REGION_WIN'
1860
1861         layout.operator("mesh.merge")
1862         layout.operator("mesh.rip_move")
1863         layout.operator("mesh.rip_move_fill")
1864         layout.operator("mesh.split")
1865         layout.operator_menu_enum("mesh.separate", "type")
1866         layout.operator("mesh.vert_connect")
1867         layout.operator("transform.vert_slide")
1868
1869         layout.separator()
1870
1871         layout.operator("mesh.bevel").vertex_only = True
1872         layout.operator("mesh.vertices_smooth")
1873         layout.operator("mesh.remove_doubles")
1874         layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {'VERT'}
1875
1876         layout.operator("mesh.select_vertex_path")
1877
1878         layout.operator("mesh.blend_from_shape")
1879
1880         layout.operator("object.vertex_group_blend")
1881         layout.operator("mesh.shape_propagate_to_all")
1882
1883         layout.separator()
1884
1885         layout.menu("VIEW3D_MT_vertex_group")
1886         layout.menu("VIEW3D_MT_hook")
1887
1888
1889 class VIEW3D_MT_edit_mesh_edges(Menu):
1890     bl_label = "Edges"
1891
1892     def draw(self, context):
1893         layout = self.layout
1894         with_freestyle = bpy.app.build_options.freestyle
1895
1896         layout.operator_context = 'INVOKE_REGION_WIN'
1897
1898         layout.operator("mesh.edge_face_add")
1899         layout.operator("mesh.subdivide")
1900         layout.operator("mesh.unsubdivide")
1901
1902         layout.separator()
1903
1904         layout.operator("transform.edge_crease")
1905         layout.operator("transform.edge_bevelweight")
1906
1907         layout.separator()
1908
1909         layout.operator("mesh.mark_seam").clear = False
1910         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1911
1912         layout.separator()
1913
1914         layout.operator("mesh.mark_sharp").clear = False
1915         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1916
1917         layout.separator()
1918
1919         if with_freestyle:
1920             layout.operator("mesh.mark_freestyle_edge").clear = False
1921             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
1922
1923         layout.separator()
1924
1925         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1926         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
1927
1928         layout.separator()
1929
1930         layout.operator("mesh.bevel")
1931         layout.operator("mesh.edge_split")
1932         layout.operator("mesh.bridge_edge_loops")
1933         layout.operator("mesh.sort_elements", text="Sort Edges").elements = {'EDGE'}
1934
1935         layout.separator()
1936
1937         layout.operator("transform.edge_slide")
1938         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1939         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1940         layout.operator("mesh.loop_to_region")
1941         layout.operator("mesh.region_to_loop")
1942
1943
1944 class VIEW3D_MT_edit_mesh_faces(Menu):
1945     bl_label = "Faces"
1946     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1947
1948     def draw(self, context):
1949         layout = self.layout
1950         with_freestyle = bpy.app.build_options.freestyle
1951
1952         layout.operator_context = 'INVOKE_REGION_WIN'
1953
1954         layout.operator("mesh.flip_normals")
1955         layout.operator("mesh.edge_face_add")
1956         layout.operator("mesh.fill")
1957         layout.operator("mesh.beautify_fill")
1958         layout.operator("mesh.inset")
1959         layout.operator("mesh.bevel")
1960         layout.operator("mesh.solidify")
1961         layout.operator("mesh.wireframe")
1962         layout.operator("mesh.sort_elements", text="Sort Faces").elements = {'FACE'}
1963
1964         layout.separator()
1965
1966         if with_freestyle:
1967             layout.operator("mesh.mark_freestyle_face").clear = False
1968             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
1969
1970         layout.separator()
1971
1972         layout.operator("mesh.poke")
1973         layout.operator("mesh.quads_convert_to_tris")
1974         layout.operator("mesh.tris_convert_to_quads")
1975
1976         layout.separator()
1977
1978         layout.operator("mesh.faces_shade_smooth")
1979         layout.operator("mesh.faces_shade_flat")
1980
1981         layout.separator()
1982
1983         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1984
1985         layout.separator()
1986
1987         layout.operator("mesh.uvs_rotate")
1988         layout.operator("mesh.uvs_reverse")
1989         layout.operator("mesh.colors_rotate")
1990         layout.operator("mesh.colors_reverse")
1991
1992
1993 class VIEW3D_MT_edit_mesh_normals(Menu):
1994     bl_label = "Normals"
1995
1996     def draw(self, context):
1997         layout = self.layout
1998
1999         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
2000         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
2001
2002         layout.separator()
2003
2004         layout.operator("mesh.flip_normals")
2005
2006
2007 class VIEW3D_MT_edit_mesh_delete(Menu):
2008     bl_label = "Delete"
2009
2010     def draw(self, context):
2011         layout = self.layout
2012
2013         layout.operator_enum("mesh.delete", "type")
2014
2015         layout.separator()
2016
2017         layout.operator("mesh.dissolve")
2018         layout.operator("mesh.dissolve_limited")
2019
2020         layout.separator()
2021
2022         layout.operator("mesh.edge_collapse")
2023         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
2024
2025
2026 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2027     _operator_name = "mesh"
2028
2029 # Edit Curve
2030 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2031
2032
2033 def draw_curve(self, context):
2034     layout = self.layout
2035
2036     toolsettings = context.tool_settings
2037
2038     layout.menu("VIEW3D_MT_transform")
2039     layout.menu("VIEW3D_MT_mirror")
2040     layout.menu("VIEW3D_MT_snap")
2041
2042     layout.separator()
2043
2044     layout.operator("curve.extrude_move")
2045     layout.operator("curve.duplicate_move")
2046     layout.operator("curve.separate")
2047     layout.operator("curve.make_segment")
2048     layout.operator("curve.cyclic_toggle")
2049     layout.operator("curve.delete", text="Delete...")
2050
2051     layout.separator()
2052
2053     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2054     layout.menu("VIEW3D_MT_edit_curve_segments")
2055
2056     layout.separator()
2057
2058     layout.prop_menu_enum(toolsettings, "proportional_edit")
2059     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2060
2061     layout.separator()
2062
2063     layout.menu("VIEW3D_MT_edit_curve_showhide")
2064
2065
2066 class VIEW3D_MT_edit_curve(Menu):
2067     bl_label = "Curve"
2068
2069     draw = draw_curve
2070
2071
2072 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2073     bl_label = "Control Points"
2074
2075     def draw(self, context):
2076         layout = self.layout
2077
2078         edit_object = context.edit_object
2079
2080         if edit_object.type == 'CURVE':
2081             layout.operator("transform.tilt")
2082             layout.operator("curve.tilt_clear")
2083             layout.operator("curve.separate")
2084
2085             layout.separator()
2086
2087             layout.operator_menu_enum("curve.handle_type_set", "type")
2088
2089             layout.separator()
2090
2091         layout.menu("VIEW3D_MT_hook")
2092
2093
2094 class VIEW3D_MT_edit_curve_segments(Menu):
2095     bl_label = "Segments"
2096
2097     def draw(self, context):
2098         layout = self.layout
2099
2100         layout.operator("curve.subdivide")
2101         layout.operator("curve.switch_direction")
2102
2103
2104 class VIEW3D_MT_edit_curve_specials(Menu):
2105     bl_label = "Specials"
2106
2107     def draw(self, context):
2108         layout = self.layout
2109
2110         layout.operator("curve.subdivide")
2111         layout.operator("curve.switch_direction")
2112         layout.operator("curve.spline_weight_set")
2113         layout.operator("curve.radius_set")
2114         layout.operator("curve.smooth")
2115         layout.operator("curve.smooth_radius")
2116
2117
2118 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2119     _operator_name = "curve"
2120
2121
2122 class VIEW3D_MT_edit_surface(Menu):
2123     bl_label = "Surface"
2124
2125     draw = draw_curve
2126
2127
2128 class VIEW3D_MT_edit_font(Menu):
2129     bl_label = "Text"
2130
2131     def draw(self, context):
2132         layout = self.layout
2133
2134         layout.operator("font.file_paste")
2135
2136         layout.separator()
2137
2138         layout.menu("VIEW3D_MT_edit_text_chars")
2139
2140         layout.separator()
2141
2142         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2143         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2144         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2145         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2146
2147
2148 class VIEW3D_MT_edit_text_chars(Menu):
2149     bl_label = "Special Characters"
2150
2151     def draw(self, context):
2152         layout = self.layout
2153
2154         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2155         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2156
2157         layout.separator()
2158
2159         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2160         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2161         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2162         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2163         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2164         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2165         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2166         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2167         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2168
2169         layout.separator()
2170
2171         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2172         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2173         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2174
2175         layout.separator()
2176
2177         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2178         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2179         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2180
2181
2182 class VIEW3D_MT_edit_meta(Menu):
2183     bl_label = "Metaball"
2184
2185     def draw(self, context):
2186         layout = self.layout
2187
2188         toolsettings = context.tool_settings
2189
2190         layout.operator("ed.undo")
2191         layout.operator("ed.redo")
2192         layout.operator("ed.undo_history")
2193
2194         layout.separator()
2195
2196         layout.menu("VIEW3D_MT_transform")
2197         layout.menu("VIEW3D_MT_mirror")
2198         layout.menu("VIEW3D_MT_snap")
2199
2200         layout.separator()
2201
2202         layout.operator("mball.delete_metaelems", text="Delete...")
2203         layout.operator("mball.duplicate_metaelems")
2204
2205         layout.separator()
2206
2207         layout.prop_menu_enum(toolsettings, "proportional_edit")
2208         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2209
2210         layout.separator()
2211
2212         layout.menu("VIEW3D_MT_edit_meta_showhide")
2213
2214
2215 class VIEW3D_MT_edit_meta_showhide(Menu):
2216     bl_label = "Show/Hide"
2217
2218     def draw(self, context):
2219         layout = self.layout
2220
2221         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2222         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2223         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2224
2225
2226 class VIEW3D_MT_edit_lattice(Menu):
2227     bl_label = "Lattice"
2228
2229     def draw(self, context):
2230         layout = self.layout
2231
2232         toolsettings = context.tool_settings
2233
2234         layout.menu("VIEW3D_MT_transform")
2235         layout.menu("VIEW3D_MT_mirror")
2236         layout.menu("VIEW3D_MT_snap")
2237         layout.operator_menu_enum("lattice.flip", "axis")
2238
2239         layout.separator()
2240
2241         layout.operator("lattice.make_regular")
2242
2243         layout.separator()
2244
2245         layout.prop_menu_enum(toolsettings, "proportional_edit")
2246         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2247
2248
2249 class VIEW3D_MT_edit_armature(Menu):
2250     bl_label = "Armature"
2251
2252     def draw(self, context):
2253         layout = self.layout
2254
2255         edit_object = context.edit_object
2256         arm = edit_object.data
2257
2258         layout.menu("VIEW3D_MT_transform_armature")
2259         layout.menu("VIEW3D_MT_mirror")
2260         layout.menu("VIEW3D_MT_snap")
2261         layout.menu("VIEW3D_MT_edit_armature_roll")
2262
2263         layout.separator()
2264
2265         layout.operator("armature.extrude_move")
2266
2267         if arm.use_mirror_x:
2268             layout.operator("armature.extrude_forked")
2269
2270         layout.operator("armature.duplicate_move")
2271         layout.operator("armature.merge")
2272         layout.operator("armature.fill")
2273         layout.operator("armature.delete")
2274         layout.operator("armature.separate")
2275
2276         layout.separator()
2277
2278         layout.operator("armature.subdivide", text="Subdivide")
2279         layout.operator("armature.switch_direction", text="Switch Direction")
2280
2281         layout.separator()
2282
2283         layout.operator_context = 'EXEC_AREA'
2284         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2285         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2286         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2287         layout.operator("armature.flip_names")
2288
2289         layout.separator()
2290
2291         layout.operator_context = 'INVOKE_DEFAULT'
2292         layout.operator("armature.armature_layers")
2293         layout.operator("armature.bone_layers")
2294
2295         layout.separator()
2296
2297         layout.menu("VIEW3D_MT_edit_armature_parent")
2298
2299         layout.separator()
2300
2301         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2302
2303
2304 class VIEW3D_MT_armature_specials(Menu):
2305     bl_label = "Specials"
2306
2307     def draw(self, context):
2308         layout = self.layout
2309
2310         layout.operator_context = 'INVOKE_REGION_WIN'
2311
2312         layout.operator("armature.subdivide", text="Subdivide")
2313         layout.operator("armature.switch_direction", text="Switch Direction")
2314
2315         layout.separator()
2316
2317         layout.operator_context = 'EXEC_REGION_WIN'
2318         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2319         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2320         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2321         layout.operator("armature.flip_names", text="Flip Names")
2322
2323
2324 class VIEW3D_MT_edit_armature_parent(Menu):
2325     bl_label = "Parent"
2326
2327     def draw(self, context):
2328         layout = self.layout
2329
2330         layout.operator("armature.parent_set", text="Make")
2331         layout.operator("armature.parent_clear", text="Clear")
2332
2333
2334 class VIEW3D_MT_edit_armature_roll(Menu):
2335     bl_label = "Bone Roll"
2336
2337     def draw(self, context):
2338         layout = self.layout
2339
2340         layout.operator_menu_enum("armature.calculate_roll", "type")
2341
2342         layout.separator()
2343
2344         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2345
2346 # ********** Panel **********
2347
2348
2349 class VIEW3D_PT_view3d_properties(Panel):
2350     bl_space_type = 'VIEW_3D'
2351     bl_region_type = 'UI'
2352     bl_label = "View"
2353
2354     @classmethod
2355     def poll(cls, context):
2356         view = context.space_data
2357         return (view)
2358
2359     def draw(self, context):
2360         layout = self.layout
2361
2362         view = context.space_data
2363
2364         col = layout.column()
2365         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2366                           view.region_quadview)
2367         col.prop(view, "lens")
2368         col.label(text="Lock to Object:")
2369         col.prop(view, "lock_object", text="")
2370         lock_object = view.lock_object
2371         if lock_object:
2372             if lock_object.type == 'ARMATURE':
2373                 col.prop_search(view, "lock_bone", lock_object.data,
2374                                 "edit_bones" if lock_object.mode == 'EDIT'
2375                                 else "bones",
2376                                 text="")
2377         else:
2378             col.prop(view, "lock_cursor", text="Lock to Cursor")
2379
2380         col = layout.column()
2381         col.prop(view, "lock_camera")
2382
2383         col = layout.column(align=True)
2384         col.label(text="Clip:")
2385         col.prop(view, "clip_start", text="Start")
2386         col.prop(view, "clip_end", text="End")
2387
2388         subcol = col.column()
2389         subcol.enabled = not view.lock_camera_and_layers
2390         subcol.label(text="Local Camera:")
2391         subcol.prop(view, "camera", text="")
2392
2393         col = layout.column(align=True)
2394         col.prop(view, "use_render_border")
2395
2396
2397 class VIEW3D_PT_view3d_cursor(Panel):
2398     bl_space_type = 'VIEW_3D'
2399     bl_region_type = 'UI'
2400     bl_label = "3D Cursor"
2401
2402     @classmethod
2403     def poll(cls, context):
2404         view = context.space_data
2405         return (view is not None)
2406
2407     def draw(self, context):
2408         layout = self.layout
2409
2410         view = context.space_data
2411         layout.column().prop(view, "cursor_location", text="Location")
2412
2413
2414 class VIEW3D_PT_view3d_name(Panel):
2415     bl_space_type = 'VIEW_3D'
2416     bl_region_type = 'UI'
2417     bl_label = "Item"
2418
2419     @classmethod
2420     def poll(cls, context):
2421         return (context.space_data and context.active_object)
2422
2423     def draw(self, context):
2424         layout = self.layout
2425
2426         ob = context.active_object
2427         row = layout.row()
2428         row.label(text="", icon='OBJECT_DATA')
2429         row.prop(ob, "name", text="")
2430
2431         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2432             bone = context.active_bone
2433             if bone:
2434                 row = layout.row()
2435                 row.label(text="", icon='BONE_DATA')
2436                 row.prop(bone, "name", text="")
2437
2438
2439 class VIEW3D_PT_view3d_display(Panel):
2440     bl_space_type = 'VIEW_3D'
2441     bl_region_type = 'UI'
2442     bl_label = "Display"
2443     bl_options = {'DEFAULT_CLOSED'}
2444
2445     @classmethod
2446     def poll(cls, context):
2447         view = context.space_data
2448         return (view)
2449
2450     def draw(self, context):
2451         layout = self.layout
2452
2453         view = context.space_data
2454         scene = context.scene
2455         gs = scene.game_settings
2456         ob = context.object
2457
2458         col = layout.column()
2459         col.prop(view, "show_only_render")
2460
2461         col = layout.column()
2462         display_all = not view.show_only_render
2463         col.active = display_all
2464         col.prop(view, "show_outline_selected")
2465         col.prop(view, "show_all_objects_origin")
2466         col.prop(view, "show_relationship_lines")
2467
2468         col = layout.column()
2469         col.active = display_all
2470         split = col.split(percentage=0.55)
2471         split.prop(view, "show_floor", text="Grid Floor")
2472
2473         row = split.row(align=True)
2474         row.prop(view, "show_axis_x", text="X", toggle=True)
2475         row.prop(view, "show_axis_y", text="Y", toggle=True)
2476         row.prop(view, "show_axis_z", text="Z", toggle=True)
2477
2478         sub = col.column(align=True)
2479         sub.active = (display_all and view.show_floor)
2480         sub.prop(view, "grid_lines", text="Lines")
2481         sub.prop(view, "grid_scale", text="Scale")
2482         subsub = sub.column(align=True)
2483         subsub.active = scene.unit_settings.system == 'NONE'
2484         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2485
2486         if not scene.render.use_shading_nodes:
2487             col = layout.column()
2488             col.label(text="Shading:")
2489             col.prop(gs, "material_mode", text="")
2490             col.prop(view, "show_textured_solid")
2491         if view.viewport_shade == 'SOLID':
2492             col.prop(view, "use_matcap")
2493             if view.use_matcap:
2494                 col.template_icon_view(view, "matcap_icon")
2495         col.prop(view, "show_backface_culling")
2496
2497         layout.separator()
2498
2499         region = view.region_quadview
2500
2501         layout.operator("screen.region_quadview", text="Toggle Quad View")
2502
2503         if region:
2504             col = layout.column()
2505             col.prop(region, "lock_rotation")
2506             row = col.row()
2507             row.enabled = region.lock_rotation
2508             row.prop(region, "show_sync_view")
2509             row = col.row()
2510             row.enabled = region.lock_rotation and region.show_sync_view
2511             row.prop(region, "use_box_clip")
2512
2513
2514 class VIEW3D_PT_view3d_motion_tracking(Panel):
2515     bl_space_type = 'VIEW_3D'
2516     bl_region_type = 'UI'
2517     bl_label = "Motion Tracking"
2518     bl_options = {'DEFAULT_CLOSED'}
2519
2520     @classmethod
2521     def poll(cls, context):
2522         view = context.space_data
2523         return (view)
2524
2525     def draw_header(self, context):
2526         view = context.space_data
2527
2528         self.layout.prop(view, "show_reconstruction", text="")
2529
2530     def draw(self, context):
2531         layout = self.layout
2532
2533         view = context.space_data
2534
2535         col = layout.column()
2536         col.active = view.show_reconstruction
2537         col.prop(view, "show_bundle_names")
2538         col.prop(view, "show_camera_path")
2539         col.label(text="Tracks:")
2540         col.prop(view, "tracks_draw_type", text="")
2541         col.prop(view, "tracks_draw_size", text="Size")
2542
2543
2544 class VIEW3D_PT_view3d_meshdisplay(Panel):
2545     bl_space_type = 'VIEW_3D'
2546     bl_region_type = 'UI'
2547     bl_label = "Mesh Display"
2548
2549     @classmethod
2550     def poll(cls, context):
2551         # The active object check is needed because of local-mode
2552         return (context.active_object and (context.mode == 'EDIT_MESH'))
2553
2554     def draw(self, context):
2555         layout = self.layout
2556         with_freestyle = bpy.app.build_options.freestyle
2557
2558         mesh = context.active_object.data
2559
2560         layout.prop(mesh, "show_weight")
2561
2562         split = layout.split()
2563
2564         col = split.column()
2565         col.label(text="Overlays:")
2566         col.prop(mesh, "show_faces", text="Faces")
2567         col.prop(mesh, "show_edges", text="Edges")
2568         col.prop(mesh, "show_edge_crease", text="Creases")
2569         if with_freestyle:
2570             col.prop(mesh, "show_edge_seams", text="Seams")
2571
2572         col = split.column()
2573         col.label()
2574         if not with_freestyle:
2575             col.prop(mesh, "show_edge_seams", text="Seams")
2576         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
2577         col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
2578         if with_freestyle:
2579             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
2580             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
2581
2582         col = layout.column()
2583
2584         col.separator()
2585         col.label(text="Normals:")
2586         row = col.row()
2587
2588         sub = row.row(align=True)
2589         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2590         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2591
2592         sub = row.row(align=True)
2593         sub.active = mesh.show_normal_vertex or mesh.show_normal_face
2594         sub.prop(context.scene.tool_settings, "normal_size", text="Size")
2595
2596         col.separator()
2597         split = layout.split()
2598         col = split.column()
2599         col.label(text="Edge Info:")
2600         col.prop(mesh, "show_extra_edge_length", text="Length")
2601         col.prop(mesh, "show_extra_edge_angle", text="Angle")
2602         col = split.column()
2603         col.label(text="Face Info:")
2604         col.prop(mesh, "show_extra_face_area", text="Area")
2605         col.prop(mesh, "show_extra_face_angle", text="Angle")
2606         if bpy.app.debug:
2607             layout.prop(mesh, "show_extra_indices")
2608
2609
2610 class VIEW3D_PT_view3d_meshstatvis(Panel):
2611     bl_space_type = 'VIEW_3D'
2612     bl_region_type = 'UI'
2613     bl_label = "Mesh Debug"
2614
2615     @classmethod
2616     def poll(cls, context):
2617         # The active object check is needed because of local-mode
2618         return (context.active_object and (context.mode == 'EDIT_MESH'))
2619
2620     def draw_header(self, context):
2621         mesh = context.active_object.data
2622
2623         self.layout.prop(mesh, "show_statvis", text="")
2624
2625     def draw(self, context):
2626         layout = self.layout
2627
2628         mesh = context.active_object.data
2629         statvis = context.tool_settings.statvis
2630         layout.active = mesh.show_statvis
2631
2632         layout.prop(statvis, "type")
2633         statvis_type = statvis.type
2634         if statvis_type == 'OVERHANG':
2635             row = layout.row(align=True)
2636             row.prop(statvis, "overhang_min", text="")
2637             row.prop(statvis, "overhang_max", text="")
2638             layout.prop(statvis, "overhang_axis", expand=True)
2639         elif statvis_type == 'THICKNESS':
2640             row = layout.row(align=True)
2641             row.prop(statvis, "thickness_min", text="")
2642             row.prop(statvis, "thickness_max", text="")
2643             layout.prop(statvis, "thickness_samples")
2644         elif statvis_type == 'INTERSECT':
2645             pass
2646         elif statvis_type == 'DISTORT':
2647             row = layout.row(align=True)
2648             row.prop(statvis, "distort_min", text="")
2649             row.prop(statvis, "distort_max", text="")
2650         elif statvis_type == 'SHARP':
2651             row = layout.row(align=True)
2652             row.prop(statvis, "sharp_min", text="")
2653             row.prop(statvis, "sharp_max", text="")
2654
2655
2656 class VIEW3D_PT_view3d_curvedisplay(Panel):
2657     bl_space_type = 'VIEW_3D'
2658     bl_region_type = 'UI'
2659     bl_label = "Curve Display"
2660
2661     @classmethod
2662     def poll(cls, context):
2663         editmesh = context.mode == 'EDIT_CURVE'
2664         return (editmesh)
2665
2666     def draw(self, context):
2667         layout = self.layout
2668
2669         curve = context.active_object.data
2670
2671         col = layout.column()
2672         col.label(text="Overlays:")
2673         col.prop(curve, "show_handles", text="Handles")
2674         col.prop(curve, "show_normal_face", text="Normals")
2675         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2676
2677
2678 class VIEW3D_PT_background_image(Panel):
2679     bl_space_type = 'VIEW_3D'
2680     bl_region_type = 'UI'
2681     bl_label = "Background Images"
2682     bl_options = {'DEFAULT_CLOSED'}
2683
2684     def draw_header(self, context):
2685         view = context.space_data
2686
2687         self.layout.prop(view, "show_background_images", text="")
2688
2689     def draw(self, context):
2690         layout = self.layout
2691
2692         view = context.space_data
2693
2694         col = layout.column()
2695         col.operator("view3d.background_image_add", text="Add Image")
2696
2697         for i, bg in enumerate(view.background_images):
2698             layout.active = view.show_background_images
2699             box = layout.box()
2700             row = box.row(align=True)
2701             row.prop(bg, "show_expanded", text="", emboss=False)
2702             if bg.source == 'IMAGE' and bg.image:
2703                 row.prop(bg.image, "name", text="", emboss=False)
2704             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2705                 row.prop(bg.clip, "name", text="", emboss=False)
2706             else:
2707                 row.label(text="Not Set")
2708
2709             if bg.show_background_image:
2710                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2711             else:
2712                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2713
2714             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2715
2716             box.prop(bg, "view_axis", text="Axis")
2717
2718             if bg.show_expanded:
2719                 row = box.row()
2720                 row.prop(bg, "source", expand=True)
2721
2722                 has_bg = False
2723                 if bg.source == 'IMAGE':
2724                     row = box.row()
2725                     row.template_ID(bg, "image", open="image.open")
2726                     if bg.image is not None:
2727                         box.template_image(bg, "image", bg.image_user, compact=True)
2728                         has_bg = True
2729
2730                 elif bg.source == 'MOVIE_CLIP':
2731                     box.prop(bg, "use_camera_clip")
2732
2733                     column = box.column()
2734                     column.active = not bg.use_camera_clip
2735                     column.template_ID(bg, "clip", open="clip.open")
2736
2737                     if bg.clip:
2738                         column.template_movieclip(bg, "clip", compact=True)
2739
2740                     if bg.use_camera_clip or bg.clip:
2741                         has_bg = True
2742
2743                     column = box.column()
2744                     column.active = has_bg
2745                     column.prop(bg.clip_user, "proxy_render_size", text="")
2746                     column.prop(bg.clip_user, "use_render_undistorted")
2747
2748                 if has_bg:
2749                     col = box.column()
2750                     col.prop(bg, "opacity", slider=True)
2751                     col.row().prop(bg, "draw_depth", expand=True)
2752
2753                     if bg.view_axis in {'CAMERA', 'ALL'}:
2754                         col.row().prop(bg, "frame_method", expand=True)
2755
2756                     row = col.row(align=True)
2757                     row.prop(bg, "offset_x", text="X")
2758                     row.prop(bg, "offset_y", text="Y")
2759
2760                     if bg.view_axis != 'CAMERA':
2761                         col.prop(bg, "size")
2762
2763
2764 class VIEW3D_PT_transform_orientations(Panel):
2765     bl_space_type = 'VIEW_3D'
2766     bl_region_type = 'UI'
2767     bl_label = "Transform Orientations"
2768     bl_options = {'DEFAULT_CLOSED'}
2769
2770     @classmethod
2771     def poll(cls, context):
2772         view = context.space_data
2773         return (view)
2774
2775     def draw(self, context):
2776         layout = self.layout
2777
2778         view = context.space_data
2779         orientation = view.current_orientation
2780
2781         row = layout.row(align=True)
2782         row.prop(view, "transform_orientation", text="")
2783         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2784
2785         if orientation:
2786             row = layout.row(align=True)
2787             row.prop(orientation, "name", text="")
2788             row.operator("transform.delete_orientation", text="", icon="X")
2789
2790
2791 class VIEW3D_PT_etch_a_ton(Panel):
2792     bl_space_type = 'VIEW_3D'
2793     bl_region_type = 'UI'
2794     bl_label = "Skeleton Sketching"
2795     bl_options = {'DEFAULT_CLOSED'}
2796
2797     @classmethod
2798     def poll(cls, context):
2799         scene = context.space_data
2800         ob = context.active_object
2801         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2802
2803     def draw_header(self, context):
2804         layout = self.layout
2805         toolsettings = context.scene.tool_settings
2806
2807         layout.prop(toolsettings, "use_bone_sketching", text="")
2808
2809     def draw(self, context):
2810         layout = self.layout
2811
2812         toolsettings = context.scene.tool_settings
2813
2814         col = layout.column()
2815
2816         col.prop(toolsettings, "use_etch_quick")
2817         col.prop(toolsettings, "use_etch_overdraw")
2818
2819         col.separator()
2820
2821         col.prop(toolsettings, "etch_convert_mode")
2822
2823         if toolsettings.etch_convert_mode == 'LENGTH':
2824             col.prop(toolsettings, "etch_length_limit")
2825         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2826             col.prop(toolsettings, "etch_adaptive_limit")
2827         elif toolsettings.etch_convert_mode == 'FIXED':
2828             col.prop(toolsettings, "etch_subdivision_number")
2829         elif toolsettings.etch_convert_mode == 'RETARGET':
2830             col.prop(toolsettings, "etch_template")
2831             col.prop(toolsettings, "etch_roll_mode")
2832
2833             col.separator()
2834
2835             colsub = col.column(align=True)
2836             colsub.prop(toolsettings, "use_etch_autoname")
2837             sub = colsub.column()
2838             sub.enabled = not toolsettings.use_etch_autoname
2839             sub.prop(toolsettings, "etch_number")
2840             sub.prop(toolsettings, "etch_side")
2841
2842         col.separator()
2843
2844         col.operator("sketch.convert", text="Convert to Bones")
2845         col.operator("sketch.delete", text="Delete Strokes")
2846
2847
2848 class VIEW3D_PT_context_properties(Panel):
2849     bl_space_type = 'VIEW_3D'
2850     bl_region_type = 'UI'
2851     bl_label = "Properties"
2852     bl_options = {'DEFAULT_CLOSED'}
2853
2854     def _active_context_member(context):
2855         obj = context.object
2856         if obj:
2857             mode = obj.mode
2858             if mode == 'POSE':
2859                 return "active_pose_bone"
2860             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2861                 return "active_bone"
2862             else:
2863                 return "object"
2864
2865         return ""
2866
2867     @classmethod
2868     def poll(cls, context):
2869         member = cls._active_context_member(context)
2870         if member:
2871             context_member = getattr(context, member)
2872             return context_member and context_member.keys()
2873
2874         return False
2875
2876     def draw(self, context):
2877         import rna_prop_ui
2878         member = VIEW3D_PT_context_properties._active_context_member(context)
2879
2880         if member:
2881             # Draw with no edit button
2882             rna_prop_ui.draw(self.layout, context, member, object, False)
2883
2884
2885 def register():
2886     bpy.utils.register_module(__name__)
2887
2888
2889 def unregister():
2890     bpy.utils.unregister_module(__name__)
2891
2892 if __name__ == "__main__":
2893     register()
2894
2895 if __name__ == "__main__":  # only for live edit.
2896     bpy.utils.register_module(__name__)