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