Multi-View and Stereo 3D
[blender-staging.git] / source / blender / makesrna / intern / rna_color.c
index a55be8e285facb2cd3523ea8e4ca2dc2c178b767..0c871317d04bb0fecea090a64364dd888042bb0f 100644 (file)
@@ -46,6 +46,8 @@
 #include "DNA_material_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_node_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
 #include "DNA_sequence_types.h"
 
 #include "MEM_guardedalloc.h"
@@ -90,7 +92,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
        if (value) cumap->flag |= CUMA_DO_CLIP;
        else cumap->flag &= ~CUMA_DO_CLIP;
 
-       curvemapping_changed(cumap, FALSE);
+       curvemapping_changed(cumap, false);
 }
 
 static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
@@ -176,7 +178,7 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
                                char *node_path;
                                
                                for (node = ntree->nodes.first; node; node = node->next) {
-                                       if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
+                                       if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
                                                if (node->storage == ptr->data) {
                                                        /* all node color ramp properties called 'color_ramp'
                                                         * prepend path from ID to the node
@@ -193,7 +195,7 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
                        
                        case ID_LS:
                        {
-                               char *path = BKE_path_from_ID_to_color_ramp((FreestyleLineStyle *)id, (ColorBand *)ptr->data);
+                               char *path = BKE_linestyle_path_to_color_ramp((FreestyleLineStyle *)id, (ColorBand *)ptr->data);
                                if (path)
                                        return path;
                                break;
@@ -265,7 +267,7 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
                                bNode *node;
                                
                                for (node = ntree->nodes.first; node; node = node->next) {
-                                       if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
+                                       if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
                                                RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr);
                                                COLRAMP_GETPATH;
                                        }
@@ -277,7 +279,7 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
                                ListBase listbase;
                                LinkData *link;
 
-                               BKE_list_modifier_color_ramps((FreestyleLineStyle *)id, &listbase);
+                               BKE_linestyle_modifier_list_color_ramps((FreestyleLineStyle *)id, &listbase);
                                for (link = (LinkData *)listbase.first; link; link = link->next) {
                                        RNA_pointer_create(id, &RNA_ColorRamp, link->data, &ramp_ptr);
                                        COLRAMP_GETPATH;
@@ -324,7 +326,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
                                bNode *node;
 
                                for (node = ntree->nodes.first; node; node = node->next) {
-                                       if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
+                                       if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
                                                ED_node_tag_update_nodetree(bmain, ntree);
                                        }
                                }
@@ -345,6 +347,13 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
                                WM_main_add_notifier(NC_LINESTYLE, linestyle);
                                break;
                        }
+                       case ID_PA:
+                       {
+                               ParticleSettings *part = ptr->id.data;
+                               
+                               DAG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+                               WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, part);
+                       }
                        default:
                                break;
                }
@@ -370,7 +379,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *repo
 {
        CBData *element = element_ptr->data;
        int index = (int)(element - coba->data);
-       if (colorband_element_remove(coba, index) == FALSE) {
+       if (colorband_element_remove(coba, index) == false) {
                BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
                return;
        }
@@ -378,10 +387,10 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *repo
        RNA_POINTER_INVALIDATE(element_ptr);
 }
 
-void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
+static void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
 {
        CurveMapPoint *point = point_ptr->data;
-       if (curvemap_remove_point(cuma, point) == FALSE) {
+       if (curvemap_remove_point(cuma, point) == false) {
                BKE_report(reports, RPT_ERROR, "Unable to remove curve point");
                return;
        }
@@ -438,6 +447,7 @@ static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(b
 
                IMB_colormanagement_validate_settings(&scene->display_settings, &scene->view_settings);
 
+               DAG_id_tag_update(id, 0);
                WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
        }
 }
@@ -596,13 +606,13 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
                if (scene->ed) {
                        ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *) ptr->data;
                        Sequence *seq;
-                       int seq_found = FALSE;
+                       bool seq_found = false;
 
                        if (&scene->sequencer_colorspace_settings != colorspace_settings) {
                                SEQ_BEGIN(scene->ed, seq);
                                {
                                        if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) {
-                                               seq_found = TRUE;
+                                               seq_found = true;
                                                break;
                                        }
                                }
@@ -610,9 +620,11 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
                        }
 
                        if (seq_found) {
-                               if (seq->anim) {
-                                       IMB_free_anim(seq->anim);
-                                       seq->anim = NULL;
+                               BKE_sequence_free_anim(seq);
+
+                               if (seq->strip->proxy && seq->strip->proxy->anim) {
+                                       IMB_free_anim(seq->strip->proxy->anim);
+                                       seq->strip->proxy->anim = NULL;
                                }
 
                                BKE_sequence_invalidate_cache(scene, seq);
@@ -621,10 +633,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
                        else {
                                SEQ_BEGIN(scene->ed, seq);
                                {
-                                       if (seq->anim) {
-                                               IMB_free_anim(seq->anim);
-                                               seq->anim = NULL;
-                                       }
+                                       BKE_sequence_free_anim(seq);
                                }
                                SEQ_END;
 
@@ -816,13 +825,15 @@ static void rna_def_curvemapping(BlenderRNA *brna)
 
        prop = RNA_def_property(srna, "black_level", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_float_sdna(prop, NULL, "black");
-       RNA_def_property_range(prop, -1000.0f, 1000.0f);
+       RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+       RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 1, 3);
        RNA_def_property_ui_text(prop, "Black Level", "For RGB curves, the color that black is mapped to");
        RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_black_level_set", NULL);
 
        prop = RNA_def_property(srna, "white_level", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_float_sdna(prop, NULL, "white");
-       RNA_def_property_range(prop, -1000.0f, 1000.0f);
+       RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+       RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 1, 3);
        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);
 
@@ -848,7 +859,12 @@ static void rna_def_color_ramp_element(BlenderRNA *brna)
        RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Color", "Set color of selected color stop");
        RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
-       
+
+       prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_COLOR);
+       RNA_def_property_float_sdna(prop, NULL, "a");
+       RNA_def_property_ui_text(prop, "Alpha", "Set alpha of selected color stop");
+       RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
+
        prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "pos");
        RNA_def_property_range(prop, 0, 1);
@@ -893,14 +909,29 @@ static void rna_def_color_ramp(BlenderRNA *brna)
        FunctionRNA *func;
 
        static EnumPropertyItem prop_interpolation_items[] = {
-               {1, "EASE", 0, "Ease", ""},
-               {3, "CARDINAL", 0, "Cardinal", ""},
-               {0, "LINEAR", 0, "Linear", ""},
-               {2, "B_SPLINE", 0, "B-Spline", ""},
-               {4, "CONSTANT", 0, "Constant", ""},
+               {COLBAND_INTERP_EASE, "EASE", 0, "Ease", ""},
+               {COLBAND_INTERP_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
+               {COLBAND_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
+               {COLBAND_INTERP_B_SPLINE, "B_SPLINE", 0, "B-Spline", ""},
+               {COLBAND_INTERP_CONSTANT, "CONSTANT", 0, "Constant", ""},
                {0, NULL, 0, NULL, NULL}
        };
        
+       static EnumPropertyItem prop_mode_items[] = {
+               {COLBAND_BLEND_RGB, "RGB", 0, "RGB", ""},
+               {COLBAND_BLEND_HSV, "HSV", 0, "HSV", ""},
+               {COLBAND_BLEND_HSL, "HSL", 0, "HSL", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       static EnumPropertyItem prop_hsv_items[] = {
+               {COLBAND_HUE_NEAR, "NEAR", 0, "Near", ""},
+               {COLBAND_HUE_FAR, "FAR", 0, "Far", ""},
+               {COLBAND_HUE_CW, "CW", 0, "Clockwise", ""},
+               {COLBAND_HUE_CCW, "CCW", 0, "Counter-Clockwise", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "ColorRamp", NULL);
        RNA_def_struct_sdna(srna, "ColorBand");
        RNA_def_struct_path_func(srna, "rna_ColorRamp_path");
@@ -919,6 +950,18 @@ static void rna_def_color_ramp(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Interpolation", "Set interpolation between color stops");
        RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
 
+       prop = RNA_def_property(srna, "hue_interpolation", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "ipotype_hue");
+       RNA_def_property_enum_items(prop, prop_hsv_items);
+       RNA_def_property_ui_text(prop, "Color Interpolation", "Set color interpolation");
+       RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
+
+       prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "color_mode");
+       RNA_def_property_enum_items(prop, prop_mode_items);
+       RNA_def_property_ui_text(prop, "Color Mode", "Set color mode to use for interpolation");
+       RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
+
 #if 0 /* use len(elements) */
        prop = RNA_def_property(srna, "total", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "tot");