Minor white space fix.
[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         layout.operator("pose.select_constraint_target")
1645         layout.operator("pose.flip_names")
1646         layout.operator("pose.paths_calculate")
1647         layout.operator("pose.paths_clear")
1648         layout.operator("pose.user_transforms_clear")
1649         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
1650         layout.operator("pose.relax")
1651
1652         layout.separator()
1653
1654         layout.operator_menu_enum("pose.autoside_names", "axis")
1655
1656
1657 class BoneOptions:
1658     def draw(self, context):
1659         layout = self.layout
1660
1661         options = [
1662             "show_wire",
1663             "use_deform",
1664             "use_envelope_multiply",
1665             "use_inherit_rotation",
1666             "use_inherit_scale",
1667         ]
1668
1669         if context.mode == 'EDIT_ARMATURE':
1670             bone_props = bpy.types.EditBone.bl_rna.properties
1671             data_path_iter = "selected_bones"
1672             opt_suffix = ""
1673             options.append("lock")
1674         else:  # pose-mode
1675             bone_props = bpy.types.Bone.bl_rna.properties
1676             data_path_iter = "selected_pose_bones"
1677             opt_suffix = "bone."
1678
1679         for opt in options:
1680             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
1681                                     text_ctxt=i18n_contexts.default)
1682             props.data_path_iter = data_path_iter
1683             props.data_path_item = opt_suffix + opt
1684             props.type = self.type
1685
1686
1687 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1688     bl_label = "Toggle Bone Options"
1689     type = 'TOGGLE'
1690
1691
1692 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1693     bl_label = "Enable Bone Options"
1694     type = 'ENABLE'
1695
1696
1697 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1698     bl_label = "Disable Bone Options"
1699     type = 'DISABLE'
1700
1701 # ********** Edit Menus, suffix from ob.type **********
1702
1703
1704 class VIEW3D_MT_edit_mesh(Menu):
1705     bl_label = "Mesh"
1706
1707     def draw(self, context):
1708         layout = self.layout
1709
1710         toolsettings = context.tool_settings
1711
1712         layout.operator("ed.undo")
1713         layout.operator("ed.redo")
1714         layout.operator("ed.undo_history")
1715
1716         layout.separator()
1717
1718         layout.menu("VIEW3D_MT_transform")
1719         layout.menu("VIEW3D_MT_mirror")
1720         layout.menu("VIEW3D_MT_snap")
1721
1722         layout.separator()
1723
1724         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1725
1726         layout.separator()
1727         layout.operator("mesh.symmetrize")
1728         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1729         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1730         layout.operator("mesh.duplicate_move")
1731         layout.menu("VIEW3D_MT_edit_mesh_delete")
1732
1733         layout.separator()
1734
1735         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1736         layout.menu("VIEW3D_MT_edit_mesh_edges")
1737         layout.menu("VIEW3D_MT_edit_mesh_faces")
1738         layout.menu("VIEW3D_MT_edit_mesh_normals")
1739
1740         layout.separator()
1741
1742         layout.prop(toolsettings, "use_mesh_automerge")
1743         layout.prop_menu_enum(toolsettings, "proportional_edit")
1744         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1745
1746         layout.separator()
1747
1748         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1749
1750
1751 class VIEW3D_MT_edit_mesh_specials(Menu):
1752     bl_label = "Specials"
1753
1754     def draw(self, context):
1755         layout = self.layout
1756
1757         layout.operator_context = 'INVOKE_REGION_WIN'
1758
1759         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1760         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1761
1762         layout.separator()
1763
1764         layout.operator("mesh.merge", text="Merge...")
1765         layout.operator("mesh.remove_doubles")
1766
1767         layout.separator()
1768
1769         layout.operator("mesh.hide", text="Hide").unselected = False
1770         layout.operator("mesh.reveal", text="Reveal")
1771         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
1772
1773         layout.separator()
1774
1775         layout.operator("mesh.flip_normals")
1776         layout.operator("mesh.vertices_smooth", text="Smooth")
1777         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
1778
1779         layout.separator()
1780
1781         layout.operator("mesh.inset")
1782         layout.operator("mesh.bevel", text="Bevel")
1783         layout.operator("mesh.bridge_edge_loops")
1784
1785         layout.separator()
1786
1787         layout.operator("mesh.faces_shade_smooth")
1788         layout.operator("mesh.faces_shade_flat")
1789
1790         layout.separator()
1791
1792         layout.operator("mesh.blend_from_shape")
1793         layout.operator("mesh.shape_propagate_to_all")
1794         layout.operator("mesh.select_vertex_path")
1795         layout.operator("mesh.sort_elements")
1796         layout.operator("mesh.symmetrize")
1797
1798
1799 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1800     bl_label = "Mesh Select Mode"
1801
1802     def draw(self, context):
1803         layout = self.layout
1804
1805         layout.operator_context = 'INVOKE_REGION_WIN'
1806         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
1807         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
1808         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
1809
1810
1811 class VIEW3D_MT_edit_mesh_extrude(Menu):
1812     bl_label = "Extrude"
1813
1814     _extrude_funcs = {
1815         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1816         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1817         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1818         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1819     }
1820
1821     @staticmethod
1822     def extrude_options(context):
1823         mesh = context.object.data
1824         select_mode = context.tool_settings.mesh_select_mode
1825
1826         menu = []
1827         if mesh.total_face_sel:
1828             menu += ['REGION', 'FACE']
1829         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1830             menu += ['EDGE']
1831         if mesh.total_vert_sel and select_mode[0]:
1832             menu += ['VERT']
1833
1834         # should never get here
1835         return menu
1836
1837     def draw(self, context):
1838         layout = self.layout
1839         layout.operator_context = 'INVOKE_REGION_WIN'
1840
1841         for menu_id in self.extrude_options(context):
1842             self._extrude_funcs[menu_id](layout)
1843
1844
1845 class VIEW3D_MT_edit_mesh_vertices(Menu):
1846     bl_label = "Vertices"
1847
1848     def draw(self, context):
1849         layout = self.layout
1850         layout.operator_context = 'INVOKE_REGION_WIN'
1851
1852         layout.operator("mesh.merge")
1853         layout.operator("mesh.rip_move")
1854         layout.operator("mesh.rip_move_fill")
1855         layout.operator("mesh.split")
1856         layout.operator_menu_enum("mesh.separate", "type")
1857         layout.operator("mesh.vert_connect")
1858         layout.operator("transform.vert_slide")
1859
1860         layout.separator()
1861
1862         layout.operator("mesh.bevel").vertex_only = True
1863         layout.operator("mesh.vertices_smooth")
1864         layout.operator("mesh.remove_doubles")
1865         layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {'VERT'}
1866
1867         layout.operator("mesh.select_vertex_path")
1868
1869         layout.operator("mesh.blend_from_shape")
1870
1871         layout.operator("object.vertex_group_blend")
1872         layout.operator("mesh.shape_propagate_to_all")
1873
1874         layout.separator()
1875
1876         layout.menu("VIEW3D_MT_vertex_group")
1877         layout.menu("VIEW3D_MT_hook")
1878
1879
1880 class VIEW3D_MT_edit_mesh_edges(Menu):
1881     bl_label = "Edges"
1882
1883     def draw(self, context):
1884         layout = self.layout
1885
1886         layout.operator_context = 'INVOKE_REGION_WIN'
1887
1888         layout.operator("mesh.edge_face_add")
1889         layout.operator("mesh.subdivide")
1890         layout.operator("mesh.unsubdivide")
1891
1892         layout.separator()
1893
1894         layout.operator("transform.edge_crease")
1895         layout.operator("transform.edge_bevelweight")
1896
1897         layout.separator()
1898
1899         layout.operator("mesh.mark_seam").clear = False
1900         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1901
1902         layout.separator()
1903
1904         layout.operator("mesh.mark_sharp").clear = False
1905         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1906
1907         layout.separator()
1908
1909         if context.scene and bpy.app.build_options.freestyle:
1910             layout.operator("mesh.mark_freestyle_edge").clear = False
1911             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").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         if context.scene and bpy.app.build_options.freestyle:
1956             layout.operator("mesh.mark_freestyle_face").clear = False
1957             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
1958
1959         layout.separator()
1960
1961         layout.operator("mesh.quads_convert_to_tris")
1962         layout.operator("mesh.tris_convert_to_quads")
1963
1964         layout.separator()
1965
1966         layout.operator("mesh.faces_shade_smooth")
1967         layout.operator("mesh.faces_shade_flat")
1968
1969         layout.separator()
1970
1971         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1972
1973         layout.separator()
1974
1975         layout.operator("mesh.uvs_rotate")
1976         layout.operator("mesh.uvs_reverse")
1977         layout.operator("mesh.colors_rotate")
1978         layout.operator("mesh.colors_reverse")
1979
1980
1981 class VIEW3D_MT_edit_mesh_normals(Menu):
1982     bl_label = "Normals"
1983
1984     def draw(self, context):
1985         layout = self.layout
1986
1987         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1988         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1989
1990         layout.separator()
1991
1992         layout.operator("mesh.flip_normals")
1993
1994
1995 class VIEW3D_MT_edit_mesh_delete(Menu):
1996     bl_label = "Delete"
1997
1998     def draw(self, context):
1999         layout = self.layout
2000
2001         layout.operator_enum("mesh.delete", "type")
2002
2003         layout.separator()
2004
2005         layout.operator("mesh.dissolve")
2006         layout.operator("mesh.dissolve_limited")
2007
2008         layout.separator()
2009
2010         layout.operator("mesh.edge_collapse")
2011         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
2012
2013
2014 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2015     _operator_name = "mesh"
2016
2017 # Edit Curve
2018 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2019
2020
2021 def draw_curve(self, context):
2022     layout = self.layout
2023
2024     toolsettings = context.tool_settings
2025
2026     layout.menu("VIEW3D_MT_transform")
2027     layout.menu("VIEW3D_MT_mirror")
2028     layout.menu("VIEW3D_MT_snap")
2029
2030     layout.separator()
2031
2032     layout.operator("curve.extrude_move")
2033     layout.operator("curve.duplicate_move")
2034     layout.operator("curve.separate")
2035     layout.operator("curve.make_segment")
2036     layout.operator("curve.cyclic_toggle")
2037     layout.operator("curve.delete", text="Delete...")
2038
2039     layout.separator()
2040
2041     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2042     layout.menu("VIEW3D_MT_edit_curve_segments")
2043
2044     layout.separator()
2045
2046     layout.prop_menu_enum(toolsettings, "proportional_edit")
2047     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2048
2049     layout.separator()
2050
2051     layout.menu("VIEW3D_MT_edit_curve_showhide")
2052
2053
2054 class VIEW3D_MT_edit_curve(Menu):
2055     bl_label = "Curve"
2056
2057     draw = draw_curve
2058
2059
2060 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2061     bl_label = "Control Points"
2062
2063     def draw(self, context):
2064         layout = self.layout
2065
2066         edit_object = context.edit_object
2067
2068         if edit_object.type == 'CURVE':
2069             layout.operator("transform.tilt")
2070             layout.operator("curve.tilt_clear")
2071             layout.operator("curve.separate")
2072
2073             layout.separator()
2074
2075             layout.operator_menu_enum("curve.handle_type_set", "type")
2076
2077             layout.separator()
2078
2079         layout.menu("VIEW3D_MT_hook")
2080
2081
2082 class VIEW3D_MT_edit_curve_segments(Menu):
2083     bl_label = "Segments"
2084
2085     def draw(self, context):
2086         layout = self.layout
2087
2088         layout.operator("curve.subdivide")
2089         layout.operator("curve.switch_direction")
2090
2091
2092 class VIEW3D_MT_edit_curve_specials(Menu):
2093     bl_label = "Specials"
2094
2095     def draw(self, context):
2096         layout = self.layout
2097
2098         layout.operator("curve.subdivide")
2099         layout.operator("curve.switch_direction")
2100         layout.operator("curve.spline_weight_set")
2101         layout.operator("curve.radius_set")
2102         layout.operator("curve.smooth")
2103         layout.operator("curve.smooth_radius")
2104
2105
2106 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2107     _operator_name = "curve"
2108
2109
2110 class VIEW3D_MT_edit_surface(Menu):
2111     bl_label = "Surface"
2112
2113     draw = draw_curve
2114
2115
2116 class VIEW3D_MT_edit_font(Menu):
2117     bl_label = "Text"
2118
2119     def draw(self, context):
2120         layout = self.layout
2121
2122         layout.operator("font.file_paste")
2123
2124         layout.separator()
2125
2126         layout.menu("VIEW3D_MT_edit_text_chars")
2127
2128         layout.separator()
2129
2130         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2131         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2132         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2133         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2134
2135
2136 class VIEW3D_MT_edit_text_chars(Menu):
2137     bl_label = "Special Characters"
2138
2139     def draw(self, context):
2140         layout = self.layout
2141
2142         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2143         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2144
2145         layout.separator()
2146
2147         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2148         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2149         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2150         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2151         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2152         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2153         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2154         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2155         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2156
2157         layout.separator()
2158
2159         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2160         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2161         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2162
2163         layout.separator()
2164
2165         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2166         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2167         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2168
2169
2170 class VIEW3D_MT_edit_meta(Menu):
2171     bl_label = "Metaball"
2172
2173     def draw(self, context):
2174         layout = self.layout
2175
2176         toolsettings = context.tool_settings
2177
2178         layout.operator("ed.undo")
2179         layout.operator("ed.redo")
2180         layout.operator("ed.undo_history")
2181
2182         layout.separator()
2183
2184         layout.menu("VIEW3D_MT_transform")
2185         layout.menu("VIEW3D_MT_mirror")
2186         layout.menu("VIEW3D_MT_snap")
2187
2188         layout.separator()
2189
2190         layout.operator("mball.delete_metaelems", text="Delete...")
2191         layout.operator("mball.duplicate_metaelems")
2192
2193         layout.separator()
2194
2195         layout.prop_menu_enum(toolsettings, "proportional_edit")
2196         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2197
2198         layout.separator()
2199
2200         layout.menu("VIEW3D_MT_edit_meta_showhide")
2201
2202
2203 class VIEW3D_MT_edit_meta_showhide(Menu):
2204     bl_label = "Show/Hide"
2205
2206     def draw(self, context):
2207         layout = self.layout
2208
2209         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2210         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2211         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2212
2213
2214 class VIEW3D_MT_edit_lattice(Menu):
2215     bl_label = "Lattice"
2216
2217     def draw(self, context):
2218         layout = self.layout
2219
2220         toolsettings = context.tool_settings
2221
2222         layout.menu("VIEW3D_MT_transform")
2223         layout.menu("VIEW3D_MT_mirror")
2224         layout.menu("VIEW3D_MT_snap")
2225         layout.operator_menu_enum("lattice.flip", "axis")
2226
2227         layout.separator()
2228
2229         layout.operator("lattice.make_regular")
2230
2231         layout.separator()
2232
2233         layout.prop_menu_enum(toolsettings, "proportional_edit")
2234         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2235
2236
2237 class VIEW3D_MT_edit_armature(Menu):
2238     bl_label = "Armature"
2239
2240     def draw(self, context):
2241         layout = self.layout
2242
2243         edit_object = context.edit_object
2244         arm = edit_object.data
2245
2246         layout.menu("VIEW3D_MT_transform_armature")
2247         layout.menu("VIEW3D_MT_mirror")
2248         layout.menu("VIEW3D_MT_snap")
2249         layout.menu("VIEW3D_MT_edit_armature_roll")
2250
2251         layout.separator()
2252
2253         layout.operator("armature.extrude_move")
2254
2255         if arm.use_mirror_x:
2256             layout.operator("armature.extrude_forked")
2257
2258         layout.operator("armature.duplicate_move")
2259         layout.operator("armature.merge")
2260         layout.operator("armature.fill")
2261         layout.operator("armature.delete")
2262         layout.operator("armature.separate")
2263
2264         layout.separator()
2265
2266         layout.operator("armature.subdivide", text="Subdivide")
2267         layout.operator("armature.switch_direction", text="Switch Direction")
2268
2269         layout.separator()
2270
2271         layout.operator_context = 'EXEC_AREA'
2272         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2273         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2274         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2275         layout.operator("armature.flip_names")
2276
2277         layout.separator()
2278
2279         layout.operator_context = 'INVOKE_DEFAULT'
2280         layout.operator("armature.armature_layers")
2281         layout.operator("armature.bone_layers")
2282
2283         layout.separator()
2284
2285         layout.menu("VIEW3D_MT_edit_armature_parent")
2286
2287         layout.separator()
2288
2289         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2290
2291
2292 class VIEW3D_MT_armature_specials(Menu):
2293     bl_label = "Specials"
2294
2295     def draw(self, context):
2296         layout = self.layout
2297
2298         layout.operator_context = 'INVOKE_REGION_WIN'
2299
2300         layout.operator("armature.subdivide", text="Subdivide")
2301         layout.operator("armature.switch_direction", text="Switch Direction")
2302
2303         layout.separator()
2304
2305         layout.operator_context = 'EXEC_REGION_WIN'
2306         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2307         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2308         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2309         layout.operator("armature.flip_names", text="Flip Names")
2310
2311
2312 class VIEW3D_MT_edit_armature_parent(Menu):
2313     bl_label = "Parent"
2314
2315     def draw(self, context):
2316         layout = self.layout
2317
2318         layout.operator("armature.parent_set", text="Make")
2319         layout.operator("armature.parent_clear", text="Clear")
2320
2321
2322 class VIEW3D_MT_edit_armature_roll(Menu):
2323     bl_label = "Bone Roll"
2324
2325     def draw(self, context):
2326         layout = self.layout
2327
2328         layout.operator_menu_enum("armature.calculate_roll", "type")
2329
2330         layout.separator()
2331
2332         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2333
2334 # ********** Panel **********
2335
2336
2337 class VIEW3D_PT_view3d_properties(Panel):
2338     bl_space_type = 'VIEW_3D'
2339     bl_region_type = 'UI'
2340     bl_label = "View"
2341
2342     @classmethod
2343     def poll(cls, context):
2344         view = context.space_data
2345         return (view)
2346
2347     def draw(self, context):
2348         layout = self.layout
2349
2350         view = context.space_data
2351
2352         col = layout.column()
2353         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2354                           view.region_quadview)
2355         col.prop(view, "lens")
2356         col.label(text="Lock to Object:")
2357         col.prop(view, "lock_object", text="")
2358         lock_object = view.lock_object
2359         if lock_object:
2360             if lock_object.type == 'ARMATURE':
2361                 col.prop_search(view, "lock_bone", lock_object.data,
2362                                 "edit_bones" if lock_object.mode == 'EDIT'
2363                                 else "bones",
2364                                 text="")
2365         else:
2366             col.prop(view, "lock_cursor", text="Lock to Cursor")
2367
2368         col = layout.column()
2369         col.prop(view, "lock_camera")
2370
2371         col = layout.column(align=True)
2372         col.label(text="Clip:")
2373         col.prop(view, "clip_start", text="Start")
2374         col.prop(view, "clip_end", text="End")
2375
2376         subcol = col.column()
2377         subcol.enabled = not view.lock_camera_and_layers
2378         subcol.label(text="Local Camera:")
2379         subcol.prop(view, "camera", text="")
2380
2381         col = layout.column(align=True)
2382         col.prop(view, "use_render_border")
2383
2384
2385 class VIEW3D_PT_view3d_cursor(Panel):
2386     bl_space_type = 'VIEW_3D'
2387     bl_region_type = 'UI'
2388     bl_label = "3D Cursor"
2389
2390     @classmethod
2391     def poll(cls, context):
2392         view = context.space_data
2393         return (view is not None)
2394
2395     def draw(self, context):
2396         layout = self.layout
2397
2398         view = context.space_data
2399         layout.column().prop(view, "cursor_location", text="Location")
2400
2401
2402 class VIEW3D_PT_view3d_name(Panel):
2403     bl_space_type = 'VIEW_3D'
2404     bl_region_type = 'UI'
2405     bl_label = "Item"
2406
2407     @classmethod
2408     def poll(cls, context):
2409         return (context.space_data and context.active_object)
2410
2411     def draw(self, context):
2412         layout = self.layout
2413
2414         ob = context.active_object
2415         row = layout.row()
2416         row.label(text="", icon='OBJECT_DATA')
2417         row.prop(ob, "name", text="")
2418
2419         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2420             bone = context.active_bone
2421             if bone:
2422                 row = layout.row()
2423                 row.label(text="", icon='BONE_DATA')
2424                 row.prop(bone, "name", text="")
2425
2426
2427 class VIEW3D_PT_view3d_display(Panel):
2428     bl_space_type = 'VIEW_3D'
2429     bl_region_type = 'UI'
2430     bl_label = "Display"
2431     bl_options = {'DEFAULT_CLOSED'}
2432
2433     @classmethod
2434     def poll(cls, context):
2435         view = context.space_data
2436         return (view)
2437
2438     def draw(self, context):
2439         layout = self.layout
2440
2441         view = context.space_data
2442         scene = context.scene
2443         gs = scene.game_settings
2444         ob = context.object
2445
2446         col = layout.column()
2447         col.prop(view, "show_only_render")
2448
2449         col = layout.column()
2450         display_all = not view.show_only_render
2451         col.active = display_all
2452         col.prop(view, "show_outline_selected")
2453         col.prop(view, "show_all_objects_origin")
2454         col.prop(view, "show_relationship_lines")
2455
2456         col = layout.column()
2457         col.active = display_all
2458         split = col.split(percentage=0.55)
2459         split.prop(view, "show_floor", text="Grid Floor")
2460
2461         row = split.row(align=True)
2462         row.prop(view, "show_axis_x", text="X", toggle=True)
2463         row.prop(view, "show_axis_y", text="Y", toggle=True)
2464         row.prop(view, "show_axis_z", text="Z", toggle=True)
2465
2466         sub = col.column(align=True)
2467         sub.active = (display_all and view.show_floor)
2468         sub.prop(view, "grid_lines", text="Lines")
2469         sub.prop(view, "grid_scale", text="Scale")
2470         subsub = sub.column(align=True)
2471         subsub.active = scene.unit_settings.system == 'NONE'
2472         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2473
2474         if not scene.render.use_shading_nodes:
2475             col = layout.column()
2476             col.label(text="Shading:")
2477             col.prop(gs, "material_mode", text="")
2478             col.prop(view, "show_textured_solid")
2479         if view.viewport_shade == 'SOLID':
2480             col.prop(view, "use_matcap")
2481             if view.use_matcap:
2482                 col.template_icon_view(view, "matcap_icon")
2483         col.prop(view, "show_backface_culling")
2484
2485         layout.separator()
2486
2487         region = view.region_quadview
2488
2489         layout.operator("screen.region_quadview", text="Toggle Quad View")
2490
2491         if region:
2492             col = layout.column()
2493             col.prop(region, "lock_rotation")
2494             row = col.row()
2495             row.enabled = region.lock_rotation
2496             row.prop(region, "show_sync_view")
2497             row = col.row()
2498             row.enabled = region.lock_rotation and region.show_sync_view
2499             row.prop(region, "use_box_clip")
2500
2501
2502 class VIEW3D_PT_view3d_motion_tracking(Panel):
2503     bl_space_type = 'VIEW_3D'
2504     bl_region_type = 'UI'
2505     bl_label = "Motion Tracking"
2506     bl_options = {'DEFAULT_CLOSED'}
2507
2508     @classmethod
2509     def poll(cls, context):
2510         view = context.space_data
2511         return (view)
2512
2513     def draw_header(self, context):
2514         view = context.space_data
2515
2516         self.layout.prop(view, "show_reconstruction", text="")
2517
2518     def draw(self, context):
2519         layout = self.layout
2520
2521         view = context.space_data
2522
2523         col = layout.column()
2524         col.active = view.show_reconstruction
2525         col.prop(view, "show_bundle_names")
2526         col.prop(view, "show_camera_path")
2527         col.label(text="Tracks:")
2528         col.prop(view, "tracks_draw_type", text="")
2529         col.prop(view, "tracks_draw_size", text="Size")
2530
2531
2532 class VIEW3D_PT_view3d_meshdisplay(Panel):
2533     bl_space_type = 'VIEW_3D'
2534     bl_region_type = 'UI'
2535     bl_label = "Mesh Display"
2536
2537     @classmethod
2538     def poll(cls, context):
2539         # The active object check is needed because of local-mode
2540         return (context.active_object and (context.mode == 'EDIT_MESH'))
2541
2542     def draw(self, context):
2543         layout = self.layout
2544
2545         mesh = context.active_object.data
2546
2547         split = layout.split()
2548
2549         with_freestyle = context.scene and bpy.app.build_options.freestyle
2550
2551         col = split.column()
2552         col.label(text="Overlays:")
2553         col.prop(mesh, "show_faces", text="Faces")
2554         col.prop(mesh, "show_edges", text="Edges")
2555         col.prop(mesh, "show_edge_crease", text="Creases")
2556         if with_freestyle:
2557             col.prop(mesh, "show_edge_seams", text="Seams")
2558
2559         col = split.column()
2560         col.label()
2561         if not with_freestyle:
2562             col.prop(mesh, "show_edge_seams", text="Seams")
2563         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
2564         col.prop(mesh, "show_edge_bevel_weight", text="Weights")
2565         if with_freestyle:
2566             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
2567             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
2568
2569         col = layout.column()
2570
2571         col.separator()
2572         col.label(text="Normals:")
2573         row = col.row()
2574
2575         sub = row.row(align=True)
2576         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2577         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2578
2579         sub = row.row(align=True)
2580         sub.active = mesh.show_normal_vertex or mesh.show_normal_face
2581         sub.prop(context.scene.tool_settings, "normal_size", text="Size")
2582
2583         col.separator()
2584         col.label(text="Numerics:")
2585         col.prop(mesh, "show_extra_edge_length")
2586         col.prop(mesh, "show_extra_edge_angle")
2587         col.prop(mesh, "show_extra_face_angle")
2588         col.prop(mesh, "show_extra_face_area")
2589         if bpy.app.debug:
2590             col.prop(mesh, "show_extra_indices")
2591
2592
2593 class VIEW3D_PT_view3d_curvedisplay(Panel):
2594     bl_space_type = 'VIEW_3D'
2595     bl_region_type = 'UI'
2596     bl_label = "Curve Display"
2597
2598     @classmethod
2599     def poll(cls, context):
2600         editmesh = context.mode == 'EDIT_CURVE'
2601         return (editmesh)
2602
2603     def draw(self, context):
2604         layout = self.layout
2605
2606         curve = context.active_object.data
2607
2608         col = layout.column()
2609         col.label(text="Overlays:")
2610         col.prop(curve, "show_handles", text="Handles")
2611         col.prop(curve, "show_normal_face", text="Normals")
2612         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2613
2614
2615 class VIEW3D_PT_background_image(Panel):
2616     bl_space_type = 'VIEW_3D'
2617     bl_region_type = 'UI'
2618     bl_label = "Background Images"
2619     bl_options = {'DEFAULT_CLOSED'}
2620
2621     def draw_header(self, context):
2622         view = context.space_data
2623
2624         self.layout.prop(view, "show_background_images", text="")
2625
2626     def draw(self, context):
2627         layout = self.layout
2628
2629         view = context.space_data
2630
2631         col = layout.column()
2632         col.operator("view3d.background_image_add", text="Add Image")
2633
2634         for i, bg in enumerate(view.background_images):
2635             layout.active = view.show_background_images
2636             box = layout.box()
2637             row = box.row(align=True)
2638             row.prop(bg, "show_expanded", text="", emboss=False)
2639             if bg.source == 'IMAGE' and bg.image:
2640                 row.prop(bg.image, "name", text="", emboss=False)
2641             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2642                 row.prop(bg.clip, "name", text="", emboss=False)
2643             else:
2644                 row.label(text="Not Set")
2645
2646             if bg.show_background_image:
2647                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2648             else:
2649                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2650
2651             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2652
2653             box.prop(bg, "view_axis", text="Axis")
2654
2655             if bg.show_expanded:
2656                 row = box.row()
2657                 row.prop(bg, "source", expand=True)
2658
2659                 has_bg = False
2660                 if bg.source == 'IMAGE':
2661                     row = box.row()
2662                     row.template_ID(bg, "image", open="image.open")
2663                     if bg.image is not None:
2664                         box.template_image(bg, "image", bg.image_user, compact=True)
2665                         has_bg = True
2666
2667                 elif bg.source == 'MOVIE_CLIP':
2668                     box.prop(bg, "use_camera_clip")
2669
2670                     column = box.column()
2671                     column.active = not bg.use_camera_clip
2672                     column.template_ID(bg, "clip", open="clip.open")
2673
2674                     if bg.clip:
2675                         column.template_movieclip(bg, "clip", compact=True)
2676
2677                     if bg.use_camera_clip or bg.clip:
2678                         has_bg = True
2679
2680                     column = box.column()
2681                     column.active = has_bg
2682                     column.prop(bg.clip_user, "proxy_render_size", text="")
2683                     column.prop(bg.clip_user, "use_render_undistorted")
2684
2685                 if has_bg:
2686                     col = box.column()
2687                     col.prop(bg, "opacity", slider=True)
2688
2689                     rowsub = col.row()
2690                     rowsub.prop(bg, "draw_depth", expand=True)
2691
2692                     if bg.view_axis in {'CAMERA', 'ALL'}:
2693                         rowsub = col.row()
2694                         rowsub.prop(bg, "frame_method", expand=True)
2695
2696                     row = col.row(align=True)
2697                     row.prop(bg, "offset_x", text="X")
2698                     row.prop(bg, "offset_y", text="Y")
2699
2700                     if bg.view_axis != 'CAMERA':
2701                         col.prop(bg, "size")
2702
2703
2704 class VIEW3D_PT_transform_orientations(Panel):
2705     bl_space_type = 'VIEW_3D'
2706     bl_region_type = 'UI'
2707     bl_label = "Transform Orientations"
2708     bl_options = {'DEFAULT_CLOSED'}
2709
2710     @classmethod
2711     def poll(cls, context):
2712         view = context.space_data
2713         return (view)
2714
2715     def draw(self, context):
2716         layout = self.layout
2717
2718         view = context.space_data
2719         orientation = view.current_orientation
2720
2721         row = layout.row(align=True)
2722         row.prop(view, "transform_orientation", text="")
2723         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2724
2725         if orientation:
2726             row = layout.row(align=True)
2727             row.prop(orientation, "name", text="")
2728             row.operator("transform.delete_orientation", text="", icon="X")
2729
2730
2731 class VIEW3D_PT_etch_a_ton(Panel):
2732     bl_space_type = 'VIEW_3D'
2733     bl_region_type = 'UI'
2734     bl_label = "Skeleton Sketching"
2735     bl_options = {'DEFAULT_CLOSED'}
2736
2737     @classmethod
2738     def poll(cls, context):
2739         scene = context.space_data
2740         ob = context.active_object
2741         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2742
2743     def draw_header(self, context):
2744         layout = self.layout
2745         toolsettings = context.scene.tool_settings
2746
2747         layout.prop(toolsettings, "use_bone_sketching", text="")
2748
2749     def draw(self, context):
2750         layout = self.layout
2751
2752         toolsettings = context.scene.tool_settings
2753
2754         col = layout.column()
2755
2756         col.prop(toolsettings, "use_etch_quick")
2757         col.prop(toolsettings, "use_etch_overdraw")
2758
2759         col.separator()
2760
2761         col.prop(toolsettings, "etch_convert_mode")
2762
2763         if toolsettings.etch_convert_mode == 'LENGTH':
2764             col.prop(toolsettings, "etch_length_limit")
2765         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2766             col.prop(toolsettings, "etch_adaptive_limit")
2767         elif toolsettings.etch_convert_mode == 'FIXED':
2768             col.prop(toolsettings, "etch_subdivision_number")
2769         elif toolsettings.etch_convert_mode == 'RETARGET':
2770             col.prop(toolsettings, "etch_template")
2771             col.prop(toolsettings, "etch_roll_mode")
2772
2773             col.separator()
2774
2775             colsub = col.column(align=True)
2776             colsub.prop(toolsettings, "use_etch_autoname")
2777             sub = colsub.column()
2778             sub.enabled = not toolsettings.use_etch_autoname
2779             sub.prop(toolsettings, "etch_number")
2780             sub.prop(toolsettings, "etch_side")
2781
2782         col.separator()
2783
2784         col.operator("sketch.convert", text="Convert to Bones")
2785         col.operator("sketch.delete", text="Delete Strokes")
2786
2787
2788 class VIEW3D_PT_context_properties(Panel):
2789     bl_space_type = 'VIEW_3D'
2790     bl_region_type = 'UI'
2791     bl_label = "Properties"
2792     bl_options = {'DEFAULT_CLOSED'}
2793
2794     def _active_context_member(context):
2795         obj = context.object
2796         if obj:
2797             mode = obj.mode
2798             if mode == 'POSE':
2799                 return "active_pose_bone"
2800             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2801                 return "active_bone"
2802             else:
2803                 return "object"
2804
2805         return ""
2806
2807     @classmethod
2808     def poll(cls, context):
2809         member = cls._active_context_member(context)
2810         if member:
2811             context_member = getattr(context, member)
2812             return context_member and context_member.keys()
2813
2814         return False
2815
2816     def draw(self, context):
2817         import rna_prop_ui
2818         member = VIEW3D_PT_context_properties._active_context_member(context)
2819
2820         if member:
2821             # Draw with no edit button
2822             rna_prop_ui.draw(self.layout, context, member, object, False)
2823
2824
2825 def register():
2826     bpy.utils.register_module(__name__)
2827
2828
2829 def unregister():
2830     bpy.utils.unregister_module(__name__)
2831
2832 if __name__ == "__main__":
2833     register()
2834
2835 if __name__ == "__main__":  # only for live edit.
2836     bpy.utils.register_module(__name__)