UI: Add preset curve buttons for curve mapping template

To support setting the custom `CurveMapping` to a well defined preset,
there exist a number of operators that are hardcoded to apply a
particular preset to a particular curve.

This commit begins to replace this functionality and make it part of the
template itself, allowing the preset to be applied to any curve. For
now, it only supports either positive or negative slopes, primarily for
the brush usecases.

The `brush.curve_preset` and `brush.sculpt_curves_falloff_preset`
operators are unneeded after this change and have been removed.

Notably, these preset controls have not been added elsewhere, they can
be added on a case by case basis in future commits by interested
modules.

Pull Request: https://projects.blender.org/blender/blender/pulls/146847
This commit is contained in:
Sean Kim
2025-09-29 20:11:29 +02:00
committed by Sean Kim
parent af8cb99b10
commit 0f3c6da272
23 changed files with 97 additions and 139 deletions

View File

@@ -185,16 +185,8 @@ class GreasePencilBrushFalloff:
col.prop(brush, "curve_distance_falloff_preset", text="")
if brush.curve_distance_falloff_preset == 'CUSTOM':
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True, use_negative_slope=True)
col = layout.column(align=True)
row = col.row(align=True)
row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True,
use_negative_slope=True, show_presets=True)
class GREASE_PENCIL_MT_move_to_layer(Menu):

View File

@@ -655,16 +655,11 @@ class FalloffPanel(BrushPanel):
col.prop(brush, "curve_distance_falloff_preset", text="")
if brush.curve_distance_falloff_preset == 'CUSTOM':
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True, use_negative_slope=True)
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True,
use_negative_slope=True, show_presets=True)
col = layout.column(align=True)
row = col.row(align=True)
row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
show_falloff_shape = False
if mode in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT'} and brush.sculpt_brush_type != 'POSE':

View File

@@ -9012,14 +9012,8 @@ class VIEW3D_PT_curves_sculpt_parameter_falloff(Panel):
layout.template_curve_mapping(
brush.curves_sculpt_settings,
"curve_parameter_falloff",
brush=True)
row = layout.row(align=True)
row.operator("brush.sculpt_curves_falloff_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
row.operator("brush.sculpt_curves_falloff_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
row.operator("brush.sculpt_curves_falloff_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
row.operator("brush.sculpt_curves_falloff_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
row.operator("brush.sculpt_curves_falloff_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.sculpt_curves_falloff_preset", icon='NOCURVE', text="").shape = 'MAX'
brush=True,
show_presets=True)
class VIEW3D_PT_curves_sculpt_grow_shrink_scaling(Panel):

View File

@@ -872,16 +872,8 @@ class VIEW3D_PT_tools_weight_gradient(Panel, View3DPaintPanel):
col.prop(brush, "curve_distance_falloff_preset", expand=True)
if brush.curve_distance_falloff_preset == 'CUSTOM':
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True, use_negative_slope=True)
col = layout.column(align=True)
row = col.row(align=True)
row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
layout.template_curve_mapping(brush, "curve_distance_falloff", brush=True,
use_negative_slope=True, show_presets=True)
# TODO, move to space_view3d.py