1 # SPDX-FileCopyrightText: 2017-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from bpy
.types
import (
10 from . import utils_core
13 class BrushCurveMenu(Menu
):
15 bl_idname
= "VIEW3D_MT_sv3_brush_curve_menu"
18 def poll(self
, context
):
19 return utils_core
.get_mode() in (
20 'SCULPT', 'VERTEX_PAINT',
21 'WEIGHT_PAINT', 'TEXTURE_PAINT',
25 def draw(self
, context
):
27 curves
= (("Smooth", "SMOOTH", "SMOOTHCURVE"),
28 ("Sphere", "ROUND", "SPHERECURVE"),
29 ("Root", "ROOT", "ROOTCURVE"),
30 ("Sharp", "SHARP", "SHARPCURVE"),
31 ("Linear", "LINE", "LINCURVE"),
32 ("Constant", "MAX", "NOCURVE"))
35 layout
.row().operator(CurvePopup
.bl_idname
, icon
="RNDCURVE")
36 layout
.row().separator()
38 # add the rest of the menu items
40 item
= layout
.row().operator("brush.curve_preset",
41 text
=curve
[0], icon
=curve
[2])
45 class CurvePopup(Operator
):
46 """Edit Falloff Curve"""
47 bl_label
= "Adjust Curve"
48 bl_idname
= "view3d.sv3_curve_popup"
49 bl_description
= "Edit Falloff Curve"
50 bl_options
= {'REGISTER'}
53 def poll(self
, context
):
54 return utils_core
.get_mode() in (
55 'SCULPT', 'VERTEX_PAINT',
56 'WEIGHT_PAINT', 'TEXTURE_PAINT'
59 def draw(self
, context
):
61 has_brush
= utils_core
.get_brush_link(context
, types
="brush")
63 if utils_core
.get_mode() == 'SCULPT' or \
64 utils_core
.get_mode() == 'VERTEX_PAINT' or \
65 utils_core
.get_mode() == 'WEIGHT_PAINT' or \
66 utils_core
.get_mode() == 'TEXTURE_PAINT':
68 layout
.column().template_curve_mapping(has_brush
,
71 layout
.row().label(text
="No brushes available", icon
="INFO")
73 layout
.row().label(text
="No brushes available", icon
="INFO")
75 def execute(self
, context
):
76 return context
.window_manager
.invoke_popup(self
, width
=180)
86 bpy
.utils
.register_class(cls
)
90 bpy
.utils
.unregister_class(cls
)