Own TODO item: sculpting on constructive modifiers
[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
643             col = layout.column()
644
645             row = col.row(align=True)
646             row.prop(brush, "size", slider=True)
647             row.prop(brush, "use_pressure_size", toggle=True, text="")
648
649             row = col.row(align=True)
650             row.prop(brush, "strength", text="Strength", slider=True)
651             row.prop(brush, "use_pressure_strength", toggle=True, text="")
652
653             row = col.row(align=True)
654             row.prop(brush, "jitter", slider=True)
655             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
656
657         # Vertex Paint Mode #
658         elif context.vertex_paint_object and brush:
659             col = layout.column()
660             col.template_color_wheel(brush, "color", value_slider=True)
661             col.prop(brush, "color", text="")
662
663             row = col.row(align=True)
664             row.prop(brush, "size", slider=True)
665             row.prop(brush, "use_pressure_size", toggle=True, text="")
666
667             row = col.row(align=True)
668             row.prop(brush, "strength", text="Strength", slider=True)
669             row.prop(brush, "use_pressure_strength", toggle=True, text="")
670
671             # XXX - TODO
672             #row = col.row(align=True)
673             #row.prop(brush, "jitter", slider=True)
674             #row.prop(brush, "use_pressure_jitter", toggle=True, text="")
675
676
677 class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel):
678     bl_label = "Texture"
679     bl_options = {'DEFAULT_CLOSED'}
680
681     @classmethod
682     def poll(cls, context):
683         settings = cls.paint_settings(context)
684         return (settings and settings.brush and (context.sculpt_object or
685                              context.image_paint_object))
686
687     def draw(self, context):
688         layout = self.layout
689
690         settings = __class__.paint_settings(context)
691         brush = settings.brush
692         tex_slot = brush.texture_slot
693
694         col = layout.column()
695
696         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
697         if brush.use_paint_image:
698             col.prop(brush, "use_fixed_texture")
699
700         if context.sculpt_object:
701             #XXX duplicated from properties_texture.py
702
703             col.separator()
704
705             col.label(text="Brush Mapping:")
706             row = col.row(align=True)
707             row.prop(tex_slot, "map_mode", expand=True)
708
709             col.separator()
710
711             col = layout.column()
712             col.active = tex_slot.map_mode in {'FIXED'}
713             col.label(text="Angle:")
714
715             col = layout.column()
716             if not brush.use_anchor and brush.sculpt_tool not in {'GRAB', 'SNAKE_HOOK', 'THUMB', 'ROTATE'} and tex_slot.map_mode in {'FIXED'}:
717                 col.prop(brush, "texture_angle_source_random", text="")
718             else:
719                 col.prop(brush, "texture_angle_source_no_random", text="")
720
721             #row = col.row(align=True)
722             #row.label(text="Angle:")
723             #row.active = tex_slot.map_mode in {'FIXED', 'TILED'}
724
725             #row = col.row(align=True)
726
727             #col = row.column()
728             #col.active = tex_slot.map_mode in {'FIXED'}
729             #col.prop(brush, "use_rake", toggle=True, icon='PARTICLEMODE', text="")
730
731             col = layout.column()
732             col.prop(tex_slot, "angle", text="")
733             col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
734
735             #col = layout.column()
736             #col.prop(brush, "use_random_rotation")
737             #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'}
738
739             split = layout.split()
740
741             col = split.column()
742             col.prop(tex_slot, "offset")
743
744             col = split.column()
745
746             col.prop(tex_slot, "scale")
747
748             col = layout.column()
749
750             row = col.row(align=True)
751             row.label(text="Sample Bias:")
752             row = col.row(align=True)
753             row.prop(brush, "texture_sample_bias", slider=True, text="")
754
755             row = col.row(align=True)
756             row.label(text="Overlay:")
757             row.active = tex_slot.map_mode in {'FIXED', 'TILED'}
758
759             row = col.row(align=True)
760
761             col = row.column()
762
763             if brush.use_texture_overlay:
764                 col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_OFF')
765             else:
766                 col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_ON')
767
768             col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
769
770             col = row.column()
771             col.prop(brush, "texture_overlay_alpha", text="Alpha")
772             col.active = tex_slot.map_mode in {'FIXED', 'TILED'} and brush.use_texture_overlay
773
774
775 class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel):
776     bl_label = "Tool"
777     bl_options = {'DEFAULT_CLOSED'}
778
779     @classmethod
780     def poll(cls, context):
781         settings = cls.paint_settings(context)
782         return (settings and settings.brush and
783             (context.sculpt_object or context.image_paint_object or
784             context.vertex_paint_object or context.weight_paint_object))
785
786     def draw(self, context):
787         layout = self.layout
788
789         settings = __class__.paint_settings(context)
790         brush = settings.brush
791
792         col = layout.column(align=True)
793
794         if context.sculpt_object:
795             col.prop(brush, "sculpt_tool", expand=False, text="")
796             col.operator("brush.reset")
797         elif context.image_paint_object:
798             col.prop(brush, "image_tool", expand=False, text="")
799         elif context.vertex_paint_object or context.weight_paint_object:
800             col.prop(brush, "vertex_tool", expand=False, text="")
801
802         row = layout.row(align=True)
803         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
804         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
805         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
806         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
807
808
809 class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel):
810     bl_label = "Stroke"
811     bl_options = {'DEFAULT_CLOSED'}
812
813     @classmethod
814     def poll(cls, context):
815         settings = cls.paint_settings(context)
816         return (settings and settings.brush and (context.sculpt_object or
817                              context.vertex_paint_object or
818                              context.weight_paint_object or
819                              context.image_paint_object))
820
821     def draw(self, context):
822         layout = self.layout
823
824         settings = __class__.paint_settings(context)
825         brush = settings.brush
826         image_paint = context.image_paint_object
827
828         col = layout.column()
829
830         if context.sculpt_object:
831             col.label(text="Stroke Method:")
832             col.prop(brush, "stroke_method", text="")
833
834             if brush.use_anchor:
835                 col.separator()
836                 row = col.row()
837                 row.prop(brush, "use_edge_to_edge", "Edge To Edge")
838
839             if brush.use_airbrush:
840                 col.separator()
841                 row = col.row()
842                 row.prop(brush, "rate", text="Rate", slider=True)
843
844             if brush.use_space:
845                 col.separator()
846                 row = col.row()
847                 row.active = brush.use_space
848                 row.prop(brush, "spacing", text="Spacing")
849
850             if (brush.sculpt_tool not in {'GRAB', 'THUMB', 'SNAKE_HOOK', 'ROTATE'}) and (not brush.use_anchor) and (not brush.use_restore_mesh):
851                 col = layout.column()
852                 col.separator()
853
854                 col.prop(brush, "use_smooth_stroke")
855
856                 sub = col.column()
857                 sub.active = brush.use_smooth_stroke
858                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
859                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
860
861                 col.separator()
862
863                 row = col.row(align=True)
864                 row.prop(brush, "jitter", slider=True)
865                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
866
867         else:
868             row = col.row()
869             row.prop(brush, "use_airbrush")
870
871             row = col.row()
872             row.active = brush.use_airbrush and (not brush.use_space) and (not brush.use_anchor)
873             row.prop(brush, "rate", slider=True)
874
875             col.separator()
876
877             if not image_paint:
878                 row = col.row()
879                 row.prop(brush, "use_smooth_stroke")
880
881                 col = layout.column()
882                 col.active = brush.use_smooth_stroke
883                 col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
884                 col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
885
886             col.separator()
887
888             col = layout.column()
889             col.active = (not brush.use_anchor) and (brush.sculpt_tool not in {'GRAB', 'THUMB', 'ROTATE', 'SNAKE_HOOK'})
890
891             row = col.row()
892             row.prop(brush, "use_space")
893
894             row = col.row()
895             row.active = brush.use_space
896             row.prop(brush, "spacing", text="Spacing")
897
898             #col.prop(brush, "use_space_atten", text="Adaptive Strength")
899             #col.prop(brush, "use_adaptive_space", text="Adaptive Spacing")
900
901             #col.separator()
902
903             #if image_paint:
904             #    row.prop(brush, "use_pressure_spacing", toggle=True, text="")
905
906
907 class VIEW3D_PT_tools_brush_curve(PaintPanel, bpy.types.Panel):
908     bl_label = "Curve"
909     bl_options = {'DEFAULT_CLOSED'}
910
911     @classmethod
912     def poll(cls, context):
913         settings = cls.paint_settings(context)
914         return (settings and settings.brush and settings.brush.curve)
915
916     def draw(self, context):
917         layout = self.layout
918
919         settings = self.paint_settings(context)
920
921         brush = settings.brush
922
923         layout.template_curve_mapping(brush, "curve", brush=True)
924
925         row = layout.row(align=True)
926         row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH'
927         row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND'
928         row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT'
929         row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP'
930         row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
931         row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
932
933
934 class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel):
935     bl_label = "Options"
936     bl_options = {'DEFAULT_CLOSED'}
937
938     @classmethod
939     def poll(cls, context):
940         return (context.sculpt_object and context.tool_settings.sculpt)
941
942     def draw(self, context):
943         layout = self.layout
944
945         tool_settings = context.tool_settings
946         sculpt = tool_settings.sculpt
947         settings = __class__.paint_settings(context)
948
949         layout.label(text="Lock:")
950         row = layout.row(align=True)
951         row.prop(sculpt, "lock_x", text="X", toggle=True)
952         row.prop(sculpt, "lock_y", text="Y", toggle=True)
953         row.prop(sculpt, "lock_z", text="Z", toggle=True)
954
955         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
956         layout.prop(sculpt, "show_low_resolution")
957         layout.prop(sculpt, "show_brush")
958         layout.prop(sculpt, "use_deform_only")
959
960         layout.label(text="Unified Settings:")
961         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
962         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
963
964
965 class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel):
966     bl_label = "Symmetry"
967     bl_options = {'DEFAULT_CLOSED'}
968
969     @classmethod
970     def poll(cls, context):
971         return (context.sculpt_object and context.tool_settings.sculpt)
972
973     def draw(self, context):
974         layout = self.layout
975
976         sculpt = context.tool_settings.sculpt
977         settings = __class__.paint_settings(context)
978
979         split = layout.split()
980
981         col = split.column()
982         col.label(text="Mirror:")
983         col.prop(sculpt, "use_symmetry_x", text="X")
984         col.prop(sculpt, "use_symmetry_y", text="Y")
985         col.prop(sculpt, "use_symmetry_z", text="Z")
986
987         split.prop(sculpt, "radial_symmetry", text="Radial")
988
989         layout.separator()
990
991         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
992
993
994 class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel):
995     bl_label = "Appearance"
996     bl_options = {'DEFAULT_CLOSED'}
997
998     @classmethod
999     def poll(cls, context):
1000         return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.image_paint_object and context.tool_settings.image_paint)
1001
1002     def draw(self, context):
1003         layout = self.layout
1004
1005         settings = __class__.paint_settings(context)
1006         brush = settings.brush
1007
1008         col = layout.column()
1009
1010         if context.sculpt_object and context.tool_settings.sculpt:
1011             #if brush.sculpt_tool in {'DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE', 'CLAY_TUBES'}:
1012             if brush.sculpt_tool in {'DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE'}:
1013                 col.prop(brush, "cursor_color_add", text="Add Color")
1014                 col.prop(brush, "cursor_color_subtract", text="Subtract Color")
1015             else:
1016                 col.prop(brush, "cursor_color_add", text="Color")
1017         else:
1018             col.prop(brush, "cursor_color_add", text="Color")
1019
1020         col = layout.column()
1021         col.label(text="Icon:")
1022
1023         row = col.row(align=True)
1024         row.prop(brush, "use_custom_icon")
1025         if brush.use_custom_icon:
1026             row = col.row(align=True)
1027             row.prop(brush, "icon_filepath", text="")
1028
1029 # ********** default tools for weightpaint ****************
1030
1031
1032 class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel):
1033     bl_context = "weightpaint"
1034     bl_label = "Weight Tools"
1035
1036     def draw(self, context):
1037         layout = self.layout
1038
1039         ob = context.active_object
1040
1041         col = layout.column()
1042         col.active = ob.vertex_groups.active != None
1043         col.operator("object.vertex_group_normalize_all", text="Normalize All")
1044         col.operator("object.vertex_group_normalize", text="Normalize")
1045         col.operator("object.vertex_group_invert", text="Invert")
1046         col.operator("object.vertex_group_clean", text="Clean")
1047         col.operator("object.vertex_group_levels", text="Levels")
1048
1049
1050 class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel):
1051     bl_context = "weightpaint"
1052     bl_label = "Options"
1053
1054     def draw(self, context):
1055         layout = self.layout
1056
1057         tool_settings = context.tool_settings
1058         wpaint = tool_settings.weight_paint
1059
1060         col = layout.column()
1061         col.prop(wpaint, "use_all_faces")
1062         col.prop(wpaint, "use_normal")
1063         col.prop(wpaint, "use_spray")
1064
1065         obj = context.weight_paint_object
1066         if obj.type == 'MESH':
1067             mesh = obj.data
1068             col.prop(mesh, "use_mirror_x")
1069             col.prop(mesh, "use_mirror_topology")
1070
1071         col.label(text="Unified Settings:")
1072         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1073         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1074
1075 # Commented out because the Apply button isn't an operator yet, making these settings useless
1076 #               col.label(text="Gamma:")
1077 #               col.prop(wpaint, "gamma", text="")
1078 #               col.label(text="Multiply:")
1079 #               col.prop(wpaint, "mul", text="")
1080
1081 # Also missing now:
1082 # Soft, Vgroup, X-Mirror and "Clear" Operator.
1083
1084 # ********** default tools for vertexpaint ****************
1085
1086
1087 class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel):
1088     bl_context = "vertexpaint"
1089     bl_label = "Options"
1090
1091     def draw(self, context):
1092         layout = self.layout
1093
1094         tool_settings = context.tool_settings
1095         vpaint = tool_settings.vertex_paint
1096
1097         col = layout.column()
1098         #col.prop(vpaint, "mode", text="")
1099         col.prop(vpaint, "use_all_faces")
1100         col.prop(vpaint, "use_normal")
1101         col.prop(vpaint, "use_spray")
1102
1103         col.label(text="Unified Settings:")
1104         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1105         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1106
1107 # Commented out because the Apply button isn't an operator yet, making these settings useless
1108 #               col.label(text="Gamma:")
1109 #               col.prop(vpaint, "gamma", text="")
1110 #               col.label(text="Multiply:")
1111 #               col.prop(vpaint, "mul", text="")
1112
1113 # ********** default tools for texturepaint ****************
1114
1115
1116 class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel):
1117     bl_context = "imagepaint"
1118     bl_label = "Project Paint"
1119
1120     @classmethod
1121     def poll(cls, context):
1122         brush = context.tool_settings.image_paint.brush
1123         return (brush and brush.image_tool != 'SOFTEN')
1124
1125     def draw_header(self, context):
1126         ipaint = context.tool_settings.image_paint
1127
1128         self.layout.prop(ipaint, "use_projection", text="")
1129
1130     def draw(self, context):
1131         layout = self.layout
1132
1133         ob = context.active_object
1134         mesh = ob.data
1135         ipaint = context.tool_settings.image_paint
1136         settings = context.tool_settings.image_paint
1137         use_projection = ipaint.use_projection
1138
1139         col = layout.column()
1140         sub = col.column()
1141         sub.active = use_projection
1142         sub.prop(ipaint, "use_occlude")
1143         sub.prop(ipaint, "use_backface_culling")
1144
1145         split = layout.split()
1146
1147         col = split.column()
1148         col.active = (use_projection)
1149         col.prop(ipaint, "use_normal_falloff")
1150
1151         col = split.column()
1152         col.active = (ipaint.use_normal_falloff and use_projection)
1153         col.prop(ipaint, "normal_angle", text="")
1154
1155         col = layout.column(align=False)
1156         row = col.row()
1157         row.active = (use_projection)
1158         row.prop(ipaint, "use_stencil_layer", text="Stencil")
1159
1160         row2 = row.row(align=False)
1161         row2.active = (use_projection and ipaint.use_stencil_layer)
1162         row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=mesh.uv_texture_stencil.name)
1163         row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1164
1165         col = layout.column()
1166         sub = col.column()
1167         row = sub.row()
1168         row.active = (settings.brush.image_tool == 'CLONE')
1169
1170         row.prop(ipaint, "use_clone_layer", text="Layer")
1171         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=mesh.uv_texture_clone.name)
1172
1173         sub = col.column()
1174         sub.prop(ipaint, "seam_bleed")
1175
1176         col.label(text="External Editing")
1177         row = col.split(align=True, percentage=0.55)
1178         row.operator("image.project_edit", text="Quick Edit")
1179         row.operator("image.project_apply", text="Apply")
1180         row = col.row(align=True)
1181         row.prop(ipaint, "screen_grab_size", text="")
1182
1183         sub = col.column()
1184         sub.operator("paint.project_image", text="Apply Camera Image")
1185
1186         sub.operator("image.save_dirty", text="Save All Edited")
1187
1188
1189 class VIEW3D_PT_imagepaint_options(PaintPanel):
1190     bl_label = "Options"
1191     bl_options = {'DEFAULT_CLOSED'}
1192
1193     @classmethod
1194     def poll(cls, context):
1195         return (context.image_paint_object and context.tool_settings.image_paint)
1196
1197     def draw(self, context):
1198         layout = self.layout
1199
1200         tool_settings = context.tool_settings
1201
1202         col = layout.column()
1203         col.label(text="Unified Settings:")
1204         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1205         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1206
1207
1208 class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
1209     bl_label = "Clone Layer"
1210
1211     def draw(self, context):
1212         layout = self.layout
1213         for i, tex in enumerate(context.active_object.data.uv_textures):
1214             prop = layout.operator("wm.context_set_int", text=tex.name)
1215             prop.data_path = "active_object.data.uv_texture_clone_index"
1216             prop.value = i
1217
1218
1219 class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
1220     bl_label = "Mask Layer"
1221
1222     def draw(self, context):
1223         layout = self.layout
1224         for i, tex in enumerate(context.active_object.data.uv_textures):
1225             prop = layout.operator("wm.context_set_int", text=tex.name)
1226             prop.data_path = "active_object.data.uv_texture_stencil_index"
1227             prop.value = i
1228
1229
1230 class VIEW3D_PT_tools_particlemode(View3DPanel, bpy.types.Panel):
1231     '''default tools for particle mode'''
1232     bl_context = "particlemode"
1233     bl_label = "Options"
1234
1235     def draw(self, context):
1236         layout = self.layout
1237
1238         pe = context.tool_settings.particle_edit
1239         ob = pe.object
1240
1241         layout.prop(pe, "type", text="")
1242
1243         ptcache = None
1244
1245         if pe.type == 'PARTICLES':
1246             if ob.particle_systems:
1247                 if len(ob.particle_systems) > 1:
1248                     layout.template_list(ob, "particle_systems", ob.particle_systems, "active_index", type='ICONS')
1249
1250                 ptcache = ob.particle_systems.active.point_cache
1251         else:
1252             for md in ob.modifiers:
1253                 if md.type == pe.type:
1254                     ptcache = md.point_cache
1255
1256         if ptcache and len(ptcache.point_caches) > 1:
1257             layout.template_list(ptcache, "point_caches", ptcache.point_caches, "active_index", type='ICONS')
1258
1259         if not pe.is_editable:
1260             layout.label(text="Point cache must be baked")
1261             layout.label(text="in memory to enable editing!")
1262
1263         col = layout.column(align=True)
1264         if pe.is_hair:
1265             col.active = pe.is_editable
1266             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1267             sub = col.row()
1268             sub.active = pe.use_emitter_deflect
1269             sub.prop(pe, "emitter_distance", text="Distance")
1270
1271         col = layout.column(align=True)
1272         col.active = pe.is_editable
1273         col.label(text="Keep:")
1274         col.prop(pe, "use_preserve_length", text="Lengths")
1275         col.prop(pe, "use_preserve_root", text="Root")
1276         if not pe.is_hair:
1277             col.label(text="Correct:")
1278             col.prop(pe, "use_auto_velocity", text="Velocity")
1279         col.prop(ob.data, "use_mirror_x")
1280
1281         col = layout.column(align=True)
1282         col.active = pe.is_editable
1283         col.label(text="Draw:")
1284         col.prop(pe, "draw_step", text="Path Steps")
1285         if pe.is_hair:
1286             col.prop(pe, "show_particles", text="Children")
1287         else:
1288             if pe.type == 'PARTICLES':
1289                 col.prop(pe, "show_particles", text="Particles")
1290             col.prop(pe, "use_fade_time")
1291             sub = col.row()
1292             sub.active = pe.use_fade_time
1293             sub.prop(pe, "fade_frames", slider=True)
1294
1295 if __name__ == "__main__":  # only for live edit.
1296     bpy.utils.register_module(__name__)