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