ac65a3dae45a4ad7a93ed323034a58b707737932
[blender-staging.git] / release / scripts / ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 import dynamic_menu
22
23
24 class VIEW3D_HT_header(bpy.types.Header):
25     bl_space_type = 'VIEW_3D'
26
27     def draw(self, context):
28         layout = self.layout
29
30         view = context.space_data
31         mode_string = context.mode
32         edit_object = context.edit_object
33         object = context.active_object
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.itemM("VIEW3D_MT_view")
43
44             # Select Menu
45             if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'):
46                 sub.itemM("VIEW3D_MT_select_%s" % mode_string.lower())
47
48             if edit_object:
49                 sub.itemM("VIEW3D_MT_edit_%s" % edit_object.type.lower())
50             elif object:
51                 ob_mode_string = object.mode
52
53                 if mode_string not in ['PAINT_WEIGHT', 'PAINT_TEXTURE']:
54                     sub.itemM("VIEW3D_MT_%s" % mode_string.lower())
55             else:
56                 sub.itemM("VIEW3D_MT_object")
57
58         layout.template_header_3D()
59
60 # ********** Menu **********
61
62 # ********** Utilities **********
63
64
65 class VIEW3D_MT_showhide(bpy.types.Menu):
66     bl_label = "Show/Hide"
67     _operator_name = ""
68
69     def draw(self, context):
70         layout = self.layout
71
72         layout.itemO("%s.reveal" % self._operator_name, text="Show Hidden")
73         layout.itemO("%s.hide" % self._operator_name, text="Hide Selected")
74         layout.item_booleanO("%s.hide" % self._operator_name, "unselected", True, text="Hide Unselected")
75
76
77 class VIEW3D_MT_snap(bpy.types.Menu):
78     bl_label = "Snap"
79
80     def draw(self, context):
81         layout = self.layout
82
83         layout.itemO("view3d.snap_selected_to_grid", text="Selection to Grid")
84         layout.itemO("view3d.snap_selected_to_cursor", text="Selection to Cursor")
85         layout.itemO("view3d.snap_selected_to_center", text="Selection to Center")
86
87         layout.itemS()
88
89         layout.itemO("view3d.snap_cursor_to_selected", text="Cursor to Selected")
90         layout.itemO("view3d.snap_cursor_to_grid", text="Cursor to Grid")
91         layout.itemO("view3d.snap_cursor_to_active", text="Cursor to Active")
92
93 # ********** View menus **********
94
95
96 class VIEW3D_MT_view(bpy.types.Menu):
97     bl_label = "View"
98
99     def draw(self, context):
100         layout = self.layout
101
102         layout.itemO("view3d.properties", icon='ICON_MENU_PANEL')
103         layout.itemO("view3d.toolbar", icon='ICON_MENU_PANEL')
104
105         layout.itemS()
106
107         layout.item_enumO("view3d.viewnumpad", "type", 'CAMERA')
108         layout.item_enumO("view3d.viewnumpad", "type", 'TOP')
109         layout.item_enumO("view3d.viewnumpad", "type", 'FRONT')
110         layout.item_enumO("view3d.viewnumpad", "type", 'RIGHT')
111
112         layout.itemM("VIEW3D_MT_view_cameras", text="Cameras")
113
114         layout.itemS()
115
116         layout.itemO("view3d.view_persportho")
117
118         layout.itemS()
119
120         layout.itemM("VIEW3D_MT_view_navigation")
121         layout.itemM("VIEW3D_MT_view_align")
122
123         layout.itemS()
124
125         layout.operator_context = "INVOKE_REGION_WIN"
126
127         layout.itemO("view3d.clip_border", text="Clipping Border...")
128         layout.itemO("view3d.zoom_border", text="Zoom Border...")
129
130         layout.itemS()
131
132         layout.item_intO("view3d.layers", "nr", 0, text="Show All Layers")
133
134         layout.itemS()
135
136         layout.itemO("view3d.localview", text="View Global/Local")
137         layout.itemO("view3d.view_center")
138         layout.itemO("view3d.view_all")
139
140         layout.itemS()
141
142         layout.itemO("screen.region_foursplit", text="Toggle Quad View")
143         layout.itemO("screen.screen_full_area", text="Toggle Full Screen")
144
145         layout.itemS()
146
147         layout.itemO("screen.animation_play", text="Playback Animation", icon='ICON_PLAY')
148
149
150 class VIEW3D_MT_view_navigation(bpy.types.Menu):
151     bl_label = "Navigation"
152
153     def draw(self, context):
154         layout = self.layout
155
156         layout.items_enumO("view3d.view_orbit", "type")
157
158         layout.itemS()
159
160         layout.items_enumO("view3d.view_pan", "type")
161
162         layout.itemS()
163
164         layout.item_floatO("view3d.zoom", "delta", 1.0, text="Zoom In")
165         layout.item_floatO("view3d.zoom", "delta", -1.0, text="Zoom Out")
166
167         layout.itemS()
168
169         layout.itemO("view3d.fly")
170
171
172 class VIEW3D_MT_view_align(bpy.types.Menu):
173     bl_label = "Align View"
174
175     def draw(self, context):
176         layout = self.layout
177
178         layout.item_booleanO("view3d.view_all", "center", True, text="Center Cursor and View All")
179         layout.itemO("view3d.camera_to_view", text="Align Active Camera to View")
180         layout.itemO("view3d.view_center")
181
182
183 class VIEW3D_MT_view_cameras(bpy.types.Menu):
184     bl_label = "Cameras"
185
186     def draw(self, context):
187         layout = self.layout
188
189         layout.itemO("view3d.object_as_camera")
190         layout.item_enumO("view3d.viewnumpad", "type", 'CAMERA', text="Active Camera")
191
192 # ********** Select menus, suffix from context.mode **********
193
194
195 class VIEW3D_MT_select_object(bpy.types.Menu):
196     bl_label = "Select"
197
198     def draw(self, context):
199         layout = self.layout
200
201         layout.itemO("view3d.select_border")
202         layout.itemO("view3d.select_circle")
203
204         layout.itemS()
205
206         layout.itemO("object.select_all_toggle", text="Select/Deselect All")
207         layout.itemO("object.select_inverse", text="Inverse")
208         layout.itemO("object.select_random", text="Random")
209         layout.itemO("object.select_mirror", text="Mirror")
210         layout.itemO("object.select_by_layer", text="Select All by Layer")
211         layout.item_menu_enumO("object.select_by_type", "type", "", text="Select All by Type...")
212         
213         layout.itemS()
214         
215         layout.item_menu_enumO("object.select_grouped", "type", text="Grouped")
216         layout.item_menu_enumO("object.select_linked", "type", text="Linked")
217         layout.itemO("object.select_pattern", text="Select Pattern...")
218
219
220 class VIEW3D_MT_select_pose(bpy.types.Menu):
221     bl_label = "Select"
222
223     def draw(self, context):
224         layout = self.layout
225
226         layout.itemO("view3d.select_border")
227
228         layout.itemS()
229
230         layout.itemO("pose.select_all_toggle", text="Select/Deselect All")
231         layout.itemO("pose.select_inverse", text="Inverse")
232         layout.itemO("pose.select_constraint_target", text="Constraint Target")
233         layout.itemO("pose.select_linked", text="Linked")
234
235         layout.itemS()
236
237         layout.item_enumO("pose.select_hierarchy", "direction", 'PARENT')
238         layout.item_enumO("pose.select_hierarchy", "direction", 'CHILD')
239
240         layout.itemS()
241
242         props = layout.itemO("pose.select_hierarchy", properties=True, text="Extend Parent")
243         props.extend = True
244         props.direction = 'PARENT'
245
246         props = layout.itemO("pose.select_hierarchy", properties=True, text="Extend Child")
247         props.extend = True
248         props.direction = 'CHILD'
249
250
251 class VIEW3D_MT_select_particle(bpy.types.Menu):
252     bl_label = "Select"
253
254     def draw(self, context):
255         layout = self.layout
256
257         layout.itemO("view3d.select_border")
258
259         layout.itemS()
260
261         layout.itemO("particle.select_all_toggle", text="Select/Deselect All")
262         layout.itemO("particle.select_linked")
263
264         layout.itemS()
265
266         layout.itemO("particle.select_more")
267         layout.itemO("particle.select_less")
268
269
270 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
271     bl_label = "Select"
272
273     def draw(self, context):
274         layout = self.layout
275
276         layout.itemO("view3d.select_border")
277         layout.itemO("view3d.select_circle")
278
279         layout.itemS()
280
281         layout.itemO("mesh.select_all_toggle", text="Select/Deselect All")
282         layout.itemO("mesh.select_inverse", text="Inverse")
283
284         layout.itemS()
285
286         layout.itemO("mesh.select_random", text="Random...")
287         layout.itemO("mesh.edges_select_sharp", text="Sharp Edges")
288         layout.itemO("mesh.faces_select_linked_flat", text="Linked Flat Faces")
289
290         layout.itemS()
291
292         layout.item_enumO("mesh.select_by_number_vertices", "type", 'TRIANGLES', text="Triangles")
293         layout.item_enumO("mesh.select_by_number_vertices", "type", 'QUADS', text="Quads")
294         layout.item_enumO("mesh.select_by_number_vertices", "type", 'OTHER', text="Loose Verts/Edges")
295         layout.itemO("mesh.select_similar", text="Similar...")
296
297         layout.itemS()
298
299         layout.itemO("mesh.select_less", text="Less")
300         layout.itemO("mesh.select_more", text="More")
301
302         layout.itemS()
303
304         layout.itemO("mesh.select_mirror", text="Mirror")
305
306         layout.itemO("mesh.select_linked", text="Linked")
307         layout.itemO("mesh.select_vertex_path", text="Vertex Path")
308         layout.itemO("mesh.loop_multi_select", text="Edge Loop")
309         layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
310
311         layout.itemS()
312
313         layout.itemO("mesh.loop_to_region")
314         layout.itemO("mesh.region_to_loop")
315
316
317 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
318     bl_label = "Select"
319
320     def draw(self, context):
321         layout = self.layout
322
323         layout.itemO("view3d.select_border")
324         layout.itemO("view3d.select_circle")
325
326         layout.itemS()
327
328         layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
329         layout.itemO("curve.select_inverse")
330         layout.itemO("curve.select_random")
331         layout.itemO("curve.select_every_nth")
332
333         layout.itemS()
334
335         layout.itemO("curve.de_select_first")
336         layout.itemO("curve.de_select_last")
337         layout.itemO("curve.select_next")
338         layout.itemO("curve.select_previous")
339
340         layout.itemS()
341
342         layout.itemO("curve.select_more")
343         layout.itemO("curve.select_less")
344
345
346 class VIEW3D_MT_select_edit_surface(bpy.types.Menu):
347     bl_label = "Select"
348
349     def draw(self, context):
350         layout = self.layout
351
352         layout.itemO("view3d.select_border")
353         layout.itemO("view3d.select_circle")
354
355         layout.itemS()
356
357         layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
358         layout.itemO("curve.select_inverse")
359         layout.itemO("curve.select_random")
360         layout.itemO("curve.select_every_nth")
361
362         layout.itemS()
363
364         layout.itemO("curve.select_row")
365
366         layout.itemS()
367
368         layout.itemO("curve.select_more")
369         layout.itemO("curve.select_less")
370
371
372 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
373     bl_label = "Select"
374
375     def draw(self, context):
376         layout = self.layout
377
378         layout.itemO("view3d.select_border")
379
380         layout.itemS()
381
382         layout.itemO("mball.select_deselect_all_metaelems")
383         layout.itemO("mball.select_inverse_metaelems")
384
385         layout.itemS()
386
387         layout.itemO("mball.select_random_metaelems")
388
389
390 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
391     bl_label = "Select"
392
393     def draw(self, context):
394         layout = self.layout
395
396         layout.itemO("view3d.select_border")
397
398         layout.itemS()
399
400         layout.itemO("lattice.select_all_toggle", text="Select/Deselect All")
401
402
403 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
404     bl_label = "Select"
405
406     def draw(self, context):
407         layout = self.layout
408
409         layout.itemO("view3d.select_border")
410         
411
412         layout.itemS()
413
414         layout.itemO("armature.select_all_toggle", text="Select/Deselect All")
415         layout.itemO("armature.select_inverse", text="Inverse")
416
417         layout.itemS()
418
419         layout.item_enumO("armature.select_hierarchy", "direction", 'PARENT', text="Parent")
420         layout.item_enumO("armature.select_hierarchy", "direction", 'CHILD', text="Child")
421
422         layout.itemS()
423
424         props = layout.itemO("armature.select_hierarchy", properties=True, text="Extend Parent")
425         props.extend = True
426         props.direction = 'PARENT'
427
428         props = layout.itemO("armature.select_hierarchy", properties=True, text="Extend Child")
429         props.extend = True
430         props.direction = 'CHILD'
431
432
433 class VIEW3D_MT_select_face(bpy.types.Menu):# XXX no matching enum
434     bl_label = "Select"
435
436     def draw(self, context):
437         layout = self.layout
438
439         layout.view3d_select_faceselmenu()
440
441 # ********** Object menu **********
442
443
444 class VIEW3D_MT_object(bpy.types.Menu):
445     bl_context = "objectmode"
446     bl_label = "Object"
447
448     def draw(self, context):
449         layout = self.layout
450
451         layout.itemM("VIEW3D_MT_object_clear")
452         layout.itemM("VIEW3D_MT_object_apply")
453         layout.itemM("VIEW3D_MT_snap")
454
455         layout.itemS()
456
457         layout.itemO("anim.insert_keyframe_menu", text="Insert Keyframe...")
458         layout.itemO("anim.delete_keyframe_v3d", text="Delete Keyframe...")
459
460         layout.itemS()
461
462         layout.itemO("object.duplicate_move")
463         layout.item_booleanO("object.duplicate", "linked", True, text="Duplicate Linked")
464         layout.itemO("object.delete", text="Delete...")
465         layout.itemO("object.proxy_make", text="Make Proxy...")
466         layout.item_menu_enumO("object.make_local", "type", text="Make Local...")
467         layout.itemM("VIEW3D_MT_make_single_user")
468
469         layout.itemS()
470
471         layout.itemM("VIEW3D_MT_object_parent")
472         layout.itemM("VIEW3D_MT_object_track")
473         layout.itemM("VIEW3D_MT_object_group")
474         layout.itemM("VIEW3D_MT_object_constraints")
475
476         layout.itemS()
477
478         layout.itemO("object.join")
479
480         layout.itemS()
481
482         layout.itemO("object.move_to_layer", text="Move to Layer...")
483         layout.itemM("VIEW3D_MT_object_showhide")
484
485         layout.item_menu_enumO("object.convert", "target")
486
487
488 class VIEW3D_MT_object_clear(bpy.types.Menu):
489     bl_label = "Clear"
490
491     def draw(self, context):
492         layout = self.layout
493
494         layout.itemO("object.location_clear", text="Location")
495         layout.itemO("object.rotation_clear", text="Rotation")
496         layout.itemO("object.scale_clear", text="Scale")
497         layout.itemO("object.origin_clear", text="Origin")
498
499
500 class VIEW3D_MT_object_apply(bpy.types.Menu):
501     bl_label = "Apply"
502
503     def draw(self, context):
504         layout = self.layout
505
506         layout.itemO("object.location_apply", text="Location")
507         layout.itemO("object.rotation_apply", text="Rotation")
508         layout.itemO("object.scale_apply", text="Scale")
509         layout.itemS()
510         layout.itemO("object.visual_transform_apply", text="Visual Transform")
511         layout.itemO("object.duplicates_make_real")
512
513
514 class VIEW3D_MT_object_parent(bpy.types.Menu):
515     bl_label = "Parent"
516
517     def draw(self, context):
518         layout = self.layout
519
520         layout.itemO("object.parent_set", text="Set")
521         layout.itemO("object.parent_clear", text="Clear")
522
523
524 class VIEW3D_MT_object_track(bpy.types.Menu):
525     bl_label = "Track"
526
527     def draw(self, context):
528         layout = self.layout
529
530         layout.itemO("object.track_set", text="Set")
531         layout.itemO("object.track_clear", text="Clear")
532
533
534 class VIEW3D_MT_object_group(bpy.types.Menu):
535     bl_label = "Group"
536
537     def draw(self, context):
538         layout = self.layout
539
540         layout.itemO("group.group_create")
541         layout.itemO("group.objects_remove")
542
543         layout.itemS()
544
545         layout.itemO("group.objects_add_active")
546         layout.itemO("group.objects_remove_active")
547
548
549 class VIEW3D_MT_object_constraints(bpy.types.Menu):
550     bl_label = "Constraints"
551
552     def draw(self, context):
553         layout = self.layout
554
555         layout.itemO("object.constraint_add_with_targets")
556         layout.itemO("object.constraints_clear")
557
558
559 class VIEW3D_MT_object_showhide(bpy.types.Menu):
560     bl_label = "Show/Hide"
561
562     def draw(self, context):
563         layout = self.layout
564
565         layout.itemO("object.restrictview_clear", text="Show Hidden")
566         layout.itemO("object.restrictview_set", text="Hide Selected")
567         layout.item_booleanO("object.restrictview_set", "unselected", True, text="Hide Unselected")
568
569
570 class VIEW3D_MT_make_single_user(bpy.types.Menu):
571     bl_label = "Make Single User"
572
573     def draw(self, context):
574         layout = self.layout
575
576         props = layout.itemO("object.make_single_user", properties=True, text="Object")
577         props.object = True
578
579         props = layout.itemO("object.make_single_user", properties=True, text="Object & ObData")
580         props.object = props.obdata = True
581
582         props = layout.itemO("object.make_single_user", properties=True, text="Object & ObData & Materials+Tex")
583         props.object = props.obdata = props.material = props.texture = True
584
585         props = layout.itemO("object.make_single_user", properties=True, text="Materials+Tex")
586         props.material = props.texture = True
587
588         props = layout.itemO("object.make_single_user", properties=True, text="Animation")
589         props.animation = True
590
591 # ********** Vertex paint menu **********
592
593
594 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
595     bl_label = "Paint"
596
597     def draw(self, context):
598         layout = self.layout
599
600         sculpt = context.tool_settings.sculpt
601
602         layout.itemO("paint.vertex_color_set")
603         props = layout.itemO("paint.vertex_color_set", text="Set Selected Vertex Colors", properties=True)
604         props.selected = True
605
606 # ********** Sculpt menu **********
607
608
609 class VIEW3D_MT_sculpt(bpy.types.Menu):
610     bl_label = "Sculpt"
611
612     def draw(self, context):
613         layout = self.layout
614
615         sculpt = context.tool_settings.sculpt
616         brush = context.tool_settings.sculpt.brush
617
618         layout.itemR(sculpt, "symmetry_x")
619         layout.itemR(sculpt, "symmetry_y")
620         layout.itemR(sculpt, "symmetry_z")
621         layout.itemS()
622         layout.itemR(sculpt, "lock_x")
623         layout.itemR(sculpt, "lock_y")
624         layout.itemR(sculpt, "lock_z")
625         layout.itemS()
626         layout.item_menu_enumO("brush.curve_preset", property="shape")
627         layout.itemS()
628
629         if brush.sculpt_tool != 'GRAB':
630             layout.itemR(brush, "use_airbrush")
631
632             if brush.sculpt_tool != 'LAYER':
633                 layout.itemR(brush, "use_anchor")
634
635             if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
636                 layout.itemR(brush, "flip_direction")
637
638             if brush.sculpt_tool == 'LAYER':
639                 layout.itemR(brush, "use_persistent")
640                 layout.itemO("sculpt.set_persistent_base")
641
642 # ********** Particle menu **********
643
644
645 class VIEW3D_MT_particle(bpy.types.Menu):
646     bl_label = "Particle"
647
648     def draw(self, context):
649         layout = self.layout
650
651         particle_edit = context.tool_settings.particle_edit
652
653         layout.itemO("particle.mirror")
654
655         layout.itemS()
656
657         layout.itemO("particle.remove_doubles")
658         layout.itemO("particle.delete")
659
660         if particle_edit.selection_mode == 'POINT':
661             layout.itemO("particle.subdivide")
662
663         layout.itemO("particle.rekey")
664
665         layout.itemS()
666
667         layout.itemM("VIEW3D_MT_particle_showhide")
668
669
670 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
671     _operator_name = "particle"
672
673 # ********** Pose Menu **********
674
675
676 class VIEW3D_MT_pose(bpy.types.Menu):
677     bl_label = "Pose"
678
679     def draw(self, context):
680         layout = self.layout
681
682         arm = context.active_object.data
683
684         if arm.drawtype in ('BBONE', 'ENVELOPE'):
685             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
686
687         layout.itemM("VIEW3D_MT_pose_transform")
688
689         layout.itemS()
690
691         layout.itemO("anim.insert_keyframe_menu", text="Insert Keyframe...")
692         layout.itemO("anim.delete_keyframe_v3d", text="Delete Keyframe...")
693
694         layout.itemS()
695
696         layout.itemO("pose.apply")
697         layout.itemO("pose.relax")
698
699         layout.itemS()
700
701         layout.itemO("pose.copy")
702         layout.itemO("pose.paste")
703         layout.item_booleanO("pose.paste", "flipped", True, text="Paste X-Flipped Pose")
704
705         layout.itemS()
706
707         layout.itemM("VIEW3D_MT_pose_pose")
708         layout.itemM("VIEW3D_MT_pose_motion")
709         layout.itemM("VIEW3D_MT_pose_group")
710
711         layout.itemS()
712
713         layout.itemM("VIEW3D_MT_pose_ik")
714         layout.itemM("VIEW3D_MT_pose_constraints")
715
716         layout.itemS()
717
718         layout.operator_context = "EXEC_AREA"
719         layout.item_enumO("pose.autoside_names", "axis", 'XAXIS', text="AutoName Left/Right")
720         layout.item_enumO("pose.autoside_names", "axis", 'YAXIS', text="AutoName Front/Back")
721         layout.item_enumO("pose.autoside_names", "axis", 'ZAXIS', text="AutoName Top/Bottom")
722
723         layout.itemO("pose.flip_names")
724
725         layout.itemS()
726
727         layout.operator_context = "INVOKE_AREA"
728         layout.itemO("pose.armature_layers", text="Change Armature Layers...")
729         layout.itemO("pose.bone_layers", text="Change Bone Layers...")
730
731         layout.itemS()
732
733         layout.itemM("VIEW3D_MT_pose_showhide")
734         layout.item_menu_enumO("pose.flags_set", 'mode', text="Bone Settings")
735
736
737 class VIEW3D_MT_pose_transform(bpy.types.Menu):
738     bl_label = "Clear Transform"
739
740     def draw(self, context):
741         layout = self.layout
742
743         layout.itemL(text="User Transform")
744
745         layout.itemO("pose.loc_clear", text="Location")
746         layout.itemO("pose.rot_clear", text="Rotation")
747         layout.itemO("pose.scale_clear", text="Scale")
748
749         layout.itemL(text="Origin")
750
751
752 class VIEW3D_MT_pose_pose(bpy.types.Menu):
753     bl_label = "Pose Library"
754
755     def draw(self, context):
756         layout = self.layout
757
758         layout.itemO("poselib.browse_interactive", text="Browse Poses...")
759
760         layout.itemS()
761
762         layout.itemO("poselib.pose_add", text="Add Pose...")
763         layout.itemO("poselib.pose_rename", text="Rename Pose...")
764         layout.itemO("poselib.pose_remove", text="Remove Pose...")
765
766
767 class VIEW3D_MT_pose_motion(bpy.types.Menu):
768     bl_label = "Motion Paths"
769
770     def draw(self, context):
771         layout = self.layout
772
773         layout.itemO("pose.paths_calculate", text="Calculate")
774         layout.itemO("pose.paths_clear", text="Clear")
775
776
777 class VIEW3D_MT_pose_group(bpy.types.Menu):
778     bl_label = "Bone Groups"
779
780     def draw(self, context):
781         layout = self.layout
782         layout.itemO("pose.group_add")
783         layout.itemO("pose.group_remove")
784
785         layout.itemS()
786
787         layout.itemO("pose.group_assign")
788         layout.itemO("pose.group_unassign")
789
790
791 class VIEW3D_MT_pose_ik(bpy.types.Menu):
792     bl_label = "Inverse Kinematics"
793
794     def draw(self, context):
795         layout = self.layout
796
797         layout.itemO("pose.ik_add")
798         layout.itemO("pose.ik_clear")
799
800
801 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
802     bl_label = "Constraints"
803
804     def draw(self, context):
805         layout = self.layout
806
807         layout.itemO("pose.constraint_add_with_targets", text="Add (With Targets)...")
808         layout.itemO("pose.constraints_clear")
809
810
811 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
812     _operator_name = "pose"
813
814 # ********** Edit Menus, suffix from ob.type **********
815
816
817 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
818     bl_label = "Mesh"
819
820     def draw(self, context):
821         layout = self.layout
822
823         settings = context.tool_settings
824
825         layout.itemO("ed.undo")
826         layout.itemO("ed.redo")
827
828         layout.itemS()
829
830         layout.itemM("VIEW3D_MT_snap")
831
832         layout.itemS()
833
834         layout.itemO("uv.mapping_menu", text="UV Unwrap...")
835
836         layout.itemS()
837
838         layout.itemO("mesh.extrude_move")
839         layout.itemO("mesh.duplicate_move")
840         layout.itemO("mesh.delete", text="Delete...")
841
842         layout.itemS()
843
844         layout.itemM("VIEW3D_MT_edit_mesh_vertices")
845         layout.itemM("VIEW3D_MT_edit_mesh_edges")
846         layout.itemM("VIEW3D_MT_edit_mesh_faces")
847         layout.itemM("VIEW3D_MT_edit_mesh_normals")
848
849         layout.itemS()
850
851         layout.itemR(settings, "automerge_editing")
852         layout.item_menu_enumR(settings, "proportional_editing")
853         layout.item_menu_enumR(settings, "proportional_editing_falloff")
854
855         layout.itemS()
856
857         layout.itemM("VIEW3D_MT_edit_mesh_showhide")
858
859
860 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
861     bl_label = "Specials"
862
863     def draw(self, context):
864         layout = self.layout
865
866         layout.operator_context = 'INVOKE_REGION_WIN'
867
868         layout.itemO("mesh.subdivide", text="Subdivide")
869         layout.item_floatO("mesh.subdivide", "smoothness", 1.0, text="Subdivide Smooth")
870         layout.itemO("mesh.merge", text="Merge...")
871         layout.itemO("mesh.remove_doubles")
872         layout.itemO("mesh.hide", text="Hide")
873         layout.itemO("mesh.reveal", text="Reveal")
874         layout.itemO("mesh.select_inverse")
875         layout.itemO("mesh.flip_normals")
876         layout.itemO("mesh.vertices_smooth", text="Smooth")
877         # layout.itemO("mesh.bevel", text="Bevel")
878         layout.itemO("mesh.faces_shade_smooth")
879         layout.itemO("mesh.faces_shade_flat")
880         layout.itemO("mesh.blend_from_shape")
881         layout.itemO("mesh.shape_propagate_to_all")
882         layout.itemO("mesh.select_vertex_path")
883
884
885 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
886     bl_label = "Vertices"
887
888     def draw(self, context):
889         layout = self.layout
890         layout.operator_context = 'INVOKE_REGION_WIN'
891
892         layout.itemO("mesh.merge")
893         layout.itemO("mesh.rip")
894         layout.itemO("mesh.split")
895         layout.itemO("mesh.separate")
896
897         layout.itemS()
898
899         layout.itemO("mesh.vertices_smooth")
900         layout.itemO("mesh.remove_doubles")
901
902         layout.itemO("mesh.select_vertex_path")
903
904         layout.itemO("mesh.blend_from_shape")
905
906         layout.itemO("object.vertex_group_blend")
907         layout.itemO("mesh.shape_propagate_to_all")
908
909
910 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
911     bl_label = "Edges"
912
913     def draw(self, context):
914         layout = self.layout
915         layout.operator_context = 'INVOKE_REGION_WIN'
916
917         layout.itemO("mesh.edge_face_add")
918         layout.itemO("mesh.subdivide")
919
920         layout.itemS()
921
922         layout.itemO("mesh.mark_seam")
923         layout.item_booleanO("mesh.mark_seam", "clear", True, text="Clear Seam")
924
925         layout.itemS()
926
927         layout.itemO("mesh.mark_sharp")
928         layout.item_booleanO("mesh.mark_sharp", "clear", True, text="Clear Sharp")
929
930         layout.itemS()
931
932         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
933         layout.item_enumO("mesh.edge_rotate", "direction", 'CCW', text="Rotate Edge CCW")
934
935         layout.itemS()
936
937         layout.itemO("TFM_OT_edge_slide", text="Edge Slide")
938         layout.itemO("mesh.loop_multi_select", text="Edge Loop")
939
940         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
941         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
942
943         layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
944
945         layout.itemO("mesh.loop_to_region")
946         layout.itemO("mesh.region_to_loop")
947
948
949 class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu):
950     bl_label = "Faces"
951     bl_idname = "VIEW3D_MT_edit_mesh_faces"
952
953     def draw(self, context):
954         layout = self.layout
955         layout.operator_context = 'INVOKE_REGION_WIN'
956
957         # layout.itemO("mesh.bevel")
958         # layout.itemO("mesh.bevel")
959         layout.itemO("mesh.edge_face_add")
960         layout.itemO("mesh.fill")
961         layout.itemO("mesh.beauty_fill")
962
963         layout.itemS()
964
965         layout.itemO("mesh.quads_convert_to_tris")
966         layout.itemO("mesh.tris_convert_to_quads")
967         layout.itemO("mesh.edge_flip")
968
969         layout.itemS()
970
971         layout.itemO("mesh.faces_shade_smooth")
972         layout.itemO("mesh.faces_shade_flat")
973
974         layout.itemS()
975
976         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
977         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
978
979         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
980
981         layout.itemS()
982
983         layout.item_menu_enumO("mesh.uvs_rotate", "direction")
984         layout.item_menu_enumO("mesh.uvs_mirror", "axis")
985         layout.item_menu_enumO("mesh.colors_rotate", "direction")
986         layout.item_menu_enumO("mesh.colors_mirror", "axis")
987
988
989 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
990     bl_label = "Normals"
991
992     def draw(self, context):
993         layout = self.layout
994
995         layout.itemO("mesh.normals_make_consistent", text="Recalculate Outside")
996         layout.item_booleanO("mesh.normals_make_consistent", "inside", True, text="Recalculate Inside")
997
998         layout.itemS()
999
1000         layout.itemO("mesh.flip_normals")
1001
1002
1003 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1004     _operator_name = "mesh"
1005
1006 # Edit Curve
1007 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1008
1009
1010 def draw_curve(self, context):
1011     layout = self.layout
1012
1013     settings = context.tool_settings
1014
1015     layout.itemM("VIEW3D_MT_snap")
1016
1017     layout.itemS()
1018
1019     layout.itemO("curve.extrude")
1020     layout.itemO("curve.duplicate")
1021     layout.itemO("curve.separate")
1022     layout.itemO("curve.make_segment")
1023     layout.itemO("curve.cyclic_toggle")
1024     layout.itemO("curve.delete", text="Delete...")
1025
1026     layout.itemS()
1027
1028     layout.itemM("VIEW3D_MT_edit_curve_ctrlpoints")
1029     layout.itemM("VIEW3D_MT_edit_curve_segments")
1030
1031     layout.itemS()
1032
1033     layout.item_menu_enumR(settings, "proportional_editing")
1034     layout.item_menu_enumR(settings, "proportional_editing_falloff")
1035
1036     layout.itemS()
1037
1038     layout.itemM("VIEW3D_MT_edit_curve_showhide")
1039
1040
1041 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1042     bl_label = "Curve"
1043
1044     draw = draw_curve
1045
1046
1047 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1048     bl_label = "Control Points"
1049
1050     def draw(self, context):
1051         layout = self.layout
1052
1053         edit_object = context.edit_object
1054
1055         if edit_object.type == 'CURVE':
1056             layout.item_enumO("tfm.transform", "mode", 'TILT')
1057             layout.itemO("curve.tilt_clear")
1058             layout.itemO("curve.separate")
1059
1060             layout.itemS()
1061
1062             layout.item_menu_enumO("curve.handle_type_set", "type")
1063
1064
1065 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1066     bl_label = "Segments"
1067
1068     def draw(self, context):
1069         layout = self.layout
1070
1071         layout.itemO("curve.subdivide")
1072         layout.itemO("curve.switch_direction")
1073
1074
1075 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1076     _operator_name = "curve"
1077
1078
1079 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1080     bl_label = "Surface"
1081
1082     draw = draw_curve
1083
1084
1085 class VIEW3D_MT_edit_text(bpy.types.Menu):
1086     bl_label = "Text"
1087
1088     def draw(self, context):
1089         layout = self.layout
1090
1091         layout.itemO("font.file_paste")
1092
1093         layout.itemS()
1094
1095         layout.itemM("VIEW3D_MT_edit_text_chars")
1096
1097
1098 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1099     bl_label = "Special Characters"
1100
1101     def draw(self, context):
1102         layout = self.layout
1103
1104         layout.item_stringO("font.text_insert", "text", b'\xC2\xA9'.decode(), text="Copyright|Alt C")
1105         layout.item_stringO("font.text_insert", "text", b'\xC2\xAE'.decode(), text="Registered Trademark|Alt R")
1106
1107         layout.itemS()
1108
1109         layout.item_stringO("font.text_insert", "text", b'\xC2\xB0'.decode(), text="Degree Sign|Alt G")
1110         layout.item_stringO("font.text_insert", "text", b'\xC3\x97'.decode(), text="Multiplication Sign|Alt x")
1111         layout.item_stringO("font.text_insert", "text", b'\xC2\x8A'.decode(), text="Circle|Alt .")
1112         layout.item_stringO("font.text_insert", "text", b'\xC2\xB9'.decode(), text="Superscript 1|Alt 1")
1113         layout.item_stringO("font.text_insert", "text", b'\xC2\xB2'.decode(), text="Superscript 2|Alt 2")
1114         layout.item_stringO("font.text_insert", "text", b'\xC2\xB3'.decode(), text="Superscript 3|Alt 3")
1115         layout.item_stringO("font.text_insert", "text", b'\xC2\xBB'.decode(), text="Double >>|Alt >")
1116         layout.item_stringO("font.text_insert", "text", b'\xC2\xAB'.decode(), text="Double <<|Alt <")
1117         layout.item_stringO("font.text_insert", "text", b'\xE2\x80\xB0'.decode(), text="Promillage|Alt %")
1118
1119         layout.itemS()
1120
1121         layout.item_stringO("font.text_insert", "text", b'\xC2\xA4'.decode(), text="Dutch Florin|Alt F")
1122         layout.item_stringO("font.text_insert", "text", b'\xC2\xA3'.decode(), text="British Pound|Alt L")
1123         layout.item_stringO("font.text_insert", "text", b'\xC2\xA5'.decode(), text="Japanese Yen|Alt Y")
1124
1125         layout.itemS()
1126
1127         layout.item_stringO("font.text_insert", "text", b'\xC3\x9F'.decode(), text="German S|Alt S")
1128         layout.item_stringO("font.text_insert", "text", b'\xC2\xBF'.decode(), text="Spanish Question Mark|Alt ?")
1129         layout.item_stringO("font.text_insert", "text", b'\xC2\xA1'.decode(), text="Spanish Exclamation Mark|Alt !")
1130
1131
1132 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1133     bl_label = "Metaball"
1134
1135     def draw(self, context):
1136         layout = self.layout
1137
1138         settings = context.tool_settings
1139
1140         layout.itemO("ed.undo")
1141         layout.itemO("ed.redo")
1142
1143         layout.itemS()
1144
1145         layout.itemM("VIEW3D_MT_snap")
1146
1147         layout.itemS()
1148
1149         layout.itemO("mball.delete_metaelems", text="Delete...")
1150         layout.itemO("mball.duplicate_metaelems")
1151
1152         layout.itemS()
1153
1154         layout.item_menu_enumR(settings, "proportional_editing")
1155         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1156
1157         layout.itemS()
1158
1159         layout.itemM("VIEW3D_MT_edit_meta_showhide")
1160
1161
1162 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1163     bl_label = "Show/Hide"
1164
1165     def draw(self, context):
1166         layout = self.layout
1167
1168         layout.itemO("mball.reveal_metaelems", text="Show Hidden")
1169         layout.itemO("mball.hide_metaelems", text="Hide Selected")
1170         layout.item_booleanO("mball.hide_metaelems", "unselected", True, text="Hide Unselected")
1171
1172
1173 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1174     bl_label = "Lattice"
1175
1176     def draw(self, context):
1177         layout = self.layout
1178
1179         settings = context.tool_settings
1180
1181         layout.itemM("VIEW3D_MT_snap")
1182
1183         layout.itemS()
1184
1185         layout.itemO("lattice.make_regular")
1186
1187         layout.itemS()
1188
1189         layout.item_menu_enumR(settings, "proportional_editing")
1190         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1191
1192
1193 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1194     bl_label = "Armature"
1195
1196     def draw(self, context):
1197         layout = self.layout
1198
1199         edit_object = context.edit_object
1200         arm = edit_object.data
1201
1202         layout.itemM("VIEW3D_MT_snap")
1203         layout.itemM("VIEW3D_MT_edit_armature_roll")
1204
1205         if arm.drawtype == 'ENVELOPE':
1206             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
1207         else:
1208             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale B-Bone Width")
1209
1210         layout.itemS()
1211
1212         layout.itemO("armature.extrude_move")
1213
1214 # EXTRUDE FORKED DOESN'T WORK YET
1215 #               if arm.x_axis_mirror:
1216 #                       layout.item_booleanO("armature.extrude_move", "forked", True, text="Extrude Forked")
1217
1218         layout.itemO("armature.duplicate_move")
1219         layout.itemO("armature.merge")
1220         layout.itemO("armature.fill")
1221         layout.itemO("armature.delete")
1222         layout.itemO("armature.separate")
1223
1224         layout.itemS()
1225
1226         layout.itemO("armature.subdivide_multi", text="Subdivide")
1227
1228         layout.itemS()
1229
1230         layout.operator_context = "EXEC_AREA"
1231         layout.item_enumO("armature.autoside_names", "type", 'XAXIS', text="AutoName Left/Right")
1232         layout.item_enumO("armature.autoside_names", "type", 'YAXIS', text="AutoName Front/Back")
1233         layout.item_enumO("armature.autoside_names", "type", 'ZAXIS', text="AutoName Top/Bottom")
1234         layout.itemO("armature.flip_names")
1235
1236         layout.itemS()
1237
1238         layout.operator_context = "INVOKE_DEFAULT"
1239         layout.itemO("armature.armature_layers")
1240         layout.itemO("armature.bone_layers")
1241
1242         layout.itemS()
1243
1244         layout.itemM("VIEW3D_MT_edit_armature_parent")
1245
1246         layout.itemS()
1247
1248         layout.item_menu_enumO("armature.flags_set", "mode", text="Bone Settings")
1249
1250
1251 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1252     bl_label = "Parent"
1253
1254     def draw(self, context):
1255         layout = self.layout
1256
1257         layout.itemO("armature.parent_set", text="Make")
1258         layout.itemO("armature.parent_clear", text="Clear")
1259
1260
1261 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1262     bl_label = "Bone Roll"
1263
1264     def draw(self, context):
1265         layout = self.layout
1266
1267         layout.item_enumO("armature.calculate_roll", "type", 'GLOBALUP', text="Clear Roll (Z-Axis Up)")
1268         layout.item_enumO("armature.calculate_roll", "type", 'CURSOR', text="Roll to Cursor")
1269
1270         layout.itemS()
1271
1272         layout.item_enumO("tfm.transform", "mode", 'BONE_ROLL', text="Set Roll")
1273
1274 # ********** Panel **********
1275
1276
1277 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1278     bl_space_type = 'VIEW_3D'
1279     bl_region_type = 'UI'
1280     bl_label = "View"
1281
1282     def poll(self, context):
1283         view = context.space_data
1284         return (view)
1285
1286     def draw(self, context):
1287         layout = self.layout
1288
1289         view = context.space_data
1290         scene = context.scene
1291
1292         col = layout.column()
1293         col.itemL(text="Camera:")
1294         col.itemR(view, "camera", text="")
1295         col.itemR(view, "lens")
1296
1297         col = layout.column(align=True)
1298         col.itemL(text="Clip:")
1299         col.itemR(view, "clip_start", text="Start")
1300         col.itemR(view, "clip_end", text="End")
1301
1302         col = layout.column(align=True)
1303         col.itemL(text="Grid:")
1304         col.itemR(view, "grid_lines", text="Lines")
1305         col.itemR(view, "grid_spacing", text="Spacing")
1306         col.itemR(view, "grid_subdivisions", text="Subdivisions")
1307
1308         layout.column().itemR(scene, "cursor_location", text="3D Cursor:")
1309
1310
1311 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1312     bl_space_type = 'VIEW_3D'
1313     bl_region_type = 'UI'
1314     bl_label = "Display"
1315     bl_default_closed = True
1316
1317     def poll(self, context):
1318         view = context.space_data
1319         return (view)
1320
1321     def draw(self, context):
1322         layout = self.layout
1323
1324         view = context.space_data
1325         gs = context.scene.game_data
1326         ob = context.object
1327
1328         col = layout.column()
1329         col.itemR(view, "display_floor", text="Grid Floor")
1330         col.itemR(view, "display_x_axis", text="X Axis")
1331         col.itemR(view, "display_y_axis", text="Y Axis")
1332         col.itemR(view, "display_z_axis", text="Z Axis")
1333         col.itemR(view, "outline_selected")
1334         col.itemR(view, "all_object_centers")
1335         col.itemR(view, "relationship_lines")
1336         if ob and ob.type == 'MESH':
1337             mesh = ob.data
1338             col.itemR(mesh, "all_edges")
1339
1340         col = layout.column()
1341         col.itemL(text="Shading:")
1342         col.itemR(gs, "material_mode", text="")
1343         col.itemR(view, "textured_solid")
1344
1345 # XXX - the Quad View options don't work yet
1346 #               layout.itemS()
1347 #
1348 #               layout.itemO("screen.region_foursplit", text="Toggle Quad View")
1349 #               col = layout.column()
1350 #               col.itemR(view, "lock_rotation")
1351 #               col.itemR(view, "box_preview")
1352 #               col.itemR(view, "box_clip")
1353
1354
1355 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1356     bl_space_type = 'VIEW_3D'
1357     bl_region_type = 'UI'
1358     bl_label = "Mesh Display"
1359
1360     def poll(self, context):
1361         editmesh = context.mode == 'EDIT_MESH'
1362         return (editmesh)
1363
1364     def draw(self, context):
1365         layout = self.layout
1366
1367         mesh = context.active_object.data
1368
1369         col = layout.column()
1370         col.itemL(text="Overlays:")
1371         col.itemR(mesh, "draw_edges", text="Edges")
1372         col.itemR(mesh, "draw_faces", text="Faces")
1373         col.itemR(mesh, "draw_creases", text="Creases")
1374         col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights")
1375         col.itemR(mesh, "draw_seams", text="Seams")
1376         col.itemR(mesh, "draw_sharp", text="Sharp")
1377
1378         col.itemS()
1379         col.itemL(text="Normals:")
1380         col.itemR(mesh, "draw_normals", text="Face")
1381         col.itemR(mesh, "draw_vertex_normals", text="Vertex")
1382         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1383
1384         col.itemS()
1385         col.itemL(text="Numerics:")
1386         col.itemR(mesh, "draw_edge_lenght")
1387         col.itemR(mesh, "draw_edge_angle")
1388         col.itemR(mesh, "draw_face_area")
1389
1390
1391 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1392     bl_space_type = 'VIEW_3D'
1393     bl_region_type = 'UI'
1394     bl_label = "Curve Display"
1395
1396     def poll(self, context):
1397         editmesh = context.mode == 'EDIT_CURVE'
1398         return (editmesh)
1399
1400     def draw(self, context):
1401         layout = self.layout
1402
1403         curve = context.active_object.data
1404
1405         col = layout.column()
1406         col.itemL(text="Overlays:")
1407         col.itemR(curve, "draw_handles", text="Handles")
1408         col.itemR(curve, "draw_normals", text="Normals")
1409         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1410
1411
1412 class VIEW3D_PT_background_image(bpy.types.Panel):
1413     bl_space_type = 'VIEW_3D'
1414     bl_region_type = 'UI'
1415     bl_label = "Background Image"
1416     bl_default_closed = True
1417
1418     def poll(self, context):
1419         view = context.space_data
1420         bg = context.space_data.background_image
1421         return (view)
1422
1423     def draw_header(self, context):
1424         layout = self.layout
1425         view = context.space_data
1426
1427         layout.itemR(view, "display_background_image", text="")
1428
1429     def draw(self, context):
1430         layout = self.layout
1431
1432         view = context.space_data
1433         bg = view.background_image
1434
1435         if bg:
1436             layout.active = view.display_background_image
1437
1438             col = layout.column()
1439             col.itemR(bg, "image", text="")
1440             #col.itemR(bg, "image_user")
1441             col.itemR(bg, "size")
1442             col.itemR(bg, "transparency", slider=True)
1443
1444
1445             col = layout.column(align=True)
1446             col.itemL(text="Offset:")
1447             col.itemR(bg, "offset_x", text="X")
1448             col.itemR(bg, "offset_y", text="Y")
1449
1450
1451 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1452     bl_space_type = 'VIEW_3D'
1453     bl_region_type = 'UI'
1454     bl_label = "Transform Orientations"
1455     bl_default_closed = True
1456
1457     def poll(self, context):
1458         view = context.space_data
1459         return (view)
1460
1461     def draw(self, context):
1462         layout = self.layout
1463
1464         view = context.space_data
1465
1466         col = layout.column()
1467
1468         col.itemR(view, "transform_orientation")
1469         col.itemO("tfm.create_orientation", text="Create")
1470
1471         orientation = view.current_orientation
1472
1473         if orientation:
1474             col.itemR(orientation, "name")
1475             col.itemO("tfm.delete_orientation", text="Delete")
1476
1477
1478 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1479     bl_space_type = 'VIEW_3D'
1480     bl_region_type = 'UI'
1481     bl_label = "Skeleton Sketching"
1482     bl_default_closed = True
1483
1484     def poll(self, context):
1485         scene = context.space_data
1486         ob = context.active_object
1487         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1488
1489     def draw_header(self, context):
1490         layout = self.layout
1491         toolsettings = context.scene.tool_settings
1492
1493         layout.itemR(toolsettings, "bone_sketching", text="")
1494
1495     def draw(self, context):
1496         layout = self.layout
1497         toolsettings = context.scene.tool_settings
1498
1499         col = layout.column()
1500
1501         col.itemR(toolsettings, "etch_quick")
1502         col.itemR(toolsettings, "etch_overdraw")
1503
1504         col.itemR(toolsettings, "etch_convert_mode")
1505
1506         if toolsettings.etch_convert_mode == "LENGTH":
1507             col.itemR(toolsettings, "etch_length_limit")
1508         elif toolsettings.etch_convert_mode == "ADAPTIVE":
1509             col.itemR(toolsettings, "etch_adaptive_limit")
1510         elif toolsettings.etch_convert_mode == "FIXED":
1511             col.itemR(toolsettings, "etch_subdivision_number")
1512         elif toolsettings.etch_convert_mode == "RETARGET":
1513             col.itemR(toolsettings, "etch_template")
1514             col.itemR(toolsettings, "etch_roll_mode")
1515             col.itemR(toolsettings, "etch_autoname")
1516             col.itemR(toolsettings, "etch_number")
1517             col.itemR(toolsettings, "etch_side")
1518
1519
1520 # Operators
1521 from bpy.props import *
1522
1523
1524 class OBJECT_OT_select_pattern(bpy.types.Operator):
1525     '''Select object matching a naming pattern.'''
1526     bl_idname = "object.select_pattern"
1527     bl_label = "Select Pattern"
1528     bl_register = True
1529     bl_undo = True
1530
1531     pattern = StringProperty(name="Pattern", description="Name filter using '*' and '?' wildcard chars", maxlen=32, default="*")
1532     case_sensitive = BoolProperty(name="Case Sensitive", description="Do a case sensitive compare", default=False)
1533     extend = BoolProperty(name="Extend", description="Extend the existing selection", default=True)
1534
1535     def execute(self, context):
1536
1537         import fnmatch
1538
1539         if self.case_sensitive:
1540             pattern_match = fnmatch.fnmatchcase
1541         else:
1542             pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())
1543
1544         for ob in context.visible_objects:
1545             if pattern_match(ob.name, self.pattern):
1546                 ob.selected = True
1547             elif not self.extend:
1548                 ob.selected = False
1549
1550         return ('FINISHED',)
1551
1552         # TODO - python cant do popups yet
1553     '''
1554     def invoke(self, context, event):
1555         wm = context.manager
1556         wm.add_fileselect(self)
1557         return ('RUNNING_MODAL',)
1558     '''
1559
1560 bpy.types.register(VIEW3D_HT_header) # Header
1561
1562 bpy.types.register(VIEW3D_MT_view) #View Menus
1563 bpy.types.register(VIEW3D_MT_view_navigation)
1564 bpy.types.register(VIEW3D_MT_view_align)
1565 bpy.types.register(VIEW3D_MT_view_cameras)
1566
1567 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1568 bpy.types.register(VIEW3D_MT_select_pose)
1569 bpy.types.register(VIEW3D_MT_select_particle)
1570 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1571 bpy.types.register(VIEW3D_MT_select_edit_curve)
1572 bpy.types.register(VIEW3D_MT_select_edit_surface)
1573 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1574 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1575 bpy.types.register(VIEW3D_MT_select_edit_armature)
1576 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1577
1578 bpy.types.register(VIEW3D_MT_object) # Object Menu
1579 bpy.types.register(VIEW3D_MT_object_apply)
1580 bpy.types.register(VIEW3D_MT_object_clear)
1581 bpy.types.register(VIEW3D_MT_object_parent)
1582 bpy.types.register(VIEW3D_MT_object_track)
1583 bpy.types.register(VIEW3D_MT_object_group)
1584 bpy.types.register(VIEW3D_MT_object_constraints)
1585 bpy.types.register(VIEW3D_MT_object_showhide)
1586 bpy.types.register(VIEW3D_MT_make_single_user)
1587
1588
1589 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1590
1591 bpy.types.register(VIEW3D_MT_paint_vertex)
1592
1593 bpy.types.register(VIEW3D_MT_particle) # Particle Menu
1594 bpy.types.register(VIEW3D_MT_particle_showhide)
1595
1596 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1597 bpy.types.register(VIEW3D_MT_pose_transform)
1598 bpy.types.register(VIEW3D_MT_pose_pose)
1599 bpy.types.register(VIEW3D_MT_pose_motion)
1600 bpy.types.register(VIEW3D_MT_pose_group)
1601 bpy.types.register(VIEW3D_MT_pose_ik)
1602 bpy.types.register(VIEW3D_MT_pose_constraints)
1603 bpy.types.register(VIEW3D_MT_pose_showhide)
1604
1605 bpy.types.register(VIEW3D_MT_snap) # Edit Menus
1606
1607 bpy.types.register(VIEW3D_MT_edit_mesh)
1608 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1609 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1610 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1611 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1612 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1613 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1614
1615 bpy.types.register(VIEW3D_MT_edit_curve)
1616 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1617 bpy.types.register(VIEW3D_MT_edit_curve_segments)
1618 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
1619
1620 bpy.types.register(VIEW3D_MT_edit_surface)
1621
1622 bpy.types.register(VIEW3D_MT_edit_text)
1623 bpy.types.register(VIEW3D_MT_edit_text_chars)
1624
1625 bpy.types.register(VIEW3D_MT_edit_meta)
1626 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
1627
1628 bpy.types.register(VIEW3D_MT_edit_lattice)
1629
1630 bpy.types.register(VIEW3D_MT_edit_armature)
1631 bpy.types.register(VIEW3D_MT_edit_armature_parent)
1632 bpy.types.register(VIEW3D_MT_edit_armature_roll)
1633
1634 bpy.types.register(VIEW3D_PT_3dview_properties) # Panels
1635 bpy.types.register(VIEW3D_PT_3dview_display)
1636 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
1637 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
1638 bpy.types.register(VIEW3D_PT_background_image)
1639 bpy.types.register(VIEW3D_PT_transform_orientations)
1640 bpy.types.register(VIEW3D_PT_etch_a_ton)
1641
1642 bpy.ops.add(OBJECT_OT_select_pattern)