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