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