Cleanup: camera_turnaround (pep8)
[blender-addons.git] / space_view3d_brush_menus / curve_menu.py
blob5a836031189b29fb2c877d03e4f23423670a0ad9
1 # gpl author: Ryan Inch (Imaginer)
3 import bpy
4 from bpy.types import (
5 Operator,
6 Menu,
8 from . import utils_core
11 class BrushCurveMenu(Menu):
12 bl_label = "Curve"
13 bl_idname = "VIEW3D_MT_sv3_brush_curve_menu"
15 @classmethod
16 def poll(self, context):
17 return utils_core.get_mode() in (
18 'SCULPT', 'VERTEX_PAINT',
19 'WEIGHT_PAINT', 'TEXTURE_PAINT',
20 'PARTICLE_EDIT'
23 def draw(self, context):
24 layout = self.layout
25 curves = (("Smooth", "SMOOTH", "SMOOTHCURVE"),
26 ("Sphere", "ROUND", "SPHERECURVE"),
27 ("Root", "ROOT", "ROOTCURVE"),
28 ("Sharp", "SHARP", "SHARPCURVE"),
29 ("Linear", "LINE", "LINCURVE"),
30 ("Constant", "MAX", "NOCURVE"))
32 # add the top slider
33 layout.row().operator(CurvePopup.bl_idname, icon="RNDCURVE")
34 layout.row().separator()
36 # add the rest of the menu items
37 for curve in curves:
38 item = layout.row().operator("brush.curve_preset",
39 text=curve[0], icon=curve[2])
40 item.shape = curve[1]
43 class CurvePopup(Operator):
44 """Edit Falloff Curve"""
45 bl_label = "Adjust Curve"
46 bl_idname = "view3d.sv3_curve_popup"
47 bl_description = "Edit Falloff Curve"
48 bl_options = {'REGISTER'}
50 @classmethod
51 def poll(self, context):
52 return utils_core.get_mode() in (
53 'SCULPT', 'VERTEX_PAINT',
54 'WEIGHT_PAINT', 'TEXTURE_PAINT'
57 def draw(self, context):
58 layout = self.layout
59 has_brush = utils_core.get_brush_link(context, types="brush")
61 if utils_core.get_mode() == 'SCULPT' or \
62 utils_core.get_mode() == 'VERTEX_PAINT' or \
63 utils_core.get_mode() == 'WEIGHT_PAINT' or \
64 utils_core.get_mode() == 'TEXTURE_PAINT':
65 if has_brush:
66 layout.column().template_curve_mapping(has_brush,
67 "curve", brush=True)
68 else:
69 layout.row().label(text="No brushes available", icon="INFO")
70 else:
71 layout.row().label(text="No brushes available", icon="INFO")
73 def execute(self, context):
74 return context.window_manager.invoke_popup(self, width=180)
77 classes = (
78 BrushCurveMenu,
79 CurvePopup
82 def register():
83 for cls in classes:
84 bpy.utils.register_class(cls)
86 def unregister():
87 for cls in classes:
88 bpy.utils.unregister_class(cls)