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