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