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