Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24330...
[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.item_enumR(brush, "direction", value="SUBTRACT")
705                 layout.item_enumR(brush, "direction", value="ADD")
706
707             if brush.sculpt_tool == 'LAYER':
708                 layout.itemR(brush, "use_persistent")
709                 layout.itemO("sculpt.set_persistent_base")
710
711 # ********** Particle menu **********
712
713
714 class VIEW3D_MT_particle(bpy.types.Menu):
715     bl_label = "Particle"
716
717     def draw(self, context):
718         layout = self.layout
719
720         particle_edit = context.tool_settings.particle_edit
721
722         layout.itemO("particle.mirror")
723
724         layout.itemS()
725
726         layout.itemO("particle.remove_doubles")
727         layout.itemO("particle.delete")
728
729         if particle_edit.selection_mode == 'POINT':
730             layout.itemO("particle.subdivide")
731
732         layout.itemO("particle.rekey")
733
734         layout.itemS()
735
736         layout.itemM("VIEW3D_MT_particle_showhide")
737
738
739 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
740     _operator_name = "particle"
741
742 # ********** Pose Menu **********
743
744
745 class VIEW3D_MT_pose(bpy.types.Menu):
746     bl_label = "Pose"
747
748     def draw(self, context):
749         layout = self.layout
750
751         arm = context.active_object.data
752
753         if arm.drawtype in ('BBONE', 'ENVELOPE'):
754             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
755
756         layout.itemM("VIEW3D_MT_pose_transform")
757
758         layout.itemS()
759
760         layout.itemO("anim.insert_keyframe_menu", text="Insert Keyframe...")
761         layout.itemO("anim.delete_keyframe_v3d", text="Delete Keyframe...")
762
763         layout.itemS()
764
765         layout.itemO("pose.apply")
766         layout.itemO("pose.relax")
767
768         layout.itemS()
769
770         layout.itemO("pose.copy")
771         layout.itemO("pose.paste")
772         layout.item_booleanO("pose.paste", "flipped", True, text="Paste X-Flipped Pose")
773
774         layout.itemS()
775
776         layout.itemM("VIEW3D_MT_pose_pose")
777         layout.itemM("VIEW3D_MT_pose_motion")
778         layout.itemM("VIEW3D_MT_pose_group")
779
780         layout.itemS()
781
782         layout.itemM("VIEW3D_MT_pose_ik")
783         layout.itemM("VIEW3D_MT_pose_constraints")
784
785         layout.itemS()
786
787         layout.operator_context = "EXEC_AREA"
788         layout.item_enumO("pose.autoside_names", "axis", 'XAXIS', text="AutoName Left/Right")
789         layout.item_enumO("pose.autoside_names", "axis", 'YAXIS', text="AutoName Front/Back")
790         layout.item_enumO("pose.autoside_names", "axis", 'ZAXIS', text="AutoName Top/Bottom")
791
792         layout.itemO("pose.flip_names")
793
794         layout.itemS()
795
796         layout.operator_context = "INVOKE_AREA"
797         layout.itemO("pose.armature_layers", text="Change Armature Layers...")
798         layout.itemO("pose.bone_layers", text="Change Bone Layers...")
799
800         layout.itemS()
801
802         layout.itemM("VIEW3D_MT_pose_showhide")
803         layout.item_menu_enumO("pose.flags_set", 'mode', text="Bone Settings")
804
805
806 class VIEW3D_MT_pose_transform(bpy.types.Menu):
807     bl_label = "Clear Transform"
808
809     def draw(self, context):
810         layout = self.layout
811
812         layout.itemL(text="User Transform")
813
814         layout.itemO("pose.loc_clear", text="Location")
815         layout.itemO("pose.rot_clear", text="Rotation")
816         layout.itemO("pose.scale_clear", text="Scale")
817
818         layout.itemL(text="Origin")
819
820
821 class VIEW3D_MT_pose_pose(bpy.types.Menu):
822     bl_label = "Pose Library"
823
824     def draw(self, context):
825         layout = self.layout
826
827         layout.itemO("poselib.browse_interactive", text="Browse Poses...")
828
829         layout.itemS()
830
831         layout.itemO("poselib.pose_add", text="Add Pose...")
832         layout.itemO("poselib.pose_rename", text="Rename Pose...")
833         layout.itemO("poselib.pose_remove", text="Remove Pose...")
834
835
836 class VIEW3D_MT_pose_motion(bpy.types.Menu):
837     bl_label = "Motion Paths"
838
839     def draw(self, context):
840         layout = self.layout
841
842         layout.itemO("pose.paths_calculate", text="Calculate")
843         layout.itemO("pose.paths_clear", text="Clear")
844
845
846 class VIEW3D_MT_pose_group(bpy.types.Menu):
847     bl_label = "Bone Groups"
848
849     def draw(self, context):
850         layout = self.layout
851         layout.itemO("pose.group_add")
852         layout.itemO("pose.group_remove")
853
854         layout.itemS()
855
856         layout.itemO("pose.group_assign")
857         layout.itemO("pose.group_unassign")
858
859
860 class VIEW3D_MT_pose_ik(bpy.types.Menu):
861     bl_label = "Inverse Kinematics"
862
863     def draw(self, context):
864         layout = self.layout
865
866         layout.itemO("pose.ik_add")
867         layout.itemO("pose.ik_clear")
868
869
870 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
871     bl_label = "Constraints"
872
873     def draw(self, context):
874         layout = self.layout
875
876         layout.itemO("pose.constraint_add_with_targets", text="Add (With Targets)...")
877         layout.itemO("pose.constraints_clear")
878
879
880 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
881     _operator_name = "pose"
882
883 # ********** Edit Menus, suffix from ob.type **********
884
885
886 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
887     bl_label = "Mesh"
888
889     def draw(self, context):
890         layout = self.layout
891
892         settings = context.tool_settings
893
894         layout.itemO("ed.undo")
895         layout.itemO("ed.redo")
896
897         layout.itemS()
898
899         layout.itemM("VIEW3D_MT_snap")
900
901         layout.itemS()
902
903         layout.itemM("VIEW3D_MT_uv_map", text="UV Unwrap...")
904
905         layout.itemS()
906
907         layout.itemO("mesh.extrude_move")
908         layout.itemO("mesh.duplicate_move")
909         layout.itemO("mesh.delete", text="Delete...")
910
911         layout.itemS()
912
913         layout.itemM("VIEW3D_MT_edit_mesh_vertices")
914         layout.itemM("VIEW3D_MT_edit_mesh_edges")
915         layout.itemM("VIEW3D_MT_edit_mesh_faces")
916         layout.itemM("VIEW3D_MT_edit_mesh_normals")
917
918         layout.itemS()
919
920         layout.itemR(settings, "automerge_editing")
921         layout.item_menu_enumR(settings, "proportional_editing")
922         layout.item_menu_enumR(settings, "proportional_editing_falloff")
923
924         layout.itemS()
925
926         layout.itemM("VIEW3D_MT_edit_mesh_showhide")
927
928
929 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
930     bl_label = "Specials"
931
932     def draw(self, context):
933         layout = self.layout
934
935         layout.operator_context = 'INVOKE_REGION_WIN'
936
937         layout.itemO("mesh.subdivide", text="Subdivide")
938         layout.item_floatO("mesh.subdivide", "smoothness", 1.0, text="Subdivide Smooth")
939         layout.itemO("mesh.merge", text="Merge...")
940         layout.itemO("mesh.remove_doubles")
941         layout.itemO("mesh.hide", text="Hide")
942         layout.itemO("mesh.reveal", text="Reveal")
943         layout.itemO("mesh.select_inverse")
944         layout.itemO("mesh.flip_normals")
945         layout.itemO("mesh.vertices_smooth", text="Smooth")
946         # layout.itemO("mesh.bevel", text="Bevel")
947         layout.itemO("mesh.faces_shade_smooth")
948         layout.itemO("mesh.faces_shade_flat")
949         layout.itemO("mesh.blend_from_shape")
950         layout.itemO("mesh.shape_propagate_to_all")
951         layout.itemO("mesh.select_vertex_path")
952
953
954 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
955     bl_label = "Vertices"
956
957     def draw(self, context):
958         layout = self.layout
959         layout.operator_context = 'INVOKE_REGION_WIN'
960
961         layout.itemO("mesh.merge")
962         layout.itemO("mesh.rip")
963         layout.itemO("mesh.split")
964         layout.itemO("mesh.separate")
965
966         layout.itemS()
967
968         layout.itemO("mesh.vertices_smooth")
969         layout.itemO("mesh.remove_doubles")
970
971         layout.itemO("mesh.select_vertex_path")
972
973         layout.itemO("mesh.blend_from_shape")
974
975         layout.itemO("object.vertex_group_blend")
976         layout.itemO("mesh.shape_propagate_to_all")
977
978
979 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
980     bl_label = "Edges"
981
982     def draw(self, context):
983         layout = self.layout
984         layout.operator_context = 'INVOKE_REGION_WIN'
985
986         layout.itemO("mesh.edge_face_add")
987         layout.itemO("mesh.subdivide")
988
989         layout.itemS()
990
991         layout.itemO("mesh.mark_seam")
992         layout.item_booleanO("mesh.mark_seam", "clear", True, text="Clear Seam")
993
994         layout.itemS()
995
996         layout.itemO("mesh.mark_sharp")
997         layout.item_booleanO("mesh.mark_sharp", "clear", True, text="Clear Sharp")
998
999         layout.itemS()
1000
1001         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
1002         layout.item_enumO("mesh.edge_rotate", "direction", 'CCW', text="Rotate Edge CCW")
1003
1004         layout.itemS()
1005
1006         layout.itemO("TFM_OT_edge_slide", text="Edge Slide")
1007         layout.itemO("mesh.loop_multi_select", text="Edge Loop")
1008
1009         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1010         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1011
1012         layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
1013
1014         layout.itemO("mesh.loop_to_region")
1015         layout.itemO("mesh.region_to_loop")
1016
1017
1018 class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu):
1019     bl_label = "Faces"
1020     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1021
1022     def draw(self, context):
1023         layout = self.layout
1024         layout.operator_context = 'INVOKE_REGION_WIN'
1025
1026         # layout.itemO("mesh.bevel")
1027         # layout.itemO("mesh.bevel")
1028         layout.itemO("mesh.edge_face_add")
1029         layout.itemO("mesh.fill")
1030         layout.itemO("mesh.beauty_fill")
1031
1032         layout.itemS()
1033
1034         layout.itemO("mesh.quads_convert_to_tris")
1035         layout.itemO("mesh.tris_convert_to_quads")
1036         layout.itemO("mesh.edge_flip")
1037
1038         layout.itemS()
1039
1040         layout.itemO("mesh.faces_shade_smooth")
1041         layout.itemO("mesh.faces_shade_flat")
1042
1043         layout.itemS()
1044
1045         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1046         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1047
1048         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
1049
1050         layout.itemS()
1051
1052         layout.item_menu_enumO("mesh.uvs_rotate", "direction")
1053         layout.item_menu_enumO("mesh.uvs_mirror", "axis")
1054         layout.item_menu_enumO("mesh.colors_rotate", "direction")
1055         layout.item_menu_enumO("mesh.colors_mirror", "axis")
1056
1057
1058 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1059     bl_label = "Normals"
1060
1061     def draw(self, context):
1062         layout = self.layout
1063
1064         layout.itemO("mesh.normals_make_consistent", text="Recalculate Outside")
1065         layout.item_booleanO("mesh.normals_make_consistent", "inside", True, text="Recalculate Inside")
1066
1067         layout.itemS()
1068
1069         layout.itemO("mesh.flip_normals")
1070
1071
1072 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1073     _operator_name = "mesh"
1074
1075 # Edit Curve
1076 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1077
1078
1079 def draw_curve(self, context):
1080     layout = self.layout
1081
1082     settings = context.tool_settings
1083
1084     layout.itemM("VIEW3D_MT_snap")
1085
1086     layout.itemS()
1087
1088     layout.itemO("curve.extrude")
1089     layout.itemO("curve.duplicate")
1090     layout.itemO("curve.separate")
1091     layout.itemO("curve.make_segment")
1092     layout.itemO("curve.cyclic_toggle")
1093     layout.itemO("curve.delete", text="Delete...")
1094
1095     layout.itemS()
1096
1097     layout.itemM("VIEW3D_MT_edit_curve_ctrlpoints")
1098     layout.itemM("VIEW3D_MT_edit_curve_segments")
1099
1100     layout.itemS()
1101
1102     layout.item_menu_enumR(settings, "proportional_editing")
1103     layout.item_menu_enumR(settings, "proportional_editing_falloff")
1104
1105     layout.itemS()
1106
1107     layout.itemM("VIEW3D_MT_edit_curve_showhide")
1108
1109
1110 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1111     bl_label = "Curve"
1112
1113     draw = draw_curve
1114
1115
1116 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1117     bl_label = "Control Points"
1118
1119     def draw(self, context):
1120         layout = self.layout
1121
1122         edit_object = context.edit_object
1123
1124         if edit_object.type == 'CURVE':
1125             layout.item_enumO("tfm.transform", "mode", 'TILT')
1126             layout.itemO("curve.tilt_clear")
1127             layout.itemO("curve.separate")
1128
1129             layout.itemS()
1130
1131             layout.item_menu_enumO("curve.handle_type_set", "type")
1132
1133
1134 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1135     bl_label = "Segments"
1136
1137     def draw(self, context):
1138         layout = self.layout
1139
1140         layout.itemO("curve.subdivide")
1141         layout.itemO("curve.switch_direction")
1142
1143
1144 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1145     _operator_name = "curve"
1146
1147
1148 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1149     bl_label = "Surface"
1150
1151     draw = draw_curve
1152
1153
1154 class VIEW3D_MT_edit_text(bpy.types.Menu):
1155     bl_label = "Text"
1156
1157     def draw(self, context):
1158         layout = self.layout
1159
1160         layout.itemO("font.file_paste")
1161
1162         layout.itemS()
1163
1164         layout.itemM("VIEW3D_MT_edit_text_chars")
1165
1166
1167 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1168     bl_label = "Special Characters"
1169
1170     def draw(self, context):
1171         layout = self.layout
1172
1173         layout.item_stringO("font.text_insert", "text", b'\xC2\xA9'.decode(), text="Copyright|Alt C")
1174         layout.item_stringO("font.text_insert", "text", b'\xC2\xAE'.decode(), text="Registered Trademark|Alt R")
1175
1176         layout.itemS()
1177
1178         layout.item_stringO("font.text_insert", "text", b'\xC2\xB0'.decode(), text="Degree Sign|Alt G")
1179         layout.item_stringO("font.text_insert", "text", b'\xC3\x97'.decode(), text="Multiplication Sign|Alt x")
1180         layout.item_stringO("font.text_insert", "text", b'\xC2\x8A'.decode(), text="Circle|Alt .")
1181         layout.item_stringO("font.text_insert", "text", b'\xC2\xB9'.decode(), text="Superscript 1|Alt 1")
1182         layout.item_stringO("font.text_insert", "text", b'\xC2\xB2'.decode(), text="Superscript 2|Alt 2")
1183         layout.item_stringO("font.text_insert", "text", b'\xC2\xB3'.decode(), text="Superscript 3|Alt 3")
1184         layout.item_stringO("font.text_insert", "text", b'\xC2\xBB'.decode(), text="Double >>|Alt >")
1185         layout.item_stringO("font.text_insert", "text", b'\xC2\xAB'.decode(), text="Double <<|Alt <")
1186         layout.item_stringO("font.text_insert", "text", b'\xE2\x80\xB0'.decode(), text="Promillage|Alt %")
1187
1188         layout.itemS()
1189
1190         layout.item_stringO("font.text_insert", "text", b'\xC2\xA4'.decode(), text="Dutch Florin|Alt F")
1191         layout.item_stringO("font.text_insert", "text", b'\xC2\xA3'.decode(), text="British Pound|Alt L")
1192         layout.item_stringO("font.text_insert", "text", b'\xC2\xA5'.decode(), text="Japanese Yen|Alt Y")
1193
1194         layout.itemS()
1195
1196         layout.item_stringO("font.text_insert", "text", b'\xC3\x9F'.decode(), text="German S|Alt S")
1197         layout.item_stringO("font.text_insert", "text", b'\xC2\xBF'.decode(), text="Spanish Question Mark|Alt ?")
1198         layout.item_stringO("font.text_insert", "text", b'\xC2\xA1'.decode(), text="Spanish Exclamation Mark|Alt !")
1199
1200
1201 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1202     bl_label = "Metaball"
1203
1204     def draw(self, context):
1205         layout = self.layout
1206
1207         settings = context.tool_settings
1208
1209         layout.itemO("ed.undo")
1210         layout.itemO("ed.redo")
1211
1212         layout.itemS()
1213
1214         layout.itemM("VIEW3D_MT_snap")
1215
1216         layout.itemS()
1217
1218         layout.itemO("mball.delete_metaelems", text="Delete...")
1219         layout.itemO("mball.duplicate_metaelems")
1220
1221         layout.itemS()
1222
1223         layout.item_menu_enumR(settings, "proportional_editing")
1224         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1225
1226         layout.itemS()
1227
1228         layout.itemM("VIEW3D_MT_edit_meta_showhide")
1229
1230
1231 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1232     bl_label = "Show/Hide"
1233
1234     def draw(self, context):
1235         layout = self.layout
1236
1237         layout.itemO("mball.reveal_metaelems", text="Show Hidden")
1238         layout.itemO("mball.hide_metaelems", text="Hide Selected")
1239         layout.item_booleanO("mball.hide_metaelems", "unselected", True, text="Hide Unselected")
1240
1241
1242 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1243     bl_label = "Lattice"
1244
1245     def draw(self, context):
1246         layout = self.layout
1247
1248         settings = context.tool_settings
1249
1250         layout.itemM("VIEW3D_MT_snap")
1251
1252         layout.itemS()
1253
1254         layout.itemO("lattice.make_regular")
1255
1256         layout.itemS()
1257
1258         layout.item_menu_enumR(settings, "proportional_editing")
1259         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1260
1261
1262 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1263     bl_label = "Armature"
1264
1265     def draw(self, context):
1266         layout = self.layout
1267
1268         edit_object = context.edit_object
1269         arm = edit_object.data
1270
1271         layout.itemM("VIEW3D_MT_snap")
1272         layout.itemM("VIEW3D_MT_edit_armature_roll")
1273
1274         if arm.drawtype == 'ENVELOPE':
1275             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
1276         else:
1277             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale B-Bone Width")
1278
1279         layout.itemS()
1280
1281         layout.itemO("armature.extrude_move")
1282
1283 # EXTRUDE FORKED DOESN'T WORK YET
1284 #               if arm.x_axis_mirror:
1285 #                       layout.item_booleanO("armature.extrude_move", "forked", True, text="Extrude Forked")
1286
1287         layout.itemO("armature.duplicate_move")
1288         layout.itemO("armature.merge")
1289         layout.itemO("armature.fill")
1290         layout.itemO("armature.delete")
1291         layout.itemO("armature.separate")
1292
1293         layout.itemS()
1294
1295         layout.itemO("armature.subdivide_multi", text="Subdivide")
1296
1297         layout.itemS()
1298
1299         layout.operator_context = "EXEC_AREA"
1300         layout.item_enumO("armature.autoside_names", "type", 'XAXIS', text="AutoName Left/Right")
1301         layout.item_enumO("armature.autoside_names", "type", 'YAXIS', text="AutoName Front/Back")
1302         layout.item_enumO("armature.autoside_names", "type", 'ZAXIS', text="AutoName Top/Bottom")
1303         layout.itemO("armature.flip_names")
1304
1305         layout.itemS()
1306
1307         layout.operator_context = "INVOKE_DEFAULT"
1308         layout.itemO("armature.armature_layers")
1309         layout.itemO("armature.bone_layers")
1310
1311         layout.itemS()
1312
1313         layout.itemM("VIEW3D_MT_edit_armature_parent")
1314
1315         layout.itemS()
1316
1317         layout.item_menu_enumO("armature.flags_set", "mode", text="Bone Settings")
1318
1319
1320 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1321     bl_label = "Parent"
1322
1323     def draw(self, context):
1324         layout = self.layout
1325
1326         layout.itemO("armature.parent_set", text="Make")
1327         layout.itemO("armature.parent_clear", text="Clear")
1328
1329
1330 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1331     bl_label = "Bone Roll"
1332
1333     def draw(self, context):
1334         layout = self.layout
1335
1336         layout.item_enumO("armature.calculate_roll", "type", 'GLOBALUP', text="Clear Roll (Z-Axis Up)")
1337         layout.item_enumO("armature.calculate_roll", "type", 'CURSOR', text="Roll to Cursor")
1338
1339         layout.itemS()
1340
1341         layout.item_enumO("tfm.transform", "mode", 'BONE_ROLL', text="Set Roll")
1342
1343 # ********** Panel **********
1344
1345
1346 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1347     bl_space_type = 'VIEW_3D'
1348     bl_region_type = 'UI'
1349     bl_label = "View"
1350
1351     def poll(self, context):
1352         view = context.space_data
1353         return (view)
1354
1355     def draw(self, context):
1356         layout = self.layout
1357
1358         view = context.space_data
1359         scene = context.scene
1360
1361         col = layout.column()
1362         col.itemL(text="Camera:")
1363         col.itemR(view, "camera", text="")
1364         col.itemR(view, "lens")
1365
1366         col = layout.column(align=True)
1367         col.itemL(text="Clip:")
1368         col.itemR(view, "clip_start", text="Start")
1369         col.itemR(view, "clip_end", text="End")
1370
1371         col = layout.column(align=True)
1372         col.itemL(text="Grid:")
1373         col.itemR(view, "grid_lines", text="Lines")
1374         col.itemR(view, "grid_spacing", text="Spacing")
1375         col.itemR(view, "grid_subdivisions", text="Subdivisions")
1376
1377         layout.column().itemR(scene, "cursor_location", text="3D Cursor:")
1378
1379 class VIEW3D_PT_3dview_item(bpy.types.Panel):
1380     bl_space_type = 'VIEW_3D'
1381     bl_region_type = 'UI'
1382     bl_label = "Item"
1383
1384     def poll(self, context):
1385         return (context.active_object or context.active_bone or context.active_pchan)
1386
1387     def draw(self, context):
1388         layout = self.layout
1389
1390         ob = context.active_object
1391
1392         row = layout.row()
1393         row.itemL(text="", icon='ICON_OBJECT_DATA')
1394         row.itemR(ob, "name", text="")
1395
1396         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1397             bone = context.active_bone
1398             if bone:
1399                 row = layout.row()
1400                 row.itemL(text="", icon='ICON_BONE_DATA')
1401                 row.itemR(bone, "name", text="")
1402
1403 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1404     bl_space_type = 'VIEW_3D'
1405     bl_region_type = 'UI'
1406     bl_label = "Display"
1407     bl_default_closed = True
1408
1409     def poll(self, context):
1410         view = context.space_data
1411         return (view)
1412
1413     def draw(self, context):
1414         layout = self.layout
1415
1416         view = context.space_data
1417         gs = context.scene.game_data
1418         ob = context.object
1419
1420         col = layout.column()
1421         col.itemR(view, "display_floor", text="Grid Floor")
1422         col.itemR(view, "display_x_axis", text="X Axis")
1423         col.itemR(view, "display_y_axis", text="Y Axis")
1424         col.itemR(view, "display_z_axis", text="Z Axis")
1425         col.itemR(view, "outline_selected")
1426         col.itemR(view, "all_object_centers")
1427         col.itemR(view, "relationship_lines")
1428         if ob and ob.type == 'MESH':
1429             mesh = ob.data
1430             col.itemR(mesh, "all_edges")
1431
1432         col = layout.column()
1433         col.itemL(text="Shading:")
1434         col.itemR(gs, "material_mode", text="")
1435         col.itemR(view, "textured_solid")
1436
1437 # XXX - the Quad View options don't work yet
1438 #               layout.itemS()
1439 #
1440 #               layout.itemO("screen.region_foursplit", text="Toggle Quad View")
1441 #               col = layout.column()
1442 #               col.itemR(view, "lock_rotation")
1443 #               col.itemR(view, "box_preview")
1444 #               col.itemR(view, "box_clip")
1445
1446
1447 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1448     bl_space_type = 'VIEW_3D'
1449     bl_region_type = 'UI'
1450     bl_label = "Mesh Display"
1451
1452     def poll(self, context):
1453         # The active object check is needed because of localmode
1454         return (context.active_object and (context.mode == 'EDIT_MESH'))
1455
1456     def draw(self, context):
1457         layout = self.layout
1458
1459         mesh = context.active_object.data
1460
1461         col = layout.column()
1462         col.itemL(text="Overlays:")
1463         col.itemR(mesh, "draw_edges", text="Edges")
1464         col.itemR(mesh, "draw_faces", text="Faces")
1465         col.itemR(mesh, "draw_creases", text="Creases")
1466         col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights")
1467         col.itemR(mesh, "draw_seams", text="Seams")
1468         col.itemR(mesh, "draw_sharp", text="Sharp")
1469
1470         col.itemS()
1471         col.itemL(text="Normals:")
1472         col.itemR(mesh, "draw_normals", text="Face")
1473         col.itemR(mesh, "draw_vertex_normals", text="Vertex")
1474         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1475
1476         col.itemS()
1477         col.itemL(text="Numerics:")
1478         col.itemR(mesh, "draw_edge_lenght")
1479         col.itemR(mesh, "draw_edge_angle")
1480         col.itemR(mesh, "draw_face_area")
1481
1482
1483 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1484     bl_space_type = 'VIEW_3D'
1485     bl_region_type = 'UI'
1486     bl_label = "Curve Display"
1487
1488     def poll(self, context):
1489         editmesh = context.mode == 'EDIT_CURVE'
1490         return (editmesh)
1491
1492     def draw(self, context):
1493         layout = self.layout
1494
1495         curve = context.active_object.data
1496
1497         col = layout.column()
1498         col.itemL(text="Overlays:")
1499         col.itemR(curve, "draw_handles", text="Handles")
1500         col.itemR(curve, "draw_normals", text="Normals")
1501         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1502
1503
1504 class VIEW3D_PT_background_image(bpy.types.Panel):
1505     bl_space_type = 'VIEW_3D'
1506     bl_region_type = 'UI'
1507     bl_label = "Background Image"
1508     bl_default_closed = True
1509
1510     def poll(self, context):
1511         view = context.space_data
1512         bg = context.space_data.background_image
1513         return (view)
1514
1515     def draw_header(self, context):
1516         layout = self.layout
1517         view = context.space_data
1518
1519         layout.itemR(view, "display_background_image", text="")
1520
1521     def draw(self, context):
1522         layout = self.layout
1523
1524         view = context.space_data
1525         bg = view.background_image
1526
1527         if bg:
1528             layout.active = view.display_background_image
1529
1530             col = layout.column()
1531             col.itemR(bg, "image", text="")
1532             #col.itemR(bg, "image_user")
1533             col.itemR(bg, "size")
1534             col.itemR(bg, "transparency", slider=True)
1535
1536
1537             col = layout.column(align=True)
1538             col.itemL(text="Offset:")
1539             col.itemR(bg, "offset_x", text="X")
1540             col.itemR(bg, "offset_y", text="Y")
1541
1542
1543 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1544     bl_space_type = 'VIEW_3D'
1545     bl_region_type = 'UI'
1546     bl_label = "Transform Orientations"
1547     bl_default_closed = True
1548
1549     def poll(self, context):
1550         view = context.space_data
1551         return (view)
1552
1553     def draw(self, context):
1554         layout = self.layout
1555
1556         view = context.space_data
1557
1558         col = layout.column()
1559
1560         col.itemR(view, "transform_orientation")
1561         col.itemO("tfm.create_orientation", text="Create")
1562
1563         orientation = view.current_orientation
1564
1565         if orientation:
1566             col.itemR(orientation, "name")
1567             col.itemO("tfm.delete_orientation", text="Delete")
1568
1569
1570 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1571     bl_space_type = 'VIEW_3D'
1572     bl_region_type = 'UI'
1573     bl_label = "Skeleton Sketching"
1574     bl_default_closed = True
1575
1576     def poll(self, context):
1577         scene = context.space_data
1578         ob = context.active_object
1579         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1580
1581     def draw_header(self, context):
1582         layout = self.layout
1583         toolsettings = context.scene.tool_settings
1584
1585         layout.itemR(toolsettings, "bone_sketching", text="")
1586
1587     def draw(self, context):
1588         layout = self.layout
1589         toolsettings = context.scene.tool_settings
1590
1591         col = layout.column()
1592
1593         col.itemR(toolsettings, "etch_quick")
1594         col.itemR(toolsettings, "etch_overdraw")
1595
1596         col.itemR(toolsettings, "etch_convert_mode")
1597
1598         if toolsettings.etch_convert_mode == 'LENGTH':
1599             col.itemR(toolsettings, "etch_length_limit")
1600         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
1601             col.itemR(toolsettings, "etch_adaptive_limit")
1602         elif toolsettings.etch_convert_mode == 'FIXED':
1603             col.itemR(toolsettings, "etch_subdivision_number")
1604         elif toolsettings.etch_convert_mode == 'RETARGET':
1605             col.itemR(toolsettings, "etch_template")
1606             col.itemR(toolsettings, "etch_roll_mode")
1607             col.itemR(toolsettings, "etch_autoname")
1608             col.itemR(toolsettings, "etch_number")
1609             col.itemR(toolsettings, "etch_side")
1610
1611
1612 # Operators
1613 from bpy.props import *
1614
1615
1616 class OBJECT_OT_select_pattern(bpy.types.Operator):
1617     '''Select object matching a naming pattern.'''
1618     bl_idname = "object.select_pattern"
1619     bl_label = "Select Pattern"
1620     bl_register = True
1621     bl_undo = True
1622
1623     pattern = StringProperty(name="Pattern", description="Name filter using '*' and '?' wildcard chars", maxlen=32, default="*")
1624     case_sensitive = BoolProperty(name="Case Sensitive", description="Do a case sensitive compare", default=False)
1625     extend = BoolProperty(name="Extend", description="Extend the existing selection", default=True)
1626
1627     def execute(self, context):
1628
1629         import fnmatch
1630
1631         if self.case_sensitive:
1632             pattern_match = fnmatch.fnmatchcase
1633         else:
1634             pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())
1635
1636         for ob in context.visible_objects:
1637             if pattern_match(ob.name, self.pattern):
1638                 ob.selected = True
1639             elif not self.extend:
1640                 ob.selected = False
1641
1642         return ('FINISHED',)
1643
1644         # TODO - python cant do popups yet
1645     '''
1646     def invoke(self, context, event):
1647         wm = context.manager
1648         wm.add_fileselect(self)
1649         return ('RUNNING_MODAL',)
1650     '''
1651
1652 bpy.types.register(VIEW3D_HT_header) # Header
1653
1654 bpy.types.register(VIEW3D_MT_view) #View Menus
1655 bpy.types.register(VIEW3D_MT_view_navigation)
1656 bpy.types.register(VIEW3D_MT_view_align)
1657 bpy.types.register(VIEW3D_MT_view_align_selected)
1658 bpy.types.register(VIEW3D_MT_view_cameras)
1659
1660 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1661 bpy.types.register(VIEW3D_MT_select_pose)
1662 bpy.types.register(VIEW3D_MT_select_particle)
1663 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1664 bpy.types.register(VIEW3D_MT_select_edit_curve)
1665 bpy.types.register(VIEW3D_MT_select_edit_surface)
1666 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1667 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1668 bpy.types.register(VIEW3D_MT_select_edit_armature)
1669 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1670
1671 bpy.types.register(VIEW3D_MT_object) # Object Menu
1672 bpy.types.register(VIEW3D_MT_object_apply)
1673 bpy.types.register(VIEW3D_MT_object_clear)
1674 bpy.types.register(VIEW3D_MT_object_parent)
1675 bpy.types.register(VIEW3D_MT_object_track)
1676 bpy.types.register(VIEW3D_MT_object_group)
1677 bpy.types.register(VIEW3D_MT_object_constraints)
1678 bpy.types.register(VIEW3D_MT_object_showhide)
1679 bpy.types.register(VIEW3D_MT_make_single_user)
1680 bpy.types.register(VIEW3D_MT_make_links)
1681
1682
1683 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1684
1685 bpy.types.register(VIEW3D_MT_paint_vertex)
1686
1687 bpy.types.register(VIEW3D_MT_particle) # Particle Menu
1688 bpy.types.register(VIEW3D_MT_particle_showhide)
1689
1690 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1691 bpy.types.register(VIEW3D_MT_pose_transform)
1692 bpy.types.register(VIEW3D_MT_pose_pose)
1693 bpy.types.register(VIEW3D_MT_pose_motion)
1694 bpy.types.register(VIEW3D_MT_pose_group)
1695 bpy.types.register(VIEW3D_MT_pose_ik)
1696 bpy.types.register(VIEW3D_MT_pose_constraints)
1697 bpy.types.register(VIEW3D_MT_pose_showhide)
1698
1699 bpy.types.register(VIEW3D_MT_snap) # Edit Menus
1700 bpy.types.register(VIEW3D_MT_uv_map) # Edit Menus
1701
1702 bpy.types.register(VIEW3D_MT_edit_mesh)
1703 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1704 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1705 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1706 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1707 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1708 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1709
1710 bpy.types.register(VIEW3D_MT_edit_curve)
1711 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1712 bpy.types.register(VIEW3D_MT_edit_curve_segments)
1713 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
1714
1715 bpy.types.register(VIEW3D_MT_edit_surface)
1716
1717 bpy.types.register(VIEW3D_MT_edit_text)
1718 bpy.types.register(VIEW3D_MT_edit_text_chars)
1719
1720 bpy.types.register(VIEW3D_MT_edit_meta)
1721 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
1722
1723 bpy.types.register(VIEW3D_MT_edit_lattice)
1724
1725 bpy.types.register(VIEW3D_MT_edit_armature)
1726 bpy.types.register(VIEW3D_MT_edit_armature_parent)
1727 bpy.types.register(VIEW3D_MT_edit_armature_roll)
1728
1729 bpy.types.register(VIEW3D_PT_3dview_item) # Panels
1730 bpy.types.register(VIEW3D_PT_3dview_properties)
1731 bpy.types.register(VIEW3D_PT_3dview_display)
1732 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
1733 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
1734 bpy.types.register(VIEW3D_PT_background_image)
1735 bpy.types.register(VIEW3D_PT_transform_orientations)
1736 bpy.types.register(VIEW3D_PT_etch_a_ton)
1737
1738 bpy.ops.add(OBJECT_OT_select_pattern)