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