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