Export_3ds: Improved distance cue node search
[blender-addons.git] / space_view3d_brush_menus / curve_menu.py
blob3152c88a195254f75eccd734f03499b1dd259037
1 # SPDX-FileCopyrightText: 2017-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
6 from bpy.types import (
7 Operator,
8 Menu,
10 from . import utils_core
13 class BrushCurveMenu(Menu):
14 bl_label = "Curve"
15 bl_idname = "VIEW3D_MT_sv3_brush_curve_menu"
17 @classmethod
18 def poll(self, context):
19 return utils_core.get_mode() in (
20 'SCULPT', 'VERTEX_PAINT',
21 'WEIGHT_PAINT', 'TEXTURE_PAINT',
22 'PARTICLE_EDIT'
25 def draw(self, context):
26 layout = self.layout
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"))
34 # add the top slider
35 layout.row().operator(CurvePopup.bl_idname, icon="RNDCURVE")
36 layout.row().separator()
38 # add the rest of the menu items
39 for curve in curves:
40 item = layout.row().operator("brush.curve_preset",
41 text=curve[0], icon=curve[2])
42 item.shape = curve[1]
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'}
52 @classmethod
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):
60 layout = self.layout
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':
67 if has_brush:
68 layout.column().template_curve_mapping(has_brush,
69 "curve", brush=True)
70 else:
71 layout.row().label(text="No brushes available", icon="INFO")
72 else:
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)
79 classes = (
80 BrushCurveMenu,
81 CurvePopup
84 def register():
85 for cls in classes:
86 bpy.utils.register_class(cls)
88 def unregister():
89 for cls in classes:
90 bpy.utils.unregister_class(cls)