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
|
# gpl author: Ryan Inch (Imaginer)
from bpy.types import (
Operator,
Menu,
)
from . import utils_core
class BrushCurveMenu(Menu):
bl_label = "Curve"
bl_idname = "VIEW3D_MT_sv3_brush_curve_menu"
@classmethod
def poll(self, context):
return utils_core.get_mode() in (
utils_core.sculpt, utils_core.vertex_paint,
utils_core.weight_paint, utils_core.texture_paint,
utils_core.particle_edit
)
def draw(self, context):
menu = utils_core.Menu(self)
curves = [["Smooth", "SMOOTH", "SMOOTHCURVE"],
["Sphere", "ROUND", "SPHERECURVE"],
["Root", "ROOT", "ROOTCURVE"],
["Sharp", "SHARP", "SHARPCURVE"],
["Linear", "LINE", "LINCURVE"],
["Constant", "MAX", "NOCURVE"]]
# add the top slider
menu.add_item().operator(CurvePopup.bl_idname, icon="RNDCURVE")
menu.add_item().separator()
# add the rest of the menu items
for curve in curves:
item = menu.add_item().operator("brush.curve_preset",
text=curve[0], icon=curve[2])
item.shape = curve[1]
class CurvePopup(Operator):
bl_label = "Adjust Curve"
bl_idname = "view3d.sv3_curve_popup"
bl_options = {'REGISTER'}
@classmethod
def poll(self, context):
return utils_core.get_mode() in (
utils_core.sculpt, utils_core.vertex_paint,
utils_core.weight_paint, utils_core.texture_paint
)
def draw(self, context):
menu = utils_core.Menu(self)
has_brush = utils_core.get_brush_link(context, types="brush")
if utils_core.get_mode() == utils_core.sculpt or \
utils_core.get_mode() == utils_core.vertex_paint or \
utils_core.get_mode() == utils_core.weight_paint or \
utils_core.get_mode() == utils_core.texture_paint:
if has_brush:
menu.add_item("column").template_curve_mapping(has_brush,
"curve", brush=True)
else:
menu.add_item().label("No brushes available", icon="INFO")
else:
menu.add_item().label("No brushes available", icon="INFO")
def execute(self, context):
return context.window_manager.invoke_popup(self, width=180)
|