More options for the blur node filter size. This can now be pixel based or relative...
authorLukas Toenne <lukas.toenne@googlemail.com>
Thu, 10 Feb 2011 18:54:49 +0000 (18:54 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Thu, 10 Feb 2011 18:54:49 +0000 (18:54 +0000)
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/nodes/intern/CMP_nodes/CMP_blur.c

index 668a7f338f2b9808ce078c76086c48c82a2aacf5..42b5835c6df83f023f0a199ae73b6df08c14a102 100644 (file)
@@ -548,15 +548,23 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point
                uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NULL);
        }
        
-       uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NULL);
+       uiItemR(col, ptr, "size_type", 0, NULL, ICON_NULL);
        col= uiLayoutColumn(layout, 1);
-       if (RNA_boolean_get(ptr, "use_relative")) {
-               uiItemR(col, ptr, "factor_x", 0, "X", ICON_NULL);
-               uiItemR(col, ptr, "factor_y", 0, "Y", ICON_NULL);
-       }
-       else {
+       switch (RNA_enum_get(ptr, "size_type")) {
+       case CMP_NODE_BLUR_SIZE_PIXEL:
                uiItemR(col, ptr, "size_x", 0, "X", ICON_NULL);
                uiItemR(col, ptr, "size_y", 0, "Y", ICON_NULL);
+               break;
+       case CMP_NODE_BLUR_SIZE_WIDTH:
+               uiItemR(col, ptr, "factor_x", 0, "X", ICON_NULL);
+               break;
+       case CMP_NODE_BLUR_SIZE_HEIGHT:
+               uiItemR(col, ptr, "factor_y", 0, "Y", ICON_NULL);
+               break;
+       case CMP_NODE_BLUR_SIZE_BOTH:
+               uiItemR(col, ptr, "factor_x", 0, "X", ICON_NULL);
+               uiItemR(col, ptr, "factor_y", 0, "Y", ICON_NULL);
+               break;
        }
 }
 
index 0d7edbbce97418a067214c74416f55c0a0c0955e..85523c3369f3ad6c71bc1c541571c019158840b3 100644 (file)
@@ -216,7 +216,7 @@ typedef struct NodeImageAnim {
 
 typedef struct NodeBlurData {
        short sizex, sizey;
-       short samples, maxspeed, minspeed, relative;
+       short samples, maxspeed, minspeed, size_type;
        float fac, percentx, percenty;
        short filtertype;
        char bokeh, gamma;
@@ -336,4 +336,10 @@ typedef struct TexNodeOutput {
 #define CMP_NODE_CHANNEL_MATTE_CS_YUV  3
 #define CMP_NODE_CHANNEL_MATTE_CS_YCC  4
 
+/* comp blur relative filter size */
+#define CMP_NODE_BLUR_SIZE_PIXEL               0
+#define CMP_NODE_BLUR_SIZE_WIDTH               1
+#define CMP_NODE_BLUR_SIZE_HEIGHT              2
+#define CMP_NODE_BLUR_SIZE_BOTH                        3
+
 #endif
index 8ce2489f2860e48ae1bd44aa2cc3d62bbc94034f..7c8d57b3191928b0f63d5d1737aa6701c61a455b 100644 (file)
@@ -1029,6 +1029,13 @@ static void def_cmp_blur(StructRNA *srna)
                {R_FILTER_MITCH,      "MITCH",      0, "Mitch",         ""},
                {0, NULL, 0, NULL, NULL}};
 
+       static EnumPropertyItem size_type_items[] = {
+               {CMP_NODE_BLUR_SIZE_PIXEL,   "PIXEL",       0, "Pixel",          ""},
+               {CMP_NODE_BLUR_SIZE_WIDTH,   "WIDTH",       0, "Width",          ""},
+               {CMP_NODE_BLUR_SIZE_HEIGHT,  "HEIGHT",      0, "Height",         ""},
+               {CMP_NODE_BLUR_SIZE_BOTH,    "BOTH",        0, "Both",           ""},
+               {0, NULL, 0, NULL, NULL}};
+
        RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage");
        
        prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
@@ -1043,9 +1050,10 @@ static void def_cmp_blur(StructRNA *srna)
        RNA_def_property_ui_text(prop, "Size Y", "");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
-       prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "relative", 1);
-       RNA_def_property_ui_text(prop, "Relative", "Use relative (percent) values to define blur radius");
+       prop = RNA_def_property(srna, "size_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "size_type");
+       RNA_def_property_enum_items(prop, size_type_items);
+       RNA_def_property_ui_text(prop, "Size Type", "Mode of filter size calculation");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
        
        prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
@@ -1054,15 +1062,15 @@ static void def_cmp_blur(StructRNA *srna)
        RNA_def_property_ui_text(prop, "Factor", "");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
        
-       prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_NONE);
+       prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_PERCENTAGE);
        RNA_def_property_float_sdna(prop, NULL, "percentx");
-       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_range(prop, 0.0f, 100.0f);
        RNA_def_property_ui_text(prop, "Relative Size X", "");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
        
-       prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_NONE);
+       prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_PERCENTAGE);
        RNA_def_property_float_sdna(prop, NULL, "percenty");
-       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_range(prop, 0.0f, 100.0f);
        RNA_def_property_ui_text(prop, "Relative Size Y", "");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
        
index 78a27bc5b16248ee1f33e801e086459647a2345d..d92ee6924c9f4b3e3f4fc89d2c971c42045e625e 100644 (file)
@@ -577,9 +577,17 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
        
        if(out[0]->hasoutput==0) return;
        
-       if(nbd->relative) {
-               nbd->sizex= (int)(nbd->percentx*nbd->image_in_width);
-               nbd->sizey= (int)(nbd->percenty*nbd->image_in_height);
+       switch (nbd->size_type) {
+       case CMP_NODE_BLUR_SIZE_WIDTH:
+               nbd->sizex= nbd->sizey= (int)(nbd->percentx*0.01f*nbd->image_in_width);
+               break;
+       case CMP_NODE_BLUR_SIZE_HEIGHT:
+               nbd->sizex= nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+               break;
+       case CMP_NODE_BLUR_SIZE_BOTH:
+               nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
+               nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+               break;
        }
 
        if (nbd->sizex==0 && nbd->sizey==0) {