2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_color.c
31 #include "RNA_define.h"
32 #include "rna_internal.h"
34 #include "DNA_color_types.h"
35 #include "DNA_texture_types.h"
40 static EnumPropertyItem view_transform_items[] = {
41 {0, "NONE", 0, "None", ""},
42 {0, NULL, 0, NULL, NULL}
47 #include "RNA_access.h"
49 #include "DNA_material_types.h"
50 #include "DNA_node_types.h"
52 #include "MEM_guardedalloc.h"
54 #include "BKE_colortools.h"
55 #include "BKE_depsgraph.h"
57 #include "BKE_texture.h"
61 #include "IMB_colormanagement.h"
63 static int rna_CurveMapping_curves_length(PointerRNA *ptr)
65 CurveMapping *cumap = (CurveMapping *)ptr->data;
68 for (len = 0; len < CM_TOT; len++)
69 if (!cumap->cm[len].curve)
75 static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
77 CurveMapping *cumap = (CurveMapping *)ptr->data;
79 rna_iterator_array_begin(iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, NULL);
82 static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
84 CurveMapping *cumap = (CurveMapping *)ptr->data;
86 if (value) cumap->flag |= CUMA_DO_CLIP;
87 else cumap->flag &= ~CUMA_DO_CLIP;
89 curvemapping_changed(cumap, 0);
92 static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
94 CurveMapping *cumap = (CurveMapping *)ptr->data;
95 cumap->black[0] = values[0];
96 cumap->black[1] = values[1];
97 cumap->black[2] = values[2];
98 curvemapping_set_black_white(cumap, NULL, NULL);
101 static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values)
103 CurveMapping *cumap = (CurveMapping *)ptr->data;
104 cumap->white[0] = values[0];
105 cumap->white[1] = values[1];
106 cumap->white[2] = values[2];
107 curvemapping_set_black_white(cumap, NULL, NULL);
110 static void rna_CurveMapping_clipminx_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
112 CurveMapping *cumap = (CurveMapping *)ptr->data;
115 *max = cumap->clipr.xmax;
118 static void rna_CurveMapping_clipminy_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
120 CurveMapping *cumap = (CurveMapping *)ptr->data;
123 *max = cumap->clipr.ymax;
126 static void rna_CurveMapping_clipmaxx_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
128 CurveMapping *cumap = (CurveMapping *)ptr->data;
130 *min = cumap->clipr.xmin;
134 static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
136 CurveMapping *cumap = (CurveMapping *)ptr->data;
138 *min = cumap->clipr.ymin;
143 static char *rna_ColorRamp_path(PointerRNA *ptr)
147 /* handle the cases where a single datablock may have 2 ramp types */
149 ID *id = ptr->id.data;
151 switch (GS(id->name)) {
152 case ID_MA: /* material has 2 cases - diffuse and specular */
154 Material *ma = (Material *)id;
156 if (ptr->data == ma->ramp_col)
157 path = BLI_strdup("diffuse_ramp");
158 else if (ptr->data == ma->ramp_spec)
159 path = BLI_strdup("specular_ramp");
165 bNodeTree *ntree = (bNodeTree *)id;
170 for (node = ntree->nodes.first; node; node = node->next) {
171 if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
172 if (node->storage == ptr->data) {
173 /* all node color ramp properties called 'color_ramp'
174 * prepend path from ID to the node
176 RNA_pointer_create(id, &RNA_Node, node, &node_ptr);
177 node_path = RNA_path_from_ID_to_struct(&node_ptr);
178 path = BLI_sprintfN("%s.color_ramp", node_path);
179 MEM_freeN(node_path);
187 /* everything else just uses 'color_ramp' */
188 path = BLI_strdup("color_ramp");
193 /* everything else just uses 'color_ramp' */
194 path = BLI_strdup("color_ramp");
200 static char *rna_ColorRampElement_path(PointerRNA *ptr)
207 /* helper macro for use here to try and get the path
208 * - this calls the standard code for getting a path to a texture...
211 #define COLRAMP_GETPATH \
213 prop = RNA_struct_find_property(&ramp_ptr, "elements"); \
215 index = RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \
217 char *texture_path = rna_ColorRamp_path(&ramp_ptr); \
218 path = BLI_sprintfN("%s.elements[%d]", texture_path, index); \
219 MEM_freeN(texture_path); \
224 /* determine the path from the ID-block to the ramp */
225 /* FIXME: this is a very slow way to do it, but it will have to suffice... */
227 ID *id = ptr->id.data;
229 switch (GS(id->name)) {
230 case ID_MA: /* 2 cases for material - diffuse and spec */
232 Material *ma = (Material *)id;
234 /* try diffuse first */
236 RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr);
239 /* try specular if not diffuse */
240 if (!path && ma->ramp_spec) {
241 RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_spec, &ramp_ptr);
249 bNodeTree *ntree = (bNodeTree *)id;
252 for (node = ntree->nodes.first; node; node = node->next) {
253 if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
254 RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr);
261 default: /* everything else should have a "color_ramp" property */
263 /* create pointer to the ID block, and try to resolve "color_ramp" pointer */
264 RNA_id_pointer_create(id, &ramp_ptr);
265 if (RNA_path_resolve(&ramp_ptr, "color_ramp", &ramp_ptr, &prop)) {
272 /* cleanup the macro we defined */
273 #undef COLRAMP_GETPATH
278 static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
281 ID *id = ptr->id.data;
283 switch (GS(id->name)) {
286 Material *ma = ptr->id.data;
288 DAG_id_tag_update(&ma->id, 0);
289 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
294 bNodeTree *ntree = (bNodeTree *)id;
297 for (node = ntree->nodes.first; node; node = node->next) {
298 if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
299 ED_node_generic_update(bmain, ntree, node);
306 Tex *tex = ptr->id.data;
308 DAG_id_tag_update(&tex->id, 0);
309 WM_main_add_notifier(NC_TEXTURE, tex);
318 void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4])
320 do_colorband(coba, position, color);
323 static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *reports, float position)
325 CBData *element = colorband_element_add(coba, position);
328 BKE_reportf(reports, RPT_ERROR, "Unable to add element to colorband (limit %d)", MAXCOLORBAND);
333 static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, CBData *element)
335 int index = (int)(element - coba->data);
336 if (colorband_element_remove(coba, index) == 0)
337 BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
341 static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
343 Scopes *s = (Scopes *)ptr->data;
347 static int rna_ColorManagedViewSettings_view_transform_get(PointerRNA *ptr)
349 ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data;
351 return IMB_colormanagement_view_get_named_index(view->view_transform);
354 static void rna_ColorManagedViewSettings_view_transform_set(PointerRNA *ptr, int value)
356 ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data;
358 const char *name = IMB_colormanagement_view_get_indexed_name(value);
361 BLI_strncpy(view->view_transform, name, sizeof(view->view_transform));
365 static EnumPropertyItem* rna_ColorManagedViewSettings_view_transform_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
367 wmWindow *win = CTX_wm_window(C);
368 EnumPropertyItem *items = NULL;
371 RNA_enum_item_add(&items, &totitem, &view_transform_items[0]);
372 IMB_colormanagement_view_items_add(&items, &totitem, win->display_device);
373 RNA_enum_item_end(&items, &totitem);
381 static void rna_def_curvemappoint(BlenderRNA *brna)
385 static EnumPropertyItem prop_handle_type_items[] = {
386 {0, "AUTO", 0, "Auto Handle", ""},
387 {CUMA_VECTOR, "VECTOR", 0, "Vector Handle", ""},
388 {0, NULL, 0, NULL, NULL}
391 srna = RNA_def_struct(brna, "CurveMapPoint", NULL);
392 RNA_def_struct_ui_text(srna, "CurveMapPoint", "Point of a curve used for a curve mapping");
394 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
395 RNA_def_property_float_sdna(prop, NULL, "x");
396 RNA_def_property_array(prop, 2);
397 RNA_def_property_ui_text(prop, "Location", "X/Y coordinates of the curve point");
399 prop = RNA_def_property(srna, "handle_type", PROP_ENUM, PROP_NONE);
400 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
401 RNA_def_property_enum_items(prop, prop_handle_type_items);
402 RNA_def_property_ui_text(prop, "Handle Type", "Curve interpolation at this point: Bezier or vector");
404 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
405 RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_SELECT);
406 RNA_def_property_ui_text(prop, "Select", "Selection state of the curve point");
409 static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop)
415 RNA_def_property_srna(cprop, "CurveMapPoints");
416 srna = RNA_def_struct(brna, "CurveMapPoints", NULL);
417 RNA_def_struct_sdna(srna, "CurveMap");
418 RNA_def_struct_ui_text(srna, "Curve Map Point", "Collection of Curve Map Points");
420 func = RNA_def_function(srna, "new", "curvemap_insert");
421 RNA_def_function_ui_description(func, "Add point to CurveMap");
422 parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to add point", -FLT_MAX, FLT_MAX);
423 RNA_def_property_flag(parm, PROP_REQUIRED);
424 parm = RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "Value", "Value of point", -FLT_MAX, FLT_MAX);
425 RNA_def_property_flag(parm, PROP_REQUIRED);
426 parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point");
427 RNA_def_function_return(func, parm);
429 func = RNA_def_function(srna, "remove", "curvemap_remove_point");
430 RNA_def_function_ui_description(func, "Delete point from CurveMap");
431 parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove");
432 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
435 static void rna_def_curvemap(BlenderRNA *brna)
438 PropertyRNA *prop, *parm;
441 static EnumPropertyItem prop_extend_items[] = {
442 {0, "HORIZONTAL", 0, "Horizontal", ""},
443 {CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", 0, "Extrapolated", ""},
444 {0, NULL, 0, NULL, NULL}
447 srna = RNA_def_struct(brna, "CurveMap", NULL);
448 RNA_def_struct_ui_text(srna, "CurveMap", "Curve in a curve mapping");
450 prop = RNA_def_property(srna, "extend", PROP_ENUM, PROP_NONE);
451 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
452 RNA_def_property_enum_items(prop, prop_extend_items);
453 RNA_def_property_ui_text(prop, "Extend", "Extrapolate the curve or extend it horizontally");
455 prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
456 RNA_def_property_collection_sdna(prop, NULL, "curve", "totpoint");
457 RNA_def_property_struct_type(prop, "CurveMapPoint");
458 RNA_def_property_ui_text(prop, "Points", "");
459 rna_def_curvemap_points_api(brna, prop);
461 func = RNA_def_function(srna, "evaluate", "curvemap_evaluateF");
462 RNA_def_function_ui_description(func, "Evaluate curve at given location");
463 parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to evaluate curve at", -FLT_MAX, FLT_MAX);
464 RNA_def_property_flag(parm, PROP_REQUIRED);
465 parm = RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "Value", "Value of curve at given location", -FLT_MAX, FLT_MAX);
466 RNA_def_function_return(func, parm);
469 static void rna_def_curvemapping(BlenderRNA *brna)
475 srna = RNA_def_struct(brna, "CurveMapping", NULL);
476 RNA_def_struct_ui_text(srna, "CurveMapping",
477 "Curve mapping to map color, vector and scalar values to other values using "
478 "a user defined curve");
480 prop = RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE);
481 RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_DO_CLIP);
482 RNA_def_property_ui_text(prop, "Clip", "Force the curve view to fit a defined boundary");
483 RNA_def_property_boolean_funcs(prop, NULL, "rna_CurveMapping_clip_set");
485 prop = RNA_def_property(srna, "clip_min_x", PROP_FLOAT, PROP_NONE);
486 RNA_def_property_float_sdna(prop, NULL, "clipr.xmin");
487 RNA_def_property_range(prop, -100.0f, 100.0f);
488 RNA_def_property_ui_text(prop, "Clip Min X", "");
489 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipminx_range");
491 prop = RNA_def_property(srna, "clip_min_y", PROP_FLOAT, PROP_NONE);
492 RNA_def_property_float_sdna(prop, NULL, "clipr.ymin");
493 RNA_def_property_range(prop, -100.0f, 100.0f);
494 RNA_def_property_ui_text(prop, "Clip Min Y", "");
495 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipminy_range");
497 prop = RNA_def_property(srna, "clip_max_x", PROP_FLOAT, PROP_NONE);
498 RNA_def_property_float_sdna(prop, NULL, "clipr.xmax");
499 RNA_def_property_range(prop, -100.0f, 100.0f);
500 RNA_def_property_ui_text(prop, "Clip Max X", "");
501 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxx_range");
503 prop = RNA_def_property(srna, "clip_max_y", PROP_FLOAT, PROP_NONE);
504 RNA_def_property_float_sdna(prop, NULL, "clipr.ymax");
505 RNA_def_property_range(prop, -100.0f, 100.0f);
506 RNA_def_property_ui_text(prop, "Clip Max Y", "");
507 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range");
509 prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE);
510 RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next",
511 "rna_iterator_array_end", "rna_iterator_array_get",
512 "rna_CurveMapping_curves_length", NULL, NULL, NULL);
513 RNA_def_property_struct_type(prop, "CurveMap");
514 RNA_def_property_ui_text(prop, "Curves", "");
516 prop = RNA_def_property(srna, "black_level", PROP_FLOAT, PROP_COLOR);
517 RNA_def_property_float_sdna(prop, NULL, "black");
518 RNA_def_property_range(prop, -1000.0f, 1000.0f);
519 RNA_def_property_ui_text(prop, "Black Level", "For RGB curves, the color that black is mapped to");
520 RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_black_level_set", NULL);
522 prop = RNA_def_property(srna, "white_level", PROP_FLOAT, PROP_COLOR);
523 RNA_def_property_float_sdna(prop, NULL, "white");
524 RNA_def_property_range(prop, -1000.0f, 1000.0f);
525 RNA_def_property_ui_text(prop, "White Level", "For RGB curves, the color that white is mapped to");
526 RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_white_level_set", NULL);
528 func = RNA_def_function(srna, "update", "curvemapping_changed_all");
529 RNA_def_function_ui_description(func, "Update curve mapping after making changes");
532 static void rna_def_color_ramp_element(BlenderRNA *brna)
537 srna = RNA_def_struct(brna, "ColorRampElement", NULL);
538 RNA_def_struct_sdna(srna, "CBData");
539 RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
540 RNA_def_struct_ui_text(srna, "Color Ramp Element", "Element defining a color at a position in the color ramp");
542 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
543 RNA_def_property_float_sdna(prop, NULL, "r");
544 RNA_def_property_array(prop, 4);
545 RNA_def_property_ui_text(prop, "Color", "Set color of selected color stop");
546 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
548 prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
549 RNA_def_property_float_sdna(prop, NULL, "pos");
550 RNA_def_property_range(prop, 0, 1);
551 RNA_def_property_ui_text(prop, "Position", "Set position of selected color stop");
552 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
555 static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
561 RNA_def_property_srna(cprop, "ColorRampElements");
562 srna = RNA_def_struct(brna, "ColorRampElements", NULL);
563 RNA_def_struct_sdna(srna, "ColorBand");
564 RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
565 RNA_def_struct_ui_text(srna, "Color Ramp Elements", "Collection of Color Ramp Elements");
567 /* TODO, make these functions generic in texture.c */
568 func = RNA_def_function(srna, "new", "rna_ColorRampElement_new");
569 RNA_def_function_ui_description(func, "Add element to ColorRamp");
570 RNA_def_function_flag(func, FUNC_USE_REPORTS);
571 parm = RNA_def_float(func, "position", 0.0f, 0.0f, 1.0f, "Position", "Position to add element", 0.0f, 1.0f);
572 RNA_def_property_flag(parm, PROP_REQUIRED);
574 parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "New element");
575 RNA_def_function_return(func, parm);
577 func = RNA_def_function(srna, "remove", "rna_ColorRampElement_remove");
578 RNA_def_function_ui_description(func, "Delete element from ColorRamp");
579 RNA_def_function_flag(func, FUNC_USE_REPORTS);
580 parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
581 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
584 static void rna_def_color_ramp(BlenderRNA *brna)
590 static EnumPropertyItem prop_interpolation_items[] = {
591 {1, "EASE", 0, "Ease", ""},
592 {3, "CARDINAL", 0, "Cardinal", ""},
593 {0, "LINEAR", 0, "Linear", ""},
594 {2, "B_SPLINE", 0, "B-Spline", ""},
595 {4, "CONSTANT", 0, "Constant", ""},
596 {0, NULL, 0, NULL, NULL}
599 srna = RNA_def_struct(brna, "ColorRamp", NULL);
600 RNA_def_struct_sdna(srna, "ColorBand");
601 RNA_def_struct_path_func(srna, "rna_ColorRamp_path");
602 RNA_def_struct_ui_text(srna, "Color Ramp", "Color ramp mapping a scalar value to a color");
604 prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_COLOR);
605 RNA_def_property_collection_sdna(prop, NULL, "data", "tot");
606 RNA_def_property_struct_type(prop, "ColorRampElement");
607 RNA_def_property_ui_text(prop, "Elements", "");
608 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
609 rna_def_color_ramp_element_api(brna, prop);
611 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
612 RNA_def_property_enum_sdna(prop, NULL, "ipotype");
613 RNA_def_property_enum_items(prop, prop_interpolation_items);
614 RNA_def_property_ui_text(prop, "Interpolation", "");
615 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
617 #if 0 /* use len(elements) */
618 prop = RNA_def_property(srna, "total", PROP_INT, PROP_NONE);
619 RNA_def_property_int_sdna(prop, NULL, "tot");
620 /* needs a function to do the right thing when adding elements like colorband_add_cb() */
621 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
622 RNA_def_property_range(prop, 0, 31); /* MAXCOLORBAND = 32 */
623 RNA_def_property_ui_text(prop, "Total", "Total number of elements");
624 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
627 func = RNA_def_function(srna, "evaluate", "rna_ColorRamp_eval");
628 RNA_def_function_ui_description(func, "Evaluate ColorRamp");
629 prop = RNA_def_float(func, "position", 1.0f, 0.0f, 1.0f, "Position", "Evaluate ColorRamp at position", 0.0f, 1.0f);
630 RNA_def_property_flag(prop, PROP_REQUIRED);
632 prop = RNA_def_float_color(func, "color", 4, NULL, -FLT_MAX, FLT_MAX, "Color", "Color at given position",
634 RNA_def_property_flag(prop, PROP_THICK_WRAP);
635 RNA_def_function_output(func, prop);
638 static void rna_def_histogram(BlenderRNA *brna)
643 static EnumPropertyItem prop_mode_items[] = {
644 {HISTO_MODE_LUMA, "LUMA", 0, "Luma", "Luma"},
645 {HISTO_MODE_RGB, "RGB", 0, "RGB", "Red Green Blue"},
646 {HISTO_MODE_R, "R", 0, "R", "Red"},
647 {HISTO_MODE_G, "G", 0, "G", "Green"},
648 {HISTO_MODE_B, "B", 0, "B", "Blue"},
649 {HISTO_MODE_ALPHA, "A", 0, "A", "Alpha"},
650 {0, NULL, 0, NULL, NULL}
653 srna = RNA_def_struct(brna, "Histogram", NULL);
654 RNA_def_struct_ui_text(srna, "Histogram", "Statistical view of the levels of color in an image");
656 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
657 RNA_def_property_enum_sdna(prop, NULL, "mode");
658 RNA_def_property_enum_items(prop, prop_mode_items);
659 RNA_def_property_ui_text(prop, "Mode", "Channels to display when drawing the histogram");
661 prop = RNA_def_property(srna, "show_line", PROP_BOOLEAN, PROP_NONE);
662 RNA_def_property_boolean_sdna(prop, NULL, "flag", HISTO_FLAG_LINE);
663 RNA_def_property_ui_text(prop, "Show Line", "Display lines rather then filled shapes");
664 RNA_def_property_ui_icon(prop, ICON_IPO, 0);
667 static void rna_def_scopes(BlenderRNA *brna)
672 static EnumPropertyItem prop_wavefrm_mode_items[] = {
673 {SCOPES_WAVEFRM_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
674 {SCOPES_WAVEFRM_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
675 {SCOPES_WAVEFRM_YCC_601, "YCBCR601", ICON_COLOR, "YCbCr (ITU 601)", ""},
676 {SCOPES_WAVEFRM_YCC_709, "YCBCR709", ICON_COLOR, "YCbCr (ITU 709)", ""},
677 {SCOPES_WAVEFRM_YCC_JPEG, "YCBCRJPG", ICON_COLOR, "YCbCr (Jpeg)", ""},
678 {0, NULL, 0, NULL, NULL}
681 srna = RNA_def_struct(brna, "Scopes", NULL);
682 RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image");
684 prop = RNA_def_property(srna, "use_full_resolution", PROP_BOOLEAN, PROP_NONE);
685 RNA_def_property_boolean_sdna(prop, "Scopes", "sample_full", 1);
686 RNA_def_property_ui_text(prop, "Full Sample", "Sample every pixel of the image");
687 RNA_def_property_update(prop, 0, "rna_Scopes_update");
689 prop = RNA_def_property(srna, "accuracy", PROP_FLOAT, PROP_PERCENTAGE);
690 RNA_def_property_float_sdna(prop, "Scopes", "accuracy");
691 RNA_def_property_range(prop, 0.0, 100.0);
692 RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1);
693 RNA_def_property_ui_text(prop, "Accuracy", "Proportion of original image source pixel lines to sample");
694 RNA_def_property_update(prop, 0, "rna_Scopes_update");
696 prop = RNA_def_property(srna, "histogram", PROP_POINTER, PROP_NONE);
697 RNA_def_property_pointer_sdna(prop, "Scopes", "hist");
698 RNA_def_property_struct_type(prop, "Histogram");
699 RNA_def_property_ui_text(prop, "Histogram", "Histogram for viewing image statistics");
701 prop = RNA_def_property(srna, "waveform_mode", PROP_ENUM, PROP_NONE);
702 RNA_def_property_enum_sdna(prop, "Scopes", "wavefrm_mode");
703 RNA_def_property_enum_items(prop, prop_wavefrm_mode_items);
704 RNA_def_property_ui_text(prop, "Waveform Mode", "");
705 RNA_def_property_update(prop, 0, "rna_Scopes_update");
707 prop = RNA_def_property(srna, "waveform_alpha", PROP_FLOAT, PROP_FACTOR);
708 RNA_def_property_float_sdna(prop, "Scopes", "wavefrm_alpha");
709 RNA_def_property_range(prop, 0, 1);
710 RNA_def_property_ui_text(prop, "Waveform Opacity", "Opacity of the points");
712 prop = RNA_def_property(srna, "vectorscope_alpha", PROP_FLOAT, PROP_FACTOR);
713 RNA_def_property_float_sdna(prop, "Scopes", "vecscope_alpha");
714 RNA_def_property_range(prop, 0, 1);
715 RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points");
718 static void rna_def_colormanage(BlenderRNA *brna)
723 srna = RNA_def_struct(brna, "ColorManagedViewSettings", NULL);
724 RNA_def_struct_ui_text(srna, "ColorManagedViewSettings", "Color management settings used for displaying images on the display");
726 prop = RNA_def_property(srna, "use_global_settings", PROP_BOOLEAN, PROP_NONE);
727 RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMANAGE_VIEW_USE_GLOBAL);
728 RNA_def_property_ui_text(prop, "Use Global Settings", "Use global display settings instead of per-space setting");
729 RNA_def_property_update(prop, NC_WINDOW, NULL);
731 prop= RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE);
732 RNA_def_property_enum_items(prop, view_transform_items);
733 RNA_def_property_enum_funcs(prop, "rna_ColorManagedViewSettings_view_transform_get",
734 "rna_ColorManagedViewSettings_view_transform_set",
735 "rna_ColorManagedViewSettings_view_transform_itemf");
736 RNA_def_property_ui_text(prop, "View Transform", "View transform used for this image editor");
737 RNA_def_property_update(prop, NC_WINDOW, NULL);
739 prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
740 RNA_def_property_float_sdna(prop, NULL, "exposure");
741 RNA_def_property_range(prop, -10.0f, 10.0f);
742 RNA_def_property_float_default(prop, 0.0f);
743 RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied on displaying image buffers");
744 RNA_def_property_update(prop, NC_WINDOW, NULL);
746 prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_FACTOR);
747 RNA_def_property_float_sdna(prop, NULL, "gamma");
748 RNA_def_property_float_default(prop, 1.0f);
749 RNA_def_property_range(prop, 0.0f, 5.0f);
750 RNA_def_property_ui_text(prop, "Gamma", "Amount f gamma modification for displaying image buffers");
751 RNA_def_property_update(prop, NC_WINDOW, NULL);
754 void RNA_def_color(BlenderRNA *brna)
756 rna_def_curvemappoint(brna);
757 rna_def_curvemap(brna);
758 rna_def_curvemapping(brna);
759 rna_def_color_ramp_element(brna);
760 rna_def_color_ramp(brna);
761 rna_def_histogram(brna);
762 rna_def_scopes(brna);
763 rna_def_colormanage(brna);