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