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