change python scripts so modules which register with blender have a register() functi...
[blender.git] / release / scripts / ui / space_view3d_toolbar.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class View3DPanel(bpy.types.Panel):
24     bl_space_type = 'VIEW_3D'
25     bl_region_type = 'TOOLS'
26
27
28 # ********** default tools for objectmode ****************
29
30
31 class VIEW3D_PT_tools_objectmode(View3DPanel):
32     bl_context = "objectmode"
33     bl_label = "Object Tools"
34
35     def draw(self, context):
36         layout = self.layout
37
38         col = layout.column(align=True)
39         col.label(text="Transform:")
40         col.operator("transform.translate")
41         col.operator("transform.rotate")
42         col.operator("transform.resize", text="Scale")
43
44         col = layout.column(align=True)
45         col.label(text="Object:")
46         col.operator("object.duplicate_move")
47         col.operator("object.delete")
48         col.operator("object.join")
49
50         active_object = context.active_object
51         if active_object and active_object.type == 'MESH':
52
53             col = layout.column(align=True)
54             col.label(text="Shading:")
55             col.operator("object.shade_smooth", text="Smooth")
56             col.operator("object.shade_flat", text="Flat")
57
58         col = layout.column(align=True)
59         col.label(text="Keyframes:")
60         col.operator("anim.keyframe_insert_menu", text="Insert")
61         col.operator("anim.keyframe_delete_v3d", text="Remove")
62
63         col = layout.column(align=True)
64         col.label(text="Repeat:")
65         col.operator("screen.repeat_last")
66         col.operator("screen.repeat_history", text="History...")
67
68         col = layout.column(align=True)
69         col.label(text="Grease Pencil:")
70         row = col.row()
71         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
72         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
73         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
74
75 # ********** default tools for editmode_mesh ****************
76
77
78 class VIEW3D_PT_tools_meshedit(View3DPanel):
79     bl_context = "mesh_edit"
80     bl_label = "Mesh Tools"
81
82     def draw(self, context):
83         layout = self.layout
84
85         col = layout.column(align=True)
86         col.label(text="Transform:")
87         col.operator("transform.translate")
88         col.operator("transform.rotate")
89         col.operator("transform.resize", text="Scale")
90         col.operator("transform.shrink_fatten", text="Along Normal")
91
92
93         col = layout.column(align=True)
94         col.label(text="Deform:")
95         col.operator("transform.edge_slide")
96         col.operator("mesh.rip_move")
97         col.operator("mesh.vertices_smooth")
98
99
100         col = layout.column(align=True)
101         col.label(text="Add:")
102         col.operator("wm.call_menu", text="Extrude").name = "VIEW3D_MT_edit_mesh_extrude"
103         col.operator("mesh.subdivide")
104         col.operator("mesh.loopcut_slide")
105         col.operator("mesh.duplicate_move", text="Duplicate")
106         col.operator("mesh.spin")
107         col.operator("mesh.screw")
108
109         col = layout.column(align=True)
110         col.label(text="Remove:")
111         col.operator("mesh.delete")
112         col.operator("mesh.merge")
113         col.operator("mesh.remove_doubles")
114
115         col = layout.column(align=True)
116         col.label(text="Normals:")
117         col.operator("mesh.normals_make_consistent", text="Recalculate")
118         col.operator("mesh.flip_normals", text="Flip Direction")
119
120         col = layout.column(align=True)
121         col.label(text="UV Mapping:")
122         col.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
123         col.operator("mesh.mark_seam")
124         col.operator("mesh.mark_seam", text="Clear Seam").clear = True
125
126
127         col = layout.column(align=True)
128         col.label(text="Shading:")
129         col.operator("mesh.faces_shade_smooth", text="Smooth")
130         col.operator("mesh.faces_shade_flat", text="Flat")
131
132         col = layout.column(align=True)
133         col.label(text="Repeat:")
134         col.operator("screen.repeat_last")
135         col.operator("screen.repeat_history", text="History...")
136
137         col = layout.column(align=True)
138         col.label(text="Grease Pencil:")
139         row = col.row()
140         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
141         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
142         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
143
144
145 class VIEW3D_PT_tools_meshedit_options(View3DPanel):
146     bl_context = "mesh_edit"
147     bl_label = "Mesh Options"
148
149     def draw(self, context):
150         layout = self.layout
151
152         ob = context.active_object
153
154         if ob:
155             mesh = context.active_object.data
156             col = layout.column(align=True)
157             col.prop(mesh, "use_mirror_x")
158             col.prop(context.tool_settings, "edge_path_mode")
159
160 # ********** default tools for editmode_curve ****************
161
162
163 class VIEW3D_PT_tools_curveedit(View3DPanel):
164     bl_context = "curve_edit"
165     bl_label = "Curve Tools"
166
167     def draw(self, context):
168         layout = self.layout
169
170         col = layout.column(align=True)
171         col.label(text="Transform:")
172         col.operator("transform.translate")
173         col.operator("transform.rotate")
174         col.operator("transform.resize", text="Scale")
175
176         col = layout.column(align=True)
177         col.operator("transform.transform", text="Tilt").mode = 'TILT'
178         col.operator("transform.transform", text="Shrink/Fatten").mode = 'CURVE_SHRINKFATTEN'
179
180         col = layout.column(align=True)
181         col.label(text="Curve:")
182         col.operator("curve.duplicate")
183         col.operator("curve.delete")
184         col.operator("curve.cyclic_toggle")
185         col.operator("curve.switch_direction")
186         col.operator("curve.spline_type_set")
187
188         col = layout.column(align=True)
189         col.label(text="Handles:")
190         row = col.row()
191         row.operator("curve.handle_type_set", text="Auto").type = 'AUTOMATIC'
192         row.operator("curve.handle_type_set", text="Vector").type = 'VECTOR'
193         row = col.row()
194         row.operator("curve.handle_type_set", text="Align").type = 'ALIGN'
195         row.operator("curve.handle_type_set", text="Free").type = 'FREE_ALIGN'
196
197         col = layout.column(align=True)
198         col.label(text="Modeling:")
199         col.operator("curve.extrude")
200         col.operator("curve.subdivide")
201
202         col = layout.column(align=True)
203         col.label(text="Repeat:")
204         col.operator("screen.repeat_last")
205         col.operator("screen.repeat_history", text="History...")
206
207         col = layout.column(align=True)
208         col.label(text="Grease Pencil:")
209         row = col.row()
210         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
211         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
212         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
213
214 # ********** default tools for editmode_surface ****************
215
216
217 class VIEW3D_PT_tools_surfaceedit(View3DPanel):
218     bl_context = "surface_edit"
219     bl_label = "Surface Tools"
220
221     def draw(self, context):
222         layout = self.layout
223
224         col = layout.column(align=True)
225         col.label(text="Transform:")
226         col.operator("transform.translate")
227         col.operator("transform.rotate")
228         col.operator("transform.resize", text="Scale")
229
230         col = layout.column(align=True)
231         col.label(text="Curve:")
232         col.operator("curve.duplicate")
233         col.operator("curve.delete")
234         col.operator("curve.cyclic_toggle")
235         col.operator("curve.switch_direction")
236
237         col = layout.column(align=True)
238         col.label(text="Modeling:")
239         col.operator("curve.extrude")
240         col.operator("curve.subdivide")
241
242         col = layout.column(align=True)
243         col.label(text="Repeat:")
244         col.operator("screen.repeat_last")
245         col.operator("screen.repeat_history", text="History...")
246
247         col = layout.column(align=True)
248         col.label(text="Grease Pencil:")
249         row = col.row()
250         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
251         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
252         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
253
254 # ********** default tools for editmode_text ****************
255
256
257 class VIEW3D_PT_tools_textedit(View3DPanel):
258     bl_context = "text_edit"
259     bl_label = "Text Tools"
260
261     def draw(self, context):
262         layout = self.layout
263
264         col = layout.column(align=True)
265         col.label(text="Text Edit:")
266         col.operator("font.text_copy", text="Copy")
267         col.operator("font.text_cut", text="Cut")
268         col.operator("font.text_paste", text="Paste")
269
270         col = layout.column(align=True)
271         col.label(text="Set Case:")
272         col.operator("font.case_set", text="To Upper").case = 'UPPER'
273         col.operator("font.case_set", text="To Lower").case = 'LOWER'
274
275         col = layout.column(align=True)
276         col.label(text="Style:")
277         col.operator("font.style_toggle", text="Bold").style = 'BOLD'
278         col.operator("font.style_toggle", text="Italic").style = 'ITALIC'
279         col.operator("font.style_toggle", text="Underline").style = 'UNDERLINE'
280
281         col = layout.column(align=True)
282         col.label(text="Repeat:")
283         col.operator("screen.repeat_last")
284         col.operator("screen.repeat_history", text="History...")
285
286
287 # ********** default tools for editmode_armature ****************
288
289
290 class VIEW3D_PT_tools_armatureedit(View3DPanel):
291     bl_context = "armature_edit"
292     bl_label = "Armature Tools"
293
294     def draw(self, context):
295         layout = self.layout
296
297         col = layout.column(align=True)
298         col.label(text="Transform:")
299         col.operator("transform.translate")
300         col.operator("transform.rotate")
301         col.operator("transform.resize", text="Scale")
302
303         col = layout.column(align=True)
304         col.label(text="Bones:")
305         col.operator("armature.bone_primitive_add", text="Add")
306         col.operator("armature.duplicate_move", text="Duplicate")
307         col.operator("armature.delete", text="Delete")
308
309         col = layout.column(align=True)
310         col.label(text="Modeling:")
311         col.operator("armature.extrude_move")
312         col.operator("armature.subdivide_multi", text="Subdivide")
313
314         col = layout.column(align=True)
315         col.label(text="Repeat:")
316         col.operator("screen.repeat_last")
317         col.operator("screen.repeat_history", text="History...")
318
319         col = layout.column(align=True)
320         col.label(text="Grease Pencil:")
321         row = col.row()
322         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
323         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
324         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
325
326
327 class VIEW3D_PT_tools_armatureedit_options(View3DPanel):
328     bl_context = "armature_edit"
329     bl_label = "Armature Options"
330
331     def draw(self, context):
332         layout = self.layout
333
334         arm = context.active_object.data
335
336         col = layout.column(align=True)
337         col.prop(arm, "x_axis_mirror")
338
339 # ********** default tools for editmode_mball ****************
340
341
342 class VIEW3D_PT_tools_mballedit(View3DPanel):
343     bl_context = "mball_edit"
344     bl_label = "Meta Tools"
345
346     def draw(self, context):
347         layout = self.layout
348
349         col = layout.column(align=True)
350         col.label(text="Transform:")
351         col.operator("transform.translate")
352         col.operator("transform.rotate")
353         col.operator("transform.resize", text="Scale")
354
355         col = layout.column(align=True)
356         col.label(text="Repeat:")
357         col.operator("screen.repeat_last")
358         col.operator("screen.repeat_history", text="History...")
359
360         col = layout.column(align=True)
361         col.label(text="Grease Pencil:")
362         row = col.row()
363         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
364         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
365         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
366
367 # ********** default tools for editmode_lattice ****************
368
369
370 class VIEW3D_PT_tools_latticeedit(View3DPanel):
371     bl_context = "lattice_edit"
372     bl_label = "Lattice Tools"
373
374     def draw(self, context):
375         layout = self.layout
376
377         col = layout.column(align=True)
378         col.label(text="Transform:")
379         col.operator("transform.translate")
380         col.operator("transform.rotate")
381         col.operator("transform.resize", text="Scale")
382
383         col = layout.column(align=True)
384         col.operator("lattice.make_regular")
385
386         col = layout.column(align=True)
387         col.label(text="Repeat:")
388         col.operator("screen.repeat_last")
389         col.operator("screen.repeat_history", text="History...")
390
391         col = layout.column(align=True)
392         col.label(text="Grease Pencil:")
393         row = col.row()
394         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
395         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
396         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
397
398
399 # ********** default tools for posemode ****************
400
401
402 class VIEW3D_PT_tools_posemode(View3DPanel):
403     bl_context = "posemode"
404     bl_label = "Pose Tools"
405
406     def draw(self, context):
407         layout = self.layout
408
409         col = layout.column(align=True)
410         col.label(text="Transform:")
411         col.operator("transform.translate")
412         col.operator("transform.rotate")
413         col.operator("transform.resize", text="Scale")
414
415         col = layout.column(align=True)
416         col.label(text="In-Between:")
417         row = col.row()
418         row.operator("pose.push", text="Push")
419         row.operator("pose.relax", text="Relax")
420         col.operator("pose.breakdown", text="Breakdowner")
421
422         col = layout.column(align=True)
423         col.label(text="Pose:")
424         row = col.row()
425         row.operator("pose.copy", text="Copy")
426         row.operator("pose.paste", text="Paste")
427
428         col = layout.column(align=True)
429         col.operator("poselib.pose_add", text="Add To Library")
430
431         col = layout.column(align=True)
432         col.label(text="Keyframes:")
433
434         col.operator("anim.keyframe_insert_menu", text="Insert")
435         col.operator("anim.keyframe_delete_v3d", text="Remove")
436
437         col = layout.column(align=True)
438         col.label(text="Repeat:")
439         col.operator("screen.repeat_last")
440         col.operator("screen.repeat_history", text="History...")
441
442         col = layout.column(align=True)
443         col.label(text="Grease Pencil:")
444         row = col.row()
445         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
446         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
447         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
448
449
450 class VIEW3D_PT_tools_posemode_options(View3DPanel):
451     bl_context = "posemode"
452     bl_label = "Pose Options"
453
454     def draw(self, context):
455         layout = self.layout
456
457         arm = context.active_object.data
458
459         col = layout.column(align=True)
460         col.prop(arm, "x_axis_mirror")
461         col.prop(arm, "auto_ik")
462
463 # ********** default tools for paint modes ****************
464
465
466 class PaintPanel(bpy.types.Panel):
467     bl_space_type = 'VIEW_3D'
468     bl_region_type = 'TOOLS'
469
470     def paint_settings(self, context):
471         ts = context.tool_settings
472
473         if context.sculpt_object:
474             return ts.sculpt
475         elif context.vertex_paint_object:
476             return ts.vertex_paint
477         elif context.weight_paint_object:
478             return ts.weight_paint
479         elif context.texture_paint_object:
480             return ts.image_paint
481         elif context.particle_edit_object:
482             return ts.particle_edit
483
484         return False
485
486
487 class VIEW3D_PT_tools_brush(PaintPanel):
488     bl_label = "Brush"
489
490     def poll(self, context):
491         return self.paint_settings(context)
492
493     def draw(self, context):
494         layout = self.layout
495
496         settings = self.paint_settings(context)
497         brush = settings.brush
498
499         if not context.particle_edit_object:
500             col = layout.split().column()
501             row = col.row()
502
503             if context.sculpt_object and brush:
504                 defaultbrushes = 8
505             elif context.texture_paint_object and brush:
506                 defaultbrushes = 4
507             else:
508                 defaultbrushes = 7
509
510             row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes)
511
512             col.template_ID(settings, "brush", new="brush.add")
513
514         # Particle Mode #
515
516         # XXX This needs a check if psys is editable.
517         if context.particle_edit_object:
518             # XXX Select Particle System
519             layout.column().prop(settings, "tool", expand=True)
520
521             if settings.tool != 'NONE':
522                 col = layout.column()
523                 col.prop(brush, "size", slider=True)
524                 col.prop(brush, "strength", slider=True)
525
526             if settings.tool == 'ADD':
527                 col = layout.column()
528                 col.prop(settings, "add_interpolate")
529                 sub = col.column(align=True)
530                 sub.active = settings.add_interpolate
531                 sub.prop(brush, "steps", slider=True)
532                 sub.prop(settings, "add_keys", slider=True)
533             elif settings.tool == 'LENGTH':
534                 layout.prop(brush, "length_mode", expand=True)
535             elif settings.tool == 'PUFF':
536                 layout.prop(brush, "puff_mode", expand=True)
537                 layout.prop(brush, "use_puff_volume")
538
539         # Sculpt Mode #
540
541         elif context.sculpt_object and brush:
542             col = layout.column()
543             col.separator()
544
545             row = col.row(align=True)
546             row.prop(brush, "size", slider=True)
547
548             if brush.sculpt_tool != 'GRAB':
549                 row.prop(brush, "use_size_pressure", toggle=True, text="")
550
551                 row = col.row(align=True)
552                 row.prop(brush, "strength", slider=True)
553                 row.prop(brush, "use_strength_pressure", text="")
554
555                 # XXX - TODO
556                 #row = col.row(align=True)
557                 #row.prop(brush, "jitter", slider=True)
558                 #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
559
560                 col = layout.column()
561
562                 if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
563                     col.row().prop(brush, "direction", expand=True)
564
565                 if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER'):
566                     col.prop(brush, "use_accumulate")
567
568                 if brush.sculpt_tool == 'LAYER':
569                     col.prop(brush, "use_persistent")
570                     col.operator("sculpt.set_persistent_base")
571
572         # Texture Paint Mode #
573
574         elif context.texture_paint_object and brush:
575             col = layout.column()
576             col.template_color_wheel(brush, "color", value_slider=True)
577             col.prop(brush, "color", text="")
578
579             row = col.row(align=True)
580             row.prop(brush, "size", slider=True)
581             row.prop(brush, "use_size_pressure", toggle=True, text="")
582
583             row = col.row(align=True)
584             row.prop(brush, "strength", slider=True)
585             row.prop(brush, "use_strength_pressure", toggle=True, text="")
586
587             row = col.row(align=True)
588             row.prop(brush, "jitter", slider=True)
589             row.prop(brush, "use_jitter_pressure", toggle=True, text="")
590
591             col.prop(brush, "blend", text="Blend")
592
593         # Weight Paint Mode #
594
595         elif context.weight_paint_object and brush:
596             layout.prop(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
597             layout.prop(context.tool_settings, "auto_normalize", text="Auto Normalize")
598
599             col = layout.column()
600             row = col.row(align=True)
601             row.prop(brush, "size", slider=True)
602             row.prop(brush, "use_size_pressure", toggle=True, text="")
603
604             row = col.row(align=True)
605             row.prop(brush, "strength", slider=True)
606             row.prop(brush, "use_strength_pressure", toggle=True, text="")
607
608             row = col.row(align=True)
609             row.prop(brush, "jitter", slider=True)
610             row.prop(brush, "use_jitter_pressure", toggle=True, text="")
611
612         # Vertex Paint Mode #
613
614         elif context.vertex_paint_object and brush:
615             col = layout.column()
616             col.template_color_wheel(brush, "color", value_slider=True)
617             col.prop(brush, "color", text="")
618
619             row = col.row(align=True)
620             row.prop(brush, "size", slider=True)
621             row.prop(brush, "use_size_pressure", toggle=True, text="")
622
623             row = col.row(align=True)
624             row.prop(brush, "strength", slider=True)
625             row.prop(brush, "use_strength_pressure", toggle=True, text="")
626
627             # XXX - TODO
628             #row = col.row(align=True)
629             #row.prop(brush, "jitter", slider=True)
630             #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
631
632
633 class VIEW3D_PT_tools_brush_texture(PaintPanel):
634     bl_label = "Texture"
635     bl_default_closed = True
636
637     def poll(self, context):
638         settings = self.paint_settings(context)
639         return (settings and settings.brush and (context.sculpt_object or
640                              context.texture_paint_object))
641
642     def draw(self, context):
643         layout = self.layout
644
645         settings = self.paint_settings(context)
646         brush = settings.brush
647         tex_slot = brush.texture_slot
648
649         col = layout.column()
650
651         col.template_ID_preview(brush, "texture", new="texture.new", rows=2, cols=4)
652
653         col.row().prop(tex_slot, "map_mode", expand=True)
654
655
656 class VIEW3D_PT_tools_brush_tool(PaintPanel):
657     bl_label = "Tool"
658     bl_default_closed = True
659
660     def poll(self, context):
661         settings = self.paint_settings(context)
662         return (settings and settings.brush and
663             (context.sculpt_object or context.texture_paint_object or
664             context.vertex_paint_object or context.weight_paint_object))
665
666     def draw(self, context):
667         layout = self.layout
668
669         settings = self.paint_settings(context)
670         brush = settings.brush
671         texture_paint = context.texture_paint_object
672         sculpt = context.sculpt_object
673
674         col = layout.column(align=True)
675
676         if context.sculpt_object:
677             col.prop(brush, "sculpt_tool", expand=True)
678         elif context.texture_paint_object:
679             col.prop(brush, "imagepaint_tool", expand=True)
680             #col.prop_enum(settings, "tool", 'DRAW')
681             #col.prop_enum(settings, "tool", 'SOFTEN')
682             #col.prop_enum(settings, "tool", 'CLONE')
683             #col.prop_enum(settings, "tool", 'SMEAR')
684         elif context.vertex_paint_object or context.weight_paint_object:
685             col.prop(brush, "vertexpaint_tool", expand=True)
686
687
688 class VIEW3D_PT_tools_brush_stroke(PaintPanel):
689     bl_label = "Stroke"
690     bl_default_closed = True
691
692     def poll(self, context):
693         settings = self.paint_settings(context)
694         return (settings and settings.brush and (context.sculpt_object or
695                              context.vertex_paint_object or
696                              context.weight_paint_object or
697                              context.texture_paint_object))
698
699     def draw(self, context):
700         layout = self.layout
701
702         settings = self.paint_settings(context)
703         brush = settings.brush
704         texture_paint = context.texture_paint_object
705
706         if context.sculpt_object:
707             if brush.sculpt_tool != 'LAYER':
708                 layout.prop(brush, "use_anchor")
709             layout.prop(brush, "use_rake")
710
711         layout.prop(brush, "use_airbrush")
712         col = layout.column()
713         col.active = brush.use_airbrush
714         col.prop(brush, "rate", slider=True)
715
716         if not texture_paint:
717             layout.prop(brush, "use_smooth_stroke")
718             col = layout.column()
719             col.active = brush.use_smooth_stroke
720             col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
721             col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
722
723         layout.prop(brush, "use_space")
724         row = layout.row(align=True)
725         row.active = brush.use_space
726         row.prop(brush, "spacing", text="Distance", slider=True)
727         if texture_paint:
728             row.prop(brush, "use_spacing_pressure", toggle=True, text="")
729
730
731 class VIEW3D_PT_tools_brush_curve(PaintPanel):
732     bl_label = "Curve"
733     bl_default_closed = True
734
735     def poll(self, context):
736         settings = self.paint_settings(context)
737         return (settings and settings.brush and settings.brush.curve)
738
739     def draw(self, context):
740         layout = self.layout
741
742         settings = self.paint_settings(context)
743         brush = settings.brush
744
745         layout.template_curve_mapping(brush, "curve", brush=True)
746         layout.operator_menu_enum("brush.curve_preset", property="shape")
747
748
749 class VIEW3D_PT_sculpt_options(PaintPanel):
750     bl_label = "Options"
751
752     def poll(self, context):
753         return (context.sculpt_object and context.tool_settings.sculpt)
754
755     def draw(self, context):
756         layout = self.layout
757
758         sculpt = context.tool_settings.sculpt
759
760         col = layout.column()
761         col.prop(sculpt, "show_brush")
762         col.prop(sculpt, "fast_navigate")
763
764         split = self.layout.split()
765
766         col = split.column()
767         col.label(text="Symmetry:")
768         col.prop(sculpt, "symmetry_x", text="X")
769         col.prop(sculpt, "symmetry_y", text="Y")
770         col.prop(sculpt, "symmetry_z", text="Z")
771
772         col = split.column()
773         col.label(text="Lock:")
774         col.prop(sculpt, "lock_x", text="X")
775         col.prop(sculpt, "lock_y", text="Y")
776         col.prop(sculpt, "lock_z", text="Z")
777
778 # ********** default tools for weightpaint ****************
779
780
781 class VIEW3D_PT_tools_weightpaint(View3DPanel):
782     bl_context = "weightpaint"
783     bl_label = "Weight Tools"
784
785     def draw(self, context):
786         layout = self.layout
787
788         col = layout.column()
789         col.operator("object.vertex_group_normalize_all", text="Normalize All")
790         col.operator("object.vertex_group_normalize", text="Normalize")
791         col.operator("object.vertex_group_invert", text="Invert")
792         col.operator("object.vertex_group_clean", text="Clean")
793         col.operator("object.vertex_group_levels", text="Levels")
794
795
796 class VIEW3D_PT_tools_weightpaint_options(View3DPanel):
797     bl_context = "weightpaint"
798     bl_label = "Options"
799
800     def draw(self, context):
801         layout = self.layout
802
803         wpaint = context.tool_settings.weight_paint
804
805         col = layout.column()
806         col.prop(wpaint, "all_faces")
807         col.prop(wpaint, "normals")
808         col.prop(wpaint, "spray")
809
810         obj = context.weight_paint_object
811         if obj.type == 'MESH':
812             col.prop(obj.data, "use_mirror_x")
813
814 # Commented out because the Apply button isn't an operator yet, making these settings useless
815 #               col.label(text="Gamma:")
816 #               col.prop(wpaint, "gamma", text="")
817 #               col.label(text="Multiply:")
818 #               col.prop(wpaint, "mul", text="")
819
820 # Also missing now:
821 # Soft, Vgroup, X-Mirror and "Clear" Operator.
822
823 # ********** default tools for vertexpaint ****************
824
825
826 class VIEW3D_PT_tools_vertexpaint(View3DPanel):
827     bl_context = "vertexpaint"
828     bl_label = "Options"
829
830     def draw(self, context):
831         layout = self.layout
832
833         vpaint = context.tool_settings.vertex_paint
834
835         col = layout.column()
836         #col.prop(vpaint, "mode", text="")
837         col.prop(vpaint, "all_faces")
838         col.prop(vpaint, "normals")
839         col.prop(vpaint, "spray")
840
841 # Commented out because the Apply button isn't an operator yet, making these settings useless
842 #               col.label(text="Gamma:")
843 #               col.prop(vpaint, "gamma", text="")
844 #               col.label(text="Multiply:")
845 #               col.prop(vpaint, "mul", text="")
846
847 # ********** default tools for texturepaint ****************
848
849
850 class VIEW3D_PT_tools_projectpaint(View3DPanel):
851     bl_context = "texturepaint"
852     bl_label = "Project Paint"
853
854     def poll(self, context):
855         return context.tool_settings.image_paint.brush.imagepaint_tool != 'SMEAR'
856
857     def draw_header(self, context):
858         ipaint = context.tool_settings.image_paint
859
860         self.layout.prop(ipaint, "use_projection", text="")
861
862     def draw(self, context):
863         layout = self.layout
864
865         ipaint = context.tool_settings.image_paint
866         settings = context.tool_settings.image_paint
867         use_projection = ipaint.use_projection
868
869         col = layout.column()
870         sub = col.column()
871         sub.active = use_projection
872         sub.prop(ipaint, "use_occlude")
873         sub.prop(ipaint, "use_backface_cull")
874
875         split = layout.split()
876
877         col = split.column()
878         col.active = (use_projection)
879         col.prop(ipaint, "use_normal_falloff")
880
881         col = split.column()
882         col.active = (ipaint.use_normal_falloff and use_projection)
883         col.prop(ipaint, "normal_angle", text="")
884
885         col = layout.column(align=False)
886         row = col.row()
887         row.active = (use_projection)
888         row.prop(ipaint, "use_stencil_layer", text="Stencil")
889
890         row2 = row.row(align=False)
891         row2.active = (use_projection and ipaint.use_stencil_layer)
892         row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=context.active_object.data.uv_texture_stencil.name)
893         row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
894
895         col = layout.column()
896         sub = col.column()
897         row = sub.row()
898         row.active = (settings.brush.imagepaint_tool == 'CLONE')
899
900         row.prop(ipaint, "use_clone_layer", text="Layer")
901         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=context.active_object.data.uv_texture_clone.name)
902
903         sub = col.column()
904         sub.prop(ipaint, "seam_bleed")
905
906
907 class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
908     bl_label = "Clone Layer"
909
910     def draw(self, context):
911         layout = self.layout
912         for i, tex in enumerate(context.active_object.data.uv_textures):
913             prop = layout.operator("wm.context_set_int", text=tex.name)
914             prop.path = "active_object.data.uv_texture_clone_index"
915             prop.value = i
916
917
918 class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
919     bl_label = "Mask Layer"
920
921     def draw(self, context):
922         layout = self.layout
923         for i, tex in enumerate(context.active_object.data.uv_textures):
924             prop = layout.operator("wm.context_set_int", text=tex.name)
925             prop.path = "active_object.data.uv_texture_stencil_index"
926             prop.value = i
927
928
929 class VIEW3D_PT_tools_particlemode(View3DPanel):
930     '''default tools for particle mode'''
931     bl_context = "particlemode"
932     bl_label = "Options"
933
934     def draw(self, context):
935         layout = self.layout
936
937         pe = context.tool_settings.particle_edit
938         ob = pe.object
939
940         layout.prop(pe, "type", text="")
941
942         ptcache = None
943
944         if pe.type == 'PARTICLES':
945             if ob.particle_systems:
946                 if len(ob.particle_systems) > 1:
947                     layout.template_list(ob, "particle_systems", ob, "active_particle_system_index", type='ICONS')
948
949                 ptcache = ob.particle_systems[ob.active_particle_system_index].point_cache
950         else:
951             for md in ob.modifiers:
952                 if md.type == pe.type:
953                     ptcache = md.point_cache
954
955         if ptcache and len(ptcache.point_cache_list) > 1:
956             layout.template_list(ptcache, "point_cache_list", ptcache, "active_point_cache_index", type='ICONS')
957
958
959         if not pe.editable:
960             layout.label(text="Point cache must be baked")
961             layout.label(text="to enable editing!")
962
963         col = layout.column(align=True)
964         if pe.hair:
965             col.active = pe.editable
966             col.prop(pe, "emitter_deflect", text="Deflect emitter")
967             sub = col.row()
968             sub.active = pe.emitter_deflect
969             sub.prop(pe, "emitter_distance", text="Distance")
970
971         col = layout.column(align=True)
972         col.active = pe.editable
973         col.label(text="Keep:")
974         col.prop(pe, "keep_lengths", text="Lenghts")
975         col.prop(pe, "keep_root", text="Root")
976         if not pe.hair:
977             col.label(text="Correct:")
978             col.prop(pe, "auto_velocity", text="Velocity")
979         col.prop(ob.data, "use_mirror_x")
980
981         col = layout.column(align=True)
982         col.active = pe.editable
983         col.label(text="Draw:")
984         col.prop(pe, "draw_step", text="Path Steps")
985         if pe.type == 'PARTICLES':
986             col.prop(pe, "draw_particles", text="Particles")
987         col.prop(pe, "fade_time")
988         sub = col.row()
989         sub.active = pe.fade_time
990         sub.prop(pe, "fade_frames", slider=True)
991
992
993 classes = [
994     VIEW3D_PT_tools_weightpaint,
995     VIEW3D_PT_tools_objectmode,
996     VIEW3D_PT_tools_meshedit,
997     VIEW3D_PT_tools_meshedit_options,
998     VIEW3D_PT_tools_curveedit,
999     VIEW3D_PT_tools_surfaceedit,
1000     VIEW3D_PT_tools_textedit,
1001     VIEW3D_PT_tools_armatureedit,
1002     VIEW3D_PT_tools_armatureedit_options,
1003     VIEW3D_PT_tools_mballedit,
1004     VIEW3D_PT_tools_latticeedit,
1005     VIEW3D_PT_tools_posemode,
1006     VIEW3D_PT_tools_posemode_options,
1007     VIEW3D_PT_tools_brush,
1008     VIEW3D_PT_tools_brush_texture,
1009     VIEW3D_PT_tools_brush_tool,
1010     VIEW3D_PT_tools_brush_stroke,
1011     VIEW3D_PT_tools_brush_curve,
1012     VIEW3D_PT_sculpt_options,
1013     VIEW3D_PT_tools_vertexpaint,
1014     VIEW3D_PT_tools_weightpaint_options,
1015
1016     VIEW3D_PT_tools_projectpaint,
1017     VIEW3D_MT_tools_projectpaint_clone,
1018     VIEW3D_MT_tools_projectpaint_stencil,
1019
1020     VIEW3D_PT_tools_particlemode]
1021
1022
1023 def register():
1024     register = bpy.types.register
1025     for cls in classes:
1026         register(cls)
1027
1028 def unregister():
1029     unregister = bpy.types.unregister
1030     for cls in classes:
1031         unregister(cls)