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