transform marker sync for extend and grab is back.
[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         # Weight Paint Mode #
596
597         elif context.weight_paint_object and brush:
598             layout.prop(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
599             layout.prop(context.tool_settings, "auto_normalize", text="Auto Normalize")
600
601             col = layout.column()
602             row = col.row(align=True)
603             row.prop(brush, "size", slider=True)
604             row.prop(brush, "use_size_pressure", toggle=True, text="")
605
606             row = col.row(align=True)
607             row.prop(brush, "strength", slider=True)
608             row.prop(brush, "use_strength_pressure", toggle=True, text="")
609
610             row = col.row(align=True)
611             row.prop(brush, "jitter", slider=True)
612             row.prop(brush, "use_jitter_pressure", toggle=True, text="")
613
614         # Vertex Paint Mode #
615
616         elif context.vertex_paint_object and brush:
617             col = layout.column()
618             col.template_color_wheel(brush, "color", value_slider=True)
619             col.prop(brush, "color", text="")
620
621             row = col.row(align=True)
622             row.prop(brush, "size", slider=True)
623             row.prop(brush, "use_size_pressure", toggle=True, text="")
624
625             row = col.row(align=True)
626             row.prop(brush, "strength", slider=True)
627             row.prop(brush, "use_strength_pressure", toggle=True, text="")
628
629             # XXX - TODO
630             #row = col.row(align=True)
631             #row.prop(brush, "jitter", slider=True)
632             #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
633
634
635 class VIEW3D_PT_tools_brush_texture(PaintPanel):
636     bl_label = "Texture"
637     bl_default_closed = True
638
639     def poll(self, context):
640         settings = self.paint_settings(context)
641         return (settings and settings.brush and (context.sculpt_object or
642                              context.texture_paint_object))
643
644     def draw(self, context):
645         layout = self.layout
646
647         settings = self.paint_settings(context)
648         brush = settings.brush
649         tex_slot = brush.texture_slot
650
651         col = layout.column()
652
653         col.template_ID_preview(brush, "texture", new="texture.new", rows=2, cols=4)
654
655         col.row().prop(tex_slot, "map_mode", expand=True)
656
657
658 class VIEW3D_PT_tools_brush_tool(PaintPanel):
659     bl_label = "Tool"
660     bl_default_closed = True
661
662     def poll(self, context):
663         settings = self.paint_settings(context)
664         return (settings and settings.brush and
665             (context.sculpt_object or context.texture_paint_object or
666             context.vertex_paint_object or context.weight_paint_object))
667
668     def draw(self, context):
669         layout = self.layout
670
671         settings = self.paint_settings(context)
672         brush = settings.brush
673         texture_paint = context.texture_paint_object
674         sculpt = context.sculpt_object
675
676         col = layout.column(align=True)
677
678         if context.sculpt_object:
679             col.prop(brush, "sculpt_tool", expand=True)
680         elif context.texture_paint_object:
681             col.prop(brush, "imagepaint_tool", expand=True)
682             #col.prop_enum(settings, "tool", 'DRAW')
683             #col.prop_enum(settings, "tool", 'SOFTEN')
684             #col.prop_enum(settings, "tool", 'CLONE')
685             #col.prop_enum(settings, "tool", 'SMEAR')
686         elif context.vertex_paint_object or context.weight_paint_object:
687             col.prop(brush, "vertexpaint_tool", expand=True)
688
689
690 class VIEW3D_PT_tools_brush_stroke(PaintPanel):
691     bl_label = "Stroke"
692     bl_default_closed = True
693
694     def poll(self, context):
695         settings = self.paint_settings(context)
696         return (settings and settings.brush and (context.sculpt_object or
697                              context.vertex_paint_object or
698                              context.weight_paint_object or
699                              context.texture_paint_object))
700
701     def draw(self, context):
702         layout = self.layout
703
704         settings = self.paint_settings(context)
705         brush = settings.brush
706         texture_paint = context.texture_paint_object
707
708         if context.sculpt_object:
709             if brush.sculpt_tool != 'LAYER':
710                 layout.prop(brush, "use_anchor")
711             layout.prop(brush, "use_rake")
712
713         layout.prop(brush, "use_airbrush")
714         col = layout.column()
715         col.active = brush.use_airbrush
716         col.prop(brush, "rate", slider=True)
717
718         if not texture_paint:
719             layout.prop(brush, "use_smooth_stroke")
720             col = layout.column()
721             col.active = brush.use_smooth_stroke
722             col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
723             col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
724
725         layout.prop(brush, "use_space")
726         row = layout.row(align=True)
727         row.active = brush.use_space
728         row.prop(brush, "spacing", text="Distance", slider=True)
729         if texture_paint:
730             row.prop(brush, "use_spacing_pressure", toggle=True, text="")
731
732
733 class VIEW3D_PT_tools_brush_curve(PaintPanel):
734     bl_label = "Curve"
735     bl_default_closed = True
736
737     def poll(self, context):
738         settings = self.paint_settings(context)
739         return (settings and settings.brush and settings.brush.curve)
740
741     def draw(self, context):
742         layout = self.layout
743
744         settings = self.paint_settings(context)
745         brush = settings.brush
746
747         layout.template_curve_mapping(brush, "curve", brush=True)
748
749         row = layout.row(align=True)
750         row.operator("brush.curve_preset", text="Sharp").shape = 'SHARP'
751         row.operator("brush.curve_preset", text="Smooth").shape = 'SMOOTH'
752         row.operator("brush.curve_preset", text="Max").shape = 'MAX'
753
754
755 class VIEW3D_PT_sculpt_options(PaintPanel):
756     bl_label = "Options"
757
758     def poll(self, context):
759         return (context.sculpt_object and context.tool_settings.sculpt)
760
761     def draw(self, context):
762         layout = self.layout
763
764         sculpt = context.tool_settings.sculpt
765
766         col = layout.column()
767         col.prop(sculpt, "show_brush")
768         col.prop(sculpt, "fast_navigate")
769
770         split = self.layout.split()
771
772         col = split.column()
773         col.label(text="Symmetry:")
774         col.prop(sculpt, "symmetry_x", text="X")
775         col.prop(sculpt, "symmetry_y", text="Y")
776         col.prop(sculpt, "symmetry_z", text="Z")
777
778         col = split.column()
779         col.label(text="Lock:")
780         col.prop(sculpt, "lock_x", text="X")
781         col.prop(sculpt, "lock_y", text="Y")
782         col.prop(sculpt, "lock_z", text="Z")
783
784 # ********** default tools for weightpaint ****************
785
786
787 class VIEW3D_PT_tools_weightpaint(View3DPanel):
788     bl_context = "weightpaint"
789     bl_label = "Weight Tools"
790
791     def draw(self, context):
792         layout = self.layout
793
794         col = layout.column()
795         col.operator("object.vertex_group_normalize_all", text="Normalize All")
796         col.operator("object.vertex_group_normalize", text="Normalize")
797         col.operator("object.vertex_group_invert", text="Invert")
798         col.operator("object.vertex_group_clean", text="Clean")
799         col.operator("object.vertex_group_levels", text="Levels")
800
801
802 class VIEW3D_PT_tools_weightpaint_options(View3DPanel):
803     bl_context = "weightpaint"
804     bl_label = "Options"
805
806     def draw(self, context):
807         layout = self.layout
808
809         wpaint = context.tool_settings.weight_paint
810
811         col = layout.column()
812         col.prop(wpaint, "all_faces")
813         col.prop(wpaint, "normals")
814         col.prop(wpaint, "spray")
815
816         obj = context.weight_paint_object
817         if obj.type == 'MESH':
818             mesh = obj.data
819             col.prop(mesh, "use_mirror_x")
820             col.prop(mesh, "use_mirror_topology")
821
822 # Commented out because the Apply button isn't an operator yet, making these settings useless
823 #               col.label(text="Gamma:")
824 #               col.prop(wpaint, "gamma", text="")
825 #               col.label(text="Multiply:")
826 #               col.prop(wpaint, "mul", text="")
827
828 # Also missing now:
829 # Soft, Vgroup, X-Mirror and "Clear" Operator.
830
831 # ********** default tools for vertexpaint ****************
832
833
834 class VIEW3D_PT_tools_vertexpaint(View3DPanel):
835     bl_context = "vertexpaint"
836     bl_label = "Options"
837
838     def draw(self, context):
839         layout = self.layout
840
841         vpaint = context.tool_settings.vertex_paint
842
843         col = layout.column()
844         #col.prop(vpaint, "mode", text="")
845         col.prop(vpaint, "all_faces")
846         col.prop(vpaint, "normals")
847         col.prop(vpaint, "spray")
848
849 # Commented out because the Apply button isn't an operator yet, making these settings useless
850 #               col.label(text="Gamma:")
851 #               col.prop(vpaint, "gamma", text="")
852 #               col.label(text="Multiply:")
853 #               col.prop(vpaint, "mul", text="")
854
855 # ********** default tools for texturepaint ****************
856
857
858 class VIEW3D_PT_tools_projectpaint(View3DPanel):
859     bl_context = "texturepaint"
860     bl_label = "Project Paint"
861
862     def poll(self, context):
863         return context.tool_settings.image_paint.brush.imagepaint_tool != 'SMEAR'
864
865     def draw_header(self, context):
866         ipaint = context.tool_settings.image_paint
867
868         self.layout.prop(ipaint, "use_projection", text="")
869
870     def draw(self, context):
871         layout = self.layout
872
873         ipaint = context.tool_settings.image_paint
874         settings = context.tool_settings.image_paint
875         use_projection = ipaint.use_projection
876
877         col = layout.column()
878         sub = col.column()
879         sub.active = use_projection
880         sub.prop(ipaint, "use_occlude")
881         sub.prop(ipaint, "use_backface_cull")
882
883         split = layout.split()
884
885         col = split.column()
886         col.active = (use_projection)
887         col.prop(ipaint, "use_normal_falloff")
888
889         col = split.column()
890         col.active = (ipaint.use_normal_falloff and use_projection)
891         col.prop(ipaint, "normal_angle", text="")
892
893         col = layout.column(align=False)
894         row = col.row()
895         row.active = (use_projection)
896         row.prop(ipaint, "use_stencil_layer", text="Stencil")
897
898         row2 = row.row(align=False)
899         row2.active = (use_projection and ipaint.use_stencil_layer)
900         row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=context.active_object.data.uv_texture_stencil.name)
901         row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
902
903         col = layout.column()
904         sub = col.column()
905         row = sub.row()
906         row.active = (settings.brush.imagepaint_tool == 'CLONE')
907
908         row.prop(ipaint, "use_clone_layer", text="Layer")
909         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=context.active_object.data.uv_texture_clone.name)
910
911         sub = col.column()
912         sub.prop(ipaint, "seam_bleed")
913
914         col.label(text="External Editing")
915         row = col.split(align=True, percentage=0.55)
916         row.operator("image.project_edit", text="Quick Edit")
917         row.operator("image.project_apply", text="Apply")
918         row = col.row(align=True)
919         row.prop(ipaint, "screen_grab_size", text="")
920
921         sub = col.column()
922         sub.operator("paint.project_image", text="Apply Camera Image")
923
924         sub.operator("image.save_dirty", text="Save All Edited")
925
926
927 class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
928     bl_label = "Clone Layer"
929
930     def draw(self, context):
931         layout = self.layout
932         for i, tex in enumerate(context.active_object.data.uv_textures):
933             prop = layout.operator("wm.context_set_int", text=tex.name)
934             prop.path = "active_object.data.uv_texture_clone_index"
935             prop.value = i
936
937
938 class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
939     bl_label = "Mask Layer"
940
941     def draw(self, context):
942         layout = self.layout
943         for i, tex in enumerate(context.active_object.data.uv_textures):
944             prop = layout.operator("wm.context_set_int", text=tex.name)
945             prop.path = "active_object.data.uv_texture_stencil_index"
946             prop.value = i
947
948
949 class VIEW3D_PT_tools_particlemode(View3DPanel):
950     '''default tools for particle mode'''
951     bl_context = "particlemode"
952     bl_label = "Options"
953
954     def draw(self, context):
955         layout = self.layout
956
957         pe = context.tool_settings.particle_edit
958         ob = pe.object
959
960         layout.prop(pe, "type", text="")
961
962         ptcache = None
963
964         if pe.type == 'PARTICLES':
965             if ob.particle_systems:
966                 if len(ob.particle_systems) > 1:
967                     layout.template_list(ob, "particle_systems", ob, "active_particle_system_index", type='ICONS')
968
969                 ptcache = ob.particle_systems[ob.active_particle_system_index].point_cache
970         else:
971             for md in ob.modifiers:
972                 if md.type == pe.type:
973                     ptcache = md.point_cache
974
975         if ptcache and len(ptcache.point_cache_list) > 1:
976             layout.template_list(ptcache, "point_cache_list", ptcache, "active_point_cache_index", type='ICONS')
977
978
979         if not pe.editable:
980             layout.label(text="Point cache must be baked")
981             layout.label(text="to enable editing!")
982
983         col = layout.column(align=True)
984         if pe.hair:
985             col.active = pe.editable
986             col.prop(pe, "emitter_deflect", text="Deflect emitter")
987             sub = col.row()
988             sub.active = pe.emitter_deflect
989             sub.prop(pe, "emitter_distance", text="Distance")
990
991         col = layout.column(align=True)
992         col.active = pe.editable
993         col.label(text="Keep:")
994         col.prop(pe, "keep_lengths", text="Lenghts")
995         col.prop(pe, "keep_root", text="Root")
996         if not pe.hair:
997             col.label(text="Correct:")
998             col.prop(pe, "auto_velocity", text="Velocity")
999         col.prop(ob.data, "use_mirror_x")
1000
1001         col = layout.column(align=True)
1002         col.active = pe.editable
1003         col.label(text="Draw:")
1004         col.prop(pe, "draw_step", text="Path Steps")
1005         if pe.type == 'PARTICLES':
1006             col.prop(pe, "draw_particles", text="Particles")
1007         col.prop(pe, "fade_time")
1008         sub = col.row()
1009         sub.active = pe.fade_time
1010         sub.prop(pe, "fade_frames", slider=True)
1011
1012
1013 classes = [
1014     VIEW3D_PT_tools_weightpaint,
1015     VIEW3D_PT_tools_objectmode,
1016     VIEW3D_PT_tools_meshedit,
1017     VIEW3D_PT_tools_meshedit_options,
1018     VIEW3D_PT_tools_curveedit,
1019     VIEW3D_PT_tools_surfaceedit,
1020     VIEW3D_PT_tools_textedit,
1021     VIEW3D_PT_tools_armatureedit,
1022     VIEW3D_PT_tools_armatureedit_options,
1023     VIEW3D_PT_tools_mballedit,
1024     VIEW3D_PT_tools_latticeedit,
1025     VIEW3D_PT_tools_posemode,
1026     VIEW3D_PT_tools_posemode_options,
1027     VIEW3D_PT_tools_brush,
1028     VIEW3D_PT_tools_brush_texture,
1029     VIEW3D_PT_tools_brush_tool,
1030     VIEW3D_PT_tools_brush_stroke,
1031     VIEW3D_PT_tools_brush_curve,
1032     VIEW3D_PT_sculpt_options,
1033     VIEW3D_PT_tools_vertexpaint,
1034     VIEW3D_PT_tools_weightpaint_options,
1035
1036     VIEW3D_PT_tools_projectpaint,
1037     VIEW3D_MT_tools_projectpaint_clone,
1038     VIEW3D_MT_tools_projectpaint_stencil,
1039
1040     VIEW3D_PT_tools_particlemode]
1041
1042
1043 def register():
1044     register = bpy.types.register
1045     for cls in classes:
1046         register(cls)
1047
1048
1049 def unregister():
1050     unregister = bpy.types.unregister
1051     for cls in classes:
1052         unregister(cls)
1053
1054 if __name__ == "__main__":
1055     register()