Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_color.c')
-rw-r--r--source/blender/makesrna/intern/rna_color.c102
1 files changed, 69 insertions, 33 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 4793310e192..3b7a8330d10 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -56,10 +56,10 @@
static int rna_CurveMapping_curves_length(PointerRNA *ptr)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
int len;
- for (len = 0; len<CM_TOT; len++)
+ for (len = 0; len < CM_TOT; len++)
if (!cumap->cm[len].curve)
break;
@@ -68,14 +68,14 @@ static int rna_CurveMapping_curves_length(PointerRNA *ptr)
static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
rna_iterator_array_begin(iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, NULL);
}
static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
if (value) cumap->flag |= CUMA_DO_CLIP;
else cumap->flag &= ~CUMA_DO_CLIP;
@@ -85,7 +85,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
cumap->black[0] = values[0];
cumap->black[1] = values[1];
cumap->black[2] = values[2];
@@ -94,7 +94,7 @@ static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *value
static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
cumap->white[0] = values[0];
cumap->white[1] = values[1];
cumap->white[2] = values[2];
@@ -103,7 +103,7 @@ static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *value
static void rna_CurveMapping_clipminx_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
*min = -100.0f;
*max = cumap->clipr.xmax;
@@ -111,7 +111,7 @@ static void rna_CurveMapping_clipminx_range(PointerRNA *ptr, float *min, float *
static void rna_CurveMapping_clipminy_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
*min = -100.0f;
*max = cumap->clipr.ymax;
@@ -119,7 +119,7 @@ static void rna_CurveMapping_clipminy_range(PointerRNA *ptr, float *min, float *
static void rna_CurveMapping_clipmaxx_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
*min = cumap->clipr.xmin;
*max = 100.0f;
@@ -127,7 +127,7 @@ static void rna_CurveMapping_clipmaxx_range(PointerRNA *ptr, float *min, float *
static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
{
- CurveMapping *cumap = (CurveMapping*)ptr->data;
+ CurveMapping *cumap = (CurveMapping *)ptr->data;
*min = cumap->clipr.ymin;
*max = 100.0f;
@@ -141,16 +141,16 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
ID *id = ptr->id.data;
switch (GS(id->name)) {
- case ID_MA: /* material has 2 cases - diffuse and specular */
+ case ID_MA: /* material has 2 cases - diffuse and specular */
{
- Material *ma = (Material*)id;
+ Material *ma = (Material *)id;
if (ptr->data == ma->ramp_col)
return BLI_strdup("diffuse_ramp");
else if (ptr->data == ma->ramp_spec)
return BLI_strdup("specular_ramp");
}
- break;
+ break;
case ID_LS:
{
@@ -211,9 +211,9 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
COLRAMP_GETPATH;
}
}
- break;
+ break;
- /* TODO: node trees need special attention */
+ /* TODO: node trees need special attention */
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;
@@ -226,7 +226,7 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
}
}
}
- break;
+ break;
case ID_LS:
{
@@ -270,9 +270,9 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
Material *ma = ptr->id.data;
DAG_id_tag_update(&ma->id, 0);
- WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ma);
+ WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
}
- break;
+ break;
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;
@@ -284,7 +284,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
}
}
}
- break;
+ break;
case ID_TE:
{
Tex *tex = ptr->id.data;
@@ -292,7 +292,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
DAG_id_tag_update(&tex->id, 0);
WM_main_add_notifier(NC_TEXTURE, tex);
}
- break;
+ break;
case ID_LS:
{
FreestyleLineStyle *linestyle= ptr->id.data;
@@ -331,7 +331,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *repo
static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- Scopes *s = (Scopes*)ptr->data;
+ Scopes *s = (Scopes *)ptr->data;
s->ok = 0;
}
@@ -350,18 +350,14 @@ static void rna_def_curvemappoint(BlenderRNA *brna)
srna = RNA_def_struct(brna, "CurveMapPoint", NULL);
RNA_def_struct_ui_text(srna, "CurveMapPoint", "Point of a curve used for a curve mapping");
- /* not editable for now, need to have CurveMapping to do curvemapping_changed */
-
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_array(prop, 2);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Location", "X/Y coordinates of the curve point");
prop = RNA_def_property(srna, "handle_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_handle_type_items);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Handle Type", "Curve interpolation at this point: Bezier or vector");
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
@@ -369,10 +365,38 @@ static void rna_def_curvemappoint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Select", "Selection state of the curve point");
}
+static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ RNA_def_property_srna(cprop, "CurveMapPoints");
+ srna = RNA_def_struct(brna, "CurveMapPoints", NULL);
+ RNA_def_struct_sdna(srna, "CurveMap");
+ RNA_def_struct_ui_text(srna, "Curve Map Point", "Collection of Curve Map Points");
+
+ func = RNA_def_function(srna, "new", "curvemap_insert");
+ RNA_def_function_ui_description(func, "Add point to CurveMap");
+ parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to add point", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "Value", "Value of point", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "curvemap_remove_point");
+ RNA_def_function_ui_description(func, "Delete point from CurveMap");
+ parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+}
+
static void rna_def_curvemap(BlenderRNA *brna)
{
StructRNA *srna;
- PropertyRNA *prop;
+ PropertyRNA *prop, *parm;
+ FunctionRNA *func;
+
static EnumPropertyItem prop_extend_items[] = {
{0, "HORIZONTAL", 0, "Horizontal", ""},
{CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", 0, "Extrapolated", ""},
@@ -382,24 +406,30 @@ static void rna_def_curvemap(BlenderRNA *brna)
srna = RNA_def_struct(brna, "CurveMap", NULL);
RNA_def_struct_ui_text(srna, "CurveMap", "Curve in a curve mapping");
- /* not editable for now, need to have CurveMapping to do curvemapping_changed */
-
prop = RNA_def_property(srna, "extend", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_extend_items);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Extend", "Extrapolate the curve or extend it horizontally");
prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "curve", "totpoint");
RNA_def_property_struct_type(prop, "CurveMapPoint");
RNA_def_property_ui_text(prop, "Points", "");
+ rna_def_curvemap_points_api(brna, prop);
+
+ func = RNA_def_function(srna, "evaluate", "curvemap_evaluateF");
+ RNA_def_function_ui_description(func, "Evaluate curve at given location");
+ parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to evaluate curve at", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "Value", "Value of curve at given location", -FLT_MAX, FLT_MAX);
+ RNA_def_function_return(func, parm);
}
static void rna_def_curvemapping(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "CurveMapping", NULL);
RNA_def_struct_ui_text(srna, "CurveMapping",
@@ -453,6 +483,9 @@ static void rna_def_curvemapping(BlenderRNA *brna)
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "White Level", "For RGB curves, the color that white is mapped to");
RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_white_level_set", NULL);
+
+ func = RNA_def_function(srna, "update", "curvemapping_changed_all");
+ RNA_def_function_ui_description(func, "Update curve mapping after making changes");
}
static void rna_def_color_ramp_element(BlenderRNA *brna)
@@ -504,7 +537,7 @@ static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Delete element from ColorRamp");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
}
static void rna_def_color_ramp(BlenderRNA *brna)
@@ -519,7 +552,8 @@ static void rna_def_color_ramp(BlenderRNA *brna)
{0, "LINEAR", 0, "Linear", ""},
{2, "B_SPLINE", 0, "B-Spline", ""},
{4, "CONSTANT", 0, "Constant", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "ColorRamp", NULL);
RNA_def_struct_sdna(srna, "ColorBand");
@@ -571,7 +605,8 @@ static void rna_def_histogram(BlenderRNA *brna)
{HISTO_MODE_R, "R", ICON_COLOR, "Red", ""},
{HISTO_MODE_G, "G", ICON_COLOR, "Green", ""},
{HISTO_MODE_B, "B", ICON_COLOR, "Blue", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "Histogram", NULL);
RNA_def_struct_ui_text(srna, "Histogram", "Statistical view of the levels of color in an image");
@@ -594,7 +629,8 @@ static void rna_def_scopes(BlenderRNA *brna)
{SCOPES_WAVEFRM_YCC_601, "YCBCR601", ICON_COLOR, "YCbCr (ITU 601)", ""},
{SCOPES_WAVEFRM_YCC_709, "YCBCR709", ICON_COLOR, "YCbCr (ITU 709)", ""},
{SCOPES_WAVEFRM_YCC_JPEG, "YCBCRJPG", ICON_COLOR, "YCbCr (Jpeg)", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "Scopes", NULL);
RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image");