0c41675658f03a2ad7a6f5a96165ce2db7b42c7a
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_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
987         layout.separator()
988
989         layout.operator("gpencil.select_more")
990         layout.operator("gpencil.select_less")
991
992
993 class VIEW3D_MT_select_paint_mask(Menu):
994     bl_label = "Select"
995
996     def draw(self, context):
997         layout = self.layout
998
999         layout.operator("view3d.select_border")
1000         layout.operator("view3d.select_circle")
1001
1002         layout.separator()
1003
1004         layout.operator("paint.face_select_all").action = 'TOGGLE'
1005         layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT'
1006
1007         layout.separator()
1008
1009         layout.operator("paint.face_select_linked", text="Linked")
1010
1011
1012 class VIEW3D_MT_select_paint_mask_vertex(Menu):
1013     bl_label = "Select"
1014
1015     def draw(self, context):
1016         layout = self.layout
1017
1018         layout.operator("view3d.select_border")
1019         layout.operator("view3d.select_circle")
1020
1021         layout.separator()
1022
1023         layout.operator("paint.vert_select_all").action = 'TOGGLE'
1024         layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT'
1025
1026         layout.separator()
1027
1028         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
1029
1030
1031 class VIEW3D_MT_angle_control(Menu):
1032     bl_label = "Angle Control"
1033
1034     @classmethod
1035     def poll(cls, context):
1036         settings = UnifiedPaintPanel.paint_settings(context)
1037         if not settings:
1038             return False
1039
1040         brush = settings.brush
1041         tex_slot = brush.texture_slot
1042
1043         return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
1044
1045     def draw(self, context):
1046         layout = self.layout
1047
1048         settings = UnifiedPaintPanel.paint_settings(context)
1049         brush = settings.brush
1050
1051         sculpt = (context.sculpt_object is not None)
1052
1053         tex_slot = brush.texture_slot
1054
1055         layout.prop(tex_slot, "use_rake", text="Rake")
1056
1057         if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
1058             if sculpt:
1059                 if brush.sculpt_capabilities.has_random_texture_angle:
1060                     layout.prop(tex_slot, "use_random", text="Random")
1061             else:
1062                 layout.prop(tex_slot, "use_random", text="Random")
1063
1064
1065 # ********** Add menu **********
1066
1067 # XXX: INFO_MT_ names used to keep backwards compatibility (Addons etc that hook into the menu)
1068
1069
1070 class INFO_MT_mesh_add(Menu):
1071     bl_idname = "INFO_MT_mesh_add"
1072     bl_label = "Mesh"
1073
1074     def draw(self, context):
1075         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1076
1077         layout = self.layout
1078
1079         layout.operator_context = 'INVOKE_REGION_WIN'
1080
1081         VIEW3D_PT_tools_add_object.draw_add_mesh(layout)
1082
1083
1084 class INFO_MT_curve_add(Menu):
1085     bl_idname = "INFO_MT_curve_add"
1086     bl_label = "Curve"
1087
1088     def draw(self, context):
1089         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1090         layout = self.layout
1091
1092         layout.operator_context = 'INVOKE_REGION_WIN'
1093
1094         VIEW3D_PT_tools_add_object.draw_add_curve(layout)
1095
1096
1097 class INFO_MT_surface_add(Menu):
1098     bl_idname = "INFO_MT_surface_add"
1099     bl_label = "Surface"
1100
1101     def draw(self, context):
1102         from .space_view3d_toolbar import VIEW3D_PT_tools_add_object
1103         layout = self.layout
1104
1105         layout.operator_context = 'INVOKE_REGION_WIN'
1106
1107         VIEW3D_PT_tools_add_object.draw_add_surface(layout)
1108
1109
1110 class INFO_MT_metaball_add(Menu):
1111     bl_idname = "INFO_MT_metaball_add"
1112     bl_label = "Metaball"
1113
1114     def draw(self, context):
1115         layout = self.layout
1116
1117         layout.operator_context = 'INVOKE_REGION_WIN'
1118         layout.operator_enum("object.metaball_add", "type")
1119
1120
1121 class INFO_MT_edit_curve_add(Menu):
1122     bl_idname = "INFO_MT_edit_curve_add"
1123     bl_label = "Add"
1124
1125     def draw(self, context):
1126         is_surf = context.active_object.type == 'SURFACE'
1127
1128         layout = self.layout
1129         layout.operator_context = 'EXEC_REGION_WIN'
1130
1131         if is_surf:
1132             INFO_MT_surface_add.draw(self, context)
1133         else:
1134             INFO_MT_curve_add.draw(self, context)
1135
1136
1137 class INFO_MT_edit_armature_add(Menu):
1138     bl_idname = "INFO_MT_edit_armature_add"
1139     bl_label = "Armature"
1140
1141     def draw(self, context):
1142         layout = self.layout
1143
1144         layout.operator_context = 'EXEC_REGION_WIN'
1145         layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA')
1146
1147
1148 class INFO_MT_armature_add(Menu):
1149     bl_idname = "INFO_MT_armature_add"
1150     bl_label = "Armature"
1151
1152     def draw(self, context):
1153         layout = self.layout
1154
1155         layout.operator_context = 'EXEC_REGION_WIN'
1156         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
1157
1158
1159 class INFO_MT_lamp_add(Menu):
1160     bl_idname = "INFO_MT_lamp_add"
1161     bl_label = "Lamp"
1162
1163     def draw(self, context):
1164         layout = self.layout
1165
1166         layout.operator_context = 'INVOKE_REGION_WIN'
1167         layout.operator_enum("object.lamp_add", "type")
1168
1169
1170 class INFO_MT_add(Menu):
1171     bl_label = "Add"
1172
1173     def draw(self, context):
1174         layout = self.layout
1175
1176         # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
1177
1178         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
1179         #       "align_view" to work on first call (see [#32719]).
1180         layout.operator_context = 'EXEC_REGION_WIN'
1181
1182         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
1183         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
1184
1185         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
1186         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
1187         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
1188         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
1189         layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
1190         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
1191         layout.separator()
1192
1193         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
1194         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
1195         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
1196         layout.separator()
1197
1198         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
1199         layout.separator()
1200
1201         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
1202         layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
1203         layout.separator()
1204
1205         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
1206         layout.separator()
1207
1208         if len(bpy.data.groups) > 10:
1209             layout.operator_context = 'INVOKE_REGION_WIN'
1210             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
1211         else:
1212             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
1213
1214
1215 # ********** Object menu **********
1216
1217
1218 class VIEW3D_MT_object(Menu):
1219     bl_context = "objectmode"
1220     bl_label = "Object"
1221
1222     def draw(self, context):
1223         layout = self.layout
1224
1225         layout.operator("ed.undo")
1226         layout.operator("ed.redo")
1227         layout.operator("ed.undo_history")
1228
1229         layout.separator()
1230
1231         layout.menu("VIEW3D_MT_transform_object")
1232         layout.menu("VIEW3D_MT_mirror")
1233         layout.menu("VIEW3D_MT_object_clear")
1234         layout.menu("VIEW3D_MT_object_apply")
1235         layout.menu("VIEW3D_MT_snap")
1236
1237         layout.separator()
1238
1239         layout.menu("VIEW3D_MT_object_animation")
1240
1241         layout.separator()
1242
1243         layout.operator("object.duplicate_move")
1244         layout.operator("object.duplicate_move_linked")
1245         layout.operator("object.delete", text="Delete...").use_global = False
1246         layout.operator("object.proxy_make", text="Make Proxy...")
1247         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
1248         layout.operator("object.make_dupli_face")
1249         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
1250         layout.menu("VIEW3D_MT_make_single_user")
1251
1252         layout.separator()
1253
1254         layout.menu("VIEW3D_MT_object_parent")
1255         layout.menu("VIEW3D_MT_object_track")
1256         layout.menu("VIEW3D_MT_object_group")
1257         layout.menu("VIEW3D_MT_object_constraints")
1258
1259         layout.separator()
1260
1261         layout.menu("VIEW3D_MT_object_quick_effects")
1262
1263         layout.separator()
1264
1265         layout.menu("VIEW3D_MT_object_game")
1266
1267         layout.separator()
1268
1269         layout.operator("object.join")
1270         layout.operator("object.data_transfer")
1271         layout.operator("object.datalayout_transfer")
1272
1273         layout.separator()
1274
1275         layout.operator("object.move_to_layer", text="Move to Layer...")
1276         layout.menu("VIEW3D_MT_object_showhide")
1277
1278         layout.operator_menu_enum("object.convert", "target")
1279
1280
1281 class VIEW3D_MT_object_animation(Menu):
1282     bl_label = "Animation"
1283
1284     def draw(self, context):
1285         layout = self.layout
1286
1287         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1288         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
1289         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
1290         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1291
1292         layout.separator()
1293
1294         layout.operator("nla.bake", text="Bake Action...")
1295
1296
1297 class VIEW3D_MT_object_clear(Menu):
1298     bl_label = "Clear"
1299
1300     def draw(self, context):
1301         layout = self.layout
1302
1303         layout.operator("object.location_clear", text="Location")
1304         layout.operator("object.rotation_clear", text="Rotation")
1305         layout.operator("object.scale_clear", text="Scale")
1306         layout.operator("object.origin_clear", text="Origin")
1307
1308
1309 class VIEW3D_MT_object_specials(Menu):
1310     bl_label = "Specials"
1311
1312     @classmethod
1313     def poll(cls, context):
1314         # add more special types
1315         return context.object
1316
1317     def draw(self, context):
1318         layout = self.layout
1319
1320         scene = context.scene
1321         obj = context.object
1322
1323         if obj.type == 'CAMERA':
1324             layout.operator_context = 'INVOKE_REGION_WIN'
1325
1326             if obj.data.type == 'PERSP':
1327                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1328                 props.data_path_iter = "selected_editable_objects"
1329                 props.data_path_item = "data.lens"
1330                 props.input_scale = 0.1
1331                 if obj.data.lens_unit == 'MILLIMETERS':
1332                     props.header_text = "Camera Lens Angle: %.1fmm"
1333                 else:
1334                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1335
1336             else:
1337                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1338                 props.data_path_iter = "selected_editable_objects"
1339                 props.data_path_item = "data.ortho_scale"
1340                 props.input_scale = 0.01
1341                 props.header_text = "Camera Lens Scale: %.3f"
1342
1343             if not obj.data.dof_object:
1344                 view = context.space_data
1345                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1346                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1347                 else:
1348                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1349                     props.data_path_iter = "selected_editable_objects"
1350                     props.data_path_item = "data.dof_distance"
1351                     props.input_scale = 0.02
1352                     props.header_text = "DOF Distance: %.3f"
1353                 del view
1354
1355         if obj.type in {'CURVE', 'FONT'}:
1356             layout.operator_context = 'INVOKE_REGION_WIN'
1357
1358             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1359             props.data_path_iter = "selected_editable_objects"
1360             props.data_path_item = "data.extrude"
1361             props.input_scale = 0.01
1362             props.header_text = "Extrude Size: %.3f"
1363
1364             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1365             props.data_path_iter = "selected_editable_objects"
1366             props.data_path_item = "data.offset"
1367             props.input_scale = 0.01
1368             props.header_text = "Width Size: %.3f"
1369
1370         if obj.type == 'EMPTY':
1371             layout.operator_context = 'INVOKE_REGION_WIN'
1372
1373             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
1374             props.data_path_iter = "selected_editable_objects"
1375             props.data_path_item = "empty_draw_size"
1376             props.input_scale = 0.01
1377             props.header_text = "Empty Draw Size: %.3f"
1378
1379         if obj.type == 'LAMP':
1380             lamp = obj.data
1381
1382             layout.operator_context = 'INVOKE_REGION_WIN'
1383
1384             if scene.render.use_shading_nodes:
1385                 try:
1386                     value = lamp.node_tree.nodes["Emission"].inputs["Strength"].default_value
1387                 except AttributeError:
1388                     value = None
1389
1390                 if value is not None:
1391                     props = layout.operator("wm.context_modal_mouse", text="Strength")
1392                     props.data_path_iter = "selected_editable_objects"
1393                     props.data_path_item = "data.node_tree.nodes[\"Emission\"].inputs[\"Strength\"].default_value"
1394                     props.header_text = "Lamp Strength: %.3f"
1395                     props.input_scale = 0.1
1396                 del value
1397
1398                 if lamp.type == 'AREA':
1399                     props = layout.operator("wm.context_modal_mouse", text="Size X")
1400                     props.data_path_iter = "selected_editable_objects"
1401                     props.data_path_item = "data.size"
1402                     props.header_text = "Lamp Size X: %.3f"
1403
1404                     if lamp.shape == 'RECTANGLE':
1405                         props = layout.operator("wm.context_modal_mouse", text="Size Y")
1406                         props.data_path_iter = "selected_editable_objects"
1407                         props.data_path_item = "data.size_y"
1408                         props.header_text = "Lamp Size Y: %.3f"
1409
1410                 elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
1411                     props = layout.operator("wm.context_modal_mouse", text="Size")
1412                     props.data_path_iter = "selected_editable_objects"
1413                     props.data_path_item = "data.shadow_soft_size"
1414                     props.header_text = "Lamp Size: %.3f"
1415             else:
1416                 props = layout.operator("wm.context_modal_mouse", text="Energy")
1417                 props.data_path_iter = "selected_editable_objects"
1418                 props.data_path_item = "data.energy"
1419                 props.header_text = "Lamp Energy: %.3f"
1420
1421                 if lamp.type in {'SPOT', 'AREA', 'POINT'}:
1422                     props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
1423                     props.data_path_iter = "selected_editable_objects"
1424                     props.data_path_item = "data.distance"
1425                     props.input_scale = 0.1
1426                     props.header_text = "Lamp Falloff Distance: %.1f"
1427
1428             if lamp.type == 'SPOT':
1429                 layout.separator()
1430                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
1431                 props.data_path_iter = "selected_editable_objects"
1432                 props.data_path_item = "data.spot_size"
1433                 props.input_scale = 0.01
1434                 props.header_text = "Spot Size: %.2f"
1435
1436                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
1437                 props.data_path_iter = "selected_editable_objects"
1438                 props.data_path_item = "data.spot_blend"
1439                 props.input_scale = -0.01
1440                 props.header_text = "Spot Blend: %.2f"
1441
1442                 if not scene.render.use_shading_nodes:
1443                     props = layout.operator("wm.context_modal_mouse", text="Clip Start")
1444                     props.data_path_iter = "selected_editable_objects"
1445                     props.data_path_item = "data.shadow_buffer_clip_start"
1446                     props.input_scale = 0.05
1447                     props.header_text = "Clip Start: %.2f"
1448
1449                     props = layout.operator("wm.context_modal_mouse", text="Clip End")
1450                     props.data_path_iter = "selected_editable_objects"
1451                     props.data_path_item = "data.shadow_buffer_clip_end"
1452                     props.input_scale = 0.05
1453                     props.header_text = "Clip End: %.2f"
1454
1455         layout.separator()
1456
1457         props = layout.operator("object.isolate_type_render")
1458         props = layout.operator("object.hide_render_clear_all")
1459
1460
1461 class VIEW3D_MT_object_apply(Menu):
1462     bl_label = "Apply"
1463
1464     def draw(self, context):
1465         layout = self.layout
1466
1467         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1468         props.location, props.rotation, props.scale = True, False, False
1469
1470         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1471         props.location, props.rotation, props.scale = False, True, False
1472
1473         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1474         props.location, props.rotation, props.scale = False, False, True
1475         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1476         props.location, props.rotation, props.scale = False, True, True
1477
1478         layout.separator()
1479
1480         layout.operator("object.visual_transform_apply", text="Visual Transform", text_ctxt=i18n_contexts.default)
1481         layout.operator("object.duplicates_make_real")
1482
1483
1484 class VIEW3D_MT_object_parent(Menu):
1485     bl_label = "Parent"
1486
1487     def draw(self, context):
1488         layout = self.layout
1489
1490         layout.operator_enum("object.parent_set", "type")
1491         layout.separator()
1492         layout.operator_enum("object.parent_clear", "type")
1493
1494
1495 class VIEW3D_MT_object_track(Menu):
1496     bl_label = "Track"
1497
1498     def draw(self, context):
1499         layout = self.layout
1500
1501         layout.operator_enum("object.track_set", "type")
1502         layout.separator()
1503         layout.operator_enum("object.track_clear", "type")
1504
1505
1506 class VIEW3D_MT_object_group(Menu):
1507     bl_label = "Group"
1508
1509     def draw(self, context):
1510         layout = self.layout
1511
1512         layout.operator("group.create")
1513         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
1514         layout.operator("group.objects_remove")
1515         layout.operator("group.objects_remove_all")
1516
1517         layout.separator()
1518
1519         layout.operator("group.objects_add_active")
1520         layout.operator("group.objects_remove_active")
1521
1522
1523 class VIEW3D_MT_object_constraints(Menu):
1524     bl_label = "Constraints"
1525
1526     def draw(self, context):
1527         layout = self.layout
1528
1529         layout.operator("object.constraint_add_with_targets")
1530         layout.operator("object.constraints_copy")
1531         layout.operator("object.constraints_clear")
1532
1533
1534 class VIEW3D_MT_object_quick_effects(Menu):
1535     bl_label = "Quick Effects"
1536
1537     def draw(self, context):
1538         layout = self.layout
1539
1540         layout.operator("object.quick_fur")
1541         layout.operator("object.quick_explode")
1542         layout.operator("object.quick_smoke")
1543         layout.operator("object.quick_fluid")
1544
1545
1546 class VIEW3D_MT_object_showhide(Menu):
1547     bl_label = "Show/Hide"
1548
1549     def draw(self, context):
1550         layout = self.layout
1551
1552         layout.operator("object.hide_view_clear", text="Show Hidden")
1553         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1554         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1555
1556
1557 class VIEW3D_MT_make_single_user(Menu):
1558     bl_label = "Make Single User"
1559
1560     def draw(self, context):
1561         layout = self.layout
1562
1563         props = layout.operator("object.make_single_user", text="Object")
1564         props.object = True
1565         props.obdata = props.material = props.texture = props.animation = False
1566
1567         props = layout.operator("object.make_single_user", text="Object & Data")
1568         props.object = props.obdata = True
1569         props.material = props.texture = props.animation = False
1570
1571         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1572         props.object = props.obdata = props.material = props.texture = True
1573         props.animation = False
1574
1575         props = layout.operator("object.make_single_user", text="Materials+Tex")
1576         props.material = props.texture = True
1577         props.object = props.obdata = props.animation = False
1578
1579         props = layout.operator("object.make_single_user", text="Object Animation")
1580         props.animation = True
1581         props.object = props.obdata = props.material = props.texture = False
1582
1583
1584 class VIEW3D_MT_make_links(Menu):
1585     bl_label = "Make Links"
1586
1587     def draw(self, context):
1588         layout = self.layout
1589         operator_context_default = layout.operator_context
1590         if len(bpy.data.scenes) > 10:
1591             layout.operator_context = 'INVOKE_REGION_WIN'
1592             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1593         else:
1594             layout.operator_context = 'EXEC_REGION_WIN'
1595             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1596         layout.operator_context = operator_context_default
1597
1598         layout.operator_enum("object.make_links_data", "type")  # inline
1599
1600         layout.operator("object.join_uvs")  # stupid place to add this!
1601
1602
1603 class VIEW3D_MT_object_game(Menu):
1604     bl_label = "Game"
1605
1606     def draw(self, context):
1607         layout = self.layout
1608
1609         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1610         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1611
1612         layout.separator()
1613
1614         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1615         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1616         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1617
1618         layout.separator()
1619
1620         layout.operator("object.game_property_clear")
1621
1622
1623 # ********** Brush menu **********
1624 class VIEW3D_MT_brush(Menu):
1625     bl_label = "Brush"
1626
1627     def draw(self, context):
1628         layout = self.layout
1629
1630         settings = UnifiedPaintPanel.paint_settings(context)
1631         brush = settings.brush
1632
1633         ups = context.tool_settings.unified_paint_settings
1634         layout.prop(ups, "use_unified_size", text="Unified Size")
1635         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1636         if context.image_paint_object or context.vertex_paint_object:
1637             layout.prop(ups, "use_unified_color", text="Unified Color")
1638         layout.separator()
1639
1640         # brush paint modes
1641         layout.menu("VIEW3D_MT_brush_paint_modes")
1642
1643         # brush tool
1644         if context.sculpt_object:
1645             layout.operator("brush.reset")
1646             layout.prop_menu_enum(brush, "sculpt_tool")
1647         elif context.image_paint_object:
1648             layout.prop_menu_enum(brush, "image_tool")
1649         elif context.vertex_paint_object or context.weight_paint_object:
1650             layout.prop_menu_enum(brush, "vertex_tool")
1651
1652         # skip if no active brush
1653         if not brush:
1654             return
1655
1656         # TODO: still missing a lot of brush options here
1657
1658         # sculpt options
1659         if context.sculpt_object:
1660
1661             sculpt_tool = brush.sculpt_tool
1662
1663             layout.separator()
1664             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1665             layout.separator()
1666
1667             if sculpt_tool != 'GRAB':
1668                 layout.prop_menu_enum(brush, "stroke_method")
1669
1670                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1671                     layout.prop_menu_enum(brush, "direction")
1672
1673                 if sculpt_tool == 'LAYER':
1674                     layout.prop(brush, "use_persistent")
1675                     layout.operator("sculpt.set_persistent_base")
1676
1677
1678 class VIEW3D_MT_brush_paint_modes(Menu):
1679     bl_label = "Enabled Modes"
1680
1681     def draw(self, context):
1682         layout = self.layout
1683
1684         settings = UnifiedPaintPanel.paint_settings(context)
1685         brush = settings.brush
1686
1687         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1688         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1689         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1690         layout.prop(brush, "use_paint_image", text="Texture Paint")
1691
1692 # ********** Vertex paint menu **********
1693
1694
1695 class VIEW3D_MT_paint_vertex(Menu):
1696     bl_label = "Paint"
1697
1698     def draw(self, context):
1699         layout = self.layout
1700
1701         layout.operator("ed.undo")
1702         layout.operator("ed.redo")
1703
1704         layout.separator()
1705
1706         layout.operator("paint.vertex_color_set")
1707         layout.operator("paint.vertex_color_smooth")
1708         layout.operator("paint.vertex_color_dirt")
1709
1710
1711 class VIEW3D_MT_hook(Menu):
1712     bl_label = "Hooks"
1713
1714     def draw(self, context):
1715         layout = self.layout
1716         layout.operator_context = 'EXEC_AREA'
1717         layout.operator("object.hook_add_newob")
1718         layout.operator("object.hook_add_selob").use_bone = False
1719         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1720
1721         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1722             layout.separator()
1723             layout.operator_menu_enum("object.hook_assign", "modifier")
1724             layout.operator_menu_enum("object.hook_remove", "modifier")
1725             layout.separator()
1726             layout.operator_menu_enum("object.hook_select", "modifier")
1727             layout.operator_menu_enum("object.hook_reset", "modifier")
1728             layout.operator_menu_enum("object.hook_recenter", "modifier")
1729
1730
1731 class VIEW3D_MT_vertex_group(Menu):
1732     bl_label = "Vertex Groups"
1733
1734     def draw(self, context):
1735         layout = self.layout
1736
1737         layout.operator_context = 'EXEC_AREA'
1738         layout.operator("object.vertex_group_assign_new")
1739
1740         ob = context.active_object
1741         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1742             if ob.vertex_groups.active:
1743                 layout.separator()
1744                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1745                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").use_all_groups = False
1746                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
1747                 layout.separator()
1748
1749         if ob.vertex_groups.active:
1750             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1751             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1752             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1753
1754 # ********** Weight paint menu **********
1755
1756
1757 class VIEW3D_MT_paint_weight(Menu):
1758     bl_label = "Weights"
1759
1760     def draw(self, context):
1761         layout = self.layout
1762
1763         layout.operator("ed.undo")
1764         layout.operator("ed.redo")
1765         layout.operator("ed.undo_history")
1766
1767         layout.separator()
1768
1769         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1770         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1771
1772         layout.separator()
1773
1774         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1775         layout.operator("object.vertex_group_normalize", text="Normalize")
1776         layout.operator("object.vertex_group_mirror", text="Mirror")
1777         layout.operator("object.vertex_group_invert", text="Invert")
1778         layout.operator("object.vertex_group_clean", text="Clean")
1779         layout.operator("object.vertex_group_quantize", text="Quantize")
1780         layout.operator("object.vertex_group_levels", text="Levels")
1781         layout.operator("object.vertex_group_smooth", text="Smooth")
1782         props = layout.operator("object.data_transfer", text="Transfer Weights")
1783         props.use_reverse_transfer = True
1784         props.data_type = 'VGROUP_WEIGHTS'
1785         layout.operator("object.vertex_group_limit_total", text="Limit Total")
1786         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1787
1788         layout.separator()
1789
1790         layout.operator("paint.weight_set")
1791
1792 # ********** Sculpt menu **********
1793
1794
1795 class VIEW3D_MT_sculpt(Menu):
1796     bl_label = "Sculpt"
1797
1798     def draw(self, context):
1799         layout = self.layout
1800
1801         toolsettings = context.tool_settings
1802         sculpt = toolsettings.sculpt
1803
1804         layout.operator("ed.undo")
1805         layout.operator("ed.redo")
1806
1807         layout.separator()
1808
1809         layout.prop(sculpt, "use_symmetry_x")
1810         layout.prop(sculpt, "use_symmetry_y")
1811         layout.prop(sculpt, "use_symmetry_z")
1812         layout.separator()
1813         layout.prop(sculpt, "lock_x")
1814         layout.prop(sculpt, "lock_y")
1815         layout.prop(sculpt, "lock_z")
1816
1817         layout.separator()
1818         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1819         layout.prop(sculpt, "show_low_resolution")
1820         layout.prop(sculpt, "show_brush")
1821         layout.prop(sculpt, "use_deform_only")
1822         layout.prop(sculpt, "show_diffuse_color")
1823
1824
1825 class VIEW3D_MT_hide_mask(Menu):
1826     bl_label = "Hide/Mask"
1827
1828     def draw(self, context):
1829         layout = self.layout
1830
1831         props = layout.operator("paint.hide_show", text="Show All")
1832         props.action = 'SHOW'
1833         props.area = 'ALL'
1834
1835         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
1836         props.action = 'HIDE'
1837         props.area = 'INSIDE'
1838
1839         props = layout.operator("paint.hide_show", text="Show Bounding Box")
1840         props.action = 'SHOW'
1841         props.area = 'INSIDE'
1842
1843         props = layout.operator("paint.hide_show", text="Hide Masked")
1844         props.area = 'MASKED'
1845         props.action = 'HIDE'
1846
1847         layout.separator()
1848
1849         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1850         props.mode = 'INVERT'
1851
1852         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1853         props.mode = 'VALUE'
1854         props.value = 1
1855
1856         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1857         props.mode = 'VALUE'
1858         props.value = 0
1859
1860         props = layout.operator("view3d.select_border", text="Box Mask")
1861         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
1862
1863
1864 # ********** Particle menu **********
1865
1866
1867 class VIEW3D_MT_particle(Menu):
1868     bl_label = "Particle"
1869
1870     def draw(self, context):
1871         layout = self.layout
1872
1873         particle_edit = context.tool_settings.particle_edit
1874
1875         layout.operator("ed.undo")
1876         layout.operator("ed.redo")
1877         layout.operator("ed.undo_history")
1878
1879         layout.separator()
1880
1881         layout.operator("particle.mirror")
1882
1883         layout.separator()
1884
1885         layout.operator("particle.remove_doubles")
1886         layout.operator("particle.delete")
1887
1888         if particle_edit.select_mode == 'POINT':
1889             layout.operator("particle.subdivide")
1890
1891         layout.operator("particle.rekey")
1892         layout.operator("particle.weight_set")
1893
1894         layout.separator()
1895
1896         layout.menu("VIEW3D_MT_particle_showhide")
1897
1898
1899 class VIEW3D_MT_particle_specials(Menu):
1900     bl_label = "Specials"
1901
1902     def draw(self, context):
1903         layout = self.layout
1904
1905         particle_edit = context.tool_settings.particle_edit
1906
1907         layout.operator("particle.rekey")
1908         layout.operator("particle.delete")
1909         layout.operator("particle.remove_doubles")
1910
1911         if particle_edit.select_mode == 'POINT':
1912             layout.operator("particle.subdivide")
1913
1914         layout.operator("particle.weight_set")
1915         layout.separator()
1916
1917         layout.operator("particle.mirror")
1918
1919         if particle_edit.select_mode == 'POINT':
1920             layout.separator()
1921             layout.operator("particle.select_roots")
1922             layout.operator("particle.select_tips")
1923
1924             layout.separator()
1925
1926             layout.operator("particle.select_random")
1927
1928             layout.separator()
1929
1930             layout.operator("particle.select_more")
1931             layout.operator("particle.select_less")
1932
1933             layout.separator()
1934
1935             layout.operator("particle.select_all").action = 'TOGGLE'
1936             layout.operator("particle.select_linked")
1937             layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
1938
1939
1940 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1941     _operator_name = "particle"
1942
1943 # ********** Pose Menu **********
1944
1945
1946 class VIEW3D_MT_pose(Menu):
1947     bl_label = "Pose"
1948
1949     def draw(self, context):
1950         layout = self.layout
1951
1952         layout.operator("ed.undo")
1953         layout.operator("ed.redo")
1954         layout.operator("ed.undo_history")
1955
1956         layout.separator()
1957
1958         layout.menu("VIEW3D_MT_transform_armature")
1959
1960         layout.menu("VIEW3D_MT_pose_transform")
1961         layout.menu("VIEW3D_MT_pose_apply")
1962
1963         layout.menu("VIEW3D_MT_snap")
1964
1965         layout.separator()
1966
1967         layout.menu("VIEW3D_MT_object_animation")
1968
1969         layout.separator()
1970
1971         layout.menu("VIEW3D_MT_pose_slide")
1972         layout.menu("VIEW3D_MT_pose_propagate")
1973
1974         layout.separator()
1975
1976         layout.operator("pose.copy")
1977         layout.operator("pose.paste").flipped = False
1978         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1979
1980         layout.separator()
1981
1982         layout.menu("VIEW3D_MT_pose_library")
1983         layout.menu("VIEW3D_MT_pose_motion")
1984         layout.menu("VIEW3D_MT_pose_group")
1985
1986         layout.separator()
1987
1988         layout.menu("VIEW3D_MT_object_parent")
1989         layout.menu("VIEW3D_MT_pose_ik")
1990         layout.menu("VIEW3D_MT_pose_constraints")
1991
1992         layout.separator()
1993
1994         layout.operator_context = 'EXEC_AREA'
1995         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1996         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1997         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1998
1999         layout.operator("pose.flip_names")
2000
2001         layout.operator("pose.quaternions_flip")
2002
2003         layout.separator()
2004
2005         layout.operator_context = 'INVOKE_AREA'
2006         layout.operator("armature.armature_layers", text="Change Armature Layers...")
2007         layout.operator("pose.bone_layers", text="Change Bone Layers...")
2008
2009         layout.separator()
2010
2011         layout.menu("VIEW3D_MT_pose_showhide")
2012         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2013
2014
2015 class VIEW3D_MT_pose_transform(Menu):
2016     bl_label = "Clear Transform"
2017
2018     def draw(self, context):
2019         layout = self.layout
2020
2021         layout.operator("pose.transforms_clear", text="All")
2022
2023         layout.separator()
2024
2025         layout.operator("pose.loc_clear", text="Location")
2026         layout.operator("pose.rot_clear", text="Rotation")
2027         layout.operator("pose.scale_clear", text="Scale")
2028
2029         layout.separator()
2030
2031         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
2032
2033
2034 class VIEW3D_MT_pose_slide(Menu):
2035     bl_label = "In-Betweens"
2036
2037     def draw(self, context):
2038         layout = self.layout
2039
2040         layout.operator("pose.push")
2041         layout.operator("pose.relax")
2042         layout.operator("pose.breakdown")
2043
2044
2045 class VIEW3D_MT_pose_propagate(Menu):
2046     bl_label = "Propagate"
2047
2048     def draw(self, context):
2049         layout = self.layout
2050
2051         layout.operator("pose.propagate").mode = 'WHILE_HELD'
2052
2053         layout.separator()
2054
2055         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
2056         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
2057
2058         layout.separator()
2059
2060         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
2061
2062         layout.separator()
2063
2064         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
2065
2066
2067 class VIEW3D_MT_pose_library(Menu):
2068     bl_label = "Pose Library"
2069
2070     def draw(self, context):
2071         layout = self.layout
2072
2073         layout.operator("poselib.browse_interactive", text="Browse Poses...")
2074
2075         layout.separator()
2076
2077         layout.operator("poselib.pose_add", text="Add Pose...")
2078         layout.operator("poselib.pose_rename", text="Rename Pose...")
2079         layout.operator("poselib.pose_remove", text="Remove Pose...")
2080
2081
2082 class VIEW3D_MT_pose_motion(Menu):
2083     bl_label = "Motion Paths"
2084
2085     def draw(self, context):
2086         layout = self.layout
2087
2088         layout.operator("pose.paths_calculate", text="Calculate")
2089         layout.operator("pose.paths_clear", text="Clear")
2090
2091
2092 class VIEW3D_MT_pose_group(Menu):
2093     bl_label = "Bone Groups"
2094
2095     def draw(self, context):
2096         layout = self.layout
2097
2098         pose = context.active_object.pose
2099
2100         layout.operator_context = 'EXEC_AREA'
2101         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
2102         if pose.bone_groups:
2103             active_group = pose.bone_groups.active_index + 1
2104             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
2105
2106             layout.separator()
2107
2108             # layout.operator_context = 'INVOKE_AREA'
2109             layout.operator("pose.group_unassign")
2110             layout.operator("pose.group_remove")
2111
2112
2113 class VIEW3D_MT_pose_ik(Menu):
2114     bl_label = "Inverse Kinematics"
2115
2116     def draw(self, context):
2117         layout = self.layout
2118
2119         layout.operator("pose.ik_add")
2120         layout.operator("pose.ik_clear")
2121
2122
2123 class VIEW3D_MT_pose_constraints(Menu):
2124     bl_label = "Constraints"
2125
2126     def draw(self, context):
2127         layout = self.layout
2128
2129         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
2130         layout.operator("pose.constraints_copy")
2131         layout.operator("pose.constraints_clear")
2132
2133
2134 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
2135     _operator_name = "pose"
2136
2137
2138 class VIEW3D_MT_pose_apply(Menu):
2139     bl_label = "Apply"
2140
2141     def draw(self, context):
2142         layout = self.layout
2143
2144         layout.operator("pose.armature_apply")
2145         layout.operator("pose.visual_transform_apply")
2146
2147
2148 class VIEW3D_MT_pose_specials(Menu):
2149     bl_label = "Specials"
2150
2151     def draw(self, context):
2152         layout = self.layout
2153
2154         layout.operator("paint.weight_from_bones", text="Assign Automatic from Bones").type = 'AUTOMATIC'
2155         layout.operator("paint.weight_from_bones", text="Assign from Bone Envelopes").type = 'ENVELOPES'
2156
2157         layout.separator()
2158
2159         layout.operator("pose.select_constraint_target")
2160         layout.operator("pose.flip_names")
2161         layout.operator("pose.paths_calculate")
2162         layout.operator("pose.paths_clear")
2163         layout.operator("pose.user_transforms_clear")
2164         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
2165         layout.operator("pose.relax")
2166
2167         layout.separator()
2168
2169         layout.operator_menu_enum("pose.autoside_names", "axis")
2170
2171
2172 class BoneOptions:
2173     def draw(self, context):
2174         layout = self.layout
2175
2176         options = [
2177             "show_wire",
2178             "use_deform",
2179             "use_envelope_multiply",
2180             "use_inherit_rotation",
2181             "use_inherit_scale",
2182         ]
2183
2184         if context.mode == 'EDIT_ARMATURE':
2185             bone_props = bpy.types.EditBone.bl_rna.properties
2186             data_path_iter = "selected_bones"
2187             opt_suffix = ""
2188             options.append("lock")
2189         else:  # pose-mode
2190             bone_props = bpy.types.Bone.bl_rna.properties
2191             data_path_iter = "selected_pose_bones"
2192             opt_suffix = "bone."
2193
2194         for opt in options:
2195             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
2196                                     text_ctxt=i18n_contexts.default)
2197             props.data_path_iter = data_path_iter
2198             props.data_path_item = opt_suffix + opt
2199             props.type = self.type
2200
2201
2202 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
2203     bl_label = "Toggle Bone Options"
2204     type = 'TOGGLE'
2205
2206
2207 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
2208     bl_label = "Enable Bone Options"
2209     type = 'ENABLE'
2210
2211
2212 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
2213     bl_label = "Disable Bone Options"
2214     type = 'DISABLE'
2215
2216 # ********** Edit Menus, suffix from ob.type **********
2217
2218
2219 class VIEW3D_MT_edit_mesh(Menu):
2220     bl_label = "Mesh"
2221
2222     def draw(self, context):
2223         layout = self.layout
2224
2225         toolsettings = context.tool_settings
2226
2227         layout.operator("ed.undo")
2228         layout.operator("ed.redo")
2229         layout.operator("ed.undo_history")
2230
2231         layout.separator()
2232
2233         layout.menu("VIEW3D_MT_transform")
2234         layout.menu("VIEW3D_MT_mirror")
2235         layout.menu("VIEW3D_MT_snap")
2236
2237         layout.separator()
2238
2239         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
2240
2241         layout.separator()
2242
2243         layout.operator("mesh.duplicate_move")
2244         layout.menu("VIEW3D_MT_edit_mesh_extrude")
2245         layout.menu("VIEW3D_MT_edit_mesh_delete")
2246
2247         layout.separator()
2248
2249         layout.menu("VIEW3D_MT_edit_mesh_vertices")
2250         layout.menu("VIEW3D_MT_edit_mesh_edges")
2251         layout.menu("VIEW3D_MT_edit_mesh_faces")
2252         layout.menu("VIEW3D_MT_edit_mesh_normals")
2253         layout.menu("VIEW3D_MT_edit_mesh_clean")
2254
2255         layout.separator()
2256
2257         layout.operator("mesh.symmetrize")
2258         layout.operator("mesh.symmetry_snap")
2259         layout.operator("mesh.bisect")
2260         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
2261
2262         layout.separator()
2263
2264         layout.prop(toolsettings, "use_mesh_automerge")
2265         layout.prop_menu_enum(toolsettings, "proportional_edit")
2266         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2267
2268         layout.separator()
2269
2270         layout.menu("VIEW3D_MT_edit_mesh_showhide")
2271
2272
2273 class VIEW3D_MT_edit_mesh_specials(Menu):
2274     bl_label = "Specials"
2275
2276     def draw(self, context):
2277         layout = self.layout
2278
2279         layout.operator_context = 'INVOKE_REGION_WIN'
2280
2281         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
2282         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
2283
2284         layout.separator()
2285
2286         layout.operator("mesh.merge", text="Merge...")
2287         layout.operator("mesh.remove_doubles")
2288
2289         layout.separator()
2290
2291         layout.operator("mesh.hide", text="Hide").unselected = False
2292         layout.operator("mesh.reveal", text="Reveal")
2293         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
2294
2295         layout.separator()
2296
2297         layout.operator("mesh.flip_normals")
2298         layout.operator("mesh.vertices_smooth", text="Smooth")
2299         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
2300
2301         layout.separator()
2302
2303         layout.operator("mesh.inset")
2304         layout.operator("mesh.bevel", text="Bevel")
2305         layout.operator("mesh.bridge_edge_loops")
2306
2307         layout.separator()
2308
2309         layout.operator("mesh.faces_shade_smooth")
2310         layout.operator("mesh.faces_shade_flat")
2311
2312         layout.separator()
2313
2314         layout.operator("mesh.blend_from_shape")
2315         layout.operator("mesh.shape_propagate_to_all")
2316         layout.operator("mesh.shortest_path_select")
2317         layout.operator("mesh.sort_elements")
2318         layout.operator("mesh.symmetrize")
2319         layout.operator("mesh.symmetry_snap")
2320
2321
2322 class VIEW3D_MT_edit_mesh_select_mode(Menu):
2323     bl_label = "Mesh Select Mode"
2324
2325     def draw(self, context):
2326         layout = self.layout
2327
2328         layout.operator_context = 'INVOKE_REGION_WIN'
2329         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
2330         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
2331         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
2332
2333
2334 class VIEW3D_MT_edit_mesh_extrude(Menu):
2335     bl_label = "Extrude"
2336
2337     _extrude_funcs = {
2338         'VERT': lambda layout:
2339             layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
2340         'EDGE': lambda layout:
2341             layout.operator("mesh.extrude_edges_move", text="Edges Only"),
2342         'FACE': lambda layout:
2343             layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
2344         'REGION': lambda layout:
2345             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
2346         'REGION_VERT_NORMAL': lambda layout:
2347             layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"),
2348     }
2349
2350     @staticmethod
2351     def extrude_options(context):
2352         mesh = context.object.data
2353         select_mode = context.tool_settings.mesh_select_mode
2354
2355         menu = []
2356         if mesh.total_face_sel:
2357             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
2358         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
2359             menu += ['EDGE']
2360         if mesh.total_vert_sel and select_mode[0]:
2361             menu += ['VERT']
2362
2363         # should never get here
2364         return menu
2365
2366     def draw(self, context):
2367         layout = self.layout
2368         layout.operator_context = 'INVOKE_REGION_WIN'
2369
2370         for menu_id in self.extrude_options(context):
2371             self._extrude_funcs[menu_id](layout)
2372
2373
2374 class VIEW3D_MT_edit_mesh_vertices(Menu):
2375     bl_label = "Vertices"
2376
2377     def draw(self, context):
2378         layout = self.layout
2379         layout.operator_context = 'INVOKE_REGION_WIN'
2380
2381         layout.operator("mesh.merge")
2382         layout.operator("mesh.rip_move")
2383         layout.operator("mesh.rip_move_fill")
2384         layout.operator("mesh.rip_edge_move")
2385         layout.operator("mesh.split")
2386         layout.operator_menu_enum("mesh.separate", "type")
2387         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2388         layout.operator("mesh.vert_connect", text="Connect Vertices")
2389         layout.operator("transform.vert_slide", text="Slide")
2390
2391         layout.separator()
2392
2393         layout.operator("mesh.mark_sharp", text="Mark Sharp Edges").use_verts = True
2394         props = layout.operator("mesh.mark_sharp", text="Clear Sharp Edges")
2395         props.use_verts = True
2396         props.clear = True
2397
2398         layout.separator()
2399
2400         layout.operator("mesh.bevel").vertex_only = True
2401         layout.operator("mesh.convex_hull")
2402         layout.operator("mesh.vertices_smooth")
2403         layout.operator("mesh.remove_doubles")
2404
2405         layout.operator("mesh.blend_from_shape")
2406
2407         layout.operator("object.vertex_group_smooth")
2408         layout.operator("mesh.shape_propagate_to_all")
2409
2410         layout.separator()
2411
2412         layout.menu("VIEW3D_MT_vertex_group")
2413         layout.menu("VIEW3D_MT_hook")
2414
2415
2416 class VIEW3D_MT_edit_mesh_edges(Menu):
2417     bl_label = "Edges"
2418
2419     def draw(self, context):
2420         layout = self.layout
2421
2422         with_freestyle = bpy.app.build_options.freestyle
2423
2424         layout.operator_context = 'INVOKE_REGION_WIN'
2425
2426         layout.operator("mesh.edge_face_add")
2427         layout.operator("mesh.subdivide")
2428         layout.operator("mesh.unsubdivide")
2429
2430         layout.separator()
2431
2432         layout.operator("transform.edge_crease")
2433         layout.operator("transform.edge_bevelweight")
2434
2435         layout.separator()
2436
2437         layout.operator("mesh.mark_seam").clear = False
2438         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
2439
2440         layout.separator()
2441
2442         layout.operator("mesh.mark_sharp")
2443         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
2444
2445         layout.separator()
2446
2447         if with_freestyle:
2448             layout.operator("mesh.mark_freestyle_edge").clear = False
2449             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
2450             layout.separator()
2451
2452         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2453         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
2454
2455         layout.separator()
2456
2457         layout.operator("mesh.bevel").vertex_only = False
2458         layout.operator("mesh.edge_split")
2459         layout.operator("mesh.bridge_edge_loops")
2460
2461         layout.separator()
2462
2463         layout.operator("transform.edge_slide")
2464         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
2465         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
2466         layout.operator("mesh.loop_to_region")
2467         layout.operator("mesh.region_to_loop")
2468
2469
2470 class VIEW3D_MT_edit_mesh_faces(Menu):
2471     bl_label = "Faces"
2472     bl_idname = "VIEW3D_MT_edit_mesh_faces"
2473
2474     def draw(self, context):
2475         layout = self.layout
2476
2477         with_freestyle = bpy.app.build_options.freestyle
2478
2479         layout.operator_context = 'INVOKE_REGION_WIN'
2480
2481         layout.operator("mesh.flip_normals")
2482         layout.operator("mesh.edge_face_add")
2483         layout.operator("mesh.fill")
2484         layout.operator("mesh.fill_grid")
2485         layout.operator("mesh.beautify_fill")
2486         layout.operator("mesh.inset")
2487         layout.operator("mesh.bevel").vertex_only = False
2488         layout.operator("mesh.solidify")
2489         layout.operator("mesh.intersect")
2490         layout.operator("mesh.intersect_boolean")
2491         layout.operator("mesh.wireframe")
2492
2493         layout.separator()
2494
2495         if with_freestyle:
2496             layout.operator("mesh.mark_freestyle_face").clear = False
2497             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
2498             layout.separator()
2499
2500         layout.operator("mesh.poke")
2501         props = layout.operator("mesh.quads_convert_to_tris")
2502         props.quad_method = props.ngon_method = 'BEAUTY'
2503         layout.operator("mesh.tris_convert_to_quads")
2504         layout.operator("mesh.face_split_by_edges")
2505
2506         layout.separator()
2507
2508         layout.operator("mesh.faces_shade_smooth")
2509         layout.operator("mesh.faces_shade_flat")
2510
2511         layout.operator("mesh.normals_make_consistent", text="Recalculate Normals").inside = False
2512
2513         layout.separator()
2514
2515         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2516
2517         layout.separator()
2518
2519         layout.operator("mesh.uvs_rotate")
2520         layout.operator("mesh.uvs_reverse")
2521         layout.operator("mesh.colors_rotate")
2522         layout.operator("mesh.colors_reverse")
2523
2524
2525 class VIEW3D_MT_edit_mesh_normals(Menu):
2526     bl_label = "Normals"
2527
2528     def draw(self, context):
2529         layout = self.layout
2530
2531         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
2532         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
2533
2534         layout.separator()
2535
2536         layout.operator("mesh.flip_normals")
2537
2538
2539 class VIEW3D_MT_edit_mesh_clean(Menu):
2540     bl_label = "Clean up"
2541
2542     def draw(self, context):
2543         layout = self.layout
2544
2545         layout.operator("mesh.delete_loose")
2546
2547         layout.separator()
2548
2549         layout.operator("mesh.dissolve_degenerate")
2550         layout.operator("mesh.dissolve_limited")
2551         layout.operator("mesh.face_make_planar")
2552         layout.operator("mesh.vert_connect_nonplanar")
2553         layout.operator("mesh.vert_connect_concave")
2554         layout.operator("mesh.fill_holes")
2555
2556
2557 class VIEW3D_MT_edit_mesh_delete(Menu):
2558     bl_label = "Delete"
2559
2560     def draw(self, context):
2561         layout = self.layout
2562
2563         layout.operator_enum("mesh.delete", "type")
2564
2565         layout.separator()
2566
2567         layout.operator("mesh.dissolve_verts")
2568         layout.operator("mesh.dissolve_edges")
2569         layout.operator("mesh.dissolve_faces")
2570
2571         layout.separator()
2572
2573         layout.operator("mesh.dissolve_limited")
2574
2575         layout.separator()
2576
2577         layout.operator("mesh.edge_collapse")
2578         layout.operator("mesh.delete_edgeloop", text="Edge Loops")
2579
2580
2581 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2582     _operator_name = "mesh"
2583
2584
2585 class VIEW3D_MT_edit_gpencil_delete(Menu):
2586     bl_label = "Delete"
2587
2588     def draw(self, context):
2589         layout = self.layout
2590
2591         layout.operator_enum("gpencil.delete", "type")
2592
2593         layout.separator()
2594
2595         layout.operator("gpencil.dissolve")
2596
2597
2598 # Edit Curve
2599 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2600
2601
2602 def draw_curve(self, context):
2603     layout = self.layout
2604
2605     toolsettings = context.tool_settings
2606
2607     layout.menu("VIEW3D_MT_transform")
2608     layout.menu("VIEW3D_MT_mirror")
2609     layout.menu("VIEW3D_MT_snap")
2610
2611     layout.separator()
2612
2613     layout.operator("curve.extrude_move")
2614     layout.operator("curve.spin")
2615     layout.operator("curve.duplicate_move")
2616     layout.operator("curve.split")
2617     layout.operator("curve.separate")
2618     layout.operator("curve.make_segment")
2619     layout.operator("curve.cyclic_toggle")
2620     layout.operator("curve.delete", text="Delete...")
2621
2622     layout.separator()
2623
2624     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2625     layout.menu("VIEW3D_MT_edit_curve_segments")
2626
2627     layout.separator()
2628
2629     layout.prop_menu_enum(toolsettings, "proportional_edit")
2630     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2631
2632     layout.separator()
2633
2634     layout.menu("VIEW3D_MT_edit_curve_showhide")
2635
2636
2637 class VIEW3D_MT_edit_curve(Menu):
2638     bl_label = "Curve"
2639
2640     draw = draw_curve
2641
2642
2643 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2644     bl_label = "Control Points"
2645
2646     def draw(self, context):
2647         layout = self.layout
2648
2649         edit_object = context.edit_object
2650
2651         if edit_object.type == 'CURVE':
2652             layout.operator("transform.tilt")
2653             layout.operator("curve.tilt_clear")
2654
2655             layout.separator()
2656
2657             layout.operator_menu_enum("curve.handle_type_set", "type")
2658             layout.operator("curve.normals_make_consistent")
2659
2660             layout.separator()
2661
2662         layout.menu("VIEW3D_MT_hook")
2663
2664
2665 class VIEW3D_MT_edit_curve_segments(Menu):
2666     bl_label = "Segments"
2667
2668     def draw(self, context):
2669         layout = self.layout
2670
2671         layout.operator("curve.subdivide")
2672         layout.operator("curve.switch_direction")
2673
2674
2675 class VIEW3D_MT_edit_curve_specials(Menu):
2676     bl_label = "Specials"
2677
2678     def draw(self, context):
2679         layout = self.layout
2680
2681         layout.operator("curve.subdivide")
2682         layout.operator("curve.switch_direction")
2683         layout.operator("curve.spline_weight_set")
2684         layout.operator("curve.radius_set")
2685         layout.operator("curve.smooth")
2686         layout.operator("curve.smooth_weight")
2687         layout.operator("curve.smooth_radius")
2688         layout.operator("curve.smooth_tilt")
2689
2690
2691 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2692     _operator_name = "curve"
2693
2694
2695 class VIEW3D_MT_edit_surface(Menu):
2696     bl_label = "Surface"
2697
2698     draw = draw_curve
2699
2700
2701 class VIEW3D_MT_edit_font(Menu):
2702     bl_label = "Text"
2703
2704     def draw(self, context):
2705         layout = self.layout
2706
2707         layout.menu("VIEW3D_MT_edit_text_chars")
2708
2709         layout.separator()
2710
2711         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2712         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2713         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2714         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2715
2716
2717 class VIEW3D_MT_edit_text_chars(Menu):
2718     bl_label = "Special Characters"
2719
2720     def draw(self, context):
2721         layout = self.layout
2722
2723         layout.operator("font.text_insert", text="Copyright").text = "\u00A9"
2724         layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE"
2725
2726         layout.separator()
2727
2728         layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0"
2729         layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7"
2730         layout.operator("font.text_insert", text="Circle").text = "\u008A"
2731         layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9"
2732         layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2"
2733         layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3"
2734         layout.operator("font.text_insert", text="Double >>").text = "\u00BB"
2735         layout.operator("font.text_insert", text="Double <<").text = "\u00AB"
2736         layout.operator("font.text_insert", text="Promillage").text = "\u2030"
2737
2738         layout.separator()
2739
2740         layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4"
2741         layout.operator("font.text_insert", text="British Pound").text = "\u00A3"
2742         layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5"
2743
2744         layout.separator()
2745
2746         layout.operator("font.text_insert", text="German S").text = "\u00DF"
2747         layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF"
2748         layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1"
2749
2750
2751 class VIEW3D_MT_edit_meta(Menu):
2752     bl_label = "Metaball"
2753
2754     def draw(self, context):
2755         layout = self.layout
2756
2757         toolsettings = context.tool_settings
2758
2759         layout.operator("ed.undo")
2760         layout.operator("ed.redo")
2761         layout.operator("ed.undo_history")
2762
2763         layout.separator()
2764
2765         layout.menu("VIEW3D_MT_transform")
2766         layout.menu("VIEW3D_MT_mirror")
2767         layout.menu("VIEW3D_MT_snap")
2768
2769         layout.separator()
2770
2771         layout.operator("mball.delete_metaelems", text="Delete...")
2772         layout.operator("mball.duplicate_metaelems")
2773
2774         layout.separator()
2775
2776         layout.prop_menu_enum(toolsettings, "proportional_edit")
2777         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2778
2779         layout.separator()
2780
2781         layout.menu("VIEW3D_MT_edit_meta_showhide")
2782
2783
2784 class VIEW3D_MT_edit_meta_showhide(Menu):
2785     bl_label = "Show/Hide"
2786
2787     def draw(self, context):
2788         layout = self.layout
2789
2790         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2791         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2792         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2793
2794
2795 class VIEW3D_MT_edit_lattice(Menu):
2796     bl_label = "Lattice"
2797
2798     def draw(self, context):
2799         layout = self.layout
2800
2801         toolsettings = context.tool_settings
2802
2803         layout.menu("VIEW3D_MT_transform")
2804         layout.menu("VIEW3D_MT_mirror")
2805         layout.menu("VIEW3D_MT_snap")
2806         layout.operator_menu_enum("lattice.flip", "axis")
2807
2808         layout.separator()
2809
2810         layout.operator("lattice.make_regular")
2811
2812         layout.separator()
2813
2814         layout.prop_menu_enum(toolsettings, "proportional_edit")
2815         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2816
2817
2818 class VIEW3D_MT_edit_armature(Menu):
2819     bl_label = "Armature"
2820
2821     def draw(self, context):
2822         layout = self.layout
2823
2824         edit_object = context.edit_object
2825         arm = edit_object.data
2826
2827         layout.menu("VIEW3D_MT_transform_armature")
2828         layout.menu("VIEW3D_MT_mirror")
2829         layout.menu("VIEW3D_MT_snap")
2830         layout.menu("VIEW3D_MT_edit_armature_roll")
2831
2832         layout.separator()
2833
2834         layout.operator("armature.extrude_move")
2835
2836         if arm.use_mirror_x:
2837             layout.operator("armature.extrude_forked")
2838
2839         layout.operator("armature.duplicate_move")
2840         layout.operator("armature.merge")
2841         layout.operator("armature.fill")
2842         layout.operator("armature.delete")
2843         layout.operator("armature.split")
2844         layout.operator("armature.separate")
2845
2846         layout.separator()
2847
2848         layout.operator("armature.subdivide", text="Subdivide")
2849         layout.operator("armature.switch_direction", text="Switch Direction")
2850
2851         layout.separator()
2852
2853         layout.operator_context = 'EXEC_AREA'
2854         layout.operator("armature.symmetrize")
2855         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2856         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2857         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2858         layout.operator("armature.flip_names")
2859
2860         layout.separator()
2861
2862         layout.operator_context = 'INVOKE_DEFAULT'
2863         layout.operator("armature.armature_layers")
2864         layout.operator("armature.bone_layers")
2865
2866         layout.separator()
2867
2868         layout.menu("VIEW3D_MT_edit_armature_parent")
2869
2870         layout.separator()
2871
2872         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2873
2874
2875 class VIEW3D_MT_armature_specials(Menu):
2876     bl_label = "Specials"
2877
2878     def draw(self, context):
2879         layout = self.layout
2880
2881         layout.operator_context = 'INVOKE_REGION_WIN'
2882
2883         layout.operator("armature.subdivide", text="Subdivide")
2884         layout.operator("armature.switch_direction", text="Switch Direction")
2885
2886         layout.separator()
2887
2888         layout.operator_context = 'EXEC_REGION_WIN'
2889         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2890         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2891         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2892         layout.operator("armature.flip_names", text="Flip Names")
2893         layout.operator("armature.symmetrize")
2894
2895
2896 class VIEW3D_MT_edit_armature_parent(Menu):
2897     bl_label = "Parent"
2898
2899     def draw(self, context):
2900         layout = self.layout
2901
2902         layout.operator("armature.parent_set", text="Make")
2903         layout.operator("armature.parent_clear", text="Clear")
2904
2905
2906 class VIEW3D_MT_edit_armature_roll(Menu):
2907     bl_label = "Bone Roll"
2908
2909     def draw(self, context):
2910         layout = self.layout
2911
2912         layout.operator_menu_enum("armature.calculate_roll", "type")
2913
2914         layout.separator()
2915
2916         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2917
2918
2919 class VIEW3D_MT_edit_armature_delete(Menu):
2920     bl_label = "Delete"
2921
2922     def draw(self, context):
2923         layout = self.layout
2924
2925         layout.operator("armature.delete", text="Delete Bones")
2926
2927         layout.separator()
2928
2929         layout.operator("armature.dissolve", text="Dissolve")
2930
2931
2932 # ********** GPencil Stroke Edit menu **********
2933
2934
2935 class VIEW3D_MT_edit_gpencil(Menu):
2936     bl_label = "GPencil"
2937     
2938     def draw(self, context):
2939         toolsettings = context.tool_settings
2940
2941         layout = self.layout
2942
2943         layout.operator("ed.undo")
2944         layout.operator("ed.redo")
2945         layout.operator("ed.undo_history")
2946
2947         layout.separator()
2948
2949         layout.operator("gpencil.brush_paint", text="Sculpt Strokes").wait_for_input = True
2950         layout.prop_menu_enum(toolsettings.gpencil_sculpt, "tool", text="Sculpt Brush")
2951
2952         layout.separator()
2953
2954         layout.menu("VIEW3D_MT_edit_gpencil_transform")
2955         layout.operator("transform.mirror", text="Mirror")
2956         layout.menu("GPENCIL_MT_snap")
2957
2958         layout.separator()
2959
2960         layout.menu("VIEW3D_MT_object_animation")   # NOTE: provides keyingset access...
2961
2962         layout.separator()
2963
2964         layout.menu("VIEW3D_MT_edit_gpencil_delete")
2965         layout.operator("gpencil.duplicate_move", text="Duplicate")
2966
2967         layout.separator()
2968
2969         layout.operator("gpencil.copy", text="Copy")
2970         layout.operator("gpencil.paste", text="Paste")
2971
2972         layout.separator()
2973
2974         layout.prop_menu_enum(toolsettings, "proportional_edit")
2975         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2976
2977         layout.separator()
2978
2979         layout.operator("gpencil.reveal")
2980         layout.operator("gpencil.hide", text="Show Active Layer Only").unselected = True
2981         layout.operator("gpencil.hide", text="Hide Active Layer").unselected = False
2982
2983         layout.separator()
2984
2985         layout.operator_menu_enum("gpencil.move_to_layer", "layer", text="Move to Layer")
2986         layout.operator_menu_enum("gpencil.convert", "type", text="Convert to Geometry...")
2987
2988
2989 class VIEW3D_MT_edit_gpencil_transform(Menu):
2990     bl_label = "Transform"
2991
2992     def draw(self, context):
2993         layout = self.layout
2994
2995         layout.operator("transform.translate")
2996         layout.operator("transform.rotate")
2997         layout.operator("transform.resize", text="Scale")
2998
2999         layout.separator()
3000
3001         layout.operator("transform.bend", text="Bend")
3002         layout.operator("transform.shear", text="Shear")
3003         layout.operator("transform.tosphere", text="To Sphere")
3004         layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN'
3005
3006
3007 # ********** Panel **********
3008
3009
3010 class VIEW3D_PT_grease_pencil(GreasePencilDataPanel, Panel):
3011     bl_space_type = 'VIEW_3D'
3012     bl_region_type = 'UI'
3013
3014     # NOTE: this is just a wrapper around the generic GP Panel
3015
3016
3017 class VIEW3D_PT_view3d_properties(Panel):
3018     bl_space_type = 'VIEW_3D'
3019     bl_region_type = 'UI'
3020     bl_label = "View"
3021
3022     @classmethod
3023     def poll(cls, context):
3024         view = context.space_data
3025         return (view)
3026
3027     def draw(self, context):
3028         layout = self.layout
3029
3030         view = context.space_data
3031
3032         col = layout.column()
3033         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
3034         col.prop(view, "lens")
3035         col.label(text="Lock to Object:")
3036         col.prop(view, "lock_object", text="")
3037         lock_object = view.lock_object
3038         if lock_object:
3039             if lock_object.type == 'ARMATURE':
3040                 col.prop_search(view, "lock_bone", lock_object.data,
3041                                 "edit_bones" if lock_object.mode == 'EDIT'
3042                                 else "bones",
3043                                 text="")
3044         else:
3045             col.prop(view, "lock_cursor", text="Lock to Cursor")
3046
3047         col = layout.column()
3048         col.prop(view, "lock_camera")
3049
3050         col = layout.column(align=True)
3051         col.label(text="Clip:")
3052         col.prop(view, "clip_start", text="Start")
3053         col.prop(view, "clip_end", text="End")
3054
3055         subcol = col.column(align=True)
3056         subcol.enabled = not view.lock_camera_and_layers
3057         subcol.label(text="Local Camera:")
3058         subcol.prop(view, "camera", text="")
3059
3060         col = layout.column(align=True)
3061         col.prop(view, "use_render_border")
3062         col.active = view.region_3d.view_perspective != 'CAMERA'
3063
3064
3065 class VIEW3D_PT_view3d_cursor(Panel):
3066     bl_space_type = 'VIEW_3D'
3067     bl_region_type = 'UI'
3068     bl_label = "3D Cursor"
3069
3070     @classmethod
3071     def poll(cls, context):
3072         view = context.space_data
3073         return (view is not None)
3074
3075     def draw(self, context):
3076         layout = self.layout
3077
3078         view = context.space_data
3079         layout.column().prop(view, "cursor_location", text="Location")
3080
3081
3082 class VIEW3D_PT_view3d_name(Panel):
3083     bl_space_type = 'VIEW_3D'
3084     bl_region_type = 'UI'
3085     bl_label = "Item"
3086
3087     @classmethod
3088     def poll(cls, context):
3089         return (context.space_data and context.active_object)
3090
3091     def draw(self, context):
3092         layout = self.layout
3093
3094         ob = context.active_object
3095         row = layout.row()
3096         row.label(text="", icon='OBJECT_DATA')
3097         row.prop(ob, "name", text="")
3098
3099         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
3100             bone = context.active_bone
3101             if bone:
3102                 row = layout.row()
3103                 row.label(text="", icon='BONE_DATA')
3104                 row.prop(bone, "name", text="")
3105
3106
3107 class VIEW3D_PT_view3d_display(Panel):
3108     bl_space_type = 'VIEW_3D'
3109     bl_region_type = 'UI'
3110     bl_label = "Display"
3111     bl_options = {'DEFAULT_CLOSED'}
3112
3113     @classmethod
3114     def poll(cls, context):
3115         view = context.space_data
3116         return (view)
3117
3118     def draw(self, context):
3119         layout = self.layout
3120
3121         view = context.space_data
3122         scene = context.scene
3123
3124         col = layout.column()
3125         col.prop(view, "show_only_render")
3126         col.prop(view, "show_world")
3127
3128         col = layout.column()
3129         display_all = not view.show_only_render
3130         col.active = display_all
3131         col.prop(view, "show_outline_selected")
3132         col.prop(view, "show_all_objects_origin")
3133         col.prop(view, "show_relationship_lines")
3134
3135         col = layout.column()
3136         col.active = display_all
3137         split = col.split(percentage=0.55)
3138         split.prop(view, "show_floor", text="Grid Floor")
3139
3140         row = split.row(align=True)
3141         row.prop(view, "show_axis_x", text="X", toggle=True)
3142         row.prop(view, "show_axis_y", text="Y", toggle=True)
3143         row.prop(view, "show_axis_z", text="Z", toggle=True)
3144
3145         sub = col.column(align=True)
3146         sub.active = (display_all and view.show_floor)
3147         sub.prop(view, "grid_lines", text="Lines")
3148         sub.prop(view, "grid_scale", text="Scale")
3149         subsub = sub.column(align=True)
3150         subsub.active = scene.unit_settings.system == 'NONE'
3151         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
3152
3153         layout.separator()
3154
3155         layout.operator("screen.region_quadview", text="Toggle Quad View")
3156
3157         if view.region_quadviews:
3158             region = view.region_quadviews[2]
3159             col = layout.column()
3160             col.prop(region, "lock_rotation")
3161             row = col.row()
3162             row.enabled = region.lock_rotation
3163             row.prop(region, "show_sync_view")
3164             row = col.row()
3165             row.enabled = region.lock_rotation and region.show_sync_view
3166             row.prop(region, "use_box_clip")
3167
3168
3169 class VIEW3D_PT_view3d_stereo(Panel):
3170     bl_space_type = 'VIEW_3D'
3171     bl_region_type = 'UI'
3172     bl_label = "Stereoscopy"
3173     bl_options = {'DEFAULT_CLOSED'}
3174
3175     @classmethod
3176     def poll(cls, context):
3177         scene = context.scene
3178
3179         multiview = scene.render.use_multiview
3180         return context.space_data and multiview
3181
3182     def draw(self, context):
3183         layout = self.layout
3184         view = context.space_data
3185
3186         basic_stereo = context.scene.render.views_format == 'STEREO_3D'
3187
3188         col = layout.column()
3189         col.row().prop(view, "stereo_3d_camera", expand=True)
3190
3191         col.label(text="Display:")
3192         row = col.row()
3193         row.active = basic_stereo
3194         row.prop(view, "show_stereo_3d_cameras")
3195         row = col.row()
3196         row.active = basic_stereo
3197         split = row.split()
3198         split.prop(view, "show_stereo_3d_convergence_plane")
3199         split = row.split()
3200         split.prop(view, "stereo_3d_convergence_plane_alpha", text="Alpha")
3201         split.active = view.show_stereo_3d_convergence_plane
3202         row = col.row()
3203         split = row.split()
3204         split.prop(view, "show_stereo_3d_volume")
3205         split = row.split()
3206         split.prop(view, "stereo_3d_volume_alpha", text="Alpha")
3207
3208
3209 class VIEW3D_PT_view3d_shading(Panel):
3210     bl_space_type = 'VIEW_3D'
3211     bl_region_type = 'UI'
3212     bl_label = "Shading"
3213
3214     def draw(self, context):
3215         layout = self.layout
3216
3217         view = context.space_data
3218         scene = context.scene
3219         gs = scene.game_settings
3220         obj = context.object
3221
3222         col = layout.column()
3223
3224         if not scene.render.use_shading_nodes:
3225             col.prop(gs, "material_mode", text="")
3226
3227         if view.viewport_shade == 'SOLID':
3228             col.prop(view, "show_textured_solid")
3229             col.prop(view, "use_matcap")
3230             if view.use_matcap:
3231                 col.template_icon_view(view, "matcap_icon")
3232         if view.viewport_shade == 'TEXTURED' or context.mode == 'PAINT_TEXTURE':
3233             if scene.render.use_shading_nodes or gs.material_mode != 'GLSL':
3234                 col.prop(view, "show_textured_shadeless")
3235
3236         col.prop(view, "show_backface_culling")
3237
3238         if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
3239             if obj and obj.mode == 'EDIT':
3240                 col.prop(view, "show_occlude_wire")
3241
3242         fx_settings = view.fx_settings
3243
3244         if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
3245             sub = col.column()
3246             sub.active = view.region_3d.view_perspective == 'CAMERA'
3247             sub.prop(fx_settings, "use_dof")
3248             col.prop(fx_settings, "use_ssao", text="Ambient Occlusion")
3249             if fx_settings.use_ssao:
3250                 ssao_settings = fx_settings.ssao
3251                 subcol = col.column(align=True)
3252                 subcol.prop(ssao_settings, "factor")
3253                 subcol.prop(ssao_settings, "distance_max")
3254                 subcol.prop(ssao_settings, "attenuation")
3255                 subcol.prop(ssao_settings, "samples")
3256                 subcol.prop(ssao_settings, "color")
3257
3258
3259 class VIEW3D_PT_view3d_motion_tracking(Panel):
3260     bl_space_type = 'VIEW_3D'
3261     bl_region_type = 'UI'
3262     bl_label = "Motion Tracking"
3263     bl_options = {'DEFAULT_CLOSED'}
3264
3265     @classmethod
3266     def poll(cls, context):
3267         view = context.space_data
3268         return (view)
3269
3270     def draw_header(self, context):
3271         view = context.space_data
3272
3273         self.layout.prop(view, "show_reconstruction", text="")
3274
3275     def draw(self, context):
3276         layout = self.layout
3277
3278         view = context.space_data
3279
3280         col = layout.column()
3281         col.active = view.show_reconstruction
3282         col.prop(view, "show_camera_path", text="Camera Path")
3283         col.prop(view, "show_bundle_names", text="3D Marker Names")
3284         col.label(text="Track Type and Size:")
3285         row = col.row(align=True)
3286         row.prop(view, "tracks_draw_type", text="")
3287         row.prop(view, "tracks_draw_size", text="")
3288
3289
3290 class VIEW3D_PT_view3d_meshdisplay(Panel):
3291     bl_space_type = 'VIEW_3D'
3292     bl_region_type = 'UI'
3293     bl_label = "Mesh Display"
3294
3295     @classmethod
3296     def poll(cls, context):
3297         # The active object check is needed because of local-mode
3298         return (context.active_object and (context.mode == 'EDIT_MESH'))
3299
3300     def draw(self, context):
3301         layout = self.layout
3302         with_freestyle = bpy.app.build_options.freestyle
3303
3304         mesh = context.active_object.data
3305         scene = context.scene
3306
3307         split = layout.split()
3308
3309         col = split.column()
3310         col.label(text="Overlays:")
3311         col.prop(mesh, "show_faces", text="Faces")
3312         col.prop(mesh, "show_edges", text="Edges")
3313         col.prop(mesh, "show_edge_crease", text="Creases")
3314         if with_freestyle:
3315             col.prop(mesh, "show_edge_seams", text="Seams")
3316
3317         layout.prop(mesh, "show_weight")
3318
3319         col = split.column()
3320         col.label()
3321         if not with_freestyle:
3322             col.prop(mesh, "show_edge_seams", text="Seams")
3323         col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
3324         col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
3325         if with_freestyle:
3326             col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
3327             col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")
3328
3329         col = layout.column()
3330
3331         col.separator()
3332         col.label(text="Normals:")
3333         row = col.row(align=True)
3334
3335         row.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
3336         row.prop(mesh, "show_normal_loop", text="", icon='LOOPSEL')
3337         row.prop(mesh, "show_normal_face", text="", icon='FACESEL')
3338
3339         sub = row.row(align=True)
3340         sub.active = mesh.show_normal_vertex or mesh.show_normal_face or mesh.show_normal_loop
3341         sub.prop(scene.tool_settings, "normal_size", text="Size")
3342
3343         col.separator()
3344         split = layout.split()
3345         col = split.column()
3346         col.label(text="Edge Info:")
3347         col.prop(mesh, "show_extra_edge_length", text="Length")
3348         col.prop(mesh, "show_extra_edge_angle", text="Angle")
3349         col = split.column()
3350         col.label(text="Face Info:")
3351         col.prop(mesh, "show_extra_face_area", text="Area")
3352         col.prop(mesh, "show_extra_face_angle", text="Angle")
3353         if bpy.app.debug:
3354             layout.prop(mesh, "show_extra_indices")
3355
3356
3357 class VIEW3D_PT_view3d_meshstatvis(Panel):
3358     bl_space_type = 'VIEW_3D'
3359     bl_region_type = 'UI'
3360     bl_label = "Mesh Analysis"
3361
3362     @classmethod
3363     def poll(cls, context):
3364         # The active object check is needed because of local-mode
3365         return (context.active_object and (context.mode == 'EDIT_MESH'))
3366
3367     def draw_header(self, context):
3368         mesh = context.active_object.data
3369
3370         self.layout.prop(mesh, "show_statvis", text="")
3371
3372     def draw(self, context):
3373         layout = self.layout
3374
3375         mesh = context.active_object.data
3376         statvis = context.tool_settings.statvis
3377         layout.active = mesh.show_statvis
3378
3379         layout.prop(statvis, "type")
3380         statvis_type = statvis.type
3381         if statvis_type == 'OVERHANG':
3382             row = layout.row(align=True)
3383             row.prop(statvis, "overhang_min", text="")
3384             row.prop(statvis, "overhang_max", text="")
3385             layout.prop(statvis, "overhang_axis", expand=True)
3386         elif statvis_type == 'THICKNESS':
3387             row = layout.row(align=True)
3388             row.prop(statvis, "thickness_min", text="")
3389             row.prop(statvis, "thickness_max", text="")
3390             layout.prop(statvis, "thickness_samples")
3391         elif statvis_type == 'INTERSECT':
3392             pass
3393         elif statvis_type == 'DISTORT':
3394             row = layout.row(align=True)
3395             row.prop(statvis, "distort_min", text="")
3396             row.prop(statvis, "distort_max", text="")
3397         elif statvis_type == 'SHARP':
3398             row = layout.row(align=True)
3399             row.prop(statvis, "sharp_min", text="")
3400             row.prop(statvis, "sharp_max", text="")
3401
3402
3403 class VIEW3D_PT_view3d_curvedisplay(Panel):
3404     bl_space_type = 'VIEW_3D'
3405     bl_region_type = 'UI'
3406     bl_label = "Curve Display"
3407
3408     @classmethod
3409     def poll(cls, context):
3410         editmesh = context.mode == 'EDIT_CURVE'
3411         return (editmesh)
3412
3413     def draw(self, context):
3414         layout = self.layout
3415
3416         curve = context.active_object.data
3417
3418         col = layout.column()
3419         row = col.row()
3420         row.prop(curve, "show_handles", text="Handles")
3421         row.prop(curve, "show_normal_face", text="Normals")
3422         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
3423
3424
3425 class VIEW3D_PT_background_image(Panel):
3426     bl_space_type = 'VIEW_3D'
3427     bl_region_type = 'UI'
3428     bl_label = "Background Images"
3429     bl_options = {'DEFAULT_CLOSED'}
3430
3431     def draw_header(self, context):
3432         view = context.space_data
3433
3434         self.layout.prop(view, "show_background_images", text="")
3435
3436     def draw(self, context):
3437         layout = self.layout
3438
3439         view = context.space_data
3440         use_multiview = context.scene.render.use_multiview
3441
3442         col = layout.column()
3443         col.operator("view3d.background_image_add", text="Add Image")
3444
3445         for i, bg in enumerate(view.background_images):
3446             layout.active = view.show_background_images
3447             box = layout.box()
3448             row = box.row(align=True)
3449             row.prop(bg, "show_expanded", text="", emboss=False)
3450             if bg.source == 'IMAGE' and bg.image:
3451                 row.prop(bg.image, "name", text="", emboss=False)
3452             elif bg.source == 'MOVIE_CLIP' and bg.clip:
3453                 row.prop(bg.clip, "name", text="", emboss=False)
3454             else:
3455                 row.label(text="Not Set")
3456
3457             if bg.show_background_image:
3458                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
3459             else:
3460                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
3461
3462             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
3463
3464             box.prop(bg, "view_axis", text="Axis")
3465
3466             if bg.show_expanded:
3467                 row = box.row()
3468                 row.prop(bg, "source", expand=True)
3469
3470                 has_bg = False
3471                 if bg.source == 'IMAGE':
3472                     row = box.row()
3473                     row.template_ID(bg, "image", open="image.open")
3474                     if bg.image is not None:
3475                         box.template_image(bg, "image", bg.image_user, compact=True)
3476                         has_bg = True
3477
3478                         if use_multiview and bg.view_axis in {'CAMERA', 'ALL'}:
3479                             box.prop(bg.image, "use_multiview")
3480
3481                             column = box.column()
3482                             column.active = bg.image.use_multiview
3483
3484                             column.label(text="Views Format:")
3485                             column.row().prop(bg.image, "views_format", expand=True)
3486
3487                             sub = column.box()
3488                             sub.active = bg.image.views_format == 'STEREO_3D'
3489                             sub.template_image_stereo_3d(bg.image.stereo_3d_format)
3490
3491                 elif bg.source == 'MOVIE_CLIP':
3492                     box.prop(bg, "use_camera_clip")
3493
3494                     column = box.column()
3495                     column.active = not bg.use_camera_clip
3496                     column.template_ID(bg, "clip", open="clip.open")
3497
3498                     if bg.clip:
3499                         column.template_movieclip(bg, "clip", compact=True)
3500
3501                     if bg.use_camera_clip or bg.clip:
3502                         has_bg = True
3503
3504                     column = box.column()
3505                     column.active = has_bg
3506                     column.prop(bg.clip_user, "proxy_render_size", text="")
3507                     column.prop(bg.clip_user, "use_render_undistorted")
3508
3509                 if has_bg:
3510                     col = box.column()
3511                     col.prop(bg, "opacity", slider=True)
3512                     col.row().prop(bg, "draw_depth", expand=True)
3513
3514                     if bg.view_axis in {'CAMERA', 'ALL'}:
3515                         col.row().prop(bg, "frame_method", expand=True)
3516
3517                     box = col.box()
3518                     row = box.row()
3519                     row.prop(bg, "offset_x", text="X")
3520                     row.prop(bg, "offset_y", text="Y")
3521
3522                     row = box.row()
3523                     row.prop(bg, "use_flip_x")
3524                     row.prop(bg, "use_flip_y")
3525
3526                     row = box.row()
3527                     if bg.view_axis != 'CAMERA':
3528                         row.prop(bg, "rotation")
3529                         row.prop(bg, "size")
3530
3531
3532 class VIEW3D_PT_transform_orientations(Panel):
3533     bl_space_type = 'VIEW_3D'
3534     bl_region_type = 'UI'
3535     bl_label = "Transform Orientations"
3536     bl_options = {'DEFAULT_CLOSED'}
3537
3538     @classmethod
3539     def poll(cls, context):
3540         view = context.space_data
3541         return (view)
3542
3543     def draw(self, context):
3544         layout = self.layout
3545
3546         view = context.space_data
3547         orientation = view.current_orientation
3548
3549         row = layout.row(align=True)
3550         row.prop(view, "transform_orientation", text="")
3551         row.operator("transform.create_orientation", text="", icon='ZOOMIN')