2dc4b9cfabb4f1bf840dd9b4da037cbf0a71ca11
[blender-staging.git] / release / scripts / 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
22
23 class VIEW3D_HT_header(bpy.types.Header):
24     bl_space_type = 'VIEW_3D'
25
26     def draw(self, context):
27         layout = self.layout
28
29         view = context.space_data
30         mode_string = context.mode
31         edit_object = context.edit_object
32         obj = context.active_object
33         toolsettings = context.tool_settings
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         # Menus
39         if context.area.show_menus:
40             sub = row.row(align=True)
41
42             sub.menu("VIEW3D_MT_view")
43
44             # Select Menu
45             if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'):
46                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
47
48             if edit_object:
49                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
50             elif obj:
51                 if mode_string not in ('PAINT_TEXTURE'):
52                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
53             else:
54                 sub.menu("VIEW3D_MT_object")
55
56         row = layout.row()
57         row.template_header_3D()
58
59         # do in C for now since these buttons cant be both toggle AND exclusive.
60         '''
61         if obj and obj.mode == 'EDIT' and obj.type == 'MESH':
62             row_sub = row.row(align=True)
63             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL')
64             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL')
65             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL')
66         '''
67
68         if obj:
69             # Particle edit
70             if obj.mode == 'PARTICLE_EDIT':
71                 row.prop(toolsettings.particle_edit, "selection_mode", text="", expand=True, toggle=True)
72
73             # Occlude geometry
74             if view.viewport_shade in ('SOLID', 'SHADED', 'TEXTURED') and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
75                 row.prop(view, "use_occlude_geometry", text="")
76
77             # Proportional editing
78             if obj.mode in ('EDIT', 'PARTICLE_EDIT'):
79                 row = layout.row(align=True)
80                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
81                 if toolsettings.proportional_edit != 'DISABLED':
82                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
83             elif obj.mode == 'OBJECT':
84                 row = layout.row(align=True)
85                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
86                 if toolsettings.use_proportional_edit_objects:
87                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
88
89         # Snap
90         row = layout.row(align=True)
91         row.prop(toolsettings, "use_snap", text="")
92         row.prop(toolsettings, "snap_element", text="", icon_only=True)
93         if toolsettings.snap_element != 'INCREMENT':
94             row.prop(toolsettings, "snap_target", text="")
95             if obj and obj.mode == 'OBJECT':
96                 row.prop(toolsettings, "use_snap_align_rotation", text="")
97         if toolsettings.snap_element == 'VOLUME':
98             row.prop(toolsettings, "use_snap_peel_object", text="")
99         elif toolsettings.snap_element == 'FACE':
100             row.prop(toolsettings, "use_snap_project", text="")
101
102         # OpenGL render
103         row = layout.row(align=True)
104         row.operator("render.opengl", text="", icon='RENDER_STILL')
105         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
106         props.animation = True
107
108         # Pose
109         if obj and obj.mode == 'POSE':
110             row = layout.row(align=True)
111             row.operator("pose.copy", text="", icon='COPYDOWN')
112             row.operator("pose.paste", text="", icon='PASTEDOWN')
113             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
114             props.flipped = 1
115
116
117 # ********** Menu **********
118
119 # ********** Utilities **********
120
121
122 class ShowHideMenu():
123     bl_label = "Show/Hide"
124     _operator_name = ""
125
126     def draw(self, context):
127         layout = self.layout
128
129         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
130         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
131         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
132
133
134 class VIEW3D_MT_transform(bpy.types.Menu):
135     bl_label = "Transform"
136
137     # TODO: get rid of the custom text strings?
138     def draw(self, context):
139         layout = self.layout
140
141         layout.operator("transform.translate", text="Grab/Move")
142         # TODO: sub-menu for grab per axis
143         layout.operator("transform.rotate", text="Rotate")
144         # TODO: sub-menu for rot per axis
145         layout.operator("transform.resize", text="Scale")
146         # TODO: sub-menu for scale per axis
147
148         layout.separator()
149
150         layout.operator("transform.tosphere", text="To Sphere")
151         layout.operator("transform.shear", text="Shear")
152         layout.operator("transform.warp", text="Warp")
153         layout.operator("transform.push_pull", text="Push/Pull")
154         if context.edit_object and context.edit_object.type == 'ARMATURE':
155             layout.operator("armature.align")
156         else:
157             layout.operator_context = 'EXEC_REGION_WIN'
158             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working
159
160         layout.separator()
161
162         layout.operator_context = 'EXEC_AREA'
163
164         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
165         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
166         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
167
168
169 class VIEW3D_MT_mirror(bpy.types.Menu):
170     bl_label = "Mirror"
171
172     def draw(self, context):
173         layout = self.layout
174
175         layout.operator("transform.mirror", text="Interactive Mirror")
176
177         layout.separator()
178
179         layout.operator_context = 'INVOKE_REGION_WIN'
180
181         props = layout.operator("transform.mirror", text="X Global")
182         props.constraint_axis = (True, False, False)
183         props.constraint_orientation = 'GLOBAL'
184         props = layout.operator("transform.mirror", text="Y Global")
185         props.constraint_axis = (False, True, False)
186         props.constraint_orientation = 'GLOBAL'
187         props = layout.operator("transform.mirror", text="Z Global")
188         props.constraint_axis = (False, False, True)
189         props.constraint_orientation = 'GLOBAL'
190
191         if context.edit_object:
192             layout.separator()
193
194             props = layout.operator("transform.mirror", text="X Local")
195             props.constraint_axis = (True, False, False)
196             props.constraint_orientation = 'LOCAL'
197             props = layout.operator("transform.mirror", text="Y Local")
198             props.constraint_axis = (False, True, False)
199             props.constraint_orientation = 'LOCAL'
200             props = layout.operator("transform.mirror", text="Z Local")
201             props.constraint_axis = (False, False, True)
202             props.constraint_orientation = 'LOCAL'
203
204             layout.operator("object.vertex_group_mirror")
205
206
207 class VIEW3D_MT_snap(bpy.types.Menu):
208     bl_label = "Snap"
209
210     def draw(self, context):
211         layout = self.layout
212
213         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
214         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
215
216         layout.separator()
217
218         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
219         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
220         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
221         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
222
223
224 class VIEW3D_MT_uv_map(bpy.types.Menu):
225     bl_label = "UV Mapping"
226
227     def draw(self, context):
228         layout = self.layout
229
230         layout.operator("uv.unwrap")
231         layout.operator("uv.cube_project")
232         layout.operator("uv.cylinder_project")
233         layout.operator("uv.sphere_project")
234         layout.operator("uv.project_from_view")
235         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
236
237         layout.separator()
238
239         layout.operator("uv.reset")
240
241 # ********** View menus **********
242
243
244 class VIEW3D_MT_view(bpy.types.Menu):
245     bl_label = "View"
246
247     def draw(self, context):
248         layout = self.layout
249
250         layout.operator("view3d.properties", icon='MENU_PANEL')
251         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
252
253         layout.separator()
254
255         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
256         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
257         layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
258         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
259         layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
260         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
261         layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
262
263         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
264
265         layout.separator()
266
267         layout.operator("view3d.view_persportho")
268
269         layout.separator()
270
271         layout.menu("VIEW3D_MT_view_navigation")
272         layout.menu("VIEW3D_MT_view_align")
273
274         layout.separator()
275
276         layout.operator_context = 'INVOKE_REGION_WIN'
277
278         layout.operator("view3d.clip_border", text="Clipping Border...")
279         layout.operator("view3d.zoom_border", text="Zoom Border...")
280
281         layout.separator()
282
283         layout.operator("view3d.layers", text="Show All Layers").nr = 0
284
285         layout.separator()
286
287         layout.operator("view3d.localview", text="View Global/Local")
288         layout.operator("view3d.view_selected")
289         layout.operator("view3d.view_all")
290
291         layout.separator()
292
293         layout.operator("screen.animation_play", text="Playback Animation")
294
295         layout.separator()
296
297         layout.operator("screen.area_dupli")
298         layout.operator("screen.region_quadview")
299         layout.operator("screen.screen_full_area")
300
301
302 class VIEW3D_MT_view_navigation(bpy.types.Menu):
303     bl_label = "Navigation"
304
305     def draw(self, context):
306         layout = self.layout
307
308         layout.operator_enums("view3d.view_orbit", "type")
309
310         layout.separator()
311
312         layout.operator_enums("view3d.view_pan", "type")
313
314         layout.separator()
315
316         layout.operator("view3d.zoom", text="Zoom In").delta = 1
317         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
318
319         layout.separator()
320
321         layout.operator("view3d.fly")
322
323
324 class VIEW3D_MT_view_align(bpy.types.Menu):
325     bl_label = "Align View"
326
327     def draw(self, context):
328         layout = self.layout
329
330         layout.menu("VIEW3D_MT_view_align_selected")
331
332         layout.separator()
333
334         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
335         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
336         layout.operator("view3d.view_selected")
337         layout.operator("view3d.view_center_cursor")
338
339
340 class VIEW3D_MT_view_align_selected(bpy.types.Menu):
341     bl_label = "Align View to Selected"
342
343     def draw(self, context):
344         layout = self.layout
345
346         props = layout.operator("view3d.viewnumpad", text="Top")
347         props.align_active = True
348         props.type = 'TOP'
349         props = layout.operator("view3d.viewnumpad", text="Bottom")
350         props.align_active = True
351         props.type = 'BOTTOM'
352         props = layout.operator("view3d.viewnumpad", text="Front")
353         props.align_active = True
354         props.type = 'FRONT'
355         props = layout.operator("view3d.viewnumpad", text="Back")
356         props.align_active = True
357         props.type = 'BACK'
358         props = layout.operator("view3d.viewnumpad", text="Right")
359         props.align_active = True
360         props.type = 'RIGHT'
361         props = layout.operator("view3d.viewnumpad", text="Left")
362         props.align_active = True
363         props.type = 'LEFT'
364
365
366 class VIEW3D_MT_view_cameras(bpy.types.Menu):
367     bl_label = "Cameras"
368
369     def draw(self, context):
370         layout = self.layout
371
372         layout.operator("view3d.object_as_camera")
373         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
374
375 # ********** Select menus, suffix from context.mode **********
376
377
378 class VIEW3D_MT_select_object(bpy.types.Menu):
379     bl_label = "Select"
380
381     def draw(self, context):
382         layout = self.layout
383
384         layout.operator("view3d.select_border")
385         layout.operator("view3d.select_circle")
386
387         layout.separator()
388
389         layout.operator("object.select_all", text="Select/Deselect All")
390         layout.operator("object.select_inverse", text="Inverse")
391         layout.operator("object.select_random", text="Random")
392         layout.operator("object.select_mirror", text="Mirror")
393         layout.operator("object.select_by_layer", text="Select All by Layer")
394         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
395         layout.operator("object.select_camera", text="Select Camera")
396
397         layout.separator()
398
399         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
400         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
401         layout.operator("object.select_pattern", text="Select Pattern...")
402
403
404 class VIEW3D_MT_select_pose(bpy.types.Menu):
405     bl_label = "Select"
406
407     def draw(self, context):
408         layout = self.layout
409
410         layout.operator("view3d.select_border")
411
412         layout.separator()
413
414         layout.operator("pose.select_all", text="Select/Deselect All")
415         layout.operator("pose.select_inverse", text="Inverse")
416         layout.operator("pose.select_constraint_target", text="Constraint Target")
417         layout.operator("pose.select_linked", text="Linked")
418
419         layout.separator()
420
421         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
422         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
423
424         layout.separator()
425
426         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
427         props.extend = True
428         props.direction = 'PARENT'
429
430         props = layout.operator("pose.select_hierarchy", text="Extend Child")
431         props.extend = True
432         props.direction = 'CHILD'
433
434         layout.separator()
435
436         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
437         layout.operator("object.select_pattern", text="Select Pattern...")
438
439
440 class VIEW3D_MT_select_particle(bpy.types.Menu):
441     bl_label = "Select"
442
443     def draw(self, context):
444         layout = self.layout
445
446         layout.operator("view3d.select_border")
447
448         layout.separator()
449
450         layout.operator("particle.select_all", text="Select/Deselect All")
451         layout.operator("particle.select_linked")
452         layout.operator("particle.select_inverse")
453
454         layout.separator()
455
456         layout.operator("particle.select_more")
457         layout.operator("particle.select_less")
458
459         layout.separator()
460
461         layout.operator("particle.select_roots", text="Roots")
462         layout.operator("particle.select_tips", text="Tips")
463
464
465 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
466     bl_label = "Select"
467
468     def draw(self, context):
469         layout = self.layout
470
471         layout.operator("view3d.select_border")
472         layout.operator("view3d.select_circle")
473
474         layout.separator()
475
476         layout.operator("mesh.select_all", text="Select/Deselect All")
477         layout.operator("mesh.select_inverse", text="Inverse")
478
479         layout.separator()
480
481         layout.operator("mesh.select_random", text="Random")
482         layout.operator("mesh.select_nth", text="Every N Number of Verts")
483         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
484         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
485         layout.operator("mesh.faces_select_interior", text="Interior Faces")
486         layout.operator("mesh.select_axis", text="Side of Active")
487
488         layout.separator()
489
490         layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
491         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
492         if context.scene.tool_settings.mesh_select_mode[2] == False:
493                 layout.operator("mesh.select_non_manifold", text="Non Manifold")
494         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
495         layout.operator("mesh.select_similar", text="Similar")
496
497         layout.separator()
498
499         layout.operator("mesh.select_less", text="Less")
500         layout.operator("mesh.select_more", text="More")
501
502         layout.separator()
503
504         layout.operator("mesh.select_mirror", text="Mirror")
505
506         layout.operator("mesh.select_linked", text="Linked")
507         layout.operator("mesh.select_vertex_path", text="Vertex Path")
508         layout.operator("mesh.loop_multi_select", text="Edge Loop")
509         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
510
511         layout.separator()
512
513         layout.operator("mesh.loop_to_region")
514         layout.operator("mesh.region_to_loop")
515
516
517 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
518     bl_label = "Select"
519
520     def draw(self, context):
521         layout = self.layout
522
523         layout.operator("view3d.select_border")
524         layout.operator("view3d.select_circle")
525
526         layout.separator()
527
528         layout.operator("curve.select_all", text="Select/Deselect All")
529         layout.operator("curve.select_inverse")
530         layout.operator("curve.select_random")
531         layout.operator("curve.select_nth", text="Every Nth Number of Points")
532
533         layout.separator()
534
535         layout.operator("curve.de_select_first")
536         layout.operator("curve.de_select_last")
537         layout.operator("curve.select_next")
538         layout.operator("curve.select_previous")
539
540         layout.separator()
541
542         layout.operator("curve.select_more")
543         layout.operator("curve.select_less")
544
545
546 class VIEW3D_MT_select_edit_surface(bpy.types.Menu):
547     bl_label = "Select"
548
549     def draw(self, context):
550         layout = self.layout
551
552         layout.operator("view3d.select_border")
553         layout.operator("view3d.select_circle")
554
555         layout.separator()
556
557         layout.operator("curve.select_all", text="Select/Deselect All")
558         layout.operator("curve.select_inverse")
559         layout.operator("curve.select_random")
560         layout.operator("curve.select_nth", text="Every Nth Number of Points")
561
562         layout.separator()
563
564         layout.operator("curve.select_row")
565
566         layout.separator()
567
568         layout.operator("curve.select_more")
569         layout.operator("curve.select_less")
570
571
572 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
573     bl_label = "Select"
574
575     def draw(self, context):
576         layout = self.layout
577
578         layout.operator("view3d.select_border")
579
580         layout.separator()
581
582         layout.operator("mball.select_deselect_all_metaelems")
583         layout.operator("mball.select_inverse_metaelems")
584
585         layout.separator()
586
587         layout.operator("mball.select_random_metaelems")
588
589
590 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
591     bl_label = "Select"
592
593     def draw(self, context):
594         layout = self.layout
595
596         layout.operator("view3d.select_border")
597
598         layout.separator()
599
600         layout.operator("lattice.select_all", text="Select/Deselect All")
601
602
603 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
604     bl_label = "Select"
605
606     def draw(self, context):
607         layout = self.layout
608
609         layout.operator("view3d.select_border")
610
611
612         layout.separator()
613
614         layout.operator("armature.select_all", text="Select/Deselect All")
615         layout.operator("armature.select_inverse", text="Inverse")
616
617         layout.separator()
618
619         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
620         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
621
622         layout.separator()
623
624         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
625         props.extend = True
626         props.direction = 'PARENT'
627
628         props = layout.operator("armature.select_hierarchy", text="Extend Child")
629         props.extend = True
630         props.direction = 'CHILD'
631
632         layout.operator("object.select_pattern", text="Select Pattern...")
633
634
635 class VIEW3D_MT_select_face(bpy.types.Menu):# XXX no matching enum
636     bl_label = "Select"
637
638     def draw(self, context):
639         layout = self.layout
640
641         # TODO
642         # see view3d_select_faceselmenu
643
644 # ********** Object menu **********
645
646
647 class VIEW3D_MT_object(bpy.types.Menu):
648     bl_context = "objectmode"
649     bl_label = "Object"
650
651     def draw(self, context):
652         layout = self.layout
653
654         layout.menu("VIEW3D_MT_transform")
655         layout.menu("VIEW3D_MT_mirror")
656         layout.menu("VIEW3D_MT_object_clear")
657         layout.menu("VIEW3D_MT_object_apply")
658         layout.menu("VIEW3D_MT_snap")
659
660         layout.separator()
661
662         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
663         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
664         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
665
666         layout.separator()
667
668         layout.operator("object.duplicate_move")
669         layout.operator("object.duplicate_move_linked")
670         layout.operator("object.delete", text="Delete...")
671         layout.operator("object.proxy_make", text="Make Proxy...")
672         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
673         layout.operator("object.make_dupli_face", text="Make Dupliface...")
674         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
675         layout.menu("VIEW3D_MT_make_single_user")
676
677         layout.separator()
678
679         layout.menu("VIEW3D_MT_object_parent")
680         layout.menu("VIEW3D_MT_object_track")
681         layout.menu("VIEW3D_MT_object_group")
682         layout.menu("VIEW3D_MT_object_constraints")
683
684         layout.separator()
685
686         layout.menu("VIEW3D_MT_object_game_properties")
687         layout.menu("VIEW3D_MT_object_game_logicbricks")
688
689         layout.separator()
690
691         layout.operator("object.join_uvs")
692         layout.operator("object.join")
693
694         layout.separator()
695
696         layout.operator("object.move_to_layer", text="Move to Layer...")
697         layout.menu("VIEW3D_MT_object_showhide")
698
699         layout.operator_menu_enum("object.convert", "target")
700
701
702 class VIEW3D_MT_object_clear(bpy.types.Menu):
703     bl_label = "Clear"
704
705     def draw(self, context):
706         layout = self.layout
707
708         layout.operator("object.location_clear", text="Location")
709         layout.operator("object.rotation_clear", text="Rotation")
710         layout.operator("object.scale_clear", text="Scale")
711         layout.operator("object.origin_clear", text="Origin")
712
713
714 class VIEW3D_MT_object_specials(bpy.types.Menu):
715     bl_label = "Specials"
716
717     @classmethod
718     def poll(cls, context):
719         # add more special types
720         return context.object
721
722     def draw(self, context):
723         layout = self.layout
724
725         obj = context.object
726         if obj.type == 'CAMERA':
727             layout.operator_context = 'INVOKE_REGION_WIN'
728
729             props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
730             props.data_path_iter = "selected_editable_objects"
731             props.data_path_item = "data.lens"
732             props.input_scale = 0.1
733
734             if not obj.data.dof_object:
735                 #layout.label(text="Test Has DOF obj");
736                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
737                 props.data_path_iter = "selected_editable_objects"
738                 props.data_path_item = "data.dof_distance"
739                 props.input_scale = 0.02
740
741         if obj.type in ('CURVE','TEXT'):
742             layout.operator_context = 'INVOKE_REGION_WIN'
743
744             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
745             props.data_path_iter = "selected_editable_objects"
746             props.data_path_item = "data.extrude"
747             props.input_scale = 0.01
748
749             props = layout.operator("wm.context_modal_mouse", text="Width Size")
750             props.data_path_iter = "selected_editable_objects"
751             props.data_path_item = "data.width"
752             props.input_scale = 0.01
753
754         if obj.type == 'EMPTY':
755             layout.operator_context = 'INVOKE_REGION_WIN'
756
757             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
758             props.data_path_iter = "selected_editable_objects"
759             props.data_path_item = "empty_draw_size"
760             props.input_scale = 0.01
761
762         if obj.type == 'LAMP':
763             layout.operator_context = 'INVOKE_REGION_WIN'
764
765             props = layout.operator("wm.context_modal_mouse", text="Energy")
766             props.data_path_iter = "selected_editable_objects"
767             props.data_path_item = "data.energy"
768
769             if obj.data.type in ('SPOT', 'AREA', 'POINT'):
770                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
771                 props.data_path_iter = "selected_editable_objects"
772                 props.data_path_item = "data.distance"
773                 props.input_scale = 0.1
774
775             if obj.data.type == 'SPOT':
776                 layout.separator()
777                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
778                 props.data_path_iter = "selected_editable_objects"
779                 props.data_path_item = "data.spot_size"
780                 props.input_scale = 0.01
781
782                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
783                 props.data_path_iter = "selected_editable_objects"
784                 props.data_path_item = "data.spot_blend"
785                 props.input_scale = -0.01
786
787                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
788                 props.data_path_iter = "selected_editable_objects"
789                 props.data_path_item = "data.shadow_buffer_clip_start"
790                 props.input_scale = 0.05
791
792                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
793                 props.data_path_iter = "selected_editable_objects"
794                 props.data_path_item = "data.shadow_buffer_clip_end"
795                 props.input_scale = 0.05
796
797         layout.separator()
798
799         props = layout.operator("object.isolate_type_render")
800         props = layout.operator("object.hide_render_clear_all")
801
802 class VIEW3D_MT_object_apply(bpy.types.Menu):
803     bl_label = "Apply"
804
805     def draw(self, context):
806         layout = self.layout
807
808         layout.operator("object.location_apply", text="Location")
809         layout.operator("object.rotation_apply", text="Rotation")
810         layout.operator("object.scale_apply", text="Scale")
811         layout.separator()
812         layout.operator("object.visual_transform_apply", text="Visual Transform")
813         layout.operator("object.duplicates_make_real")
814
815
816 class VIEW3D_MT_object_parent(bpy.types.Menu):
817     bl_label = "Parent"
818
819     def draw(self, context):
820         layout = self.layout
821
822         layout.operator("object.parent_set", text="Set")
823         layout.operator("object.parent_clear", text="Clear")
824
825
826 class VIEW3D_MT_object_track(bpy.types.Menu):
827     bl_label = "Track"
828
829     def draw(self, context):
830         layout = self.layout
831
832         layout.operator("object.track_set", text="Set")
833         layout.operator("object.track_clear", text="Clear")
834
835
836 class VIEW3D_MT_object_group(bpy.types.Menu):
837     bl_label = "Group"
838
839     def draw(self, context):
840         layout = self.layout
841
842         layout.operator("group.create")
843         layout.operator("group.objects_remove")
844
845         layout.separator()
846
847         layout.operator("group.objects_add_active")
848         layout.operator("group.objects_remove_active")
849
850
851 class VIEW3D_MT_object_constraints(bpy.types.Menu):
852     bl_label = "Constraints"
853
854     def draw(self, context):
855         layout = self.layout
856
857         layout.operator("object.constraint_add_with_targets")
858         layout.operator("object.constraints_copy")
859         layout.operator("object.constraints_clear")
860
861
862 class VIEW3D_MT_object_showhide(bpy.types.Menu):
863     bl_label = "Show/Hide"
864
865     def draw(self, context):
866         layout = self.layout
867
868         layout.operator("object.hide_view_clear", text="Show Hidden")
869         layout.operator("object.hide_view_set", text="Hide Selected")
870         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
871
872
873 class VIEW3D_MT_make_single_user(bpy.types.Menu):
874     bl_label = "Make Single User"
875
876     def draw(self, context):
877         layout = self.layout
878
879         props = layout.operator("object.make_single_user", text="Object")
880         props.object = True
881
882         props = layout.operator("object.make_single_user", text="Object & ObData")
883         props.object = props.obdata = True
884
885         props = layout.operator("object.make_single_user", text="Object & ObData & Materials+Tex")
886         props.object = props.obdata = props.material = props.texture = True
887
888         props = layout.operator("object.make_single_user", text="Materials+Tex")
889         props.material = props.texture = True
890
891         props = layout.operator("object.make_single_user", text="Animation")
892         props.animation = True
893
894
895 class VIEW3D_MT_make_links(bpy.types.Menu):
896     bl_label = "Make Links"
897
898     def draw(self, context):
899         layout = self.layout
900
901         layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
902         layout.operator_menu_enum("marker.make_links_scene", "scene", text="Markers to Scene...")
903         layout.operator_enums("object.make_links_data", "type") # inline
904
905
906 class VIEW3D_MT_object_game_properties(bpy.types.Menu):
907     bl_label = "Game Properties"
908
909     def draw(self, context):
910         layout = self.layout
911
912         layout.operator("object.game_property_copy", text="Replace").operation = 'REPLACE'
913         layout.operator("object.game_property_copy", text="Merge").operation = 'MERGE'
914         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy...")
915         layout.separator()
916         layout.operator("object.game_property_clear")
917
918
919 class VIEW3D_MT_object_game_logicbricks(bpy.types.Menu):
920     bl_label = "Logic Bricks"
921
922     def draw(self, context):
923         layout = self.layout
924
925         layout.operator("object.logic_bricks_copy", text="Copy")
926
927 # ********** Vertex paint menu **********
928
929
930 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
931     bl_label = "Paint"
932
933     def draw(self, context):
934         layout = self.layout
935
936         layout.operator("paint.vertex_color_set")
937         layout.operator("paint.vertex_color_dirt")
938
939
940 class VIEW3D_MT_hook(bpy.types.Menu):
941     bl_label = "Hooks"
942
943     def draw(self, context):
944         layout = self.layout
945         layout.operator_context = 'EXEC_AREA'
946         layout.operator("object.hook_add_newob")
947         layout.operator("object.hook_add_selob")
948
949         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
950             layout.separator()
951             layout.operator_menu_enum("object.hook_assign", "modifier")
952             layout.operator_menu_enum("object.hook_remove", "modifier")
953             layout.separator()
954             layout.operator_menu_enum("object.hook_select", "modifier")
955             layout.operator_menu_enum("object.hook_reset", "modifier")
956             layout.operator_menu_enum("object.hook_recenter", "modifier")
957
958
959 class VIEW3D_MT_vertex_group(bpy.types.Menu):
960     bl_label = "Vertex Groups"
961
962     def draw(self, context):
963         layout = self.layout
964         layout.operator_context = 'EXEC_AREA'
965         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
966
967         ob = context.active_object
968         if ob.mode == 'EDIT':
969             if ob.vertex_groups and ob.active_vertex_group:
970                 layout.separator()
971                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
972                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
973                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
974                 layout.separator()
975
976         if ob.vertex_groups and ob.active_vertex_group:
977             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
978             layout.operator("object.vertex_group_remove", text="Remove Active Group")
979             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
980
981 # ********** Weight paint menu **********
982
983
984 class VIEW3D_MT_paint_weight(bpy.types.Menu):
985     bl_label = "Weights"
986
987     def draw(self, context):
988         layout = self.layout
989
990         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
991         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
992
993         layout.separator()
994
995         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
996         layout.operator("object.vertex_group_normalize", text="Normalize")
997         layout.operator("object.vertex_group_invert", text="Invert")
998         layout.operator("object.vertex_group_clean", text="Clean")
999         layout.operator("object.vertex_group_levels", text="Levels")
1000
1001 # ********** Sculpt menu **********
1002
1003
1004 class VIEW3D_MT_sculpt(bpy.types.Menu):
1005     bl_label = "Sculpt"
1006
1007     def draw(self, context):
1008         layout = self.layout
1009
1010         tool_settings = context.tool_settings
1011         sculpt = tool_settings.sculpt
1012         brush = tool_settings.sculpt.brush
1013
1014         layout.prop(sculpt, "use_symmetry_x")
1015         layout.prop(sculpt, "use_symmetry_y")
1016         layout.prop(sculpt, "use_symmetry_z")
1017         layout.separator()
1018         layout.prop(sculpt, "lock_x")
1019         layout.prop(sculpt, "lock_y")
1020         layout.prop(sculpt, "lock_z")
1021         layout.separator()
1022         layout.operator_menu_enum("brush.curve_preset", "shape")
1023         layout.separator()
1024
1025         sculpt_tool = brush.sculpt_tool
1026
1027         if sculpt_tool != 'GRAB':
1028             layout.prop(brush, "use_airbrush")
1029
1030             if sculpt_tool != 'LAYER':
1031                 layout.prop(brush, "use_anchor")
1032
1033             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
1034                 layout.prop_menu_enum(brush, "direction")
1035
1036             if sculpt_tool == 'LAYER':
1037                 layout.prop(brush, "use_persistent")
1038                 layout.operator("sculpt.set_persistent_base")
1039
1040         layout.separator()
1041         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1042         layout.prop(sculpt, "show_brush")
1043
1044         # TODO, make availabel from paint menu!
1045         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Unify Size")
1046         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Unify Strength")
1047
1048 # ********** Particle menu **********
1049
1050
1051 class VIEW3D_MT_particle(bpy.types.Menu):
1052     bl_label = "Particle"
1053
1054     def draw(self, context):
1055         layout = self.layout
1056
1057         particle_edit = context.tool_settings.particle_edit
1058
1059         layout.operator("particle.mirror")
1060
1061         layout.separator()
1062
1063         layout.operator("particle.remove_doubles")
1064         layout.operator("particle.delete")
1065
1066         if particle_edit.selection_mode == 'POINT':
1067             layout.operator("particle.subdivide")
1068
1069         layout.operator("particle.rekey")
1070         layout.operator("particle.weight_set")
1071
1072         layout.separator()
1073
1074         layout.menu("VIEW3D_MT_particle_showhide")
1075
1076
1077 class VIEW3D_MT_particle_specials(bpy.types.Menu):
1078     bl_label = "Specials"
1079
1080     def draw(self, context):
1081         layout = self.layout
1082         particle_edit = context.tool_settings.particle_edit
1083
1084         layout.operator("particle.rekey")
1085
1086         layout.separator()
1087         if particle_edit.selection_mode == 'POINT':
1088             layout.operator("particle.subdivide")
1089             layout.operator("particle.select_roots")
1090             layout.operator("particle.select_tips")
1091
1092         layout.operator("particle.remove_doubles")
1093
1094
1095 class VIEW3D_MT_particle_showhide(ShowHideMenu, bpy.types.Menu):
1096     _operator_name = "particle"
1097
1098 # ********** Pose Menu **********
1099
1100
1101 class VIEW3D_MT_pose(bpy.types.Menu):
1102     bl_label = "Pose"
1103
1104     def draw(self, context):
1105         layout = self.layout
1106
1107         arm = context.active_object.data
1108
1109         layout.menu("VIEW3D_MT_transform")
1110         layout.menu("VIEW3D_MT_snap")
1111         if arm.drawtype in ('BBONE', 'ENVELOPE'):
1112             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1113
1114         layout.menu("VIEW3D_MT_pose_transform")
1115
1116         layout.separator()
1117
1118         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1119         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
1120         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1121
1122         layout.separator()
1123
1124         layout.operator("pose.relax")
1125
1126         layout.separator()
1127
1128         layout.menu("VIEW3D_MT_pose_apply")
1129
1130         layout.separator()
1131
1132         layout.operator("pose.copy")
1133         layout.operator("pose.paste")
1134         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1135
1136         layout.separator()
1137
1138         layout.menu("VIEW3D_MT_pose_pose")
1139         layout.menu("VIEW3D_MT_pose_motion")
1140         layout.menu("VIEW3D_MT_pose_group")
1141
1142         layout.separator()
1143
1144         layout.menu("VIEW3D_MT_pose_ik")
1145         layout.menu("VIEW3D_MT_pose_constraints")
1146
1147         layout.separator()
1148
1149         layout.operator_context = 'EXEC_AREA'
1150         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1151         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1152         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1153
1154         layout.operator("pose.flip_names")
1155
1156         layout.operator("pose.quaternions_flip")
1157
1158         layout.separator()
1159
1160         layout.operator_context = 'INVOKE_AREA'
1161         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1162         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1163
1164         layout.separator()
1165
1166         layout.menu("VIEW3D_MT_pose_showhide")
1167         layout.operator_menu_enum("pose.flags_set", 'mode', text="Bone Settings")
1168
1169
1170 class VIEW3D_MT_pose_transform(bpy.types.Menu):
1171     bl_label = "Clear Transform"
1172
1173     def draw(self, context):
1174         layout = self.layout
1175
1176         layout.label(text="User Transform")
1177
1178         layout.operator("pose.loc_clear", text="Location")
1179         layout.operator("pose.rot_clear", text="Rotation")
1180         layout.operator("pose.scale_clear", text="Scale")
1181
1182         layout.label(text="Origin")
1183
1184
1185 class VIEW3D_MT_pose_pose(bpy.types.Menu):
1186     bl_label = "Pose Library"
1187
1188     def draw(self, context):
1189         layout = self.layout
1190
1191         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1192
1193         layout.separator()
1194
1195         layout.operator("poselib.pose_add", text="Add Pose...")
1196         layout.operator("poselib.pose_rename", text="Rename Pose...")
1197         layout.operator("poselib.pose_remove", text="Remove Pose...")
1198
1199
1200 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1201     bl_label = "Motion Paths"
1202
1203     def draw(self, context):
1204         layout = self.layout
1205
1206         layout.operator("pose.paths_calculate", text="Calculate")
1207         layout.operator("pose.paths_clear", text="Clear")
1208
1209
1210 class VIEW3D_MT_pose_group(bpy.types.Menu):
1211     bl_label = "Bone Groups"
1212
1213     def draw(self, context):
1214         layout = self.layout
1215         layout.operator("pose.group_add")
1216         layout.operator("pose.group_remove")
1217
1218         layout.separator()
1219
1220         layout.operator("pose.group_assign")
1221         layout.operator("pose.group_unassign")
1222
1223
1224 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1225     bl_label = "Inverse Kinematics"
1226
1227     def draw(self, context):
1228         layout = self.layout
1229
1230         layout.operator("pose.ik_add")
1231         layout.operator("pose.ik_clear")
1232
1233
1234 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1235     bl_label = "Constraints"
1236
1237     def draw(self, context):
1238         layout = self.layout
1239
1240         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1241         layout.operator("pose.constraints_copy")
1242         layout.operator("pose.constraints_clear")
1243
1244
1245 class VIEW3D_MT_pose_showhide(ShowHideMenu, bpy.types.Menu):
1246     _operator_name = "pose"
1247
1248
1249 class VIEW3D_MT_pose_apply(bpy.types.Menu):
1250     bl_label = "Apply"
1251
1252     def draw(self, context):
1253         layout = self.layout
1254
1255         layout.operator("pose.armature_apply")
1256         layout.operator("pose.visual_transform_apply")
1257
1258
1259 # ********** Edit Menus, suffix from ob.type **********
1260
1261
1262 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1263     bl_label = "Mesh"
1264
1265     def draw(self, context):
1266         layout = self.layout
1267
1268         settings = context.tool_settings
1269
1270         layout.operator("ed.undo")
1271         layout.operator("ed.redo")
1272
1273         layout.separator()
1274
1275         layout.menu("VIEW3D_MT_transform")
1276         layout.menu("VIEW3D_MT_mirror")
1277         layout.menu("VIEW3D_MT_snap")
1278
1279         layout.separator()
1280
1281         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1282
1283         layout.separator()
1284
1285         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1286         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1287         layout.operator("mesh.duplicate_move")
1288         layout.operator("mesh.delete", text="Delete...")
1289
1290         layout.separator()
1291
1292         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1293         layout.menu("VIEW3D_MT_edit_mesh_edges")
1294         layout.menu("VIEW3D_MT_edit_mesh_faces")
1295         layout.menu("VIEW3D_MT_edit_mesh_normals")
1296
1297         layout.separator()
1298
1299         layout.prop(settings, "use_mesh_automerge")
1300         layout.prop_menu_enum(settings, "proportional_edit")
1301         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1302
1303         layout.separator()
1304
1305         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1306
1307
1308 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1309     bl_label = "Specials"
1310
1311     def draw(self, context):
1312         layout = self.layout
1313
1314         layout.operator_context = 'INVOKE_REGION_WIN'
1315
1316         layout.operator("mesh.subdivide", text="Subdivide")
1317         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1318         layout.operator("mesh.merge", text="Merge...")
1319         layout.operator("mesh.remove_doubles")
1320         layout.operator("mesh.hide", text="Hide")
1321         layout.operator("mesh.reveal", text="Reveal")
1322         layout.operator("mesh.select_inverse")
1323         layout.operator("mesh.flip_normals")
1324         layout.operator("mesh.vertices_smooth", text="Smooth")
1325         # layout.operator("mesh.bevel", text="Bevel")
1326         layout.operator("mesh.faces_shade_smooth")
1327         layout.operator("mesh.faces_shade_flat")
1328         layout.operator("mesh.blend_from_shape")
1329         layout.operator("mesh.shape_propagate_to_all")
1330         layout.operator("mesh.select_vertex_path")
1331
1332
1333 class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu):
1334     bl_label = "Mesh Select Mode"
1335
1336     def draw(self, context):
1337         layout = self.layout
1338
1339         layout.operator_context = 'INVOKE_REGION_WIN'
1340
1341         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1342         prop.value = "(True, False, False)"
1343         prop.data_path = "tool_settings.mesh_select_mode"
1344
1345         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1346         prop.value = "(False, True, False)"
1347         prop.data_path = "tool_settings.mesh_select_mode"
1348
1349         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1350         prop.value = "(False, False, True)"
1351         prop.data_path = "tool_settings.mesh_select_mode"
1352
1353
1354 class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu):
1355     bl_label = "Extrude"
1356
1357     @staticmethod
1358     def extrude_options(context):
1359         mesh = context.object.data
1360         selection_mode = context.tool_settings.mesh_select_mode
1361
1362         totface = mesh.total_face_sel
1363         totedge = mesh.total_edge_sel
1364         totvert = mesh.total_vert_sel
1365
1366         # the following is dependent on selection modes
1367         # we don't really want that
1368 #        if selection_mode[0]: # vert
1369 #            if totvert == 0:
1370 #                return ()
1371 #            elif totvert == 1:
1372 #                return (3,)
1373 #            elif totedge == 0:
1374 #                return (3,)
1375 #            elif totface == 0:
1376 #                return (2, 3)
1377 #            elif totface == 1:
1378 #                return (0, 2, 3)
1379 #            else:
1380 #                return (0, 1, 2, 3)
1381 #        elif selection_mode[1]: # edge
1382 #            if totedge == 0:
1383 #                return ()
1384 #            elif totedge == 1:
1385 #                return (2,)
1386 #            elif totface == 0:
1387 #                return (2,)
1388 #            elif totface == 1:
1389 #                return (0, 2)
1390 #            else:
1391 #                return (0, 1, 2)
1392 #        elif selection_mode[2]: # face
1393 #            if totface == 0:
1394 #                return ()
1395 #            elif totface == 1:
1396 #                return (0,)
1397 #            else:
1398 #                return (0, 1)
1399
1400         if totvert == 0:
1401             return ()
1402         elif totedge == 0:
1403             return (0, 3)
1404         elif totface == 0:
1405             return (0, 2, 3)
1406         else:
1407             return (0, 1, 2, 3)
1408
1409         # should never get here
1410         return ()
1411
1412     def draw(self, context):
1413         layout = self.layout
1414         layout.operator_context = 'INVOKE_REGION_WIN'
1415
1416         def region_menu():
1417             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region")
1418
1419         def face_menu():
1420             layout.operator("mesh.extrude_faces_move", text="Individual Faces")
1421
1422         def edge_menu():
1423             layout.operator("mesh.extrude_edges_move", text="Edges Only")
1424
1425         def vert_menu():
1426             layout.operator("mesh.extrude_vertices_move", text="Vertices Only")
1427
1428         menu_funcs = region_menu, face_menu, edge_menu, vert_menu
1429
1430         for i in self.extrude_options(context):
1431             func = menu_funcs[i]
1432             func()
1433
1434
1435 class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator):
1436     "Extrude individual elements and move"
1437     bl_label = "Extrude Individual and Move"
1438     bl_idname = "view3d.edit_mesh_extrude_individual_move"
1439
1440     def execute(self, context):
1441         mesh = context.object.data
1442         selection_mode = context.tool_settings.mesh_select_mode
1443
1444         totface = mesh.total_face_sel
1445         totedge = mesh.total_edge_sel
1446         totvert = mesh.total_vert_sel
1447
1448         if selection_mode[2] and totface == 1:
1449             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [False, False, True]})
1450         elif selection_mode[2] and totface > 1:
1451             return bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
1452         elif selection_mode[1] and totedge >= 1:
1453             return bpy.ops.mesh.extrude_edges_move('INVOKE_REGION_WIN')
1454         else:
1455             return bpy.ops.mesh.extrude_vertices_move('INVOKE_REGION_WIN')
1456
1457     def invoke(self, context, event):
1458         return self.execute(context)
1459
1460
1461 class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator):
1462     "Extrude and move along normals"
1463     bl_label = "Extrude and Move on Normals"
1464     bl_idname = "view3d.edit_mesh_extrude_move_normal"
1465
1466     def execute(self, context):
1467         mesh = context.object.data
1468
1469         totface = mesh.total_face_sel
1470         totedge = mesh.total_edge_sel
1471         totvert = mesh.total_vert_sel
1472
1473         if totface >= 1:
1474             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [False, False, True]})
1475         elif totedge == 1:
1476             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [True, True, False]})
1477         else:
1478             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')
1479
1480     def invoke(self, context, event):
1481         return self.execute(context)
1482
1483
1484 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1485     bl_label = "Vertices"
1486
1487     def draw(self, context):
1488         layout = self.layout
1489         layout.operator_context = 'INVOKE_REGION_WIN'
1490
1491         layout.operator("mesh.merge")
1492         layout.operator("mesh.rip")
1493         layout.operator("mesh.split")
1494         layout.operator("mesh.separate")
1495
1496         layout.separator()
1497
1498         layout.operator("mesh.vertices_smooth")
1499         layout.operator("mesh.remove_doubles")
1500
1501         layout.operator("mesh.select_vertex_path")
1502
1503         layout.operator("mesh.blend_from_shape")
1504
1505         layout.operator("object.vertex_group_blend")
1506         layout.operator("mesh.shape_propagate_to_all")
1507
1508         layout.separator()
1509
1510         layout.menu("VIEW3D_MT_vertex_group")
1511         layout.menu("VIEW3D_MT_hook")
1512
1513
1514 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1515     bl_label = "Edges"
1516
1517     def draw(self, context):
1518         layout = self.layout
1519         layout.operator_context = 'INVOKE_REGION_WIN'
1520
1521         layout.operator("mesh.edge_face_add")
1522         layout.operator("mesh.subdivide")
1523
1524         layout.separator()
1525
1526         layout.operator("mesh.mark_seam")
1527         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1528
1529         layout.separator()
1530
1531         layout.operator("mesh.mark_sharp")
1532         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1533
1534         layout.separator()
1535
1536         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1537         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1538
1539         layout.separator()
1540
1541         layout.operator("TRANSFORM_OT_edge_slide")
1542         layout.operator("TRANSFORM_OT_edge_crease")
1543         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1544
1545         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1546         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1547
1548         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1549
1550         layout.operator("mesh.loop_to_region")
1551         layout.operator("mesh.region_to_loop")
1552
1553
1554 class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
1555     bl_label = "Faces"
1556     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1557
1558     def draw(self, context):
1559         layout = self.layout
1560         layout.operator_context = 'INVOKE_REGION_WIN'
1561
1562         layout.operator("mesh.flip_normals")
1563         # layout.operator("mesh.bevel")
1564         # layout.operator("mesh.bevel")
1565         layout.operator("mesh.edge_face_add")
1566         layout.operator("mesh.fill")
1567         layout.operator("mesh.beautify_fill")
1568         layout.operator("mesh.solidify")
1569         layout.operator("mesh.sort_faces")
1570
1571         layout.separator()
1572
1573         layout.operator("mesh.quads_convert_to_tris")
1574         layout.operator("mesh.tris_convert_to_quads")
1575         layout.operator("mesh.edge_flip")
1576
1577         layout.separator()
1578
1579         layout.operator("mesh.faces_shade_smooth")
1580         layout.operator("mesh.faces_shade_flat")
1581
1582         layout.separator()
1583
1584         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1585         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1586
1587         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1588
1589         layout.separator()
1590
1591         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1592         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1593         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1594         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1595
1596
1597 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1598     bl_label = "Normals"
1599
1600     def draw(self, context):
1601         layout = self.layout
1602
1603         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1604         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1605
1606         layout.separator()
1607
1608         layout.operator("mesh.flip_normals")
1609
1610
1611 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, bpy.types.Menu):
1612     _operator_name = "mesh"
1613
1614 # Edit Curve
1615 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1616
1617
1618 def draw_curve(self, context):
1619     layout = self.layout
1620
1621     settings = context.tool_settings
1622
1623     layout.menu("VIEW3D_MT_transform")
1624     layout.menu("VIEW3D_MT_mirror")
1625     layout.menu("VIEW3D_MT_snap")
1626
1627     layout.separator()
1628
1629     layout.operator("curve.extrude")
1630     layout.operator("curve.duplicate")
1631     layout.operator("curve.separate")
1632     layout.operator("curve.make_segment")
1633     layout.operator("curve.cyclic_toggle")
1634     layout.operator("curve.delete", text="Delete...")
1635
1636     layout.separator()
1637
1638     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1639     layout.menu("VIEW3D_MT_edit_curve_segments")
1640
1641     layout.separator()
1642
1643     layout.prop_menu_enum(settings, "proportional_edit")
1644     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1645
1646     layout.separator()
1647
1648     layout.menu("VIEW3D_MT_edit_curve_showhide")
1649
1650
1651 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1652     bl_label = "Curve"
1653
1654     draw = draw_curve
1655
1656
1657 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1658     bl_label = "Control Points"
1659
1660     def draw(self, context):
1661         layout = self.layout
1662
1663         edit_object = context.edit_object
1664
1665         if edit_object.type == 'CURVE':
1666             layout.operator("transform.transform").mode = 'TILT'
1667             layout.operator("curve.tilt_clear")
1668             layout.operator("curve.separate")
1669
1670             layout.separator()
1671
1672             layout.operator_menu_enum("curve.handle_type_set", "type")
1673
1674             layout.separator()
1675
1676             layout.menu("VIEW3D_MT_hook")
1677
1678
1679 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1680     bl_label = "Segments"
1681
1682     def draw(self, context):
1683         layout = self.layout
1684
1685         layout.operator("curve.subdivide")
1686         layout.operator("curve.switch_direction")
1687
1688
1689 class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
1690     bl_label = "Specials"
1691
1692     def draw(self, context):
1693         layout = self.layout
1694
1695         layout.operator("curve.subdivide")
1696         layout.operator("curve.switch_direction")
1697         layout.operator("curve.spline_weight_set")
1698         layout.operator("curve.radius_set")
1699         layout.operator("curve.smooth")
1700         layout.operator("curve.smooth_radius")
1701
1702
1703 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, bpy.types.Menu):
1704     _operator_name = "curve"
1705
1706
1707 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1708     bl_label = "Surface"
1709
1710     draw = draw_curve
1711
1712
1713 class VIEW3D_MT_edit_text(bpy.types.Menu):
1714     bl_label = "Text"
1715
1716     def draw(self, context):
1717         layout = self.layout
1718
1719         layout.operator("font.file_paste")
1720
1721         layout.separator()
1722
1723         layout.menu("VIEW3D_MT_edit_text_chars")
1724
1725         layout.separator()
1726         
1727         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1728         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1729         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1730         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1731
1732
1733 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1734     bl_label = "Special Characters"
1735
1736     def draw(self, context):
1737         layout = self.layout
1738
1739         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1740         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1741
1742         layout.separator()
1743
1744         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1745         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1746         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1747         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1748         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1749         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1750         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1751         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1752         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1753
1754         layout.separator()
1755
1756         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1757         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1758         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1759
1760         layout.separator()
1761
1762         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1763         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1764         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1765
1766
1767 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1768     bl_label = "Metaball"
1769
1770     def draw(self, context):
1771         layout = self.layout
1772
1773         settings = context.tool_settings
1774
1775         layout.operator("ed.undo")
1776         layout.operator("ed.redo")
1777
1778         layout.separator()
1779
1780         layout.menu("VIEW3D_MT_transform")
1781         layout.menu("VIEW3D_MT_mirror")
1782         layout.menu("VIEW3D_MT_snap")
1783
1784         layout.separator()
1785
1786         layout.operator("mball.delete_metaelems", text="Delete...")
1787         layout.operator("mball.duplicate_metaelems")
1788
1789         layout.separator()
1790
1791         layout.prop_menu_enum(settings, "proportional_edit")
1792         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1793
1794         layout.separator()
1795
1796         layout.menu("VIEW3D_MT_edit_meta_showhide")
1797
1798
1799 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1800     bl_label = "Show/Hide"
1801
1802     def draw(self, context):
1803         layout = self.layout
1804
1805         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1806         layout.operator("mball.hide_metaelems", text="Hide Selected")
1807         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1808
1809
1810 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1811     bl_label = "Lattice"
1812
1813     def draw(self, context):
1814         layout = self.layout
1815
1816         settings = context.tool_settings
1817
1818         layout.menu("VIEW3D_MT_transform")
1819         layout.menu("VIEW3D_MT_mirror")
1820         layout.menu("VIEW3D_MT_snap")
1821
1822         layout.separator()
1823
1824         layout.operator("lattice.make_regular")
1825
1826         layout.separator()
1827
1828         layout.prop_menu_enum(settings, "proportional_edit")
1829         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1830
1831
1832 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1833     bl_label = "Armature"
1834
1835     def draw(self, context):
1836         layout = self.layout
1837
1838         edit_object = context.edit_object
1839         arm = edit_object.data
1840
1841         layout.menu("VIEW3D_MT_transform")
1842         layout.menu("VIEW3D_MT_mirror")
1843         layout.menu("VIEW3D_MT_snap")
1844         layout.menu("VIEW3D_MT_edit_armature_roll")
1845
1846         if arm.drawtype == 'ENVELOPE':
1847             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1848         else:
1849             layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
1850
1851         layout.separator()
1852
1853         layout.operator("armature.extrude_move")
1854
1855         if arm.x_axis_mirror:
1856             layout.operator("armature.extrude_forked")
1857
1858         layout.operator("armature.duplicate_move")
1859         layout.operator("armature.merge")
1860         layout.operator("armature.fill")
1861         layout.operator("armature.delete")
1862         layout.operator("armature.separate")
1863
1864         layout.separator()
1865
1866         layout.operator("armature.subdivide_multi", text="Subdivide")
1867         layout.operator("armature.switch_direction", text="Switch Direction")
1868
1869         layout.separator()
1870
1871         layout.operator_context = 'EXEC_AREA'
1872         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1873         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1874         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1875         layout.operator("armature.flip_names")
1876
1877         layout.separator()
1878
1879         layout.operator_context = 'INVOKE_DEFAULT'
1880         layout.operator("armature.armature_layers")
1881         layout.operator("armature.bone_layers")
1882
1883         layout.separator()
1884
1885         layout.menu("VIEW3D_MT_edit_armature_parent")
1886
1887         layout.separator()
1888
1889         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1890
1891
1892 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1893     bl_label = "Specials"
1894
1895     def draw(self, context):
1896         layout = self.layout
1897
1898         layout.operator_context = 'INVOKE_REGION_WIN'
1899
1900         layout.operator("armature.subdivide_multi", text="Subdivide")
1901         layout.operator("armature.switch_direction", text="Switch Direction")
1902
1903         layout.separator()
1904
1905         layout.operator_context = 'EXEC_REGION_WIN'
1906         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1907         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1908         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1909         layout.operator("armature.flip_names", text="Flip Names")
1910
1911
1912 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1913     bl_label = "Parent"
1914
1915     def draw(self, context):
1916         layout = self.layout
1917
1918         layout.operator("armature.parent_set", text="Make")
1919         layout.operator("armature.parent_clear", text="Clear")
1920
1921
1922 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1923     bl_label = "Bone Roll"
1924
1925     def draw(self, context):
1926         layout = self.layout
1927
1928         layout.operator("armature.calculate_roll", text="Recalculate with Z-Axis Up").type = 'GLOBALUP'
1929         layout.operator("armature.calculate_roll", text="Recalculate with Z-Axis to Cursor").type = 'CURSOR'
1930
1931         layout.separator()
1932
1933         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
1934
1935 # ********** Panel **********
1936
1937
1938 class VIEW3D_PT_view3d_properties(bpy.types.Panel):
1939     bl_space_type = 'VIEW_3D'
1940     bl_region_type = 'UI'
1941     bl_label = "View"
1942
1943     @classmethod
1944     def poll(cls, context):
1945         view = context.space_data
1946         return (view)
1947
1948     def draw(self, context):
1949         layout = self.layout
1950
1951         view = context.space_data
1952         scene = context.scene
1953
1954         col = layout.column()
1955         col.active = view.region_3d.view_perspective != 'CAMERA'
1956         col.prop(view, "lens")
1957         col.label(text="Lock to Object:")
1958         col.prop(view, "lock_object", text="")
1959         if view.lock_object and view.lock_object.type == 'ARMATURE':
1960             col.prop_object(view, "lock_bone", view.lock_object.data, "bones", text="")
1961
1962         col = layout.column(align=True)
1963         col.label(text="Clip:")
1964         col.prop(view, "clip_start", text="Start")
1965         col.prop(view, "clip_end", text="End")
1966
1967         subcol = col.column()
1968         subcol.enabled = not view.lock_camera_and_layers
1969         subcol.label(text="Local Camera:")
1970         subcol.prop(view, "camera", text="")
1971
1972         layout.column().prop(view, "cursor_location")
1973
1974
1975 class VIEW3D_PT_view3d_name(bpy.types.Panel):
1976     bl_space_type = 'VIEW_3D'
1977     bl_region_type = 'UI'
1978     bl_label = "Item"
1979
1980     @classmethod
1981     def poll(cls, context):
1982         return (context.space_data and context.active_object)
1983
1984     def draw(self, context):
1985         layout = self.layout
1986
1987         ob = context.active_object
1988         row = layout.row()
1989         row.label(text="", icon='OBJECT_DATA')
1990         row.prop(ob, "name", text="")
1991
1992         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1993             bone = context.active_bone
1994             if bone:
1995                 row = layout.row()
1996                 row.label(text="", icon='BONE_DATA')
1997                 row.prop(bone, "name", text="")
1998
1999
2000 class VIEW3D_PT_view3d_display(bpy.types.Panel):
2001     bl_space_type = 'VIEW_3D'
2002     bl_region_type = 'UI'
2003     bl_label = "Display"
2004     bl_default_closed = True
2005
2006     @classmethod
2007     def poll(cls, context):
2008         view = context.space_data
2009         return (view)
2010
2011     def draw(self, context):
2012         layout = self.layout
2013
2014         view = context.space_data
2015         gs = context.scene.game_settings
2016         ob = context.object
2017
2018         col = layout.column()
2019         col.prop(view, "show_only_render")
2020
2021         col = layout.column()
2022         display_all = not view.show_only_render
2023         col.active = display_all
2024         col.prop(view, "show_outline_selected")
2025         col.prop(view, "show_all_objects_origin")
2026         col.prop(view, "show_relationship_lines")
2027         if ob and ob.type == 'MESH':
2028             mesh = ob.data
2029             col.prop(mesh, "show_all_edges")
2030
2031         col = layout.column()
2032         col.active = display_all
2033         split = col.split(percentage=0.55)
2034         split.prop(view, "show_floor", text="Grid Floor")
2035
2036         row = split.row(align=True)
2037         row.prop(view, "show_axis_x", text="X", toggle=True)
2038         row.prop(view, "show_axis_y", text="Y", toggle=True)
2039         row.prop(view, "show_axis_z", text="Z", toggle=True)
2040
2041         sub = col.column(align=True)
2042         sub.active = (display_all and view.show_floor)
2043         sub.prop(view, "grid_lines", text="Lines")
2044         sub.prop(view, "grid_spacing", text="Spacing")
2045         sub.prop(view, "grid_subdivisions", text="Subdivisions")
2046
2047         col = layout.column()
2048         col.label(text="Shading:")
2049         col.prop(gs, "material_mode", text="")
2050         col.prop(view, "show_textured_solid")
2051
2052         layout.separator()
2053
2054         region = view.region_quadview
2055
2056         layout.operator("screen.region_quadview", text="Toggle Quad View")
2057
2058         if region:
2059             col = layout.column()
2060             col.prop(region, "lock_rotation")
2061             row = col.row()
2062             row.enabled = region.lock_rotation
2063             row.prop(region, "show_sync_view")
2064             row = col.row()
2065             row.enabled = region.lock_rotation and region.show_sync_view
2066             row.prop(region, "use_box_clip")
2067
2068
2069 class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel):
2070     bl_space_type = 'VIEW_3D'
2071     bl_region_type = 'UI'
2072     bl_label = "Mesh Display"
2073
2074     @classmethod
2075     def poll(cls, context):
2076         # The active object check is needed because of localmode
2077         return (context.active_object and (context.mode == 'EDIT_MESH'))
2078
2079     def draw(self, context):
2080         layout = self.layout
2081
2082         mesh = context.active_object.data
2083
2084         col = layout.column()
2085         col.label(text="Overlays:")
2086         col.prop(mesh, "show_edges", text="Edges")
2087         col.prop(mesh, "show_faces", text="Faces")
2088         col.prop(mesh, "show_edge_crease", text="Creases")
2089         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2090         col.prop(mesh, "show_edge_seams", text="Seams")
2091         col.prop(mesh, "show_edge_sharp", text="Sharp")
2092
2093         col.separator()
2094         col.label(text="Normals:")
2095         col.prop(mesh, "show_normal_face", text="Face")
2096         col.prop(mesh, "show_normal_vertex", text="Vertex")
2097         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2098
2099         col.separator()
2100         col.label(text="Numerics:")
2101         col.prop(mesh, "show_extra_edge_length")
2102         col.prop(mesh, "show_extra_edge_angle")
2103         col.prop(mesh, "show_extra_face_area")
2104
2105
2106 class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel):
2107     bl_space_type = 'VIEW_3D'
2108     bl_region_type = 'UI'
2109     bl_label = "Curve Display"
2110
2111     @classmethod
2112     def poll(cls, context):
2113         editmesh = context.mode == 'EDIT_CURVE'
2114         return (editmesh)
2115
2116     def draw(self, context):
2117         layout = self.layout
2118
2119         curve = context.active_object.data
2120
2121         col = layout.column()
2122         col.label(text="Overlays:")
2123         col.prop(curve, "show_handles", text="Handles")
2124         col.prop(curve, "show_normal_face", text="Normals")
2125         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2126
2127
2128 class VIEW3D_PT_background_image(bpy.types.Panel):
2129     bl_space_type = 'VIEW_3D'
2130     bl_region_type = 'UI'
2131     bl_label = "Background Images"
2132     bl_default_closed = True
2133
2134     @classmethod
2135     def poll(cls, context):
2136         view = context.space_data
2137         # bg = context.space_data.background_image
2138         return (view)
2139
2140     def draw_header(self, context):
2141         layout = self.layout
2142         view = context.space_data
2143
2144         layout.prop(view, "show_background_images", text="")
2145
2146     def draw(self, context):
2147         layout = self.layout
2148
2149         view = context.space_data
2150
2151         col = layout.column()
2152         col.operator("view3d.add_background_image", text="Add Image")
2153
2154         for i, bg in enumerate(view.background_images):
2155             layout.active = view.show_background_images
2156             box = layout.box()
2157             row = box.row(align=True)
2158             row.prop(bg, "show_expanded", text="", emboss=False)
2159             row.label(text=getattr(bg.image, "name", "Not Set"))
2160             row.operator("view3d.remove_background_image", text="", icon='X').index = i
2161
2162             box.prop(bg, "view_axis", text="Axis")
2163
2164             if bg.show_expanded:
2165                 row = box.row()
2166                 row.template_ID(bg, "image", open="image.open")
2167                 if (bg.image):
2168                     box.template_image(bg, "image", bg.image_user, compact=True)
2169
2170                     box.prop(bg, "transparency", slider=True)
2171                     if bg.view_axis != 'CAMERA':
2172                         box.prop(bg, "size")
2173                         row = box.row(align=True)
2174                         row.prop(bg, "offset_x", text="X")
2175                         row.prop(bg, "offset_y", text="Y")
2176
2177
2178 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
2179     bl_space_type = 'VIEW_3D'
2180     bl_region_type = 'UI'
2181     bl_label = "Transform Orientations"
2182     bl_default_closed = True
2183
2184     @classmethod
2185     def poll(cls, context):
2186         view = context.space_data
2187         return (view)
2188
2189     def draw(self, context):
2190         layout = self.layout
2191
2192         view = context.space_data
2193
2194         col = layout.column()
2195
2196         col.prop(view, "transform_orientation")
2197         col.operator("transform.create_orientation", text="Create")
2198
2199         orientation = view.current_orientation
2200
2201         if orientation:
2202             col.prop(orientation, "name")
2203             col.operator("transform.delete_orientation", text="Delete")
2204
2205
2206 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
2207     bl_space_type = 'VIEW_3D'
2208     bl_region_type = 'UI'
2209     bl_label = "Skeleton Sketching"
2210     bl_default_closed = True
2211
2212     @classmethod
2213     def poll(cls, context):
2214         scene = context.space_data
2215         ob = context.active_object
2216         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2217
2218     def draw_header(self, context):
2219         layout = self.layout
2220         toolsettings = context.scene.tool_settings
2221
2222         layout.prop(toolsettings, "use_bone_sketching", text="")
2223
2224     def draw(self, context):
2225         layout = self.layout
2226         toolsettings = context.scene.tool_settings
2227
2228         col = layout.column()
2229
2230         col.prop(toolsettings, "use_etch_quick")
2231         col.prop(toolsettings, "use_etch_overdraw")
2232
2233         col.prop(toolsettings, "etch_convert_mode")
2234
2235         if toolsettings.etch_convert_mode == 'LENGTH':
2236             col.prop(toolsettings, "etch_length_limit")
2237         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2238             col.prop(toolsettings, "etch_adaptive_limit")
2239         elif toolsettings.etch_convert_mode == 'FIXED':
2240             col.prop(toolsettings, "etch_subdivision_number")
2241         elif toolsettings.etch_convert_mode == 'RETARGET':
2242             col.prop(toolsettings, "etch_template")
2243             col.prop(toolsettings, "etch_roll_mode")
2244             col.prop(toolsettings, "use_etch_autoname")
2245             col.prop(toolsettings, "etch_number")
2246             col.prop(toolsettings, "etch_side")
2247             col.operator("sketch.convert", text="Convert")
2248
2249
2250 class VIEW3D_PT_context_properties(bpy.types.Panel):
2251     bl_space_type = 'VIEW_3D'
2252     bl_region_type = 'UI'
2253     bl_label = "Properties"
2254     bl_default_closed = True
2255
2256     def _active_context_member(context):
2257         obj = context.object
2258         if obj:
2259             mode = obj.mode
2260             if mode == 'POSE':
2261                 return "active_pose_bone"
2262             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2263                 return "active_bone"
2264             else:
2265                 return "object"
2266
2267         return ""
2268
2269     @classmethod
2270     def poll(cls, context):
2271         member = cls._active_context_member(context)
2272         if member:
2273             context_member = getattr(context, member)
2274             return context_member and context_member.keys()
2275
2276         return False
2277
2278     def draw(self, context):
2279         import rna_prop_ui
2280         # reload(rna_prop_ui)
2281         member = __class__._active_context_member(context)
2282
2283         if member:
2284             # Draw with no edit button
2285             rna_prop_ui.draw(self.layout, context, member, False)
2286
2287
2288 def register():
2289     pass
2290
2291
2292 def unregister():
2293     pass
2294
2295 if __name__ == "__main__":
2296     register()