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