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