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