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