Cycles lamp specials menu now includes separate X/Y size for area lamps
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_paint_common import UnifiedPaintPanel
23 from bpy.app.translations import contexts as i18n_contexts
24
25
26 class VIEW3D_HT_header(Header):
27     bl_space_type = 'VIEW_3D'
28
29     def draw(self, context):
30         layout = self.layout
31
32         view = context.space_data
33         mode_string = context.mode
34         edit_object = context.edit_object
35         obj = context.active_object
36         toolsettings = context.tool_settings
37
38         row = layout.row(align=True)
39         row.template_header()
40
41         # Menus
42         if context.area.show_menus:
43             sub = row.row(align=True)
44
45             sub.menu("VIEW3D_MT_view")
46
47             # Select Menu
48             if mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
49                 mesh = obj.data
50                 if mesh.use_paint_mask:
51                     sub.menu("VIEW3D_MT_select_paint_mask")
52                 elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
53                     sub.menu("VIEW3D_MT_select_paint_mask_vertex")
54             elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
55                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
56
57             if edit_object:
58                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
59             elif obj:
60                 if mode_string not in {'PAINT_TEXTURE'}:
61                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
62                 if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
63                     sub.menu("VIEW3D_MT_brush")
64                 if mode_string == 'SCULPT':
65                     sub.menu("VIEW3D_MT_hide_mask")
66             else:
67                 sub.menu("VIEW3D_MT_object")
68
69         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
70         row = layout
71         layout.template_header_3D()
72
73         if obj:
74             mode = obj.mode
75             # Particle edit
76             if mode == 'PARTICLE_EDIT':
77                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
78
79             # Occlude geometry
80             if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
81                     (mode == 'WEIGHT_PAINT')):
82                 row.prop(view, "use_occlude_geometry", text="")
83
84             # Proportional editing
85             if mode in {'EDIT', 'PARTICLE_EDIT'}:
86                 row = layout.row(align=True)
87                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
88                 if toolsettings.proportional_edit != 'DISABLED':
89                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
90             elif mode == 'OBJECT':
91                 row = layout.row(align=True)
92                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
93                 if toolsettings.use_proportional_edit_objects:
94                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
95
96         # Snap
97         if not obj or mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
98             snap_element = toolsettings.snap_element
99             row = layout.row(align=True)
100             row.prop(toolsettings, "use_snap", text="")
101             row.prop(toolsettings, "snap_element", text="", icon_only=True)
102             if snap_element != 'INCREMENT':
103                 row.prop(toolsettings, "snap_target", text="")
104                 if obj:
105                     if mode in {'OBJECT', 'POSE'} and snap_element != 'VOLUME':
106                         row.prop(toolsettings, "use_snap_align_rotation", text="")
107                     elif mode == 'EDIT':
108                         row.prop(toolsettings, "use_snap_self", text="")
109
110             if snap_element == 'VOLUME':
111                 row.prop(toolsettings, "use_snap_peel_object", text="")
112             elif snap_element == 'FACE':
113                 row.prop(toolsettings, "use_snap_project", text="")
114
115         # AutoMerge editing
116         if obj:
117             if (mode == 'EDIT' and obj.type == 'MESH'):
118                 layout.prop(toolsettings, "use_mesh_automerge", text="", icon='AUTOMERGE_ON')
119
120         # OpenGL render
121         row = layout.row(align=True)
122         row.operator("render.opengl", text="", icon='RENDER_STILL')
123         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
124         props.animation = True
125
126         # Pose
127         if obj and mode == 'POSE':
128             row = layout.row(align=True)
129             row.operator("pose.copy", text="", icon='COPYDOWN')
130             row.operator("pose.paste", text="", icon='PASTEDOWN')
131             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
132             props.flipped = 1
133
134
135 # ********** Menu **********
136
137 # ********** Utilities **********
138
139
140 class ShowHideMenu():
141     bl_label = "Show/Hide"
142     _operator_name = ""
143
144     def draw(self, context):
145         layout = self.layout
146
147         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
148         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
149         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
150
151
152 # Standard transforms which apply to all cases
153 # NOTE: this doesn't seem to be able to be used directly
154 class VIEW3D_MT_transform_base(Menu):
155     bl_label = "Transform"
156
157     # TODO: get rid of the custom text strings?
158     def draw(self, context):
159         layout = self.layout
160
161         layout.operator("transform.translate", text="Grab/Move")
162         # TODO: sub-menu for grab per axis
163         layout.operator("transform.rotate", text="Rotate")
164         # TODO: sub-menu for rot per axis
165         layout.operator("transform.resize", text="Scale")
166         # TODO: sub-menu for scale per axis
167
168         layout.separator()
169
170         layout.operator("transform.tosphere", text="To Sphere")
171         layout.operator("transform.shear", text="Shear")
172         layout.operator("transform.warp", text="Warp")
173         layout.operator("transform.push_pull", text="Push/Pull")
174
175
176 # Generic transform menu - geometry types
177 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
178     def draw(self, context):
179         # base menu
180         VIEW3D_MT_transform_base.draw(self, context)
181
182         # generic...
183         layout = self.layout
184         layout.operator("transform.shrink_fatten", text="Shrink Fatten")
185
186         layout.separator()
187
188         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
189         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
190
191
192 # Object-specific extensions to Transform menu
193 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
194     def draw(self, context):
195         layout = self.layout
196
197         # base menu
198         VIEW3D_MT_transform_base.draw(self, context)
199
200         # object-specific option follow...
201         layout.separator()
202
203         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
204         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
205
206         layout.separator()
207
208         layout.operator_context = 'EXEC_REGION_WIN'
209         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
210
211         layout.separator()
212
213         layout.operator_context = 'EXEC_AREA'
214
215         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
216         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
217         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
218         layout.operator("object.origin_set", text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'
219         layout.separator()
220
221         layout.operator("object.randomize_transform")
222         layout.operator("object.align")
223
224         layout.separator()
225
226         layout.operator("object.anim_transforms_to_deltas")
227
228
229 # Armature EditMode extensions to Transform menu
230 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
231     def draw(self, context):
232         layout = self.layout
233
234         # base menu
235         VIEW3D_MT_transform_base.draw(self, context)
236
237         # armature specific extensions follow...
238         layout.separator()
239
240         obj = context.object
241         if     (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
242                 obj.data.draw_type in {'BBONE', 'ENVELOPE'}):
243             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
244
245         if context.edit_object and context.edit_object.type == 'ARMATURE':
246             layout.operator("armature.align")
247
248
249 class VIEW3D_MT_mirror(Menu):
250     bl_label = "Mirror"
251
252     def draw(self, context):
253         layout = self.layout
254
255         layout.operator("transform.mirror", text="Interactive Mirror")
256
257         layout.separator()
258
259         layout.operator_context = 'INVOKE_REGION_WIN'
260
261         props = layout.operator("transform.mirror", text="X Global")
262         props.constraint_axis = (True, False, False)
263         props.constraint_orientation = 'GLOBAL'
264         props = layout.operator("transform.mirror", text="Y Global")
265         props.constraint_axis = (False, True, False)
266         props.constraint_orientation = 'GLOBAL'
267         props = layout.operator("transform.mirror", text="Z Global")
268         props.constraint_axis = (False, False, True)
269         props.constraint_orientation = 'GLOBAL'
270
271         if context.edit_object:
272             layout.separator()
273
274             props = layout.operator("transform.mirror", text="X Local")
275             props.constraint_axis = (True, False, False)
276             props.constraint_orientation = 'LOCAL'
277             props = layout.operator("transform.mirror", text="Y Local")
278             props.constraint_axis = (False, True, False)
279             props.constraint_orientation = 'LOCAL'
280             props = layout.operator("transform.mirror", text="Z Local")
281             props.constraint_axis = (False, False, True)
282             props.constraint_orientation = 'LOCAL'
283
284             layout.operator("object.vertex_group_mirror")
285
286
287 class VIEW3D_MT_snap(Menu):
288     bl_label = "Snap"
289
290     def draw(self, context):
291         layout = self.layout
292
293         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
294         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
295
296         layout.separator()
297
298         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
299         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
300         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
301         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
302
303
304 class VIEW3D_MT_uv_map(Menu):
305     bl_label = "UV Mapping"
306
307     def draw(self, context):
308         layout = self.layout
309
310         layout.operator("uv.unwrap")
311
312         layout.operator_context = 'INVOKE_DEFAULT'
313         layout.operator("uv.smart_project")
314         layout.operator("uv.lightmap_pack")
315         layout.operator("uv.follow_active_quads")
316
317         layout.separator()
318
319         layout.operator_context = 'EXEC_REGION_WIN'
320         layout.operator("uv.cube_project")
321         layout.operator("uv.cylinder_project")
322         layout.operator("uv.sphere_project")
323
324         layout.separator()
325
326         layout.operator_context = '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         mesh_select_mode = context.tool_settings.mesh_select_mode[:]
2079         if mesh_select_mode[2]:
2080             layout.operator("mesh.dissolve_faces")
2081         elif mesh_select_mode[1]:
2082             layout.operator("mesh.dissolve_edges")
2083         elif mesh_select_mode[0]:
2084             layout.operator("mesh.dissolve_verts")
2085
2086         layout.operator("mesh.dissolve_limited")
2087
2088         layout.separator()
2089
2090         layout.operator("mesh.edge_collapse")
2091         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
2092
2093
2094 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2095     _operator_name = "mesh"
2096
2097 # Edit Curve
2098 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2099
2100
2101 def draw_curve(self, context):
2102     layout = self.layout
2103
2104     toolsettings = context.tool_settings
2105
2106     layout.menu("VIEW3D_MT_transform")
2107     layout.menu("VIEW3D_MT_mirror")
2108     layout.menu("VIEW3D_MT_snap")
2109
2110     layout.separator()
2111
2112     layout.operator("curve.extrude_move")
2113     layout.operator("curve.duplicate_move")
2114     layout.operator("curve.separate")
2115     layout.operator("curve.make_segment")
2116     layout.operator("curve.cyclic_toggle")
2117     layout.operator("curve.delete", text="Delete...")
2118
2119     layout.separator()
2120
2121     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2122     layout.menu("VIEW3D_MT_edit_curve_segments")
2123
2124     layout.separator()
2125
2126     layout.prop_menu_enum(toolsettings, "proportional_edit")
2127     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2128
2129     layout.separator()
2130
2131     layout.menu("VIEW3D_MT_edit_curve_showhide")
2132
2133
2134 class VIEW3D_MT_edit_curve(Menu):
2135     bl_label = "Curve"
2136
2137     draw = draw_curve
2138
2139
2140 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2141     bl_label = "Control Points"
2142
2143     def draw(self, context):
2144         layout = self.layout
2145
2146         edit_object = context.edit_object
2147
2148         if edit_object.type == 'CURVE':
2149             layout.operator("transform.tilt")
2150             layout.operator("curve.tilt_clear")
2151             layout.operator("curve.separate")
2152
2153             layout.separator()
2154
2155             layout.operator_menu_enum("curve.handle_type_set", "type")
2156
2157             layout.separator()
2158
2159         layout.menu("VIEW3D_MT_hook")
2160
2161
2162 class VIEW3D_MT_edit_curve_segments(Menu):
2163     bl_label = "Segments"
2164
2165     def draw(self, context):
2166         layout = self.layout
2167
2168         layout.operator("curve.subdivide")
2169         layout.operator("curve.switch_direction")
2170
2171
2172 class VIEW3D_MT_edit_curve_specials(Menu):
2173     bl_label = "Specials"
2174
2175     def draw(self, context):
2176         layout = self.layout
2177
2178         layout.operator("curve.subdivide")
2179         layout.operator("curve.switch_direction")
2180         layout.operator("curve.spline_weight_set")
2181         layout.operator("curve.radius_set")
2182         layout.operator("curve.smooth")
2183         layout.operator("curve.smooth_radius")
2184
2185
2186 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2187     _operator_name = "curve"
2188
2189
2190 class VIEW3D_MT_edit_surface(Menu):
2191     bl_label = "Surface"
2192
2193     draw = draw_curve
2194
2195
2196 class VIEW3D_MT_edit_font(Menu):
2197     bl_label = "Text"
2198
2199     def draw(self, context):
2200         layout = self.layout
2201
2202         layout.operator("font.file_paste")
2203
2204         layout.separator()
2205
2206         layout.menu("VIEW3D_MT_edit_text_chars")
2207
2208         layout.separator()
2209
2210         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2211         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2212         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2213         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2214
2215
2216 class VIEW3D_MT_edit_text_chars(Menu):
2217     bl_label = "Special Characters"
2218
2219     def draw(self, context):
2220         layout = self.layout
2221
2222         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2223         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2224
2225         layout.separator()
2226
2227         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2228         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2229         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2230         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2231         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2232         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2233         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2234         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2235         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2236
2237         layout.separator()
2238
2239         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2240         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2241         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2242
2243         layout.separator()
2244
2245         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2246         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2247         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2248
2249
2250 class VIEW3D_MT_edit_meta(Menu):
2251     bl_label = "Metaball"
2252
2253     def draw(self, context):
2254         layout = self.layout
2255
2256         toolsettings = context.tool_settings
2257
2258         layout.operator("ed.undo")
2259         layout.operator("ed.redo")
2260         layout.operator("ed.undo_history")
2261
2262         layout.separator()
2263
2264         layout.menu("VIEW3D_MT_transform")
2265         layout.menu("VIEW3D_MT_mirror")
2266         layout.menu("VIEW3D_MT_snap")
2267
2268         layout.separator()
2269
2270         layout.operator("mball.delete_metaelems", text="Delete...")
2271         layout.operator("mball.duplicate_metaelems")
2272
2273         layout.separator()
2274
2275         layout.prop_menu_enum(toolsettings, "proportional_edit")
2276         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2277
2278         layout.separator()
2279
2280         layout.menu("VIEW3D_MT_edit_meta_showhide")
2281
2282
2283 class VIEW3D_MT_edit_meta_showhide(Menu):
2284     bl_label = "Show/Hide"
2285
2286     def draw(self, context):
2287         layout = self.layout
2288
2289         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2290         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2291         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2292
2293
2294 class VIEW3D_MT_edit_lattice(Menu):
2295     bl_label = "Lattice"
2296
2297     def draw(self, context):
2298         layout = self.layout
2299
2300         toolsettings = context.tool_settings
2301
2302         layout.menu("VIEW3D_MT_transform")
2303         layout.menu("VIEW3D_MT_mirror")
2304         layout.menu("VIEW3D_MT_snap")
2305         layout.operator_menu_enum("lattice.flip", "axis")
2306
2307         layout.separator()
2308
2309         layout.operator("lattice.make_regular")
2310
2311         layout.separator()
2312
2313         layout.prop_menu_enum(toolsettings, "proportional_edit")
2314         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2315
2316
2317 class VIEW3D_MT_edit_armature(Menu):
2318     bl_label = "Armature"
2319
2320     def draw(self, context):
2321         layout = self.layout
2322
2323         edit_object = context.edit_object
2324         arm = edit_object.data
2325
2326         layout.menu("VIEW3D_MT_transform_armature")
2327         layout.menu("VIEW3D_MT_mirror")
2328         layout.menu("VIEW3D_MT_snap")
2329         layout.menu("VIEW3D_MT_edit_armature_roll")
2330
2331         layout.separator()
2332
2333         layout.operator("armature.extrude_move")
2334
2335         if arm.use_mirror_x:
2336             layout.operator("armature.extrude_forked")
2337
2338         layout.operator("armature.duplicate_move")
2339         layout.operator("armature.merge")
2340         layout.operator("armature.fill")
2341         layout.operator("armature.delete")
2342         layout.operator("armature.separate")
2343
2344         layout.separator()
2345
2346         layout.operator("armature.subdivide", text="Subdivide")
2347         layout.operator("armature.switch_direction", text="Switch Direction")
2348
2349         layout.separator()
2350
2351         layout.operator_context = 'EXEC_AREA'
2352         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2353         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2354         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2355         layout.operator("armature.flip_names")
2356
2357         layout.separator()
2358
2359         layout.operator_context = 'INVOKE_DEFAULT'
2360         layout.operator("armature.armature_layers")
2361         layout.operator("armature.bone_layers")
2362
2363         layout.separator()
2364
2365         layout.menu("VIEW3D_MT_edit_armature_parent")
2366
2367         layout.separator()
2368
2369         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2370
2371
2372 class VIEW3D_MT_armature_specials(Menu):
2373     bl_label = "Specials"
2374
2375     def draw(self, context):
2376         layout = self.layout
2377
2378         layout.operator_context = 'INVOKE_REGION_WIN'
2379
2380         layout.operator("armature.subdivide", text="Subdivide")
2381         layout.operator("armature.switch_direction", text="Switch Direction")
2382
2383         layout.separator()
2384
2385         layout.operator_context = 'EXEC_REGION_WIN'
2386         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2387         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2388         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2389         layout.operator("armature.flip_names", text="Flip Names")
2390
2391
2392 class VIEW3D_MT_edit_armature_parent(Menu):
2393     bl_label = "Parent"
2394
2395     def draw(self, context):
2396         layout = self.layout
2397
2398         layout.operator("armature.parent_set", text="Make")
2399         layout.operator("armature.parent_clear", text="Clear")
2400
2401
2402 class VIEW3D_MT_edit_armature_roll(Menu):
2403     bl_label = "Bone Roll"
2404
2405     def draw(self, context):
2406         layout = self.layout
2407
2408         layout.operator_menu_enum("armature.calculate_roll", "type")
2409
2410         layout.separator()
2411
2412         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2413
2414 # ********** Panel **********
2415
2416
2417 class VIEW3D_PT_view3d_properties(Panel):
2418     bl_space_type = 'VIEW_3D'
2419     bl_region_type = 'UI'
2420     bl_label = "View"
2421
2422     @classmethod
2423     def poll(cls, context):
2424         view = context.space_data
2425         return (view)
2426
2427     def draw(self, context):
2428         layout = self.layout
2429
2430         view = context.space_data
2431
2432         col = layout.column()
2433         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2434                           view.region_quadview)
2435         col.prop(view, "lens")
2436         col.label(text="Lock to Object:")
2437         col.prop(view, "lock_object", text="")
2438         lock_object = view.lock_object
2439         if lock_object:
2440             if lock_object.type == 'ARMATURE':
2441                 col.prop_search(view, "lock_bone", lock_object.data,
2442                                 "edit_bones" if lock_object.mode == 'EDIT'
2443                                 else "bones",
2444                                 text="")
2445         else:
2446             col.prop(view, "lock_cursor", text="Lock to Cursor")
2447
2448         col = layout.column()
2449         col.prop(view, "lock_camera")
2450
2451         col = layout.column(align=True)
2452         col.label(text="Clip:")
2453         col.prop(view, "clip_start", text="Start")
2454         col.prop(view, "clip_end", text="End")
2455
2456         subcol = col.column()
2457         subcol.enabled = not view.lock_camera_and_layers
2458         subcol.label(text="Local Camera:")
2459         subcol.prop(view, "camera", text="")
2460
2461         col = layout.column(align=True)
2462         col.prop(view, "use_render_border")
2463         col.active = view.region_3d.view_perspective != 'CAMERA'
2464
2465
2466 class VIEW3D_PT_view3d_cursor(Panel):
2467     bl_space_type = 'VIEW_3D'
2468     bl_region_type = 'UI'
2469     bl_label = "3D Cursor"
2470
2471     @classmethod
2472     def poll(cls, context):
2473         view = context.space_data
2474         return (view is not None)
2475
2476     def draw(self, context):
2477         layout = self.layout
2478
2479         view = context.space_data
2480         layout.column().prop(view, "cursor_location", text="Location")
2481
2482
2483 class VIEW3D_PT_view3d_name(Panel):
2484     bl_space_type = 'VIEW_3D'
2485     bl_region_type = 'UI'
2486     bl_label = "Item"
2487
2488     @classmethod
2489     def poll(cls, context):
2490         return (context.space_data and context.active_object)
2491
2492     def draw(self, context):
2493         layout = self.layout
2494
2495         ob = context.active_object
2496         row = layout.row()
2497         row.label(text="", icon='OBJECT_DATA')
2498         row.prop(ob, "name", text="")
2499
2500         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2501             bone = context.active_bone
2502             if bone:
2503                 row = layout.row()
2504                 row.label(text="", icon='BONE_DATA')
2505                 row.prop(bone, "name", text="")
2506
2507
2508 class VIEW3D_PT_view3d_display(Panel):
2509     bl_space_type = 'VIEW_3D'
2510     bl_region_type = 'UI'
2511     bl_label = "Display"
2512     bl_options = {'DEFAULT_CLOSED'}
2513
2514     @classmethod
2515     def poll(cls, context):
2516         view = context.space_data
2517         return (view)
2518
2519     def draw(self, context):
2520         layout = self.layout
2521
2522         view = context.space_data
2523         scene = context.scene
2524         gs = scene.game_settings
2525         ob = context.object
2526
2527         col = layout.column()
2528         col.prop(view, "show_only_render")
2529
2530         col = layout.column()
2531         display_all = not view.show_only_render
2532         col.active = display_all
2533         col.prop(view, "show_outline_selected")
2534         col.prop(view, "show_all_objects_origin")
2535         col.prop(view, "show_relationship_lines")
2536
2537         col = layout.column()
2538         col.active = display_all
2539         split = col.split(percentage=0.55)
2540         split.prop(view, "show_floor", text="Grid Floor")
2541
2542         row = split.row(align=True)
2543         row.prop(view, "show_axis_x", text="X", toggle=True)
2544         row.prop(view, "show_axis_y", text="Y", toggle=True)
2545         row.prop(view, "show_axis_z", text="Z", toggle=True)
2546
2547         sub = col.column(align=True)
2548         sub.active = (display_all and view.show_floor)
2549         sub.prop(view, "grid_lines", text="Lines")
2550         sub.prop(view, "grid_scale", text="Scale")
2551         subsub = sub.column(align=True)
2552         subsub.active = scene.unit_settings.system == 'NONE'
2553         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2554
2555         if not scene.render.use_shading_nodes:
2556             col = layout.column()
2557             col.label(text="Shading:")
2558             col.prop(gs, "material_mode", text="")
2559             col.prop(view, "show_textured_solid")
2560         if view.viewport_shade == 'SOLID':
2561             col.prop(view, "use_matcap")
2562             if view.use_matcap:
2563                 col.template_icon_view(view, "matcap_icon")
2564         col.prop(view, "show_backface_culling")
2565
2566         layout.separator()
2567
2568         region = view.region_quadview
2569
2570         layout.operator("screen.region_quadview", text="Toggle Quad View")
2571
2572         if region:
2573             col = layout.column()
2574             col.prop(region, "lock_rotation")
2575             row = col.row()
2576             row.enabled = region.lock_rotation
2577             row.prop(region, "show_sync_view")
2578             row = col.row()
2579             row.enabled = region.lock_rotation and region.show_sync_view
2580             row.prop(region, "use_box_clip")
2581
2582
2583 class VIEW3D_PT_view3d_motion_tracking(Panel):
2584     bl_space_type = 'VIEW_3D'
2585     bl_region_type = 'UI'
2586     bl_label = "Motion Tracking"
2587     bl_options = {'DEFAULT_CLOSED'}
2588
2589     @classmethod
2590     def poll(cls, context):
2591         view = context.space_data
2592         return (view)
2593
2594     def draw_header(self, context):
2595         view = context.space_data
2596
2597         self.layout.prop(view, "show_reconstruction", text="")
2598
2599     def draw(self, context):
2600         layout = self.layout
2601
2602         view = context.space_data
2603
2604         col = layout.column()
2605         col.active = view.show_reconstruction
2606         col.prop(view, "show_bundle_names")
2607         col.prop(view, "show_camera_path")
2608         col.label(text="Tracks:")
2609         col.prop(view, "tracks_draw_type", text="")
2610         col.prop(view, "tracks_draw_size", text="Size")
2611
2612
2613 class VIEW3D_PT_view3d_meshdisplay(Panel):
2614     bl_space_type = 'VIEW_3D'
2615     bl_region_type = 'UI'
2616     bl_label = "Mesh Display"
2617
2618     @classmethod
2619     def poll(cls, context):
2620         # The active object check is needed because of local-mode
2621         return (context.active_object and (context.mode == 'EDIT_MESH'))
2622
2623     def draw(self, context):
2624         layout = self.layout
2625         with_freestyle = bpy.app.build_options.freestyle
2626
2627         mesh = context.active_object.data
2628
2629         split = layout.split()
2630
2631         col = split.column()
2632         col.label(text="Overlays:")
2633         col.prop(mesh, "show_faces", text="Faces")
2634         col.prop(mesh, "show_edges", text="Edges")
2635         col.prop(mesh, "show_edge_crease", text="Creases")
2636         if with_freestyle:
2637             col.prop(mesh, "show_edge_seams", text="Seams")
2638
2639         layout.prop(mesh, "show_weight")
2640
2641         col = split.column()
2642         col.label()
2643         if not with_freestyle:
2644             col.prop(mesh, "show_edge_seams", text="Seams")
2645         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
2646         col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
2647         if with_freestyle:
2648             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
2649             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
2650
2651         col = layout.column()
2652
2653         col.separator()
2654         col.label(text="Normals:")
2655         row = col.row()
2656
2657         sub = row.row(align=True)
2658         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2659         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2660
2661         sub = row.row(align=True)
2662         sub.active = mesh.show_normal_vertex or mesh.show_normal_face
2663         sub.prop(context.scene.tool_settings, "normal_size", text="Size")
2664
2665         col.separator()
2666         split = layout.split()
2667         col = split.column()
2668         col.label(text="Edge Info:")
2669         col.prop(mesh, "show_extra_edge_length", text="Length")
2670         col.prop(mesh, "show_extra_edge_angle", text="Angle")
2671         col = split.column()
2672         col.label(text="Face Info:")
2673         col.prop(mesh, "show_extra_face_area", text="Area")
2674         col.prop(mesh, "show_extra_face_angle", text="Angle")
2675         if bpy.app.debug:
2676             layout.prop(mesh, "show_extra_indices")
2677
2678
2679 class VIEW3D_PT_view3d_meshstatvis(Panel):
2680     bl_space_type = 'VIEW_3D'
2681     bl_region_type = 'UI'
2682     bl_label = "Mesh Analysis"
2683
2684     @classmethod
2685     def poll(cls, context):
2686         # The active object check is needed because of local-mode
2687         return (context.active_object and (context.mode == 'EDIT_MESH'))
2688
2689     def draw_header(self, context):
2690         mesh = context.active_object.data
2691
2692         self.layout.prop(mesh, "show_statvis", text="")
2693
2694     def draw(self, context):
2695         layout = self.layout
2696
2697         mesh = context.active_object.data
2698         statvis = context.tool_settings.statvis
2699         layout.active = mesh.show_statvis
2700
2701         layout.prop(statvis, "type")
2702         statvis_type = statvis.type
2703         if statvis_type == 'OVERHANG':
2704             row = layout.row(align=True)
2705             row.prop(statvis, "overhang_min", text="")
2706             row.prop(statvis, "overhang_max", text="")
2707             layout.prop(statvis, "overhang_axis", expand=True)
2708         elif statvis_type == 'THICKNESS':
2709             row = layout.row(align=True)
2710             row.prop(statvis, "thickness_min", text="")
2711             row.prop(statvis, "thickness_max", text="")
2712             layout.prop(statvis, "thickness_samples")
2713         elif statvis_type == 'INTERSECT':
2714             pass
2715         elif statvis_type == 'DISTORT':
2716             row = layout.row(align=True)
2717             row.prop(statvis, "distort_min", text="")
2718             row.prop(statvis, "distort_max", text="")
2719         elif statvis_type == 'SHARP':
2720             row = layout.row(align=True)
2721             row.prop(statvis, "sharp_min", text="")
2722             row.prop(statvis, "sharp_max", text="")
2723
2724
2725 class VIEW3D_PT_view3d_curvedisplay(Panel):
2726     bl_space_type = 'VIEW_3D'
2727     bl_region_type = 'UI'
2728     bl_label = "Curve Display"
2729
2730     @classmethod
2731     def poll(cls, context):
2732         editmesh = context.mode == 'EDIT_CURVE'
2733         return (editmesh)
2734
2735     def draw(self, context):
2736         layout = self.layout
2737
2738         curve = context.active_object.data
2739
2740         col = layout.column()
2741         col.label(text="Overlays:")
2742         col.prop(curve, "show_handles", text="Handles")
2743         col.prop(curve, "show_normal_face", text="Normals")
2744         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2745
2746
2747 class VIEW3D_PT_background_image(Panel):
2748     bl_space_type = 'VIEW_3D'
2749     bl_region_type = 'UI'
2750     bl_label = "Background Images"
2751     bl_options = {'DEFAULT_CLOSED'}
2752
2753     def draw_header(self, context):
2754         view = context.space_data
2755
2756         self.layout.prop(view, "show_background_images", text="")
2757
2758     def draw(self, context):
2759         layout = self.layout
2760
2761         view = context.space_data
2762
2763         col = layout.column()
2764         col.operator("view3d.background_image_add", text="Add Image")
2765
2766         for i, bg in enumerate(view.background_images):
2767             layout.active = view.show_background_images
2768             box = layout.box()
2769             row = box.row(align=True)
2770             row.prop(bg, "show_expanded", text="", emboss=False)
2771             if bg.source == 'IMAGE' and bg.image:
2772                 row.prop(bg.image, "name", text="", emboss=False)
2773             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2774                 row.prop(bg.clip, "name", text="", emboss=False)
2775             else:
2776                 row.label(text="Not Set")
2777
2778             if bg.show_background_image:
2779                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2780             else:
2781                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2782
2783             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2784
2785             box.prop(bg, "view_axis", text="Axis")
2786
2787             if bg.show_expanded:
2788                 row = box.row()
2789                 row.prop(bg, "source", expand=True)
2790
2791                 has_bg = False
2792                 if bg.source == 'IMAGE':
2793                     row = box.row()
2794                     row.template_ID(bg, "image", open="image.open")
2795                     if bg.image is not None:
2796                         box.template_image(bg, "image", bg.image_user, compact=True)
2797                         has_bg = True
2798
2799                 elif bg.source == 'MOVIE_CLIP':
2800                     box.prop(bg, "use_camera_clip")
2801
2802                     column = box.column()
2803                     column.active = not bg.use_camera_clip
2804                     column.template_ID(bg, "clip", open="clip.open")
2805
2806                     if bg.clip:
2807                         column.template_movieclip(bg, "clip", compact=True)
2808
2809                     if bg.use_camera_clip or bg.clip:
2810                         has_bg = True
2811
2812                     column = box.column()
2813                     column.active = has_bg
2814                     column.prop(bg.clip_user, "proxy_render_size", text="")
2815                     column.prop(bg.clip_user, "use_render_undistorted")
2816
2817                 if has_bg:
2818                     col = box.column()
2819                     col.prop(bg, "opacity", slider=True)
2820                     col.row().prop(bg, "draw_depth", expand=True)
2821
2822                     if bg.view_axis in {'CAMERA', 'ALL'}:
2823                         col.row().prop(bg, "frame_method", expand=True)
2824
2825                     row = col.row(align=True)
2826                     row.prop(bg, "offset_x", text="X")
2827                     row.prop(bg, "offset_y", text="Y")
2828
2829                     if bg.view_axis != 'CAMERA':
2830                         col.prop(bg, "size")
2831
2832
2833 class VIEW3D_PT_transform_orientations(Panel):
2834     bl_space_type = 'VIEW_3D'
2835     bl_region_type = 'UI'
2836     bl_label = "Transform Orientations"
2837     bl_options = {'DEFAULT_CLOSED'}
2838
2839     @classmethod
2840     def poll(cls, context):
2841         view = context.space_data
2842         return (view)
2843
2844     def draw(self, context):
2845         layout = self.layout
2846
2847         view = context.space_data
2848         orientation = view.current_orientation
2849
2850         row = layout.row(align=True)
2851         row.prop(view, "transform_orientation", text="")
2852         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2853
2854         if orientation:
2855             row = layout.row(align=True)
2856             row.prop(orientation, "name", text="")
2857             row.operator("transform.delete_orientation", text="", icon="X")
2858
2859
2860 class VIEW3D_PT_etch_a_ton(Panel):
2861     bl_space_type = 'VIEW_3D'
2862     bl_region_type = 'UI'
2863     bl_label = "Skeleton Sketching"
2864     bl_options = {'DEFAULT_CLOSED'}
2865
2866     @classmethod
2867     def poll(cls, context):
2868         scene = context.space_data
2869         ob = context.active_object
2870         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2871
2872     def draw_header(self, context):
2873         layout = self.layout
2874         toolsettings = context.scene.tool_settings
2875
2876         layout.prop(toolsettings, "use_bone_sketching", text="")
2877
2878     def draw(self, context):
2879         layout = self.layout
2880
2881         toolsettings = context.scene.tool_settings
2882
2883         col = layout.column()
2884
2885         col.prop(toolsettings, "use_etch_quick")
2886         col.prop(toolsettings, "use_etch_overdraw")
2887
2888         col.separator()
2889
2890         col.prop(toolsettings, "etch_convert_mode")
2891
2892         if toolsettings.etch_convert_mode == 'LENGTH':
2893             col.prop(toolsettings, "etch_length_limit")
2894         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2895             col.prop(toolsettings, "etch_adaptive_limit")
2896         elif toolsettings.etch_convert_mode == 'FIXED':
2897             col.prop(toolsettings, "etch_subdivision_number")
2898         elif toolsettings.etch_convert_mode == 'RETARGET':
2899             col.prop(toolsettings, "etch_template")
2900             col.prop(toolsettings, "etch_roll_mode")
2901
2902             col.separator()
2903
2904             colsub = col.column(align=True)
2905             colsub.prop(toolsettings, "use_etch_autoname")
2906             sub = colsub.column()
2907             sub.enabled = not toolsettings.use_etch_autoname
2908             sub.prop(toolsettings, "etch_number")
2909             sub.prop(toolsettings, "etch_side")
2910
2911         col.separator()
2912
2913         col.operator("sketch.convert", text="Convert to Bones")
2914         col.operator("sketch.delete", text="Delete Strokes")
2915
2916
2917 class VIEW3D_PT_context_properties(Panel):
2918     bl_space_type = 'VIEW_3D'
2919     bl_region_type = 'UI'
2920     bl_label = "Properties"
2921     bl_options = {'DEFAULT_CLOSED'}
2922
2923     def _active_context_member(context):
2924         obj = context.object
2925         if obj:
2926             mode = obj.mode
2927             if mode == 'POSE':
2928                 return "active_pose_bone"
2929             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2930                 return "active_bone"
2931             else:
2932                 return "object"
2933
2934         return ""
2935
2936     @classmethod
2937     def poll(cls, context):
2938         member = cls._active_context_member(context)
2939         if member:
2940             context_member = getattr(context, member)
2941             return context_member and context_member.keys()
2942
2943         return False
2944
2945     def draw(self, context):
2946         import rna_prop_ui
2947         member = VIEW3D_PT_context_properties._active_context_member(context)
2948
2949         if member:
2950             # Draw with no edit button
2951             rna_prop_ui.draw(self.layout, context, member, object, False)
2952
2953
2954 def register():
2955     bpy.utils.register_module(__name__)
2956
2957
2958 def unregister():
2959     bpy.utils.unregister_module(__name__)
2960
2961 if __name__ == "__main__":
2962     register()
2963
2964 if __name__ == "__main__":  # only for live edit.
2965     bpy.utils.register_module(__name__)