svn merge -r37793:37865 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / release / scripts / startup / bl_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():
24     bl_space_type = 'VIEW_3D'
25     bl_region_type = 'TOOLS'
26
27
28 # **************** standard tool clusters ******************
29
30 # History/Repeat tools
31 def draw_repeat_tools(context, layout):
32     col = layout.column(align=True)
33     col.label(text="Repeat:")
34     col.operator("screen.repeat_last")
35     col.operator("screen.repeat_history", text="History...")
36
37
38 # Keyframing tools
39 def draw_keyframing_tools(context, layout):
40     col = layout.column(align=True)
41     col.label(text="Keyframes:")
42     row = col.row()
43     row.operator("anim.keyframe_insert_menu", text="Insert")
44     row.operator("anim.keyframe_delete_v3d", text="Remove")
45
46
47 # Grease Pencil tools
48 def draw_gpencil_tools(context, layout):
49     col = layout.column(align=True)
50
51     col.label(text="Grease Pencil:")
52
53     row = col.row()
54     row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
55     row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
56     row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
57
58     row = col.row()
59     row.prop(context.tool_settings, "use_grease_pencil_sessions")
60
61 # ********** default tools for objectmode ****************
62
63
64 class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel):
65     bl_context = "objectmode"
66     bl_label = "Object Tools"
67
68     def draw(self, context):
69         layout = self.layout
70
71         col = layout.column(align=True)
72         col.label(text="Transform:")
73         col.operator("transform.translate")
74         col.operator("transform.rotate")
75         col.operator("transform.resize", text="Scale")
76
77         col = layout.column(align=True)
78         col.operator("object.origin_set", text="Origin")
79
80         col = layout.column(align=True)
81         col.label(text="Object:")
82         col.operator("object.duplicate_move")
83         col.operator("object.delete")
84         col.operator("object.join")
85
86         active_object = context.active_object
87         if active_object and active_object.type == 'MESH':
88
89             col = layout.column(align=True)
90             col.label(text="Shading:")
91             col.operator("object.shade_smooth", text="Smooth")
92             col.operator("object.shade_flat", text="Flat")
93
94         draw_keyframing_tools(context, layout)
95
96         col = layout.column(align=True)
97         col.label(text="Motion Paths:")
98         col.operator("object.paths_calculate", text="Calculate Paths")
99         col.operator("object.paths_clear", text="Clear Paths")
100
101         draw_repeat_tools(context, layout)
102
103         draw_gpencil_tools(context, layout)
104
105 # ********** default tools for editmode_mesh ****************
106
107
108 class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel):
109     bl_context = "mesh_edit"
110     bl_label = "Mesh Tools"
111
112     def draw(self, context):
113         layout = self.layout
114
115         col = layout.column(align=True)
116         col.label(text="Transform:")
117         col.operator("transform.translate")
118         col.operator("transform.rotate")
119         col.operator("transform.resize", text="Scale")
120         col.operator("transform.shrink_fatten", text="Along Normal")
121
122         col = layout.column(align=True)
123         col.label(text="Deform:")
124         col.operator("transform.edge_slide")
125         col.operator("mesh.noise")
126         col.operator("mesh.vertices_smooth")
127
128         col = layout.column(align=True)
129         col.label(text="Add:")
130         col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
131         col.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
132         col.operator("mesh.subdivide")
133         col.operator("mesh.loopcut_slide")
134         col.operator("mesh.duplicate_move", text="Duplicate")
135         col.operator("mesh.spin")
136         col.operator("mesh.screw")
137
138         col = layout.column(align=True)
139         col.label(text="Remove:")
140         col.operator("mesh.delete")
141         col.operator("mesh.merge")
142         col.operator("mesh.remove_doubles")
143
144         col = layout.column(align=True)
145         col.label(text="Normals:")
146         col.operator("mesh.normals_make_consistent", text="Recalculate")
147         col.operator("mesh.flip_normals", text="Flip Direction")
148
149         col = layout.column(align=True)
150         col.label(text="UV Mapping:")
151         col.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
152         col.operator("mesh.mark_seam")
153         col.operator("mesh.mark_seam", text="Clear Seam").clear = True
154
155         col = layout.column(align=True)
156         col.label(text="Shading:")
157         col.operator("mesh.faces_shade_smooth", text="Smooth")
158         col.operator("mesh.faces_shade_flat", text="Flat")
159
160         draw_repeat_tools(context, layout)
161
162         draw_gpencil_tools(context, layout)
163
164
165 class VIEW3D_PT_tools_meshedit_options(View3DPanel, bpy.types.Panel):
166     bl_context = "mesh_edit"
167     bl_label = "Mesh Options"
168
169     def draw(self, context):
170         layout = self.layout
171
172         ob = context.active_object
173
174         if ob:
175             mesh = ob.data
176             col = layout.column(align=True)
177             col.prop(mesh, "use_mirror_x")
178             sub = col.column()
179             sub.active = ob.data.use_mirror_x
180             sub.prop(mesh, "use_mirror_topology")
181
182             ts = context.tool_settings
183
184             col.label("Edge Select Mode")
185             col.prop(ts, "edge_path_mode", text="")
186             col.prop(context.tool_settings, "edge_path_live_unwrap")
187
188 # ********** default tools for editmode_curve ****************
189
190
191 class VIEW3D_PT_tools_curveedit(View3DPanel, bpy.types.Panel):
192     bl_context = "curve_edit"
193     bl_label = "Curve Tools"
194
195     def draw(self, context):
196         layout = self.layout
197
198         col = layout.column(align=True)
199         col.label(text="Transform:")
200         col.operator("transform.translate")
201         col.operator("transform.rotate")
202         col.operator("transform.resize", text="Scale")
203
204         col = layout.column(align=True)
205         col.operator("transform.transform", text="Tilt").mode = 'TILT'
206         col.operator("transform.transform", text="Shrink/Fatten").mode = 'CURVE_SHRINKFATTEN'
207
208         col = layout.column(align=True)
209         col.label(text="Curve:")
210         col.operator("curve.duplicate")
211         col.operator("curve.delete")
212         col.operator("curve.cyclic_toggle")
213         col.operator("curve.switch_direction")
214         col.operator("curve.spline_type_set")
215
216         col = layout.column(align=True)
217         col.label(text="Handles:")
218         row = col.row()
219         row.operator("curve.handle_type_set", text="Auto").type = 'AUTOMATIC'
220         row.operator("curve.handle_type_set", text="Vector").type = 'VECTOR'
221         row = col.row()
222         row.operator("curve.handle_type_set", text="Align").type = 'ALIGNED'
223         row.operator("curve.handle_type_set", text="Free").type = 'FREE_ALIGN'
224
225         col = layout.column(align=True)
226         col.label(text="Modeling:")
227         col.operator("curve.extrude")
228         col.operator("curve.subdivide")
229
230         draw_repeat_tools(context, layout)
231
232         draw_gpencil_tools(context, layout)
233
234 # ********** default tools for editmode_surface ****************
235
236
237 class VIEW3D_PT_tools_surfaceedit(View3DPanel, bpy.types.Panel):
238     bl_context = "surface_edit"
239     bl_label = "Surface Tools"
240
241     def draw(self, context):
242         layout = self.layout
243
244         col = layout.column(align=True)
245         col.label(text="Transform:")
246         col.operator("transform.translate")
247         col.operator("transform.rotate")
248         col.operator("transform.resize", text="Scale")
249
250         col = layout.column(align=True)
251         col.label(text="Curve:")
252         col.operator("curve.duplicate")
253         col.operator("curve.delete")
254         col.operator("curve.cyclic_toggle")
255         col.operator("curve.switch_direction")
256
257         col = layout.column(align=True)
258         col.label(text="Modeling:")
259         col.operator("curve.extrude")
260         col.operator("curve.subdivide")
261
262         draw_repeat_tools(context, layout)
263
264         draw_gpencil_tools(context, layout)
265
266 # ********** default tools for editmode_text ****************
267
268
269 class VIEW3D_PT_tools_textedit(View3DPanel, bpy.types.Panel):
270     bl_context = "text_edit"
271     bl_label = "Text Tools"
272
273     def draw(self, context):
274         layout = self.layout
275
276         col = layout.column(align=True)
277         col.label(text="Text Edit:")
278         col.operator("font.text_copy", text="Copy")
279         col.operator("font.text_cut", text="Cut")
280         col.operator("font.text_paste", text="Paste")
281
282         col = layout.column(align=True)
283         col.label(text="Set Case:")
284         col.operator("font.case_set", text="To Upper").case = 'UPPER'
285         col.operator("font.case_set", text="To Lower").case = 'LOWER'
286
287         col = layout.column(align=True)
288         col.label(text="Style:")
289         col.operator("font.style_toggle", text="Bold").style = 'BOLD'
290         col.operator("font.style_toggle", text="Italic").style = 'ITALIC'
291         col.operator("font.style_toggle", text="Underline").style = 'UNDERLINE'
292
293         draw_repeat_tools(context, layout)
294
295
296 # ********** default tools for editmode_armature ****************
297
298
299 class VIEW3D_PT_tools_armatureedit(View3DPanel, bpy.types.Panel):
300     bl_context = "armature_edit"
301     bl_label = "Armature Tools"
302
303     def draw(self, context):
304         layout = self.layout
305
306         col = layout.column(align=True)
307         col.label(text="Transform:")
308         col.operator("transform.translate")
309         col.operator("transform.rotate")
310         col.operator("transform.resize", text="Scale")
311
312         col = layout.column(align=True)
313         col.label(text="Bones:")
314         col.operator("armature.bone_primitive_add", text="Add")
315         col.operator("armature.duplicate_move", text="Duplicate")
316         col.operator("armature.delete", text="Delete")
317
318         col = layout.column(align=True)
319         col.label(text="Modeling:")
320         col.operator("armature.extrude_move")
321         col.operator("armature.subdivide", text="Subdivide")
322
323         draw_repeat_tools(context, layout)
324
325         draw_gpencil_tools(context, layout)
326
327
328 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, bpy.types.Panel):
329     bl_context = "armature_edit"
330     bl_label = "Armature Options"
331
332     def draw(self, context):
333         arm = context.active_object.data
334
335         self.layout.prop(arm, "use_mirror_x")
336
337 # ********** default tools for editmode_mball ****************
338
339
340 class VIEW3D_PT_tools_mballedit(View3DPanel, bpy.types.Panel):
341     bl_context = "mball_edit"
342     bl_label = "Meta Tools"
343
344     def draw(self, context):
345         layout = self.layout
346
347         col = layout.column(align=True)
348         col.label(text="Transform:")
349         col.operator("transform.translate")
350         col.operator("transform.rotate")
351         col.operator("transform.resize", text="Scale")
352
353         draw_repeat_tools(context, layout)
354
355         draw_gpencil_tools(context, layout)
356
357 # ********** default tools for editmode_lattice ****************
358
359
360 class VIEW3D_PT_tools_latticeedit(View3DPanel, bpy.types.Panel):
361     bl_context = "lattice_edit"
362     bl_label = "Lattice Tools"
363
364     def draw(self, context):
365         layout = self.layout
366
367         col = layout.column(align=True)
368         col.label(text="Transform:")
369         col.operator("transform.translate")
370         col.operator("transform.rotate")
371         col.operator("transform.resize", text="Scale")
372
373         col = layout.column(align=True)
374         col.operator("lattice.make_regular")
375
376         draw_repeat_tools(context, layout)
377
378         draw_gpencil_tools(context, layout)
379
380
381 # ********** default tools for posemode ****************
382
383
384 class VIEW3D_PT_tools_posemode(View3DPanel, bpy.types.Panel):
385     bl_context = "posemode"
386     bl_label = "Pose Tools"
387
388     def draw(self, context):
389         layout = self.layout
390
391         col = layout.column(align=True)
392         col.label(text="Transform:")
393         col.operator("transform.translate")
394         col.operator("transform.rotate")
395         col.operator("transform.resize", text="Scale")
396
397         col = layout.column(align=True)
398         col.label(text="In-Between:")
399         row = col.row()
400         row.operator("pose.push", text="Push")
401         row.operator("pose.relax", text="Relax")
402         col.operator("pose.breakdown", text="Breakdowner")
403
404         col = layout.column(align=True)
405         col.label(text="Pose:")
406         row = col.row()
407         row.operator("pose.copy", text="Copy")
408         row.operator("pose.paste", text="Paste")
409
410         col = layout.column(align=True)
411         col.operator("poselib.pose_add", text="Add To Library")
412
413         draw_keyframing_tools(context, layout)
414
415         col = layout.column(align=True)
416         col.label(text="Motion Paths:")
417         col.operator("pose.paths_calculate", text="Calculate Paths")
418         col.operator("pose.paths_clear", text="Clear Paths")
419
420         draw_repeat_tools(context, layout)
421
422         draw_gpencil_tools(context, layout)
423
424
425 class VIEW3D_PT_tools_posemode_options(View3DPanel, bpy.types.Panel):
426     bl_context = "posemode"
427     bl_label = "Pose Options"
428
429     def draw(self, context):
430         arm = context.active_object.data
431
432         self.layout.prop(arm, "use_auto_ik")
433
434 # ********** default tools for paint modes ****************
435
436
437 class PaintPanel():
438     bl_space_type = 'VIEW_3D'
439     bl_region_type = 'TOOLS'
440
441     @staticmethod
442     def paint_settings(context):
443         ts = context.tool_settings
444
445         if context.sculpt_object:
446             return ts.sculpt
447         elif context.vertex_paint_object:
448             return ts.vertex_paint
449         elif context.weight_paint_object:
450             return ts.weight_paint
451         elif context.image_paint_object:
452             return ts.image_paint
453         elif context.particle_edit_object:
454             return ts.particle_edit
455
456         return None
457
458
459 class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel):
460     bl_label = "Brush"
461
462     @classmethod
463     def poll(cls, context):
464         return cls.paint_settings(context)
465
466     def draw(self, context):
467         layout = self.layout
468
469         settings = __class__.paint_settings(context)
470         brush = settings.brush
471
472         if not context.particle_edit_object:
473             col = layout.split().column()
474             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
475
476         # Particle Mode #
477
478         # XXX This needs a check if psys is editable.
479         if context.particle_edit_object:
480             # XXX Select Particle System
481             layout.column().prop(settings, "tool", expand=True)
482
483             if settings.tool != 'NONE':
484                 col = layout.column()
485                 col.prop(brush, "size", slider=True)
486                 if settings.tool != 'ADD':
487                     col.prop(brush, "strength", slider=True)
488
489             if settings.tool == 'ADD':
490                 col.prop(brush, "count")
491                 col = layout.column()
492                 col.prop(settings, "use_default_interpolate")
493                 sub = col.column(align=True)
494                 sub.active = settings.use_default_interpolate
495                 sub.prop(brush, "steps", slider=True)
496                 sub.prop(settings, "default_key_count", slider=True)
497             elif settings.tool == 'LENGTH':
498                 layout.prop(brush, "length_mode", expand=True)
499             elif settings.tool == 'PUFF':
500                 layout.prop(brush, "puff_mode", expand=True)
501                 layout.prop(brush, "use_puff_volume")
502
503         # Sculpt Mode #
504
505         elif context.sculpt_object and brush:
506
507             col = layout.column()
508
509             col.separator()
510
511             row = col.row(align=True)
512
513             if brush.use_locked_size:
514                 row.prop(brush, "use_locked_size", toggle=True, text="", icon='LOCKED')
515                 row.prop(brush, "unprojected_radius", text="Radius", slider=True)
516             else:
517                 row.prop(brush, "use_locked_size", toggle=True, text="", icon='UNLOCKED')
518                 row.prop(brush, "size", slider=True)
519
520             row.prop(brush, "use_pressure_size", toggle=True, text="")
521
522             if brush.sculpt_tool not in {'SNAKE_HOOK', 'GRAB', 'ROTATE'}:
523                 col.separator()
524
525                 row = col.row(align=True)
526
527                 if brush.use_space and brush.sculpt_tool not in {'SMOOTH'}:
528                     if brush.use_space_atten:
529                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='LOCKED')
530                     else:
531                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
532
533                 row.prop(brush, "strength", text="Strength", slider=True)
534                 row.prop(brush, "use_pressure_strength", text="")
535
536             if brush.sculpt_tool not in {'SMOOTH'}:
537                 col.separator()
538
539                 row = col.row(align=True)
540                 row.prop(brush, "auto_smooth_factor", slider=True)
541                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
542
543             if brush.sculpt_tool in {'GRAB', 'SNAKE_HOOK'}:
544                 col.separator()
545
546                 row = col.row(align=True)
547                 row.prop(brush, "normal_weight", slider=True)
548
549             if brush.sculpt_tool in {'CREASE', 'BLOB'}:
550                 col.separator()
551
552                 row = col.row(align=True)
553                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
554
555             if brush.sculpt_tool not in {'PINCH', 'INFLATE', 'SMOOTH'}:
556                 row = col.row(align=True)
557
558                 col.separator()
559
560                 if brush.use_original_normal:
561                     row.prop(brush, "use_original_normal", toggle=True, text="", icon='LOCKED')
562                 else:
563                     row.prop(brush, "use_original_normal", toggle=True, text="", icon='UNLOCKED')
564
565                 row.prop(brush, "sculpt_plane", text="")
566
567             #if brush.sculpt_tool in {'CLAY', 'CLAY_TUBES', 'FLATTEN', 'FILL', 'SCRAPE'}:
568             if brush.sculpt_tool in {'CLAY', 'FLATTEN', 'FILL', 'SCRAPE'}:
569                 row = col.row(align=True)
570                 row.prop(brush, "plane_offset", slider=True)
571                 row.prop(brush, "use_offset_pressure", text="")
572
573                 col.separator()
574
575                 row = col.row()
576                 row.prop(brush, "use_plane_trim", text="Trim")
577                 row = col.row()
578                 row.active = brush.use_plane_trim
579                 row.prop(brush, "plane_trim", slider=True, text="Distance")
580
581             if brush.sculpt_tool == 'LAYER':
582                 row = col.row()
583                 row.prop(brush, "height", slider=True, text="Height")
584
585             col.separator()
586
587             row = col.row()
588             row.prop(brush, "use_frontface", text="Front Faces Only")
589
590             col.separator()
591             col.row().prop(brush, "direction", expand=True)
592
593             if brush.sculpt_tool in {'DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY'}:
594                 col.separator()
595
596                 col.prop(brush, "use_accumulate")
597
598             if brush.sculpt_tool == 'LAYER':
599                 col.separator()
600
601                 ob = context.sculpt_object
602                 do_persistent = True
603
604                 # not supported yet for this case
605                 for md in ob.modifiers:
606                     if md.type == 'MULTIRES':
607                         do_persistent = False
608
609                 if do_persistent:
610                     col.prop(brush, "use_persistent")
611                     col.operator("sculpt.set_persistent_base")
612
613         # Texture Paint Mode #
614
615         elif context.image_paint_object and brush:
616             col = layout.column()
617             col.template_color_wheel(brush, "color", value_slider=True)
618             col.prop(brush, "color", text="")
619
620             row = col.row(align=True)
621             row.prop(brush, "size", slider=True)
622             row.prop(brush, "use_pressure_size", toggle=True, text="")
623
624             row = col.row(align=True)
625             row.prop(brush, "strength", text="Strength", slider=True)
626             row.prop(brush, "use_pressure_strength", toggle=True, text="")
627
628             row = col.row(align=True)
629             row.prop(brush, "jitter", slider=True)
630             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
631
632             col.prop(brush, "blend", text="Blend")
633
634             col = layout.column()
635             col.active = (brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'})
636             col.prop(brush, "use_alpha")
637
638         # Weight Paint Mode #
639         elif context.weight_paint_object and brush:
640             layout.prop(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
641             layout.prop(context.tool_settings, "use_auto_normalize", text="Auto Normalize")
642             # Jason was here
643             layout.prop(context.tool_settings, "use_multipaint", text="Multi-Paint")
644
645             col = layout.column()
646
647             row = col.row(align=True)
648             row.prop(brush, "size", slider=True)
649             row.prop(brush, "use_pressure_size", toggle=True, text="")
650
651             row = col.row(align=True)
652             row.prop(brush, "strength", text="Strength", slider=True)
653             row.prop(brush, "use_pressure_strength", toggle=True, text="")
654
655             row = col.row(align=True)
656             row.prop(brush, "jitter", slider=True)
657             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
658
659         # Vertex Paint Mode #
660         elif context.vertex_paint_object and brush:
661             col = layout.column()
662             col.template_color_wheel(brush, "color", value_slider=True)
663             col.prop(brush, "color", text="")
664
665             row = col.row(align=True)
666             row.prop(brush, "size", slider=True)
667             row.prop(brush, "use_pressure_size", toggle=True, text="")
668
669             row = col.row(align=True)
670             row.prop(brush, "strength", text="Strength", slider=True)
671             row.prop(brush, "use_pressure_strength", toggle=True, text="")
672
673             # XXX - TODO
674             #row = col.row(align=True)
675             #row.prop(brush, "jitter", slider=True)
676             #row.prop(brush, "use_pressure_jitter", toggle=True, text="")
677
678
679 class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel):
680     bl_label = "Texture"
681     bl_options = {'DEFAULT_CLOSED'}
682
683     @classmethod
684     def poll(cls, context):
685         settings = cls.paint_settings(context)
686         return (settings and settings.brush and (context.sculpt_object or
687                              context.image_paint_object))
688
689     def draw(self, context):
690         layout = self.layout
691
692         settings = __class__.paint_settings(context)
693         brush = settings.brush
694         tex_slot = brush.texture_slot
695
696         col = layout.column()
697
698         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
699         if brush.use_paint_image:
700             col.prop(brush, "use_fixed_texture")
701
702         if context.sculpt_object:
703             #XXX duplicated from properties_texture.py
704
705             col.separator()
706
707             col.label(text="Brush Mapping:")
708             row = col.row(align=True)
709             row.prop(tex_slot, "map_mode", expand=True)
710
711             col.separator()
712
713             col = layout.column()
714             col.active = tex_slot.map_mode in {'FIXED'}
715             col.label(text="Angle:")
716
717             col = layout.column()
718             if not brush.use_anchor and brush.sculpt_tool not in {'GRAB', 'SNAKE_HOOK', 'THUMB', 'ROTATE'} and tex_slot.map_mode in {'FIXED'}:
719                 col.prop(brush, "texture_angle_source_random", text="")
720             else:
721                 col.prop(brush, "texture_angle_source_no_random", text="")
722
723             #row = col.row(align=True)
724             #row.label(text="Angle:")
725             #row.active = tex_slot.map_mode in {'FIXED', 'TILED'}
726
727             #row = col.row(align=True)
728
729             #col = row.column()
730             #col.active = tex_slot.map_mode in {'FIXED'}
731             #col.prop(brush, "use_rake", toggle=True, icon='PARTICLEMODE', text="")
732
733             col = layout.column()
734             col.prop(tex_slot, "angle", text="")
735             col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
736
737             #col = layout.column()
738             #col.prop(brush, "use_random_rotation")
739             #col.active = (not brush.use_rake) and (not brush.use_anchor) and (brush.sculpt_tool not in {'GRAB', 'SNAKE_HOOK', 'THUMB', 'ROTATE'}) and tex_slot.map_mode in {'FIXED'}
740
741             split = layout.split()
742
743             col = split.column()
744             col.prop(tex_slot, "offset")
745
746             col = split.column()
747
748             col.prop(tex_slot, "scale")
749
750             col = layout.column()
751
752             row = col.row(align=True)
753             row.label(text="Sample Bias:")
754             row = col.row(align=True)
755             row.prop(brush, "texture_sample_bias", slider=True, text="")
756
757             row = col.row(align=True)
758             row.label(text="Overlay:")
759             row.active = tex_slot.map_mode in {'FIXED', 'TILED'}
760
761             row = col.row(align=True)
762
763             col = row.column()
764
765             if brush.use_texture_overlay:
766                 col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_OFF')
767             else:
768                 col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_ON')
769
770             col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
771
772             col = row.column()
773             col.prop(brush, "texture_overlay_alpha", text="Alpha")
774             col.active = tex_slot.map_mode in {'FIXED', 'TILED'} and brush.use_texture_overlay
775
776
777 class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel):
778     bl_label = "Tool"
779     bl_options = {'DEFAULT_CLOSED'}
780
781     @classmethod
782     def poll(cls, context):
783         settings = cls.paint_settings(context)
784         return (settings and settings.brush and
785             (context.sculpt_object or context.image_paint_object or
786             context.vertex_paint_object or context.weight_paint_object))
787
788     def draw(self, context):
789         layout = self.layout
790
791         settings = __class__.paint_settings(context)
792         brush = settings.brush
793
794         col = layout.column(align=True)
795
796         if context.sculpt_object:
797             col.prop(brush, "sculpt_tool", expand=False, text="")
798             col.operator("brush.reset")
799         elif context.image_paint_object:
800             col.prop(brush, "image_tool", expand=False, text="")
801         elif context.vertex_paint_object or context.weight_paint_object:
802             col.prop(brush, "vertex_tool", expand=False, text="")
803
804         row = layout.row(align=True)
805         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
806         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
807         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
808         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
809
810
811 class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel):
812     bl_label = "Stroke"
813     bl_options = {'DEFAULT_CLOSED'}
814
815     @classmethod
816     def poll(cls, context):
817         settings = cls.paint_settings(context)
818         return (settings and settings.brush and (context.sculpt_object or
819                              context.vertex_paint_object or
820                              context.weight_paint_object or
821                              context.image_paint_object))
822
823     def draw(self, context):
824         layout = self.layout
825
826         settings = __class__.paint_settings(context)
827         brush = settings.brush
828         image_paint = context.image_paint_object
829
830         col = layout.column()
831
832         if context.sculpt_object:
833             col.label(text="Stroke Method:")
834             col.prop(brush, "stroke_method", text="")
835
836             if brush.use_anchor:
837                 col.separator()
838                 row = col.row()
839                 row.prop(brush, "use_edge_to_edge", "Edge To Edge")
840
841             if brush.use_airbrush:
842                 col.separator()
843                 row = col.row()
844                 row.prop(brush, "rate", text="Rate", slider=True)
845
846             if brush.use_space:
847                 col.separator()
848                 row = col.row()
849                 row.active = brush.use_space
850                 row.prop(brush, "spacing", text="Spacing")
851
852             if (brush.sculpt_tool not in {'GRAB', 'THUMB', 'SNAKE_HOOK', 'ROTATE'}) and (not brush.use_anchor) and (not brush.use_restore_mesh):
853                 col = layout.column()
854                 col.separator()
855
856                 col.prop(brush, "use_smooth_stroke")
857
858                 sub = col.column()
859                 sub.active = brush.use_smooth_stroke
860                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
861                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
862
863                 col.separator()
864
865                 row = col.row(align=True)
866                 row.prop(brush, "jitter", slider=True)
867                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
868
869         else:
870             row = col.row()
871             row.prop(brush, "use_airbrush")
872
873             row = col.row()
874             row.active = brush.use_airbrush and (not brush.use_space) and (not brush.use_anchor)
875             row.prop(brush, "rate", slider=True)
876
877             col.separator()
878
879             if not image_paint:
880                 row = col.row()
881                 row.prop(brush, "use_smooth_stroke")
882
883                 col = layout.column()
884                 col.active = brush.use_smooth_stroke
885                 col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
886                 col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
887
888             col.separator()
889
890             col = layout.column()
891             col.active = (not brush.use_anchor) and (brush.sculpt_tool not in {'GRAB', 'THUMB', 'ROTATE', 'SNAKE_HOOK'})
892
893             row = col.row()
894             row.prop(brush, "use_space")
895
896             row = col.row()
897             row.active = brush.use_space
898             row.prop(brush, "spacing", text="Spacing")
899
900             #col.prop(brush, "use_space_atten", text="Adaptive Strength")
901             #col.prop(brush, "use_adaptive_space", text="Adaptive Spacing")
902
903             #col.separator()
904
905             #if image_paint:
906             #    row.prop(brush, "use_pressure_spacing", toggle=True, text="")
907
908
909 class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel):
910     bl_label = "Curve"
911     bl_options = {'DEFAULT_CLOSED'}
912
913     @classmethod
914     def poll(cls, context):
915         settings = cls.paint_settings(context)
916         return (settings and settings.brush and settings.brush.curve)
917
918     def draw(self, context):
919         layout = self.layout
920
921         settings = self.paint_settings(context)
922
923         brush = settings.brush
924
925         layout.template_curve_mapping(brush, "curve", brush=True)
926
927         row = layout.row(align=True)
928         row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH'
929         row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND'
930         row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT'
931         row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP'
932         row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
933         row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
934
935
936 class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel):
937     bl_label = "Options"
938     bl_options = {'DEFAULT_CLOSED'}
939
940     @classmethod
941     def poll(cls, context):
942         return (context.sculpt_object and context.tool_settings.sculpt)
943
944     def draw(self, context):
945         layout = self.layout
946
947         tool_settings = context.tool_settings
948         sculpt = tool_settings.sculpt
949         settings = __class__.paint_settings(context)
950
951         layout.label(text="Lock:")
952         row = layout.row(align=True)
953         row.prop(sculpt, "lock_x", text="X", toggle=True)
954         row.prop(sculpt, "lock_y", text="Y", toggle=True)
955         row.prop(sculpt, "lock_z", text="Z", toggle=True)
956
957         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
958         layout.prop(sculpt, "show_low_resolution")
959         layout.prop(sculpt, "show_brush")
960         layout.prop(sculpt, "use_deform_only")
961
962         layout.label(text="Unified Settings:")
963         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
964         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
965
966
967 class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel):
968     bl_label = "Symmetry"
969     bl_options = {'DEFAULT_CLOSED'}
970
971     @classmethod
972     def poll(cls, context):
973         return (context.sculpt_object and context.tool_settings.sculpt)
974
975     def draw(self, context):
976         layout = self.layout
977
978         sculpt = context.tool_settings.sculpt
979         settings = __class__.paint_settings(context)
980
981         split = layout.split()
982
983         col = split.column()
984         col.label(text="Mirror:")
985         col.prop(sculpt, "use_symmetry_x", text="X")
986         col.prop(sculpt, "use_symmetry_y", text="Y")
987         col.prop(sculpt, "use_symmetry_z", text="Z")
988
989         split.prop(sculpt, "radial_symmetry", text="Radial")
990
991         layout.separator()
992
993         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
994
995
996 class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel):
997     bl_label = "Appearance"
998     bl_options = {'DEFAULT_CLOSED'}
999
1000     @classmethod
1001     def poll(cls, context):
1002         ts = context.tool_settings
1003         return ((context.sculpt_object and ts.sculpt) or
1004                 (context.vertex_paint_object and ts.vertex_paint) or
1005                 (context.weight_paint_object and ts.weight_paint) or
1006                 (context.image_paint_object and ts.image_paint))
1007
1008     def draw(self, context):
1009         layout = self.layout
1010
1011         settings = __class__.paint_settings(context)
1012         brush = settings.brush
1013
1014         if brush is None:  # unlikely but can happen
1015             layout.label(text="Brush Unset")
1016             return
1017
1018         col = layout.column()
1019
1020         if context.sculpt_object and context.tool_settings.sculpt:
1021             #if brush.sculpt_tool in {'DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE', 'CLAY_TUBES'}:
1022             if brush.sculpt_tool in {'DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE'}:
1023                 col.prop(brush, "cursor_color_add", text="Add Color")
1024                 col.prop(brush, "cursor_color_subtract", text="Subtract Color")
1025             else:
1026                 col.prop(brush, "cursor_color_add", text="Color")
1027         else:
1028             col.prop(brush, "cursor_color_add", text="Color")
1029
1030         col = layout.column()
1031         col.label(text="Icon:")
1032
1033         row = col.row(align=True)
1034         row.prop(brush, "use_custom_icon")
1035         if brush.use_custom_icon:
1036             row = col.row(align=True)
1037             row.prop(brush, "icon_filepath", text="")
1038
1039 # ********** default tools for weightpaint ****************
1040
1041
1042 class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel):
1043     bl_context = "weightpaint"
1044     bl_label = "Weight Tools"
1045
1046     def draw(self, context):
1047         layout = self.layout
1048
1049         ob = context.active_object
1050
1051         col = layout.column()
1052         col.active = ob.vertex_groups.active != None
1053         col.operator("object.vertex_group_normalize_all", text="Normalize All")
1054         col.operator("object.vertex_group_normalize", text="Normalize")
1055         col.operator("object.vertex_group_invert", text="Invert")
1056         col.operator("object.vertex_group_clean", text="Clean")
1057         col.operator("object.vertex_group_levels", text="Levels")
1058
1059
1060 class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel):
1061     bl_context = "weightpaint"
1062     bl_label = "Options"
1063
1064     def draw(self, context):
1065         layout = self.layout
1066
1067         tool_settings = context.tool_settings
1068         wpaint = tool_settings.weight_paint
1069
1070         col = layout.column()
1071         col.prop(wpaint, "use_all_faces")
1072         col.prop(wpaint, "use_normal")
1073         col.prop(wpaint, "use_spray")
1074
1075         obj = context.weight_paint_object
1076         if obj.type == 'MESH':
1077             mesh = obj.data
1078             col.prop(mesh, "use_mirror_x")
1079             col.prop(mesh, "use_mirror_topology")
1080
1081         col.label(text="Unified Settings:")
1082         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1083         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1084
1085 # Commented out because the Apply button isn't an operator yet, making these settings useless
1086 #               col.label(text="Gamma:")
1087 #               col.prop(wpaint, "gamma", text="")
1088 #               col.label(text="Multiply:")
1089 #               col.prop(wpaint, "mul", text="")
1090
1091 # Also missing now:
1092 # Soft, Vgroup, X-Mirror and "Clear" Operator.
1093
1094 # ********** default tools for vertexpaint ****************
1095
1096
1097 class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel):
1098     bl_context = "vertexpaint"
1099     bl_label = "Options"
1100
1101     def draw(self, context):
1102         layout = self.layout
1103
1104         tool_settings = context.tool_settings
1105         vpaint = tool_settings.vertex_paint
1106
1107         col = layout.column()
1108         #col.prop(vpaint, "mode", text="")
1109         col.prop(vpaint, "use_all_faces")
1110         col.prop(vpaint, "use_normal")
1111         col.prop(vpaint, "use_spray")
1112
1113         col.label(text="Unified Settings:")
1114         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1115         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1116
1117 # Commented out because the Apply button isn't an operator yet, making these settings useless
1118 #               col.label(text="Gamma:")
1119 #               col.prop(vpaint, "gamma", text="")
1120 #               col.label(text="Multiply:")
1121 #               col.prop(vpaint, "mul", text="")
1122
1123 # ********** default tools for texturepaint ****************
1124
1125
1126 class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel):
1127     bl_context = "imagepaint"
1128     bl_label = "Project Paint"
1129
1130     @classmethod
1131     def poll(cls, context):
1132         brush = context.tool_settings.image_paint.brush
1133         return (brush and brush.image_tool != 'SOFTEN')
1134
1135     def draw_header(self, context):
1136         ipaint = context.tool_settings.image_paint
1137
1138         self.layout.prop(ipaint, "use_projection", text="")
1139
1140     def draw(self, context):
1141         layout = self.layout
1142
1143         ob = context.active_object
1144         mesh = ob.data
1145         ipaint = context.tool_settings.image_paint
1146         settings = context.tool_settings.image_paint
1147         use_projection = ipaint.use_projection
1148
1149         col = layout.column()
1150         sub = col.column()
1151         sub.active = use_projection
1152         sub.prop(ipaint, "use_occlude")
1153         sub.prop(ipaint, "use_backface_culling")
1154
1155         split = layout.split()
1156
1157         col = split.column()
1158         col.active = (use_projection)
1159         col.prop(ipaint, "use_normal_falloff")
1160
1161         col = split.column()
1162         col.active = (ipaint.use_normal_falloff and use_projection)
1163         col.prop(ipaint, "normal_angle", text="")
1164
1165         col = layout.column(align=False)
1166         row = col.row()
1167         row.active = (use_projection)
1168         row.prop(ipaint, "use_stencil_layer", text="Stencil")
1169
1170         row2 = row.row(align=False)
1171         row2.active = (use_projection and ipaint.use_stencil_layer)
1172         row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=mesh.uv_texture_stencil.name)
1173         row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1174
1175         col = layout.column()
1176         sub = col.column()
1177         row = sub.row()
1178         row.active = (settings.brush.image_tool == 'CLONE')
1179
1180         row.prop(ipaint, "use_clone_layer", text="Layer")
1181         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=mesh.uv_texture_clone.name)
1182
1183         sub = col.column()
1184         sub.prop(ipaint, "seam_bleed")
1185
1186         col.label(text="External Editing")
1187         row = col.split(align=True, percentage=0.55)
1188         row.operator("image.project_edit", text="Quick Edit")
1189         row.operator("image.project_apply", text="Apply")
1190         row = col.row(align=True)
1191         row.prop(ipaint, "screen_grab_size", text="")
1192
1193         sub = col.column()
1194         sub.operator("paint.project_image", text="Apply Camera Image")
1195
1196         sub.operator("image.save_dirty", text="Save All Edited")
1197
1198
1199 class VIEW3D_PT_imagepaint_options(PaintPanel):
1200     bl_label = "Options"
1201     bl_options = {'DEFAULT_CLOSED'}
1202
1203     @classmethod
1204     def poll(cls, context):
1205         return (context.image_paint_object and context.tool_settings.image_paint)
1206
1207     def draw(self, context):
1208         layout = self.layout
1209
1210         tool_settings = context.tool_settings
1211
1212         col = layout.column()
1213         col.label(text="Unified Settings:")
1214         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1215         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1216
1217
1218 class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
1219     bl_label = "Clone Layer"
1220
1221     def draw(self, context):
1222         layout = self.layout
1223         for i, tex in enumerate(context.active_object.data.uv_textures):
1224             prop = layout.operator("wm.context_set_int", text=tex.name)
1225             prop.data_path = "active_object.data.uv_texture_clone_index"
1226             prop.value = i
1227
1228
1229 class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
1230     bl_label = "Mask Layer"
1231
1232     def draw(self, context):
1233         layout = self.layout
1234         for i, tex in enumerate(context.active_object.data.uv_textures):
1235             prop = layout.operator("wm.context_set_int", text=tex.name)
1236             prop.data_path = "active_object.data.uv_texture_stencil_index"
1237             prop.value = i
1238
1239
1240 class VIEW3D_PT_tools_particlemode(View3DPanel, bpy.types.Panel):
1241     '''default tools for particle mode'''
1242     bl_context = "particlemode"
1243     bl_label = "Options"
1244
1245     def draw(self, context):
1246         layout = self.layout
1247
1248         pe = context.tool_settings.particle_edit
1249         ob = pe.object
1250
1251         layout.prop(pe, "type", text="")
1252
1253         ptcache = None
1254
1255         if pe.type == 'PARTICLES':
1256             if ob.particle_systems:
1257                 if len(ob.particle_systems) > 1:
1258                     layout.template_list(ob, "particle_systems", ob.particle_systems, "active_index", rows=2, maxrows=3)
1259
1260                 ptcache = ob.particle_systems.active.point_cache
1261         else:
1262             for md in ob.modifiers:
1263                 if md.type == pe.type:
1264                     ptcache = md.point_cache
1265
1266         if ptcache and len(ptcache.point_caches) > 1:
1267             layout.template_list(ptcache, "point_caches", ptcache.point_caches, "active_index", rows=2, maxrows=3)
1268
1269         if not pe.is_editable:
1270             layout.label(text="Point cache must be baked")
1271             layout.label(text="in memory to enable editing!")
1272
1273         col = layout.column(align=True)
1274         if pe.is_hair:
1275             col.active = pe.is_editable
1276             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1277             sub = col.row()
1278             sub.active = pe.use_emitter_deflect
1279             sub.prop(pe, "emitter_distance", text="Distance")
1280
1281         col = layout.column(align=True)
1282         col.active = pe.is_editable
1283         col.label(text="Keep:")
1284         col.prop(pe, "use_preserve_length", text="Lengths")
1285         col.prop(pe, "use_preserve_root", text="Root")
1286         if not pe.is_hair:
1287             col.label(text="Correct:")
1288             col.prop(pe, "use_auto_velocity", text="Velocity")
1289         col.prop(ob.data, "use_mirror_x")
1290
1291         col = layout.column(align=True)
1292         col.active = pe.is_editable
1293         col.label(text="Draw:")
1294         col.prop(pe, "draw_step", text="Path Steps")
1295         if pe.is_hair:
1296             col.prop(pe, "show_particles", text="Children")
1297         else:
1298             if pe.type == 'PARTICLES':
1299                 col.prop(pe, "show_particles", text="Particles")
1300             col.prop(pe, "use_fade_time")
1301             sub = col.row()
1302             sub.active = pe.use_fade_time
1303             sub.prop(pe, "fade_frames", slider=True)
1304
1305 if __name__ == "__main__":  # only for live edit.
1306     bpy.utils.register_module(__name__)