-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_operator.py
More file actions
270 lines (230 loc) · 8.32 KB
/
Copy pathui_operator.py
File metadata and controls
270 lines (230 loc) · 8.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
from bpy import types, props, app
from . import dataUtil
temp = dataUtil.apaint_temp
def toggle_fallof(mode:str, b:types.Brush):
if app.version[0] == 5:
b.curve_distance_falloff_preset = mode
else:
b.curve_preset = mode
class APAINT_OT_toggle_eraser(types.Operator):
bl_idname = "apaint.toggle_eraser"
bl_label = "Toggle Eraser"
bl_description = "Toggle bursh blend to eraser"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["toggle_eraser"]:
temp["brush_blend"] = b.blend
b.blend = "ERASE_ALPHA"
else:
if not temp.get("brush_blend"):
temp["brush_blend"] = "MIX"
b.blend = temp["brush_blend"]
return {'FINISHED'}
class APAINT_OT_toggle_alpha_lock(types.Operator):
bl_idname = "apaint.toggle_alpha_lock"
bl_label = "Toggle Alpha Lock"
bl_description = "Toggle Alpha Lock"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if b.use_alpha :
b.use_alpha = False
else :
b.use_alpha = True
return {'FINISHED'}
class APAINT_OT_toggle_occlude(types.Operator):
bl_idname = "apaint.toggle_occlude"
bl_label = "Toggle Occlude"
bl_description = "Toggle Occlude"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if ip.use_occlude :
ip.use_occlude = False
else :
ip.use_occlude = True
return {'FINISHED'}
class APAINT_OT_toggle_culling(types.Operator):
bl_idname = "apaint.toggle_culling"
bl_label = "Toggle Culling"
bl_description = "Toggle Backface Culling"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if ip.use_backface_culling :
ip.use_backface_culling = False
else :
ip.use_backface_culling = True
return {'FINISHED'}
class APAINT_OT_toggle_draw(types.Operator):
bl_idname = "apaint.toggle_draw"
bl_label = "Draw Tool"
bl_description = "Use Draw Tool"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_draw"]:
temp["is_draw"] = True
b.stroke_method = "SPACE"
return {'FINISHED'}
class APAINT_OT_toggle_line(types.Operator):
bl_idname = "apaint.toggle_line"
bl_label = "Line Tool"
bl_description = "Use Line Tool"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_line"]:
temp["is_line"] = True
b.stroke_method = "LINE"
return {'FINISHED'}
class APAINT_OT_toggle_stamp(types.Operator):
bl_idname = "apaint.toggle_stamp"
bl_label = "Stamp Tool"
bl_description = "Use Stamp Tool"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_stamp"]:
temp["is_stamp"] = True
b.stroke_method = "ANCHORED"
return {'FINISHED'}
class APAINT_OT_palette_operator(types.Operator):
bl_idname = "apaint.palette_operator"
bl_label = "Palletes"
bl_description = "Select Palletes"
palette_name : props.StringProperty(name="pallete_name")
@classmethod
def poll(cls, context):
return context.object is not None
def execute(self, context: types.Context):
ip = context.tool_settings.image_paint
if self.palette_name == "-" :
ip.palette = None
else :
print(self.palette_name)
ip.palette = context.blend_data.palettes[self.palette_name]
return {'FINISHED'}
class APAINT_OT_toggle_smooth(types.Operator):
bl_idname = "apaint.toggle_smooth"
bl_label = "use smooth brush"
bl_description = "use smooth brush"
def execute(self, context: types.Context):
ip = context.tool_settings.image_paint
b = ip.brush
if b.use_smooth_stroke:
b.use_smooth_stroke = False
else:
b.use_smooth_stroke = True
return {'FINISHED'}
class APAINT_OT_toggle_fallof_custom(types.Operator):
bl_idname = "apaint.toggle_fallof_custom"
bl_label = "custom fallof"
bl_description = "Use Custom Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_custom"]:
temp["is_fallof_custom"] = True
toggle_fallof("CUSTOM", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_smooth(types.Operator):
bl_idname = "apaint.toggle_fallof_smooth"
bl_label = "smooth fallof"
bl_description = "Use Smooth Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_smooth"]:
temp["is_fallof_smooth"] = True
toggle_fallof("SMOOTH", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_smoother(types.Operator):
bl_idname = "apaint.toggle_fallof_smoother"
bl_label = "smoother fallof"
bl_description = "Use Smoother Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_smoother"]:
temp["is_fallof_smoother"] = True
toggle_fallof("SMOOTHER", b)
return {'FINISHED'}
class APAINT_OT_fallof_sphere(types.Operator):
bl_idname = "apaint.toggle_fallof_sphere"
bl_label = "sphere fallof"
bl_description = "Use Sphere Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_sphere"]:
temp["is_fallof_sphere"] = True
toggle_fallof("SPHERE", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_root(types.Operator):
bl_idname = "apaint.toggle_fallof_root"
bl_label = "root fallof"
bl_description = "Use Root Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_root"]:
temp["is_fallof_root"] = True
toggle_fallof("ROOT", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_sharp(types.Operator):
bl_idname = "apaint.toggle_fallof_sharp"
bl_label = "sharp fallof"
bl_description = "Use Sharp Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_sharp"]:
temp["is_fallof_sharp"] = True
toggle_fallof("SHARP", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_lin(types.Operator):
bl_idname = "apaint.toggle_fallof_lin"
bl_label = "lin fallof"
bl_description = "Use Lin Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_lin"]:
temp["is_fallof_lin"] = True
toggle_fallof("LIN", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_pow4(types.Operator):
bl_idname = "apaint.toggle_fallof_pow4"
bl_label = "pow fallof"
bl_description = "Use Pow4 Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_pow4"]:
temp["is_fallof_pow4"] = True
toggle_fallof("POW4", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_invsquare(types.Operator):
bl_idname = "apaint.toggle_fallof_invsquare"
bl_label = "invsquare fallof"
bl_description = "Use Invsquare Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_invsquare"]:
temp["is_fallof_invsquare"] = True
toggle_fallof("INVSQUARE", b)
return {'FINISHED'}
class APAINT_OT_toggle_fallof_constant(types.Operator):
bl_idname = "apaint.toggle_fallof_constant"
bl_label = "constant fallof"
bl_description = "Use Constant Fallof"
def execute(self, context):
ip = context.tool_settings.image_paint
b = ip.brush
if not temp["is_fallof_constant"]:
temp["is_fallof_constant"] = True
toggle_fallof("CONSTANT", b)
return {'FINISHED'}