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