Code cleanup: unused python vars & imports
[blender-staging.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         row = parent.row()
49         row.prop(ups, "use_unified_size", text="Size")
50         row.prop(ups, "use_unified_strength", text="Strength")
51         if context.weight_paint_object:
52             parent.prop(ups, "use_unified_weight", text="Weight")
53
54     @staticmethod
55     def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
56         ups = context.tool_settings.unified_paint_settings
57         ptr = ups if ups.use_unified_size else brush
58         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
59
60     @staticmethod
61     def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
62         ups = context.tool_settings.unified_paint_settings
63         ptr = ups if ups.use_unified_strength else brush
64         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
65
66     @staticmethod
67     def prop_unified_weight(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
68         ups = context.tool_settings.unified_paint_settings
69         ptr = ups if ups.use_unified_weight else brush
70         parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
71
72
73 # Used in both the View3D toolbar and texture properties
74 def brush_texture_settings(layout, brush, sculpt):
75     tex_slot = brush.texture_slot
76
77     layout.label(text="Brush Mapping:")
78
79     # map_mode
80     if sculpt:
81         layout.row().prop(tex_slot, "map_mode", text="")
82         layout.separator()
83     else:
84         layout.row().prop(tex_slot, "tex_paint_map_mode", text="")
85         layout.separator()
86
87     if tex_slot.map_mode == 'STENCIL':
88         if brush.texture and brush.texture.type == 'IMAGE':
89             layout.operator("brush.stencil_fit_image_aspect")
90         layout.operator("brush.stencil_reset_transform")
91
92     # angle and texture_angle_source
93     if brush.brush_capabilities.has_texture_angle:
94         col = layout.column()
95         col.label(text="Angle:")
96         row = col.row(align=True)
97         if brush.brush_capabilities.has_texture_angle_source:
98             if brush.brush_capabilities.has_random_texture_angle:
99                 if sculpt:
100                     if brush.sculpt_capabilities.has_random_texture_angle:
101                         row.prop(brush, "texture_angle_source_random", text="")
102                     else:
103                         row.prop(brush, "texture_angle_source_no_random", text="")
104
105                 else:
106                     row.prop(brush, "texture_angle_source_random", text="")
107             else:
108                 row.prop(brush, "texture_angle_source_no_random", text="")
109
110         row.prop(tex_slot, "angle", text="")
111
112     # scale and offset
113     split = layout.split()
114     split.prop(tex_slot, "offset")
115     split.prop(tex_slot, "scale")
116
117     if sculpt:
118         # texture_sample_bias
119         col = layout.column(align=True)
120         col.label(text="Sample Bias:")
121         col.prop(brush, "texture_sample_bias", slider=True, text="")
122
123
124 def brush_mask_texture_settings(layout, brush):
125     mask_tex_slot = brush.mask_texture_slot
126
127     layout.label(text="Mask Mapping:")
128
129     # map_mode
130     layout.row().prop(mask_tex_slot, "mask_map_mode", text="")
131     layout.separator()
132
133     if mask_tex_slot.map_mode == 'STENCIL':
134         if brush.mask_texture and brush.mask_texture.type == 'IMAGE':
135             layout.operator("brush.stencil_fit_image_aspect").mask = True
136         layout.operator("brush.stencil_reset_transform").mask = True
137
138     col = layout.column()
139     col.label(text="Angle:")
140     col.active = brush.brush_capabilities.has_texture_angle
141     col.prop(mask_tex_slot, "angle", text="")
142
143     # scale and offset
144     split = layout.split()
145     split.prop(mask_tex_slot, "offset")
146     split.prop(mask_tex_slot, "scale")