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