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