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