rna data path names which are more likely to break animations.
[blender-staging.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, "use_mirror_x")
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, "use_mirror_x")
466         col.prop(arm, "use_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 None
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, "use_default_interpolate")
527                 sub = col.column(align=True)
528                 sub.active = settings.use_default_interpolate
529                 sub.prop(brush, "steps", slider=True)
530                 sub.prop(settings, "default_key_count", 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_pressure_size", 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_pressure_strength", 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, "auto_smooth_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_pressure_size", toggle=True, text="")
663
664             row = col.row(align=True)
665             row.prop(brush, "strength", text="Strength", slider=True)
666             row.prop(brush, "use_pressure_strength", toggle=True, text="")
667
668             row = col.row(align=True)
669             row.prop(brush, "jitter", slider=True)
670             row.prop(brush, "use_pressure_jitter", 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, "use_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_pressure_size", toggle=True, text="")
690
691             row = col.row(align=True)
692             row.prop(brush, "strength", text="Strength", slider=True)
693             row.prop(brush, "use_pressure_strength", toggle=True, text="")
694
695             row = col.row(align=True)
696             row.prop(brush, "jitter", slider=True)
697             row.prop(brush, "use_pressure_jitter", 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_pressure_size", toggle=True, text="")
709
710             row = col.row(align=True)
711             row.prop(brush, "strength", text="Strength", slider=True)
712             row.prop(brush, "use_pressure_strength", 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_pressure_jitter", 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_random", 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, "use_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.use_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_pressure_jitter", 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_pressure_spacing", 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
967         brush = settings.brush
968
969         layout.template_curve_mapping(brush, "curve", brush=True)
970
971         row = layout.row(align=True)
972         row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH'
973         row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND'
974         row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT'
975         row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP'
976         row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
977         row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
978
979
980 class VIEW3D_PT_sculpt_options(PaintPanel, bpy.types.Panel):
981     bl_label = "Options"
982     bl_default_closed = True
983
984     @classmethod
985     def poll(cls, context):
986         return (context.sculpt_object and context.tool_settings.sculpt)
987
988     def draw(self, context):
989         layout = self.layout
990
991
992         tool_settings = context.tool_settings
993         sculpt = tool_settings.sculpt
994         settings = __class__.paint_settings(context)
995         brush = settings.brush
996
997         split = layout.split()
998
999         col = split.column()
1000
1001         col.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1002         col.prop(sculpt, "show_low_resolution")
1003         col.prop(sculpt, "show_brush")
1004
1005         col.label(text="Unified Settings:")
1006         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1007         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1008
1009         col = split.column()
1010
1011         col.label(text="Lock:")
1012         row = col.row(align=True)
1013         row.prop(sculpt, "lock_x", text="X", toggle=True)
1014         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1015         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1016
1017                 
1018                 
1019 class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel):
1020     bl_label = "Symmetry"
1021     bl_default_closed = True
1022
1023     @classmethod
1024     def poll(cls, context):
1025         return (context.sculpt_object and context.tool_settings.sculpt)
1026
1027     def draw(self, context):
1028
1029         layout = self.layout
1030
1031         sculpt = context.tool_settings.sculpt
1032         settings = __class__.paint_settings(context)
1033         brush = settings.brush
1034
1035         split = layout.split()
1036
1037         col = split.column()
1038
1039         col.label(text="Mirror:")
1040         col.prop(sculpt, "use_symmetry_x", text="X")
1041         col.prop(sculpt, "use_symmetry_y", text="Y")
1042         col.prop(sculpt, "use_symmetry_z", text="Z")
1043
1044         col = split.column()
1045
1046         col.prop(sculpt, "radial_symmetry", text="Radial")
1047
1048         col = layout.column()
1049
1050         col.separator()
1051
1052         col.prop(sculpt, "use_symmetry_feather", text="Feather")
1053
1054 class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel):
1055     bl_label = "Appearance"
1056     bl_default_closed = True
1057
1058     @classmethod
1059     def poll(cls, context):
1060         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)
1061
1062     def draw(self, context):
1063         layout = self.layout
1064
1065         sculpt = context.tool_settings.sculpt
1066         settings = __class__.paint_settings(context)
1067         brush = settings.brush
1068
1069         col = layout.column();
1070
1071         if context.sculpt_object and context.tool_settings.sculpt:
1072             #if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE', 'CLAY_TUBES'):
1073             if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN', 'FILL', 'SCRAPE'):
1074                 col.prop(brush, "cursor_color_add", text="Add Color")
1075                 col.prop(brush, "cursor_color_subtract", text="Subtract Color")
1076             else:
1077                 col.prop(brush, "cursor_color_add", text="Color")
1078         else:
1079             col.prop(brush, "cursor_color_add", text="Color")
1080
1081         col = layout.column()
1082         col.label(text="Icon:")
1083
1084         row = col.row(align=True)
1085         row.prop(brush, "use_custom_icon")
1086         if brush.use_custom_icon:
1087             row = col.row(align=True)
1088             row.prop(brush, "icon_filepath", text="")
1089
1090 # ********** default tools for weightpaint ****************
1091
1092
1093 class VIEW3D_PT_tools_weightpaint(View3DPanel, bpy.types.Panel):
1094     bl_context = "weightpaint"
1095     bl_label = "Weight Tools"
1096
1097     def draw(self, context):
1098         layout = self.layout
1099
1100         col = layout.column()
1101         col.operator("object.vertex_group_normalize_all", text="Normalize All")
1102         col.operator("object.vertex_group_normalize", text="Normalize")
1103         col.operator("object.vertex_group_invert", text="Invert")
1104         col.operator("object.vertex_group_clean", text="Clean")
1105         col.operator("object.vertex_group_levels", text="Levels")
1106
1107
1108 class VIEW3D_PT_tools_weightpaint_options(View3DPanel, bpy.types.Panel):
1109     bl_context = "weightpaint"
1110     bl_label = "Options"
1111
1112     def draw(self, context):
1113         layout = self.layout
1114
1115         tool_settings = context.tool_settings
1116         wpaint = tool_settings.weight_paint
1117
1118         col = layout.column()
1119         col.prop(wpaint, "use_all_faces")
1120         col.prop(wpaint, "normals")
1121         col.prop(wpaint, "use_spray")
1122
1123         obj = context.weight_paint_object
1124         if obj.type == 'MESH':
1125             mesh = obj.data
1126             col.prop(mesh, "use_mirror_x")
1127             col.prop(mesh, "use_mirror_topology")
1128
1129         col.label(text="Unified Settings:")
1130         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1131         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1132
1133 # Commented out because the Apply button isn't an operator yet, making these settings useless
1134 #               col.label(text="Gamma:")
1135 #               col.prop(wpaint, "gamma", text="")
1136 #               col.label(text="Multiply:")
1137 #               col.prop(wpaint, "mul", text="")
1138
1139 # Also missing now:
1140 # Soft, Vgroup, X-Mirror and "Clear" Operator.
1141
1142 # ********** default tools for vertexpaint ****************
1143
1144
1145 class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel):
1146     bl_context = "vertexpaint"
1147     bl_label = "Options"
1148
1149     def draw(self, context):
1150         layout = self.layout
1151
1152         tool_settings = context.tool_settings
1153         vpaint = tool_settings.vertex_paint
1154
1155         col = layout.column()
1156         #col.prop(vpaint, "mode", text="")
1157         col.prop(vpaint, "use_all_faces")
1158         col.prop(vpaint, "normals")
1159         col.prop(vpaint, "use_spray")
1160
1161         col.label(text="Unified Settings:")
1162         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1163         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1164
1165 # Commented out because the Apply button isn't an operator yet, making these settings useless
1166 #               col.label(text="Gamma:")
1167 #               col.prop(vpaint, "gamma", text="")
1168 #               col.label(text="Multiply:")
1169 #               col.prop(vpaint, "mul", text="")
1170
1171 # ********** default tools for texturepaint ****************
1172
1173
1174 class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel):
1175     bl_context = "texturepaint"
1176     bl_label = "Project Paint"
1177
1178     @classmethod
1179     def poll(cls, context):
1180         brush = context.tool_settings.image_paint.brush
1181         return (brush and brush.imagepaint_tool != 'SMEAR')
1182
1183     def draw_header(self, context):
1184         ipaint = context.tool_settings.image_paint
1185
1186         self.layout.prop(ipaint, "use_projection", text="")
1187
1188     def draw(self, context):
1189         layout = self.layout
1190
1191         ipaint = context.tool_settings.image_paint
1192         settings = context.tool_settings.image_paint
1193         use_projection = ipaint.use_projection
1194
1195         col = layout.column()
1196         sub = col.column()
1197         sub.active = use_projection
1198         sub.prop(ipaint, "use_occlude")
1199         sub.prop(ipaint, "use_backface_culling")
1200
1201         split = layout.split()
1202
1203         col = split.column()
1204         col.active = (use_projection)
1205         col.prop(ipaint, "use_normal_falloff")
1206
1207         col = split.column()
1208         col.active = (ipaint.use_normal_falloff and use_projection)
1209         col.prop(ipaint, "normal_angle", text="")
1210
1211         col = layout.column(align=False)
1212         row = col.row()
1213         row.active = (use_projection)
1214         row.prop(ipaint, "use_stencil_layer", text="Stencil")
1215
1216         row2 = row.row(align=False)
1217         row2.active = (use_projection and ipaint.use_stencil_layer)
1218         row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=context.active_object.data.uv_texture_stencil.name)
1219         row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1220
1221         col = layout.column()
1222         sub = col.column()
1223         row = sub.row()
1224         row.active = (settings.brush.imagepaint_tool == 'CLONE')
1225
1226         row.prop(ipaint, "use_clone_layer", text="Layer")
1227         row.menu("VIEW3D_MT_tools_projectpaint_clone", text=context.active_object.data.uv_texture_clone.name)
1228
1229         sub = col.column()
1230         sub.prop(ipaint, "seam_bleed")
1231
1232         col.label(text="External Editing")
1233         row = col.split(align=True, percentage=0.55)
1234         row.operator("image.project_edit", text="Quick Edit")
1235         row.operator("image.project_apply", text="Apply")
1236         row = col.row(align=True)
1237         row.prop(ipaint, "screen_grab_size", text="")
1238
1239         sub = col.column()
1240         sub.operator("paint.project_image", text="Apply Camera Image")
1241
1242         sub.operator("image.save_dirty", text="Save All Edited")
1243
1244
1245 class VIEW3D_PT_imagepaint_options(PaintPanel):
1246     bl_label = "Options"
1247     bl_default_closed = True
1248
1249     @classmethod
1250     def poll(cls, context):
1251         return (context.texture_paint_object and context.tool_settings.image_paint)
1252
1253     def draw(self, context):
1254         layout = self.layout
1255
1256         col = layout.column()
1257
1258         tool_settings = context.tool_settings
1259         col.label(text="Unified Settings:")
1260         col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
1261         col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
1262         
1263 class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
1264     bl_label = "Clone Layer"
1265
1266     def draw(self, context):
1267         layout = self.layout
1268         for i, tex in enumerate(context.active_object.data.uv_textures):
1269             prop = layout.operator("wm.context_set_int", text=tex.name)
1270             prop.data_path = "active_object.data.uv_texture_clone_index"
1271             prop.value = i
1272
1273
1274 class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
1275     bl_label = "Mask Layer"
1276
1277     def draw(self, context):
1278         layout = self.layout
1279         for i, tex in enumerate(context.active_object.data.uv_textures):
1280             prop = layout.operator("wm.context_set_int", text=tex.name)
1281             prop.data_path = "active_object.data.uv_texture_stencil_index"
1282             prop.value = i
1283
1284
1285 class VIEW3D_PT_tools_particlemode(View3DPanel, bpy.types.Panel):
1286     '''default tools for particle mode'''
1287     bl_context = "particlemode"
1288     bl_label = "Options"
1289
1290     def draw(self, context):
1291         layout = self.layout
1292
1293         pe = context.tool_settings.particle_edit
1294         ob = pe.object
1295
1296         layout.prop(pe, "type", text="")
1297
1298         ptcache = None
1299
1300         if pe.type == 'PARTICLES':
1301             if ob.particle_systems:
1302                 if len(ob.particle_systems) > 1:
1303                     layout.template_list(ob, "particle_systems", ob, "active_particle_system_index", type='ICONS')
1304
1305                 ptcache = ob.particle_systems[ob.active_particle_system_index].point_cache
1306         else:
1307             for md in ob.modifiers:
1308                 if md.type == pe.type:
1309                     ptcache = md.point_cache
1310
1311         if ptcache and len(ptcache.point_caches) > 1:
1312             layout.template_list(ptcache, "point_caches", ptcache, "active_point_cache_index", type='ICONS')
1313
1314
1315         if not pe.is_editable:
1316             layout.label(text="Point cache must be baked")
1317             layout.label(text="to enable editing!")
1318
1319         col = layout.column(align=True)
1320         if pe.is_hair:
1321             col.active = pe.is_editable
1322             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1323             sub = col.row()
1324             sub.active = pe.use_emitter_deflect
1325             sub.prop(pe, "emitter_distance", text="Distance")
1326
1327         col = layout.column(align=True)
1328         col.active = pe.is_editable
1329         col.label(text="Keep:")
1330         col.prop(pe, "use_preserve_length", text="Lengths")
1331         col.prop(pe, "use_preserve_root", text="Root")
1332         if not pe.is_hair:
1333             col.label(text="Correct:")
1334             col.prop(pe, "use_auto_velocity", text="Velocity")
1335         col.prop(ob.data, "use_mirror_x")
1336
1337         col = layout.column(align=True)
1338         col.active = pe.is_editable
1339         col.label(text="Draw:")
1340         col.prop(pe, "draw_step", text="Path Steps")
1341         if pe.is_hair:
1342             col.prop(pe, "show_particles", text="Children")
1343         else:
1344             if pe.type == 'PARTICLES':
1345                 col.prop(pe, "show_particles", text="Particles")
1346             col.prop(pe, "use_fade_time")
1347             sub = col.row()
1348             sub.active = pe.use_fade_time
1349             sub.prop(pe, "fade_frames", slider=True)
1350
1351
1352 def register():
1353     pass
1354
1355
1356 def unregister():
1357     pass
1358
1359 if __name__ == "__main__":
1360     register()