[Bf-blender-cvs] [3eb8307160e] master: Python API: Expose CurveMapping Reset View function

Patrick Busch noreply at git.blender.org
Tue Mar 2 20:15:28 CET 2021


Commit: 3eb8307160e327f64593d218125d02289285aa17
Author: Patrick Busch
Date:   Tue Mar 2 13:13:36 2021 -0600
Branches: master
https://developer.blender.org/rB3eb8307160e327f64593d218125d02289285aa17

Python API: Expose CurveMapping Reset View function

The Python API for the curve mapping widget offers the `update`
function, but no way to reset the view to the clipping rectangle.

This commit adds a blenkernel function for this operation,
and exposes it to the CurvMapping RNA API. This allows addons
to display a more user-friendly view of the data in this widget.

Differential Revision: https://developer.blender.org/D10561

===================================================================

M	source/blender/blenkernel/BKE_colortools.h
M	source/blender/blenkernel/intern/colortools.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesrna/intern/rna_color.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 3631feb5071..ec2262d4f60 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -59,6 +59,7 @@ enum {
   CURVEMAP_SLOPE_POS_NEG = 2,
 };
 
+void BKE_curvemapping_reset_view(struct CurveMapping *cumap);
 void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope);
 void BKE_curvemap_remove(struct CurveMap *cuma, const short flag);
 bool BKE_curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 3eb9fb6161d..44d9bd6b2d2 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -965,6 +965,12 @@ void BKE_curvemapping_changed_all(CurveMapping *cumap)
   cumap->cur = cur;
 }
 
+/* Reset the view for current curve. */
+void BKE_curvemapping_reset_view(CurveMapping *cumap)
+{
+  cumap->curr = cumap->clipr;
+}
+
 /* table should be verified */
 float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, float value)
 {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index eadbe618899..c5e67e0334e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3987,7 +3987,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
       BKE_curvemapping_changed(cumap, false);
       break;
     case UICURVE_FUNC_RESET_VIEW:
-      cumap->curr = cumap->clipr;
+      BKE_curvemapping_reset_view(cumap);
       break;
     case UICURVE_FUNC_HANDLE_VECTOR: /* set vector */
       BKE_curvemap_handle_set(cuma, HD_VECT);
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 9770ffca5b8..206ebc2cb14 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -896,6 +896,9 @@ static void rna_def_curvemapping(BlenderRNA *brna)
   func = RNA_def_function(srna, "update", "BKE_curvemapping_changed_all");
   RNA_def_function_ui_description(func, "Update curve mapping after making changes");
 
+  func = RNA_def_function(srna, "reset_view", "BKE_curvemapping_reset_view");
+  RNA_def_function_ui_description(func, "Reset the curve mapping grid to its clipping size");
+
   func = RNA_def_function(srna, "initialize", "rna_CurveMap_initialize");
   RNA_def_function_ui_description(func, "Initialize curve");



More information about the Bf-blender-cvs mailing list