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