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