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