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