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