First fix for install_deps and ubuntu 10.04 (no libtiff5, only libtiff4, wonder why...
[blender.git] / release / scripts / startup / bl_ui / properties_paint_common.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
21
22 class UnifiedPaintPanel():
23     # subclass must set
24     # bl_space_type = 'IMAGE_EDITOR'
25     # bl_region_type = 'UI'
26
27     @staticmethod
28     def paint_settings(context):
29         toolsettings = context.tool_settings
30
31         if context.sculpt_object:
32             return toolsettings.sculpt
33         elif context.vertex_paint_object:
34             return toolsettings.vertex_paint
35         elif context.weight_paint_object:
36             return toolsettings.weight_paint
37         elif context.image_paint_object:
38             return toolsettings.image_paint
39         elif context.particle_edit_object:
40             return toolsettings.particle_edit
41
42         return None
43
44     @staticmethod
45     def unified_paint_settings(parent, context):
46         ups = context.tool_settings.unified_paint_settings
47         parent.label(text="Unified Settings:")
48         parent.prop(ups, "use_unified_size", text="Size")
49         parent.prop(ups, "use_unified_strength", text="Strength")
50         if context.weight_paint_object:
51             parent.prop(ups, "use_unified_weight", text="Weight")
52
53     @staticmethod
54     def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
55         ups = context.tool_settings.unified_paint_settings
56         ptr = ups if ups.use_unified_size else brush
57         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
58
59     @staticmethod
60     def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
61         ups = context.tool_settings.unified_paint_settings
62         ptr = ups if ups.use_unified_strength else brush
63         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
64
65     @staticmethod
66     def prop_unified_weight(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
67         ups = context.tool_settings.unified_paint_settings
68         ptr = ups if ups.use_unified_weight else brush
69         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
70
71
72 # Used in both the View3D toolbar and texture properties
73 def brush_texture_settings(layout, brush, sculpt):
74     tex_slot = brush.texture_slot
75
76     layout.label(text="Brush Mapping:")
77
78     # map_mode
79     if sculpt:
80         layout.row().prop(tex_slot, "map_mode", text="")
81         layout.separator()
82     else:
83         layout.row().prop(tex_slot, "tex_paint_map_mode", text="")
84         layout.separator()
85
86     # angle and texture_angle_source
87     col = layout.column()
88     col.active = brush.brush_capabilities.has_texture_angle_source
89     col.label(text="Angle:")
90     if brush.brush_capabilities.has_random_texture_angle:
91         if sculpt:
92             if brush.sculpt_capabilities.has_random_texture_angle:
93                 col.prop(brush, "texture_angle_source_random", text="")
94             else:
95                 col.prop(brush, "texture_angle_source_no_random", text="")
96
97         else:
98             col.prop(brush, "texture_angle_source_random", text="")
99     else:
100         col.prop(brush, "texture_angle_source_no_random", text="")
101     col = layout.column()
102     col.active = brush.brush_capabilities.has_texture_angle
103     col.prop(tex_slot, "angle", text="")
104
105     # scale and offset
106     split = layout.split()
107     split.prop(tex_slot, "offset")
108     split.prop(tex_slot, "scale")
109
110     if sculpt:
111         # texture_sample_bias
112         col = layout.column(align=True)
113         col.label(text="Sample Bias:")
114         col.prop(brush, "texture_sample_bias", slider=True, text="")
115
116
117 def brush_mask_texture_settings(layout, brush):
118     mask_tex_slot = brush.mask_texture_slot
119
120     if brush.mask_texture:
121         layout.label(text="Mask Mapping:")
122         col = layout.column()
123         col.active = brush.brush_capabilities.has_texture_angle
124         col.prop(mask_tex_slot, "angle", text="")
125
126         # scale and offset
127         split = layout.split()
128         split.prop(mask_tex_slot, "offset")
129         split.prop(mask_tex_slot, "scale")