style cleanup: pep8
[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 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="Scale Feather").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             col.prop(brush, "vertex_tool", text="Blend")
680
681         # Vertex Paint Mode #
682         elif context.vertex_paint_object and brush:
683             col = layout.column()
684             col.template_color_wheel(brush, "color", value_slider=True)
685             col.prop(brush, "color", text="")
686
687             row = col.row(align=True)
688             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
689             self.prop_unified_size(row, context, brush, "use_pressure_size")
690
691             row = col.row(align=True)
692             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
693             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
694
695             # XXX - TODO
696             #row = col.row(align=True)
697             #row.prop(brush, "jitter", slider=True)
698             #row.prop(brush, "use_pressure_jitter", toggle=True, text="")
699
700             col.prop(brush, "vertex_tool", text="Blend")
701
702
703 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
704     bl_label = "Texture"
705     bl_options = {'DEFAULT_CLOSED'}
706
707     @classmethod
708     def poll(cls, context):
709         settings = cls.paint_settings(context)
710         return (settings and settings.brush and
711                 (context.sculpt_object or context.image_paint_object))
712
713     def draw(self, context):
714         layout = self.layout
715
716         settings = self.paint_settings(context)
717         brush = settings.brush
718         tex_slot = brush.texture_slot
719
720         col = layout.column()
721
722         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
723         if brush.use_paint_image:
724             col.prop(brush, "use_fixed_texture")
725
726         if context.sculpt_object:
727             sculpt_brush_texture_settings(col, brush)
728
729             # use_texture_overlay and texture_overlay_alpha
730             col = layout.column(align=True)
731             col.active = brush.sculpt_capabilities.has_overlay
732             col.label(text="Overlay:")
733
734             row = col.row()
735             if brush.use_texture_overlay:
736                 row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
737             else:
738                 row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
739             sub = row.row()
740             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
741
742
743 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
744     bl_label = "Stroke"
745     bl_options = {'DEFAULT_CLOSED'}
746
747     @classmethod
748     def poll(cls, context):
749         settings = cls.paint_settings(context)
750         return (settings and
751                 settings.brush and
752                 (context.sculpt_object or
753                  context.vertex_paint_object or
754                  context.weight_paint_object or
755                  context.image_paint_object))
756
757     def draw(self, context):
758         layout = self.layout
759
760         settings = self.paint_settings(context)
761         brush = settings.brush
762         image_paint = context.image_paint_object
763
764         col = layout.column()
765
766         if context.sculpt_object:
767             col.label(text="Stroke Method:")
768             col.prop(brush, "stroke_method", text="")
769
770             if brush.use_anchor:
771                 col.separator()
772                 col.prop(brush, "use_edge_to_edge", "Edge To Edge")
773
774             if brush.use_airbrush:
775                 col.separator()
776                 col.prop(brush, "rate", text="Rate", slider=True)
777
778             if brush.use_space:
779                 col.separator()
780                 row = col.row()
781                 row.active = brush.use_space
782                 row.prop(brush, "spacing", text="Spacing")
783
784             if brush.sculpt_capabilities.has_smooth_stroke:
785                 col = layout.column()
786                 col.separator()
787
788                 col.prop(brush, "use_smooth_stroke")
789
790                 sub = col.column()
791                 sub.active = brush.use_smooth_stroke
792                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
793                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
794
795             if brush.sculpt_capabilities.has_jitter:
796                 col.separator()
797
798                 row = col.row(align=True)
799                 row.prop(brush, "jitter", slider=True)
800                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
801
802         else:
803             col.prop(brush, "use_airbrush")
804
805             row = col.row()
806             row.active = brush.use_airbrush and (not brush.use_space) and (not brush.use_anchor)
807             row.prop(brush, "rate", slider=True)
808
809             col.separator()
810
811             if not image_paint:
812                 col.prop(brush, "use_smooth_stroke")
813
814                 col = layout.column()
815                 col.active = brush.use_smooth_stroke
816                 col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
817                 col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
818
819             col.separator()
820
821             col = layout.column()
822             col.active = brush.sculpt_capabilities.has_spacing
823             col.prop(brush, "use_space")
824
825             row = col.row()
826             row.active = brush.use_space
827             row.prop(brush, "spacing", text="Spacing")
828
829
830 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
831     bl_label = "Curve"
832     bl_options = {'DEFAULT_CLOSED'}
833
834     @classmethod
835     def poll(cls, context):
836         settings = cls.paint_settings(context)
837         return (settings and settings.brush and settings.brush.curve)
838
839     def draw(self, context):
840         layout = self.layout
841
842         settings = self.paint_settings(context)
843
844         brush = settings.brush
845
846         layout.template_curve_mapping(brush, "curve", brush=True)
847
848         row = layout.row(align=True)
849         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
850         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
851         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
852         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
853         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
854         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
855
856
857 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
858     bl_label = "Options"
859     bl_options = {'DEFAULT_CLOSED'}
860
861     @classmethod
862     def poll(cls, context):
863         return (context.sculpt_object and context.tool_settings.sculpt)
864
865     def draw(self, context):
866         layout = self.layout
867
868         toolsettings = context.tool_settings
869         sculpt = toolsettings.sculpt
870
871         layout.label(text="Lock:")
872         row = layout.row(align=True)
873         row.prop(sculpt, "lock_x", text="X", toggle=True)
874         row.prop(sculpt, "lock_y", text="Y", toggle=True)
875         row.prop(sculpt, "lock_z", text="Z", toggle=True)
876
877         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
878         layout.prop(sculpt, "show_low_resolution")
879         layout.prop(sculpt, "show_brush")
880         layout.prop(sculpt, "use_deform_only")
881
882         layout.prop(sculpt, "input_samples")
883
884         self.unified_paint_settings(layout, context)
885
886
887 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
888     bl_label = "Symmetry"
889     bl_options = {'DEFAULT_CLOSED'}
890
891     @classmethod
892     def poll(cls, context):
893         return (context.sculpt_object and context.tool_settings.sculpt)
894
895     def draw(self, context):
896         layout = self.layout
897
898         sculpt = context.tool_settings.sculpt
899
900         col = layout.column(align=True)
901         col.label(text="Mirror:")
902         row = col.row()
903         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
904         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
905         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
906
907         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
908         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
909
910
911 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
912     bl_label = "Appearance"
913     bl_options = {'DEFAULT_CLOSED'}
914
915     @classmethod
916     def poll(cls, context):
917         toolsettings = context.tool_settings
918         return ((context.sculpt_object and toolsettings.sculpt) or
919                 (context.vertex_paint_object and toolsettings.vertex_paint) or
920                 (context.weight_paint_object and toolsettings.weight_paint) or
921                 (context.image_paint_object and toolsettings.image_paint))
922
923     def draw(self, context):
924         layout = self.layout
925
926         settings = self.paint_settings(context)
927         brush = settings.brush
928
929         if brush is None:  # unlikely but can happen
930             layout.label(text="Brush Unset")
931             return
932
933         col = layout.column()
934
935         if context.sculpt_object and context.tool_settings.sculpt:
936             if brush.sculpt_capabilities.has_secondary_color:
937                 col.prop(brush, "cursor_color_add", text="Add Color")
938                 col.prop(brush, "cursor_color_subtract", text="Subtract Color")
939             else:
940                 col.prop(brush, "cursor_color_add", text="Color")
941         else:
942             col.prop(brush, "cursor_color_add", text="Color")
943
944         col = layout.column(align=True)
945         col.prop(brush, "use_custom_icon")
946         if brush.use_custom_icon:
947             col.prop(brush, "icon_filepath", text="")
948
949 # ********** default tools for weight-paint ****************
950
951
952 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
953     bl_context = "weightpaint"
954     bl_label = "Weight Tools"
955
956     def draw(self, context):
957         layout = self.layout
958
959         ob = context.active_object
960
961         col = layout.column()
962         col.active = ob.vertex_groups.active is not None
963         col.operator("object.vertex_group_normalize_all", text="Normalize All")
964         col.operator("object.vertex_group_normalize", text="Normalize")
965         col.operator("object.vertex_group_mirror", text="Mirror")
966         col.operator("object.vertex_group_invert", text="Invert")
967         col.operator("object.vertex_group_clean", text="Clean")
968         col.operator("object.vertex_group_levels", text="Levels")
969         col.operator("object.vertex_group_blend", text="Blend")
970         col.operator("object.vertex_group_fix", text="Fix Deforms")
971
972
973 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
974     bl_context = "weightpaint"
975     bl_label = "Options"
976
977     def draw(self, context):
978         layout = self.layout
979
980         tool_settings = context.tool_settings
981         wpaint = tool_settings.weight_paint
982
983         col = layout.column()
984
985         col.prop(wpaint, "use_all_faces")
986         col.prop(wpaint, "use_normal")
987         col.prop(wpaint, "use_spray")
988         col.prop(wpaint, "use_group_restrict")
989
990         obj = context.weight_paint_object
991         if obj.type == 'MESH':
992             mesh = obj.data
993             col.prop(mesh, "use_mirror_x")
994             col.prop(mesh, "use_mirror_topology")
995
996         col.prop(wpaint, "input_samples")
997
998         self.unified_paint_settings(col, context)
999
1000 # Commented out because the Apply button isn't an operator yet, making these settings useless
1001 #~         col.label(text="Gamma:")
1002 #~         col.prop(wpaint, "gamma", text="")
1003 #~         col.label(text="Multiply:")
1004 #~         col.prop(wpaint, "mul", text="")
1005
1006 # Also missing now:
1007 # Soft, Vertex-Group, X-Mirror and "Clear" Operator.
1008
1009 # ********** default tools for vertex-paint ****************
1010
1011
1012 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1013     bl_context = "vertexpaint"
1014     bl_label = "Options"
1015
1016     def draw(self, context):
1017         layout = self.layout
1018
1019         toolsettings = context.tool_settings
1020         vpaint = toolsettings.vertex_paint
1021
1022         col = layout.column()
1023         #col.prop(vpaint, "mode", text="")
1024         col.prop(vpaint, "use_all_faces")
1025         col.prop(vpaint, "use_normal")
1026         col.prop(vpaint, "use_spray")
1027
1028         col.prop(vpaint, "input_samples")
1029
1030         self.unified_paint_settings(col, context)
1031
1032 # Commented out because the Apply button isn't an operator yet, making these settings useless
1033 #~         col.label(text="Gamma:")
1034 #~         col.prop(vpaint, "gamma", text="")
1035 #~         col.label(text="Multiply:")
1036 #~         col.prop(vpaint, "mul", text="")
1037
1038 # ********** default tools for texture-paint ****************
1039
1040
1041 class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
1042     bl_context = "imagepaint"
1043     bl_label = "Project Paint"
1044
1045     @classmethod
1046     def poll(cls, context):
1047         brush = context.tool_settings.image_paint.brush
1048         return (brush and brush.image_tool != 'SOFTEN')
1049
1050     def draw_header(self, context):
1051         ipaint = context.tool_settings.image_paint
1052
1053         self.layout.prop(ipaint, "use_projection", text="")
1054
1055     def draw(self, context):
1056         layout = self.layout
1057
1058         ob = context.active_object
1059         mesh = ob.data
1060         toolsettings = context.tool_settings
1061         ipaint = toolsettings.image_paint
1062         settings = toolsettings.image_paint
1063         use_projection = ipaint.use_projection
1064
1065         col = layout.column()
1066         col.active = use_projection
1067         col.prop(ipaint, "use_occlude")
1068         col.prop(ipaint, "use_backface_culling")
1069
1070         row = layout.row()
1071         row.active = (use_projection)
1072         row.prop(ipaint, "use_normal_falloff")
1073
1074         sub = row.row()
1075         sub.active = (ipaint.use_normal_falloff)
1076         sub.prop(ipaint, "normal_angle", text="")
1077
1078         split = layout.split()
1079
1080         split.active = (use_projection)
1081         split.prop(ipaint, "use_stencil_layer", text="Stencil")
1082
1083         row = split.row()
1084         row.active = (ipaint.use_stencil_layer)
1085         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1086         row.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text)
1087         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1088
1089         row = layout.row()
1090         row.active = (settings.brush.image_tool == 'CLONE')
1091         row.prop(ipaint, "use_clone_layer", text="Clone")
1092         clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
1093         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text)
1094
1095         layout.prop(ipaint, "seam_bleed")
1096
1097         col = layout.column()
1098         col.label(text="External Editing:")
1099
1100         row = col.split(align=True, percentage=0.55)
1101         row.operator("image.project_edit", text="Quick Edit")
1102         row.operator("image.project_apply", text="Apply")
1103
1104         col.row().prop(ipaint, "screen_grab_size", text="")
1105
1106         col.operator("paint.project_image", text="Apply Camera Image")
1107         col.operator("image.save_dirty", text="Save All Edited")
1108
1109
1110 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1111     bl_label = "Options"
1112     bl_options = {'DEFAULT_CLOSED'}
1113
1114     @classmethod
1115     def poll(cls, context):
1116         return (context.image_paint_object and context.tool_settings.image_paint)
1117
1118     def draw(self, context):
1119         layout = self.layout
1120
1121         col = layout.column()
1122         self.unified_paint_settings(col, context)
1123
1124
1125 class VIEW3D_MT_tools_projectpaint_clone(Menu):
1126     bl_label = "Clone Layer"
1127
1128     def draw(self, context):
1129         layout = self.layout
1130
1131         for i, tex in enumerate(context.active_object.data.uv_textures):
1132             props = layout.operator("wm.context_set_int", text=tex.name)
1133             props.data_path = "active_object.data.uv_texture_clone_index"
1134             props.value = i
1135
1136
1137 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1138     bl_label = "Mask Layer"
1139
1140     def draw(self, context):
1141         layout = self.layout
1142         for i, tex in enumerate(context.active_object.data.uv_textures):
1143             props = layout.operator("wm.context_set_int", text=tex.name)
1144             props.data_path = "active_object.data.uv_texture_stencil_index"
1145             props.value = i
1146
1147
1148 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1149     """default tools for particle mode"""
1150     bl_context = "particlemode"
1151     bl_label = "Options"
1152
1153     def draw(self, context):
1154         layout = self.layout
1155
1156         pe = context.tool_settings.particle_edit
1157         ob = pe.object
1158
1159         layout.prop(pe, "type", text="")
1160
1161         ptcache = None
1162
1163         if pe.type == 'PARTICLES':
1164             if ob.particle_systems:
1165                 if len(ob.particle_systems) > 1:
1166                     layout.template_list(ob, "particle_systems", ob.particle_systems, "active_index", rows=2, maxrows=3)
1167
1168                 ptcache = ob.particle_systems.active.point_cache
1169         else:
1170             for md in ob.modifiers:
1171                 if md.type == pe.type:
1172                     ptcache = md.point_cache
1173
1174         if ptcache and len(ptcache.point_caches) > 1:
1175             layout.template_list(ptcache, "point_caches", ptcache.point_caches, "active_index", rows=2, maxrows=3)
1176
1177         if not pe.is_editable:
1178             layout.label(text="Point cache must be baked")
1179             layout.label(text="in memory to enable editing!")
1180
1181         col = layout.column(align=True)
1182         if pe.is_hair:
1183             col.active = pe.is_editable
1184             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1185             sub = col.row()
1186             sub.active = pe.use_emitter_deflect
1187             sub.prop(pe, "emitter_distance", text="Distance")
1188
1189         col = layout.column(align=True)
1190         col.active = pe.is_editable
1191         col.label(text="Keep:")
1192         col.prop(pe, "use_preserve_length", text="Lengths")
1193         col.prop(pe, "use_preserve_root", text="Root")
1194         if not pe.is_hair:
1195             col.label(text="Correct:")
1196             col.prop(pe, "use_auto_velocity", text="Velocity")
1197         col.prop(ob.data, "use_mirror_x")
1198
1199         col = layout.column(align=True)
1200         col.active = pe.is_editable
1201         col.label(text="Draw:")
1202         col.prop(pe, "draw_step", text="Path Steps")
1203         if pe.is_hair:
1204             col.prop(pe, "show_particles", text="Children")
1205         else:
1206             if pe.type == 'PARTICLES':
1207                 col.prop(pe, "show_particles", text="Particles")
1208             col.prop(pe, "use_fade_time")
1209             sub = col.row()
1210             sub.active = pe.use_fade_time
1211             sub.prop(pe, "fade_frames", slider=True)
1212
1213 if __name__ == "__main__":  # only for live edit.
1214     bpy.utils.register_module(__name__)