Blender V4.3
rna_color.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10#include <cstdlib>
11
12#include "DNA_color_types.h"
13#include "DNA_texture_types.h"
14
15#include "BLI_utildefines.h"
16
17#include "BLT_translation.hh"
18
20
21#include "RNA_define.hh"
22#include "RNA_enum_types.hh"
23#include "rna_internal.hh"
24
25#include "WM_api.hh"
26#include "WM_types.hh"
27
29 {0,
30 "NONE",
31 0,
32 "None",
33 "Do not perform any color transform on load, treat colors as in scene linear space "
34 "already"},
35 {0, nullptr, 0, nullptr, nullptr},
36};
37
38#ifdef RNA_RUNTIME
39
40# include <fmt/format.h>
41
42# include "RNA_access.hh"
43# include "RNA_path.hh"
44
45# include "DNA_image_types.h"
46# include "DNA_material_types.h"
47# include "DNA_movieclip_types.h"
48# include "DNA_node_types.h"
49# include "DNA_object_types.h"
50# include "DNA_particle_types.h"
51# include "DNA_sequence_types.h"
52
53# include "MEM_guardedalloc.h"
54
55# include "BKE_colorband.hh"
56# include "BKE_colortools.hh"
57# include "BKE_image.hh"
58# include "BKE_linestyle.h"
59# include "BKE_movieclip.h"
60# include "BKE_node.hh"
61
62# include "DEG_depsgraph.hh"
63
64# include "ED_node.hh"
65
66# include "IMB_colormanagement.hh"
67# include "IMB_imbuf.hh"
68
69# include "SEQ_iterator.hh"
70# include "SEQ_relations.hh"
71# include "SEQ_thumbnail_cache.hh"
72
73static int rna_CurveMapping_curves_length(PointerRNA *ptr)
74{
75 CurveMapping *cumap = (CurveMapping *)ptr->data;
76 int len;
77
78 for (len = 0; len < CM_TOT; len++) {
79 if (!cumap->cm[len].curve) {
80 break;
81 }
82 }
83
84 return len;
85}
86
87static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
88{
89 CurveMapping *cumap = (CurveMapping *)ptr->data;
90
92 iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, nullptr);
93}
94
95static void rna_CurveMapping_clip_set(PointerRNA *ptr, bool value)
96{
97 CurveMapping *cumap = (CurveMapping *)ptr->data;
98
99 /* Clipping is always done for wrapped curves, so don't allow user to change it. */
100 if (cumap->flag & CUMA_USE_WRAPPING) {
101 return;
102 }
103
104 if (value) {
105 cumap->flag |= CUMA_DO_CLIP;
106 }
107 else {
108 cumap->flag &= ~CUMA_DO_CLIP;
109 }
110
111 BKE_curvemapping_changed(cumap, false);
112}
113
114static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
115{
116 CurveMapping *cumap = (CurveMapping *)ptr->data;
117 cumap->black[0] = values[0];
118 cumap->black[1] = values[1];
119 cumap->black[2] = values[2];
120 BKE_curvemapping_set_black_white(cumap, nullptr, nullptr);
121}
122
123static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values)
124{
125 CurveMapping *cumap = (CurveMapping *)ptr->data;
126 cumap->white[0] = values[0];
127 cumap->white[1] = values[1];
128 cumap->white[2] = values[2];
129 BKE_curvemapping_set_black_white(cumap, nullptr, nullptr);
130}
131
132static void rna_CurveMapping_tone_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
133{
134 /* Film-like tone only works with the combined curve, which is the fourth curve, so if the user
135 * changed to film-like make the combined curve current, as we now hide the rest of the curves
136 * since they no longer have an effect. */
137 CurveMapping *curve_mapping = (CurveMapping *)ptr->data;
138 if (curve_mapping->tone == CURVE_TONE_FILMLIKE) {
139 curve_mapping->cur = 3;
140 }
141
144}
145
146static void rna_CurveMapping_extend_update(Main * /*bmain*/,
147 Scene * /*scene*/,
148 PointerRNA * /*ptr*/)
149{
152}
153
154static void rna_CurveMapping_clipminx_range(
155 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
156{
157 CurveMapping *cumap = (CurveMapping *)ptr->data;
158
159 *min = -100.0f;
160 *max = cumap->clipr.xmax;
161}
162
163static void rna_CurveMapping_clipminy_range(
164 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
165{
166 CurveMapping *cumap = (CurveMapping *)ptr->data;
167
168 *min = -100.0f;
169 *max = cumap->clipr.ymax;
170}
171
172static void rna_CurveMapping_clipmaxx_range(
173 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
174{
175 CurveMapping *cumap = (CurveMapping *)ptr->data;
176
177 *min = cumap->clipr.xmin;
178 *max = 100.0f;
179}
180
181static void rna_CurveMapping_clipmaxy_range(
182 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
183{
184 CurveMapping *cumap = (CurveMapping *)ptr->data;
185
186 *min = cumap->clipr.ymin;
187 *max = 100.0f;
188}
189
190static std::optional<std::string> rna_ColorRamp_path(const PointerRNA *ptr)
191{
192 /* handle the cases where a single data-block may have 2 ramp types */
193 if (ptr->owner_id) {
194 ID *id = ptr->owner_id;
195
196 switch (GS(id->name)) {
197 case ID_NT: {
198 bNodeTree *ntree = (bNodeTree *)id;
199 bNode *node;
200
201 for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
203 if (node->storage == ptr->data) {
204 /* all node color ramp properties called 'color_ramp'
205 * prepend path from ID to the node
206 */
207 PointerRNA node_ptr = RNA_pointer_create(id, &RNA_Node, node);
208 std::string node_path = RNA_path_from_ID_to_struct(&node_ptr).value_or("");
209 return fmt::format("{}.color_ramp", node_path);
210 }
211 }
212 }
213 break;
214 }
215
216 case ID_LS: {
217 /* may be nullptr */
219 }
220
221 default:
222 /* everything else just uses 'color_ramp' */
223 return "color_ramp";
224 }
225 }
226 else {
227 /* everything else just uses 'color_ramp' */
228 return "color_ramp";
229 }
230
231 return std::nullopt;
232}
233
234static std::optional<std::string> rna_ColorRampElement_path(const PointerRNA *ptr)
235{
236 PointerRNA ramp_ptr;
237 PropertyRNA *prop;
238 std::optional<std::string> path;
239 int index;
240
241 /* helper macro for use here to try and get the path
242 * - this calls the standard code for getting a path to a texture...
243 */
244
245# define COLRAMP_GETPATH \
246 { \
247 prop = RNA_struct_find_property(&ramp_ptr, "elements"); \
248 if (prop) { \
249 index = RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \
250 if (index != -1) { \
251 std::string texture_path = rna_ColorRamp_path(&ramp_ptr).value_or(""); \
252 path = fmt::format("{}.elements[{}]", texture_path, index); \
253 } \
254 } \
255 } \
256 (void)0
257
258 /* determine the path from the ID-block to the ramp */
259 /* FIXME: this is a very slow way to do it, but it will have to suffice... */
260 if (ptr->owner_id) {
261 ID *id = ptr->owner_id;
262
263 switch (GS(id->name)) {
264 case ID_NT: {
265 bNodeTree *ntree = (bNodeTree *)id;
266 bNode *node;
267
268 for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
270 ramp_ptr = RNA_pointer_create(id, &RNA_ColorRamp, node->storage);
271 COLRAMP_GETPATH;
272 }
273 }
274 break;
275 }
276 case ID_LS: {
277 ListBase listbase;
278 LinkData *link;
279
281 for (link = (LinkData *)listbase.first; link; link = link->next) {
282 ramp_ptr = RNA_pointer_create(id, &RNA_ColorRamp, link->data);
283 COLRAMP_GETPATH;
284 }
285 BLI_freelistN(&listbase);
286 break;
287 }
288
289 default: /* everything else should have a "color_ramp" property */
290 {
291 /* create pointer to the ID block, and try to resolve "color_ramp" pointer */
292 ramp_ptr = RNA_id_pointer_create(id);
293 if (RNA_path_resolve(&ramp_ptr, "color_ramp", &ramp_ptr, &prop)) {
294 COLRAMP_GETPATH;
295 }
296 break;
297 }
298 }
299 }
300
301 /* cleanup the macro we defined */
302# undef COLRAMP_GETPATH
303
304 return path;
305}
306
307static void rna_ColorRamp_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
308{
309 if (ptr->owner_id) {
310 ID *id = ptr->owner_id;
311
312 switch (GS(id->name)) {
313 case ID_MA: {
314 Material *ma = (Material *)ptr->owner_id;
315
316 DEG_id_tag_update(&ma->id, 0);
318 break;
319 }
320 case ID_NT: {
321 bNodeTree *ntree = (bNodeTree *)id;
322 bNode *node;
323
324 for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
327 ED_node_tree_propagate_change(nullptr, bmain, ntree);
328 }
329 }
330 break;
331 }
332 case ID_TE: {
333 Tex *tex = (Tex *)ptr->owner_id;
334
335 DEG_id_tag_update(&tex->id, 0);
337 break;
338 }
339 case ID_LS: {
340 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
341
343 break;
344 }
345 /* Color Ramp for particle display is owned by the object (see #54422) */
346 case ID_OB:
347 case ID_PA: {
348 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
349
351 }
352 default:
353 break;
354 }
355 }
356}
357
358static void rna_ColorRamp_eval(ColorBand *coba, float position, float color[4])
359{
360 BKE_colorband_evaluate(coba, position, color);
361}
362
363static CBData *rna_ColorRampElement_new(ColorBand *coba, ReportList *reports, float position)
364{
365 CBData *element = BKE_colorband_element_add(coba, position);
366
367 if (element == nullptr) {
368 BKE_reportf(reports, RPT_ERROR, "Unable to add element to colorband (limit %d)", MAXCOLORBAND);
369 }
370
371 return element;
372}
373
374static void rna_ColorRampElement_remove(ColorBand *coba,
375 ReportList *reports,
376 PointerRNA *element_ptr)
377{
378 CBData *element = static_cast<CBData *>(element_ptr->data);
379 int index = int(element - coba->data);
380 if (!BKE_colorband_element_remove(coba, index)) {
381 BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
382 return;
383 }
384
385 RNA_POINTER_INVALIDATE(element_ptr);
386}
387
388static void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
389{
390 CurveMapPoint *point = static_cast<CurveMapPoint *>(point_ptr->data);
391 if (BKE_curvemap_remove_point(cuma, point) == false) {
392 BKE_report(reports, RPT_ERROR, "Unable to remove curve point");
393 return;
394 }
395
396 RNA_POINTER_INVALIDATE(point_ptr);
397}
398
399static void rna_Scopes_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
400{
401 Scopes *s = (Scopes *)ptr->data;
402 s->ok = 0;
403}
404
405static int rna_ColorManagedDisplaySettings_display_device_get(PointerRNA *ptr)
406{
408
409 return IMB_colormanagement_display_get_named_index(display->display_device);
410}
411
412static void rna_ColorManagedDisplaySettings_display_device_set(PointerRNA *ptr, int value)
413{
415 const char *name = IMB_colormanagement_display_get_indexed_name(value);
416
417 if (name) {
418 STRNCPY(display->display_device, name);
419 }
420}
421
422static const EnumPropertyItem *rna_ColorManagedDisplaySettings_display_device_itemf(
423 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
424{
425 EnumPropertyItem *items = nullptr;
426 int totitem = 0;
427
429 RNA_enum_item_end(&items, &totitem);
430
431 *r_free = true;
432
433 return items;
434}
435
436static void rna_ColorManagedDisplaySettings_display_device_update(Main *bmain,
437 Scene * /*scene*/,
439{
440 ID *id = ptr->owner_id;
441
442 if (!id) {
443 return;
444 }
445
446 if (GS(id->name) == ID_SCE) {
447 Scene *scene = (Scene *)id;
448
450
451 DEG_id_tag_update(id, 0);
453
454 /* Color management can be baked into shaders, need to refresh. */
455 for (Material *ma = static_cast<Material *>(bmain->materials.first); ma;
456 ma = static_cast<Material *>(ma->id.next))
457 {
459 }
460 }
461}
462
463static std::optional<std::string> rna_ColorManagedDisplaySettings_path(const PointerRNA * /*ptr*/)
464{
465 return "display_settings";
466}
467
468static int rna_ColorManagedViewSettings_view_transform_get(PointerRNA *ptr)
469{
471
472 return IMB_colormanagement_view_get_named_index(view->view_transform);
473}
474
475static void rna_ColorManagedViewSettings_view_transform_set(PointerRNA *ptr, int value)
476{
478
479 const char *view_name = IMB_colormanagement_view_get_indexed_name(value);
480 if (!view_name) {
481 return;
482 }
483
484 STRNCPY(view->view_transform, view_name);
485
486 const char *look_name = IMB_colormanagement_look_validate_for_view(view_name, view->look);
487 if (look_name) {
488 STRNCPY(view->look, look_name);
489 }
490}
491
492static const EnumPropertyItem *rna_ColorManagedViewSettings_view_transform_itemf(
493 bContext *C, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
494{
495 Scene *scene = CTX_data_scene(C);
496 EnumPropertyItem *items = nullptr;
497 ColorManagedDisplaySettings *display_settings = &scene->display_settings;
498 int totitem = 0;
499
500 IMB_colormanagement_view_items_add(&items, &totitem, display_settings->display_device);
501 RNA_enum_item_end(&items, &totitem);
502
503 *r_free = true;
504 return items;
505}
506
507static int rna_ColorManagedViewSettings_look_get(PointerRNA *ptr)
508{
510
512}
513
514static void rna_ColorManagedViewSettings_look_set(PointerRNA *ptr, int value)
515{
517
518 const char *name = IMB_colormanagement_look_get_indexed_name(value);
519
520 if (name) {
521 STRNCPY(view->look, name);
522 }
523}
524
525static const EnumPropertyItem *rna_ColorManagedViewSettings_look_itemf(bContext * /*C*/,
527 PropertyRNA * /*prop*/,
528 bool *r_free)
529{
531 EnumPropertyItem *items = nullptr;
532 int totitem = 0;
533
534 IMB_colormanagement_look_items_add(&items, &totitem, view->view_transform);
535 RNA_enum_item_end(&items, &totitem);
536
537 *r_free = true;
538 return items;
539}
540
541static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool value)
542{
543 ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *)ptr->data;
544
545 if (value) {
546 view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES;
547
548 if (view_settings->curve_mapping == nullptr) {
549 view_settings->curve_mapping = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
550 }
551 }
552 else {
553 view_settings->flag &= ~COLORMANAGE_VIEW_USE_CURVES;
554 }
555}
556
557static std::optional<std::string> rna_ColorManagedViewSettings_path(const PointerRNA * /*ptr*/)
558{
559 return "view_settings";
560}
561
562static void rna_ColorManagedViewSettings_whitepoint_get(PointerRNA *ptr, float value[3])
563{
564 const ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *)ptr->data;
565 IMB_colormanagement_get_whitepoint(view_settings->temperature, view_settings->tint, value);
566}
567
568static void rna_ColorManagedViewSettings_whitepoint_set(PointerRNA *ptr, const float value[3])
569{
570 ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *)ptr->data;
571 IMB_colormanagement_set_whitepoint(value, view_settings->temperature, view_settings->tint);
572}
573
574static bool rna_ColorManagedColorspaceSettings_is_data_get(PointerRNA *ptr)
575{
578 return STREQ(colorspace->name, data_name);
579}
580
581static void rna_ColorManagedColorspaceSettings_is_data_set(PointerRNA *ptr, bool value)
582{
584 if (value) {
586 STRNCPY(colorspace->name, data_name);
587 }
588}
589
590static int rna_ColorManagedColorspaceSettings_colorspace_get(PointerRNA *ptr)
591{
593
594 return IMB_colormanagement_colorspace_get_named_index(colorspace->name);
595}
596
597static void rna_ColorManagedColorspaceSettings_colorspace_set(PointerRNA *ptr, int value)
598{
600 const char *name = IMB_colormanagement_colorspace_get_indexed_name(value);
601
602 if (name && name[0]) {
603 STRNCPY(colorspace->name, name);
604 }
605}
606
607static const EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_itemf(
608 bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
609{
610 EnumPropertyItem *items = nullptr;
611 int totitem = 0;
612
614 RNA_enum_item_end(&items, &totitem);
615
616 *r_free = true;
617
618 return items;
619}
620
621struct Seq_colorspace_cb_data {
622 ColorManagedColorspaceSettings *colorspace_settings;
623 Sequence *r_seq;
624};
625
631static bool seq_find_colorspace_settings_cb(Sequence *seq, void *user_data)
632{
633 Seq_colorspace_cb_data *cd = (Seq_colorspace_cb_data *)user_data;
634 if (seq->strip && &seq->strip->colorspace_settings == cd->colorspace_settings) {
635 cd->r_seq = seq;
636 return false;
637 }
638 return true;
639}
640
641static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
642 Scene * /*scene*/,
644{
645 ID *id = ptr->owner_id;
646
647 if (!id) {
648 /* Happens for color space settings on operators. */
649 return;
650 }
651
652 if (GS(id->name) == ID_IM) {
653 Image *ima = (Image *)id;
654
655 DEG_id_tag_update(&ima->id, 0);
657
658 BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_COLORMANAGE);
659
662 }
663 else if (GS(id->name) == ID_MC) {
664 MovieClip *clip = (MovieClip *)id;
665
668
671 }
672 else if (GS(id->name) == ID_SCE) {
673 Scene *scene = (Scene *)id;
675
676 if (scene->ed) {
678 ptr->data;
679 Seq_colorspace_cb_data cb_data = {colorspace_settings, nullptr};
680
681 if (&scene->sequencer_colorspace_settings == colorspace_settings) {
682 /* Scene colorspace was changed. */
683 SEQ_cache_cleanup(scene);
685 }
686 else {
687 /* Strip colorspace was likely changed. */
688 SEQ_for_each_callback(&scene->ed->seqbase, seq_find_colorspace_settings_cb, &cb_data);
689 Sequence *seq = cb_data.r_seq;
690
691 if (seq) {
693
694 if (seq->strip->proxy && seq->strip->proxy->anim) {
696 seq->strip->proxy->anim = nullptr;
697 }
698
700 }
701 }
702
704 }
705 }
706}
707
708static std::optional<std::string> rna_ColorManagedSequencerColorspaceSettings_path(
709 const PointerRNA * /*ptr*/)
710{
711 return "sequencer_colorspace_settings";
712}
713
714static std::optional<std::string> rna_ColorManagedInputColorspaceSettings_path(
715 const PointerRNA * /*ptr*/)
716{
717 return "colorspace_settings";
718}
719
720static void rna_ColorManagement_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
721{
722 ID *id = ptr->owner_id;
723
724 if (!id) {
725 return;
726 }
727
728 if (GS(id->name) == ID_SCE) {
730 }
731}
732
733/* this function only exists because #BKE_curvemap_evaluateF uses a 'const' qualifier */
734static float rna_CurveMapping_evaluateF(CurveMapping *cumap,
735 ReportList *reports,
736 CurveMap *cuma,
737 float value)
738{
739 if (&cumap->cm[0] != cuma && &cumap->cm[1] != cuma && &cumap->cm[2] != cuma &&
740 &cumap->cm[3] != cuma)
741 {
742 BKE_report(reports, RPT_ERROR, "CurveMapping does not own CurveMap");
743 return 0.0f;
744 }
745
746 if (!cuma->table) {
748 }
749 return BKE_curvemap_evaluateF(cumap, cuma, value);
750}
751
752static void rna_CurveMap_initialize(CurveMapping *cumap)
753{
755}
756#else
757
759{
760 StructRNA *srna;
761 PropertyRNA *prop;
763 {0, "AUTO", 0, "Auto Handle", ""},
764 {CUMA_HANDLE_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto-Clamped Handle", ""},
765 {CUMA_HANDLE_VECTOR, "VECTOR", 0, "Vector Handle", ""},
766 {0, nullptr, 0, nullptr, nullptr},
767 };
768
769 srna = RNA_def_struct(brna, "CurveMapPoint", nullptr);
770 RNA_def_struct_ui_text(srna, "CurveMapPoint", "Point of a curve used for a curve mapping");
771
772 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
773 RNA_def_property_float_sdna(prop, nullptr, "x");
774 RNA_def_property_array(prop, 2);
775 RNA_def_property_ui_text(prop, "Location", "X/Y coordinates of the curve point");
776
777 prop = RNA_def_property(srna, "handle_type", PROP_ENUM, PROP_NONE);
778 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
781 prop, "Handle Type", "Curve interpolation at this point: Bézier or vector");
782
783 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
784 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CUMA_SELECT);
785 RNA_def_property_ui_text(prop, "Select", "Selection state of the curve point");
786}
787
789{
790 StructRNA *srna;
791 PropertyRNA *parm;
792 FunctionRNA *func;
793
794 RNA_def_property_srna(cprop, "CurveMapPoints");
795 srna = RNA_def_struct(brna, "CurveMapPoints", nullptr);
796 RNA_def_struct_sdna(srna, "CurveMap");
797 RNA_def_struct_ui_text(srna, "Curve Map Point", "Collection of Curve Map Points");
798
799 func = RNA_def_function(srna, "new", "BKE_curvemap_insert");
800 RNA_def_function_ui_description(func, "Add point to CurveMap");
801 parm = RNA_def_float(func,
802 "position",
803 0.0f,
804 -FLT_MAX,
805 FLT_MAX,
806 "Position",
807 "Position to add point",
808 -FLT_MAX,
809 FLT_MAX);
811 parm = RNA_def_float(
812 func, "value", 0.0f, -FLT_MAX, FLT_MAX, "Value", "Value of point", -FLT_MAX, FLT_MAX);
814 parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point");
815 RNA_def_function_return(func, parm);
816
817 func = RNA_def_function(srna, "remove", "rna_CurveMap_remove_point");
819 RNA_def_function_ui_description(func, "Delete point from CurveMap");
820 parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove");
823}
824
825static void rna_def_curvemap(BlenderRNA *brna)
826{
827 StructRNA *srna;
828 PropertyRNA *prop;
829
830 srna = RNA_def_struct(brna, "CurveMap", nullptr);
831 RNA_def_struct_ui_text(srna, "CurveMap", "Curve in a curve mapping");
832
833 prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
834 RNA_def_property_collection_sdna(prop, nullptr, "curve", "totpoint");
835 RNA_def_property_struct_type(prop, "CurveMapPoint");
836 RNA_def_property_ui_text(prop, "Points", "");
837 rna_def_curvemap_points_api(brna, prop);
838}
839
841{
842 StructRNA *srna;
843 PropertyRNA *prop, *parm;
844 FunctionRNA *func;
845
846 static const EnumPropertyItem tone_items[] = {
848 "STANDARD",
849 0,
850 "Standard",
851 "Combined curve is applied to each channel individually, which may result in a change of "
852 "hue"},
853 {CURVE_TONE_FILMLIKE, "FILMLIKE", 0, "Filmlike", "Keeps the hue constant"},
854 {0, nullptr, 0, nullptr, nullptr},
855 };
856
857 static const EnumPropertyItem prop_extend_items[] = {
858 {0, "HORIZONTAL", 0, "Horizontal", ""},
859 {CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", 0, "Extrapolated", ""},
860 {0, nullptr, 0, nullptr, nullptr},
861 };
862
863 srna = RNA_def_struct(brna, "CurveMapping", nullptr);
865 srna,
866 "CurveMapping",
867 "Curve mapping to map color, vector and scalar values to other values using "
868 "a user defined curve");
869
870 prop = RNA_def_property(srna, "tone", PROP_ENUM, PROP_NONE);
871 RNA_def_property_enum_sdna(prop, nullptr, "tone");
872 RNA_def_property_enum_items(prop, tone_items);
873 RNA_def_property_ui_text(prop, "Tone", "Tone of the curve");
874 RNA_def_property_update(prop, 0, "rna_CurveMapping_tone_update");
875
876 prop = RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE);
877 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CUMA_DO_CLIP);
878 RNA_def_property_ui_text(prop, "Clip", "Force the curve view to fit a defined boundary");
879 RNA_def_property_boolean_funcs(prop, nullptr, "rna_CurveMapping_clip_set");
880
881 prop = RNA_def_property(srna, "clip_min_x", PROP_FLOAT, PROP_NONE);
882 RNA_def_property_float_sdna(prop, nullptr, "clipr.xmin");
883 RNA_def_property_range(prop, -100.0f, 100.0f);
884 RNA_def_property_ui_text(prop, "Clip Min X", "");
885 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_CurveMapping_clipminx_range");
886
887 prop = RNA_def_property(srna, "clip_min_y", PROP_FLOAT, PROP_NONE);
888 RNA_def_property_float_sdna(prop, nullptr, "clipr.ymin");
889 RNA_def_property_range(prop, -100.0f, 100.0f);
890 RNA_def_property_ui_text(prop, "Clip Min Y", "");
891 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_CurveMapping_clipminy_range");
892
893 prop = RNA_def_property(srna, "clip_max_x", PROP_FLOAT, PROP_NONE);
894 RNA_def_property_float_sdna(prop, nullptr, "clipr.xmax");
895 RNA_def_property_range(prop, -100.0f, 100.0f);
896 RNA_def_property_ui_text(prop, "Clip Max X", "");
897 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_CurveMapping_clipmaxx_range");
898
899 prop = RNA_def_property(srna, "clip_max_y", PROP_FLOAT, PROP_NONE);
900 RNA_def_property_float_sdna(prop, nullptr, "clipr.ymax");
901 RNA_def_property_range(prop, -100.0f, 100.0f);
902 RNA_def_property_ui_text(prop, "Clip Max Y", "");
903 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_CurveMapping_clipmaxy_range");
904
905 prop = RNA_def_property(srna, "extend", PROP_ENUM, PROP_NONE);
906 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
907 RNA_def_property_enum_items(prop, prop_extend_items);
908 RNA_def_property_ui_text(prop, "Extend", "Extrapolate the curve or extend it horizontally");
909 RNA_def_property_update(prop, 0, "rna_CurveMapping_extend_update");
910
911 prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE);
913 "rna_CurveMapping_curves_begin",
914 "rna_iterator_array_next",
915 "rna_iterator_array_end",
916 "rna_iterator_array_get",
917 "rna_CurveMapping_curves_length",
918 nullptr,
919 nullptr,
920 nullptr);
921 RNA_def_property_struct_type(prop, "CurveMap");
922 RNA_def_property_ui_text(prop, "Curves", "");
923
924 prop = RNA_def_property(srna, "black_level", PROP_FLOAT, PROP_COLOR);
925 RNA_def_property_float_sdna(prop, nullptr, "black");
927 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 1, 3);
929 prop, "Black Level", "For RGB curves, the color that black is mapped to");
930 RNA_def_property_float_funcs(prop, nullptr, "rna_CurveMapping_black_level_set", nullptr);
931
932 prop = RNA_def_property(srna, "white_level", PROP_FLOAT, PROP_COLOR);
933 RNA_def_property_float_sdna(prop, nullptr, "white");
935 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 1, 3);
937 prop, "White Level", "For RGB curves, the color that white is mapped to");
938 RNA_def_property_float_funcs(prop, nullptr, "rna_CurveMapping_white_level_set", nullptr);
939
940 func = RNA_def_function(srna, "update", "BKE_curvemapping_changed_all");
941 RNA_def_function_ui_description(func, "Update curve mapping after making changes");
942
943 func = RNA_def_function(srna, "reset_view", "BKE_curvemapping_reset_view");
944 RNA_def_function_ui_description(func, "Reset the curve mapping grid to its clipping size");
945
946 func = RNA_def_function(srna, "initialize", "rna_CurveMap_initialize");
947 RNA_def_function_ui_description(func, "Initialize curve");
948
949 func = RNA_def_function(srna, "evaluate", "rna_CurveMapping_evaluateF");
951 RNA_def_function_ui_description(func, "Evaluate curve at given location");
952 parm = RNA_def_pointer(func, "curve", "CurveMap", "curve", "Curve to evaluate");
954 parm = RNA_def_float(func,
955 "position",
956 0.0f,
957 -FLT_MAX,
958 FLT_MAX,
959 "Position",
960 "Position to evaluate curve at",
961 -FLT_MAX,
962 FLT_MAX);
964 parm = RNA_def_float(func,
965 "value",
966 0.0f,
967 -FLT_MAX,
968 FLT_MAX,
969 "Value",
970 "Value of curve at given location",
971 -FLT_MAX,
972 FLT_MAX);
973 RNA_def_function_return(func, parm);
974}
975
977{
978 StructRNA *srna;
979 PropertyRNA *prop;
980
981 srna = RNA_def_struct(brna, "ColorRampElement", nullptr);
982 RNA_def_struct_sdna(srna, "CBData");
983 RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
985 srna, "Color Ramp Element", "Element defining a color at a position in the color ramp");
986
987 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
988 RNA_def_property_float_sdna(prop, nullptr, "r");
989 RNA_def_property_array(prop, 4);
990 RNA_def_property_ui_text(prop, "Color", "Set color of selected color stop");
991 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
992
993 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_COLOR);
994 RNA_def_property_float_sdna(prop, nullptr, "a");
995 RNA_def_property_ui_text(prop, "Alpha", "Set alpha of selected color stop");
996 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
997
998 prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
999 RNA_def_property_float_sdna(prop, nullptr, "pos");
1000 RNA_def_property_range(prop, 0, 1);
1001 RNA_def_property_ui_range(prop, 0, 1, 1, 3);
1002 RNA_def_property_ui_text(prop, "Position", "Set position of selected color stop");
1003 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1004}
1005
1007{
1008 StructRNA *srna;
1009 PropertyRNA *parm;
1010 FunctionRNA *func;
1011
1012 RNA_def_property_srna(cprop, "ColorRampElements");
1013 srna = RNA_def_struct(brna, "ColorRampElements", nullptr);
1014 RNA_def_struct_sdna(srna, "ColorBand");
1015 RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
1016 RNA_def_struct_ui_text(srna, "Color Ramp Elements", "Collection of Color Ramp Elements");
1017
1018 /* TODO: make these functions generic in `texture.cc`. */
1019 func = RNA_def_function(srna, "new", "rna_ColorRampElement_new");
1020 RNA_def_function_ui_description(func, "Add element to Color Ramp");
1022 parm = RNA_def_float(
1023 func, "position", 0.0f, 0.0f, 1.0f, "Position", "Position to add element", 0.0f, 1.0f);
1025 /* return type */
1026 parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "New element");
1027 RNA_def_function_return(func, parm);
1028
1029 func = RNA_def_function(srna, "remove", "rna_ColorRampElement_remove");
1030 RNA_def_function_ui_description(func, "Delete element from Color Ramp");
1032 parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
1035}
1036
1038{
1039 StructRNA *srna;
1040 PropertyRNA *prop;
1041
1042 FunctionRNA *func;
1043 PropertyRNA *parm;
1044
1045 static const EnumPropertyItem prop_interpolation_items[] = {
1046 {COLBAND_INTERP_EASE, "EASE", 0, "Ease", ""},
1047 {COLBAND_INTERP_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
1048 {COLBAND_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
1049 {COLBAND_INTERP_B_SPLINE, "B_SPLINE", 0, "B-Spline", ""},
1050 {COLBAND_INTERP_CONSTANT, "CONSTANT", 0, "Constant", ""},
1051 {0, nullptr, 0, nullptr, nullptr},
1052 };
1053
1054 static const EnumPropertyItem prop_mode_items[] = {
1055 {COLBAND_BLEND_RGB, "RGB", 0, "RGB", ""},
1056 {COLBAND_BLEND_HSV, "HSV", 0, "HSV", ""},
1057 {COLBAND_BLEND_HSL, "HSL", 0, "HSL", ""},
1058 {0, nullptr, 0, nullptr, nullptr},
1059 };
1060
1061 static const EnumPropertyItem prop_hsv_items[] = {
1062 {COLBAND_HUE_NEAR, "NEAR", 0, "Near", ""},
1063 {COLBAND_HUE_FAR, "FAR", 0, "Far", ""},
1064 {COLBAND_HUE_CW, "CW", 0, "Clockwise", ""},
1065 {COLBAND_HUE_CCW, "CCW", 0, "Counter-Clockwise", ""},
1066 {0, nullptr, 0, nullptr, nullptr},
1067 };
1068
1069 srna = RNA_def_struct(brna, "ColorRamp", nullptr);
1070 RNA_def_struct_sdna(srna, "ColorBand");
1071 RNA_def_struct_path_func(srna, "rna_ColorRamp_path");
1072 RNA_def_struct_ui_text(srna, "Color Ramp", "Color ramp mapping a scalar value to a color");
1073
1074 prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_COLOR);
1075 RNA_def_property_collection_sdna(prop, nullptr, "data", "tot");
1076 RNA_def_property_struct_type(prop, "ColorRampElement");
1077 RNA_def_property_ui_text(prop, "Elements", "");
1078 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1080
1081 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
1082 RNA_def_property_enum_sdna(prop, nullptr, "ipotype");
1083 RNA_def_property_enum_items(prop, prop_interpolation_items);
1084 RNA_def_property_ui_text(prop, "Interpolation", "Set interpolation between color stops");
1085 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1086
1087 prop = RNA_def_property(srna, "hue_interpolation", PROP_ENUM, PROP_NONE);
1088 RNA_def_property_enum_sdna(prop, nullptr, "ipotype_hue");
1089 RNA_def_property_enum_items(prop, prop_hsv_items);
1090 RNA_def_property_ui_text(prop, "Color Interpolation", "Set color interpolation");
1091 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1092
1093 prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
1094 RNA_def_property_enum_sdna(prop, nullptr, "color_mode");
1095 RNA_def_property_enum_items(prop, prop_mode_items);
1096 RNA_def_property_ui_text(prop, "Color Mode", "Set color mode to use for interpolation");
1097 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1098
1099# if 0 /* use len(elements) */
1100 prop = RNA_def_property(srna, "total", PROP_INT, PROP_NONE);
1101 RNA_def_property_int_sdna(prop, nullptr, "tot");
1102 /* needs a function to do the right thing when adding elements like colorband_add_cb() */
1104 RNA_def_property_range(prop, 0, 31); /* MAXCOLORBAND = 32 */
1105 RNA_def_property_ui_text(prop, "Total", "Total number of elements");
1106 RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
1107# endif
1108
1109 func = RNA_def_function(srna, "evaluate", "rna_ColorRamp_eval");
1110 RNA_def_function_ui_description(func, "Evaluate Color Ramp");
1111 parm = RNA_def_float(func,
1112 "position",
1113 1.0f,
1114 0.0f,
1115 1.0f,
1116 "Position",
1117 "Evaluate Color Ramp at position",
1118 0.0f,
1119 1.0f);
1121 /* return */
1122 parm = RNA_def_float_color(func,
1123 "color",
1124 4,
1125 nullptr,
1126 -FLT_MAX,
1127 FLT_MAX,
1128 "Color",
1129 "Color at given position",
1130 -FLT_MAX,
1131 FLT_MAX);
1133 RNA_def_function_output(func, parm);
1134}
1135
1137{
1138 StructRNA *srna;
1139 PropertyRNA *prop;
1140
1141 static const EnumPropertyItem prop_mode_items[] = {
1142 {HISTO_MODE_LUMA, "LUMA", 0, "Luma", "Luma"},
1143 {HISTO_MODE_RGB, "RGB", 0, "RGB", "Red Green Blue"},
1144 {HISTO_MODE_R, "R", 0, "R", "Red"},
1145 {HISTO_MODE_G, "G", 0, "G", "Green"},
1146 {HISTO_MODE_B, "B", 0, "B", "Blue"},
1147 {HISTO_MODE_ALPHA, "A", 0, "A", "Alpha"},
1148 {0, nullptr, 0, nullptr, nullptr},
1149 };
1150
1151 srna = RNA_def_struct(brna, "Histogram", nullptr);
1152 RNA_def_struct_ui_text(srna, "Histogram", "Statistical view of the levels of color in an image");
1153
1154 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1155 RNA_def_property_enum_sdna(prop, nullptr, "mode");
1156 RNA_def_property_enum_items(prop, prop_mode_items);
1157 RNA_def_property_ui_text(prop, "Mode", "Channels to display in the histogram");
1159
1160 prop = RNA_def_property(srna, "show_line", PROP_BOOLEAN, PROP_NONE);
1161 RNA_def_property_boolean_sdna(prop, nullptr, "flag", HISTO_FLAG_LINE);
1162 RNA_def_property_ui_text(prop, "Show Line", "Display lines rather than filled shapes");
1163 RNA_def_property_ui_icon(prop, ICON_GRAPH, 0);
1164}
1165
1166static void rna_def_scopes(BlenderRNA *brna)
1167{
1168 StructRNA *srna;
1169 PropertyRNA *prop;
1170
1171 static const EnumPropertyItem prop_wavefrm_mode_items[] = {
1172 {SCOPES_WAVEFRM_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
1173 {SCOPES_WAVEFRM_RGB_PARADE, "PARADE", ICON_COLOR, "Parade", ""},
1174 {SCOPES_WAVEFRM_YCC_601, "YCBCR601", ICON_COLOR, "YCbCr (ITU 601)", ""},
1175 {SCOPES_WAVEFRM_YCC_709, "YCBCR709", ICON_COLOR, "YCbCr (ITU 709)", ""},
1176 {SCOPES_WAVEFRM_YCC_JPEG, "YCBCRJPG", ICON_COLOR, "YCbCr (JPEG)", ""},
1177 {SCOPES_WAVEFRM_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
1178 {0, nullptr, 0, nullptr, nullptr},
1179 };
1180
1181 static const EnumPropertyItem prop_vecscope_mode_items[] = {
1182 {SCOPES_VECSCOPE_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
1183 {SCOPES_VECSCOPE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
1184 {0, nullptr, 0, nullptr, nullptr},
1185 };
1186
1187 srna = RNA_def_struct(brna, "Scopes", nullptr);
1188 RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image");
1189
1190 prop = RNA_def_property(srna, "use_full_resolution", PROP_BOOLEAN, PROP_NONE);
1191 RNA_def_property_boolean_sdna(prop, "Scopes", "sample_full", 1);
1192 RNA_def_property_ui_text(prop, "Full Sample", "Sample every pixel of the image");
1193 RNA_def_property_update(prop, 0, "rna_Scopes_update");
1194
1195 prop = RNA_def_property(srna, "accuracy", PROP_FLOAT, PROP_PERCENTAGE);
1196 RNA_def_property_float_sdna(prop, "Scopes", "accuracy");
1197 RNA_def_property_range(prop, 0.0, 100.0);
1198 RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1);
1200 prop, "Accuracy", "Proportion of original image source pixel lines to sample");
1201 RNA_def_property_update(prop, 0, "rna_Scopes_update");
1202
1203 prop = RNA_def_property(srna, "histogram", PROP_POINTER, PROP_NONE);
1204 RNA_def_property_pointer_sdna(prop, "Scopes", "hist");
1205 RNA_def_property_struct_type(prop, "Histogram");
1206 RNA_def_property_ui_text(prop, "Histogram", "Histogram for viewing image statistics");
1207
1208 prop = RNA_def_property(srna, "waveform_mode", PROP_ENUM, PROP_NONE);
1209 RNA_def_property_enum_sdna(prop, "Scopes", "wavefrm_mode");
1210 RNA_def_property_enum_items(prop, prop_wavefrm_mode_items);
1211 RNA_def_property_ui_text(prop, "Waveform Mode", "");
1212 RNA_def_property_update(prop, 0, "rna_Scopes_update");
1213
1214 prop = RNA_def_property(srna, "waveform_alpha", PROP_FLOAT, PROP_FACTOR);
1215 RNA_def_property_float_sdna(prop, "Scopes", "wavefrm_alpha");
1216 RNA_def_property_range(prop, 0, 1);
1217 RNA_def_property_ui_text(prop, "Waveform Opacity", "Opacity of the points");
1218
1219 prop = RNA_def_property(srna, "vectorscope_mode", PROP_ENUM, PROP_NONE);
1220 RNA_def_property_enum_sdna(prop, "Scopes", "vecscope_mode");
1221 RNA_def_property_enum_items(prop, prop_vecscope_mode_items);
1222 RNA_def_property_ui_text(prop, "Vectorscope Mode", "");
1223 RNA_def_property_update(prop, 0, "rna_Scopes_update");
1224
1225 prop = RNA_def_property(srna, "vectorscope_alpha", PROP_FLOAT, PROP_FACTOR);
1226 RNA_def_property_float_sdna(prop, "Scopes", "vecscope_alpha");
1227 RNA_def_property_range(prop, 0, 1);
1228 RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points");
1229}
1230
1232{
1233 StructRNA *srna;
1234 PropertyRNA *prop;
1235
1236 static const EnumPropertyItem display_device_items[] = {
1237 {0, "NONE", 0, "None", ""},
1238 {0, nullptr, 0, nullptr, nullptr},
1239 };
1240
1241 static const EnumPropertyItem look_items[] = {
1242 {0, "NONE", 0, "None", "Do not modify image in an artistic manner"},
1243 {0, nullptr, 0, nullptr, nullptr},
1244 };
1245
1246 static const EnumPropertyItem view_transform_items[] = {
1247 {0,
1248 "NONE",
1249 0,
1250 "None",
1251 "Do not perform any color transform on display, use old non-color managed technique for "
1252 "display"},
1253 {0, nullptr, 0, nullptr, nullptr},
1254 };
1255
1256 /* ** Display Settings ** */
1257 srna = RNA_def_struct(brna, "ColorManagedDisplaySettings", nullptr);
1258 RNA_def_struct_path_func(srna, "rna_ColorManagedDisplaySettings_path");
1260 srna, "ColorManagedDisplaySettings", "Color management specific to display device");
1261
1262 prop = RNA_def_property(srna, "display_device", PROP_ENUM, PROP_NONE);
1263 RNA_def_property_enum_items(prop, display_device_items);
1265 "rna_ColorManagedDisplaySettings_display_device_get",
1266 "rna_ColorManagedDisplaySettings_display_device_set",
1267 "rna_ColorManagedDisplaySettings_display_device_itemf");
1268 RNA_def_property_ui_text(prop, "Display Device", "Display device name");
1270 prop, NC_WINDOW, "rna_ColorManagedDisplaySettings_display_device_update");
1271
1272 /* ** View Settings ** */
1273 srna = RNA_def_struct(brna, "ColorManagedViewSettings", nullptr);
1274 RNA_def_struct_path_func(srna, "rna_ColorManagedViewSettings_path");
1276 "ColorManagedViewSettings",
1277 "Color management settings used for displaying images on the display");
1278
1279 prop = RNA_def_property(srna, "look", PROP_ENUM, PROP_NONE);
1280 RNA_def_property_enum_items(prop, look_items);
1282 "rna_ColorManagedViewSettings_look_get",
1283 "rna_ColorManagedViewSettings_look_set",
1284 "rna_ColorManagedViewSettings_look_itemf");
1286 prop, "Look", "Additional transform applied before view transform for artistic needs");
1287 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1288
1289 prop = RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE);
1290 RNA_def_property_enum_items(prop, view_transform_items);
1292 "rna_ColorManagedViewSettings_view_transform_get",
1293 "rna_ColorManagedViewSettings_view_transform_set",
1294 "rna_ColorManagedViewSettings_view_transform_itemf");
1296 prop, "View Transform", "View used when converting image to a display space");
1297 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1298
1299 prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
1300 RNA_def_property_float_sdna(prop, nullptr, "exposure");
1302 RNA_def_property_range(prop, -32.0f, 32.0f);
1303 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 1, 3);
1304 RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied before display transform");
1305 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1306
1307 prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_FACTOR);
1308 RNA_def_property_float_sdna(prop, nullptr, "gamma");
1310 RNA_def_property_range(prop, 0.0f, 5.0f);
1312 prop, "Gamma", "Amount of gamma modification applied after display transform");
1313 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1314
1315 prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE);
1316 RNA_def_property_pointer_sdna(prop, nullptr, "curve_mapping");
1317 RNA_def_property_ui_text(prop, "Curve", "Color curve mapping applied before display transform");
1318 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1319
1320 prop = RNA_def_property(srna, "use_curve_mapping", PROP_BOOLEAN, PROP_NONE);
1322 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ColorManagedViewSettings_use_curves_set");
1323 RNA_def_property_ui_text(prop, "Use Curves", "Use RGB curved for pre-display transformation");
1324 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1325
1326 prop = RNA_def_property(srna, "use_white_balance", PROP_BOOLEAN, PROP_NONE);
1329 prop, "Use White Balance", "Perform chromatic adaption from a different white point");
1330 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1331
1332 prop = RNA_def_property(srna, "white_balance_temperature", PROP_FLOAT, PROP_COLOR_TEMPERATURE);
1333 RNA_def_property_float_sdna(prop, nullptr, "temperature");
1334 RNA_def_property_float_default(prop, 6500.0f);
1335 RNA_def_property_range(prop, 1800.0f, 100000.0f);
1336 RNA_def_property_ui_range(prop, 2000.0f, 11000.0f, 100, 0);
1337 RNA_def_property_ui_text(prop, "Temperature", "Color temperature of the scene's white point");
1338 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1339
1340 prop = RNA_def_property(srna, "white_balance_tint", PROP_FLOAT, PROP_FACTOR);
1341 RNA_def_property_float_sdna(prop, nullptr, "tint");
1342 RNA_def_property_float_default(prop, 10.0f);
1343 RNA_def_property_range(prop, -500.0f, 500.0f);
1344 RNA_def_property_ui_range(prop, -150.0f, 150.0f, 1, 1);
1346 prop, "Tint", "Color tint of the scene's white point (the default of 10 matches daylight)");
1347 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1348
1349 prop = RNA_def_property(srna, "white_balance_whitepoint", PROP_FLOAT, PROP_COLOR);
1350 RNA_def_property_array(prop, 3);
1352 "rna_ColorManagedViewSettings_whitepoint_get",
1353 "rna_ColorManagedViewSettings_whitepoint_set",
1354 nullptr);
1356 "White Point",
1357 "The color which gets mapped to white "
1358 "(automatically converted to/from temperature and tint)");
1359 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1360
1361 prop = RNA_def_property(srna, "use_hdr_view", PROP_BOOLEAN, PROP_NONE);
1364 prop,
1365 "High Dynamic Range",
1366 "Enable high dynamic range display in rendered viewport, uncapping display brightness. This "
1367 "requires a monitor with HDR support and a view transform designed for HDR. "
1368 "'Filmic' and 'AgX' do not generate HDR colors.");
1369 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
1370
1371 /* ** Color-space ** */
1372 srna = RNA_def_struct(brna, "ColorManagedInputColorspaceSettings", nullptr);
1373 RNA_def_struct_path_func(srna, "rna_ColorManagedInputColorspaceSettings_path");
1375 srna, "ColorManagedInputColorspaceSettings", "Input color space settings");
1376
1377 prop = RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE);
1382 "rna_ColorManagedColorspaceSettings_colorspace_get",
1383 "rna_ColorManagedColorspaceSettings_colorspace_set",
1384 "rna_ColorManagedColorspaceSettings_colorspace_itemf");
1386 prop,
1387 "Input Color Space",
1388 "Color space in the image file, to convert to and from when saving and loading the image");
1389 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
1390
1391 prop = RNA_def_property(srna, "is_data", PROP_BOOLEAN, PROP_NONE);
1394 "rna_ColorManagedColorspaceSettings_is_data_get",
1395 "rna_ColorManagedColorspaceSettings_is_data_set");
1397 prop,
1398 "Is Data",
1399 "Treat image as non-color data without color management, like normal or displacement maps");
1400 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
1401
1402 //
1403 srna = RNA_def_struct(brna, "ColorManagedSequencerColorspaceSettings", nullptr);
1404 RNA_def_struct_path_func(srna, "rna_ColorManagedSequencerColorspaceSettings_path");
1406 srna, "ColorManagedSequencerColorspaceSettings", "Input color space settings");
1407
1408 prop = RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE);
1412 "rna_ColorManagedColorspaceSettings_colorspace_get",
1413 "rna_ColorManagedColorspaceSettings_colorspace_set",
1414 "rna_ColorManagedColorspaceSettings_colorspace_itemf");
1415 RNA_def_property_ui_text(prop, "Color Space", "Color space that the sequencer operates in");
1416 RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
1417}
1418
1420{
1422 rna_def_curvemap(brna);
1425 rna_def_color_ramp(brna);
1426 rna_def_histogram(brna);
1427 rna_def_scopes(brna);
1428 rna_def_colormanage(brna);
1429}
1430
1431#endif
#define MAXCOLORBAND
CBData * BKE_colorband_element_add(ColorBand *coba, float position)
Definition colorband.cc:606
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
Definition colorband.cc:396
bool BKE_colorband_element_remove(ColorBand *coba, int index)
Definition colorband.cc:632
void BKE_curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
bool BKE_curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
void BKE_curvemapping_init(CurveMapping *cumap)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:90
void BKE_curvemapping_changed(CurveMapping *cumap, bool rem_doubles)
float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, float value)
Scene * CTX_data_scene(const bContext *C)
#define IMA_SIGNAL_COLORMANAGE
Definition BKE_image.hh:143
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
Blender kernel freestyle line style functionality.
void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase)
std::optional< std::string > BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, const struct ColorBand *color_ramp)
#define CMP_NODE_VALTORGB
Definition BKE_node.hh:1016
#define SH_NODE_VALTORGB
Definition BKE_node.hh:894
#define TEX_NODE_VALTORGB
Definition BKE_node.hh:1142
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:496
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define ELEM(...)
#define STREQ(a, b)
#define BLT_I18NCONTEXT_COLOR
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1110
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1085
@ ID_MC
@ ID_TE
@ ID_IM
@ ID_NT
@ ID_SCE
@ ID_LS
@ ID_MA
@ ID_OB
@ ID_PA
#define CM_TOT
@ CUMA_EXTEND_EXTRAPOLATE
@ CUMA_DO_CLIP
@ CUMA_USE_WRAPPING
@ HISTO_FLAG_LINE
@ CUMA_HANDLE_AUTO_ANIM
@ CUMA_SELECT
@ CUMA_HANDLE_VECTOR
@ COLORMANAGE_VIEW_USE_WHITE_BALANCE
@ COLORMANAGE_VIEW_USE_CURVES
@ COLORMANAGE_VIEW_USE_HDR
struct ColorManagedColorspaceSettings ColorManagedColorspaceSettings
@ SCOPES_VECSCOPE_LUMA
@ SCOPES_VECSCOPE_RGB
@ CURVE_TONE_STANDARD
@ CURVE_TONE_FILMLIKE
@ HISTO_MODE_B
@ HISTO_MODE_G
@ HISTO_MODE_LUMA
@ HISTO_MODE_RGB
@ HISTO_MODE_ALPHA
@ HISTO_MODE_R
@ SCOPES_WAVEFRM_YCC_JPEG
@ SCOPES_WAVEFRM_RGB
@ SCOPES_WAVEFRM_YCC_601
@ SCOPES_WAVEFRM_YCC_709
@ SCOPES_WAVEFRM_LUMA
@ SCOPES_WAVEFRM_RGB_PARADE
Object is a sort of wrapper for general info.
struct Sequence Sequence
@ COLBAND_BLEND_RGB
@ COLBAND_BLEND_HSL
@ COLBAND_BLEND_HSV
@ COLBAND_HUE_FAR
@ COLBAND_HUE_CW
@ COLBAND_HUE_NEAR
@ COLBAND_HUE_CCW
@ COLBAND_INTERP_LINEAR
@ COLBAND_INTERP_CONSTANT
@ COLBAND_INTERP_B_SPLINE
@ COLBAND_INTERP_EASE
@ COLBAND_INTERP_CARDINAL
void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ntree)
Definition node_edit.cc:492
static AppView * view
@ COLOR_ROLE_DATA
void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem)
bool IMB_colormanagement_set_whitepoint(const float whitepoint[3], float &temperature, float &tint)
const char * IMB_colormanagement_colorspace_get_indexed_name(int index)
void IMB_colormanagement_view_items_add(EnumPropertyItem **items, int *totitem, const char *display_name)
const char * IMB_colormanagement_look_get_indexed_name(int index)
const char * IMB_colormanagement_look_validate_for_view(const char *view_name, const char *look_name)
int IMB_colormanagement_view_get_named_index(const char *name)
void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings)
void IMB_colormanagement_get_whitepoint(const float temperature, const float tint, float whitepoint[3])
const char * IMB_colormanagement_role_colorspace_name_get(int role)
const char * IMB_colormanagement_display_get_indexed_name(int index)
int IMB_colormanagement_look_get_named_index(const char *name)
const char * IMB_colormanagement_view_get_indexed_name(int index)
void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem)
int IMB_colormanagement_colorspace_get_named_index(const char *name)
void IMB_colormanagement_look_items_add(EnumPropertyItem **items, int *totitem, const char *view_name)
int IMB_colormanagement_display_get_named_index(const char *name)
void IMB_free_anim(ImBufAnim *anim)
Definition anim_movie.cc:60
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
#define RNA_POINTER_INVALIDATE(ptr)
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ENUM_NO_CONTEXT
Definition RNA_types.hh:319
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_XYZ
Definition RNA_types.hh:172
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:193
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_PERCENTAGE
Definition RNA_types.hh:153
@ PROP_FACTOR
Definition RNA_types.hh:154
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:404
#define NC_WINDOW
Definition WM_types.hh:342
#define NC_NODE
Definition WM_types.hh:361
#define NC_LINESTYLE
Definition WM_types.hh:367
#define ND_DISPLAY
Definition WM_types.hh:458
#define NC_MOVIECLIP
Definition WM_types.hh:364
#define NC_SCENE
Definition WM_types.hh:345
#define NA_EDITED
Definition WM_types.hh:550
#define ND_PARTICLE
Definition WM_types.hh:432
#define NC_MATERIAL
Definition WM_types.hh:347
#define NC_IMAGE
Definition WM_types.hh:351
#define NC_TEXTURE
Definition WM_types.hh:348
#define NC_OBJECT
Definition WM_types.hh:346
#define ND_SHADING_DRAW
Definition WM_types.hh:445
ATTR_WARN_UNUSED_RESULT const void * element
int len
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void SEQ_cache_cleanup(Scene *scene)
#define GS(x)
Definition iris.cc:202
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data)
Definition iterator.cc:43
void index(const bNode &, void *r_value)
void thumbnail_cache_clear(Scene *scene)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)
static void rna_def_curvemap(BlenderRNA *brna)
Definition rna_color.cc:825
static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_color.cc:788
void RNA_def_color(BlenderRNA *brna)
static void rna_def_curvemappoint(BlenderRNA *brna)
Definition rna_color.cc:758
static void rna_def_color_ramp(BlenderRNA *brna)
static void rna_def_curvemapping(BlenderRNA *brna)
Definition rna_color.cc:840
static void rna_def_histogram(BlenderRNA *brna)
static void rna_def_color_ramp_element(BlenderRNA *brna)
Definition rna_color.cc:976
static void rna_def_scopes(BlenderRNA *brna)
static void rna_def_colormanage(BlenderRNA *brna)
const EnumPropertyItem rna_enum_color_space_convert_default_items[]
Definition rna_color.cc:28
static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
static const EnumPropertyItem prop_handle_type_items[]
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
std::optional< std::string > RNA_path_from_ID_to_struct(const PointerRNA *ptr)
Definition rna_path.cc:1007
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:525
#define min(a, b)
Definition sort.c:32
#define FLT_MAX
Definition stdcycles.h:14
void SEQ_relations_invalidate_cache_raw(Scene *scene, Sequence *seq)
void SEQ_relations_sequence_free_anim(Sequence *seq)
void SEQ_relations_invalidate_scene_strips(Main *bmain, Scene *scene_target)
void SEQ_relations_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target)
CBData data[32]
CurveMapPoint * table
CurveMap cm[4]
ListBase seqbase
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
void * data
struct LinkData * next
void * first
ListBase materials
Definition BKE_main.hh:216
void * data
Definition RNA_types.hh:42
ColorManagedViewSettings view_settings
struct Editing * ed
ColorManagedColorspaceSettings sequencer_colorspace_settings
ColorManagedDisplaySettings display_settings
struct ImBufAnim * anim
ColorManagedColorspaceSettings colorspace_settings
StripProxy * proxy
ListBase nodes
struct bNode * next
void * storage
int16_t type
float max
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126