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