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