Revision: 58767
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58767
Author:   psy-fi
Date:     2013-07-31 13:58:55 +0000 (Wed, 31 Jul 2013)
Log Message:
-----------
UI for color ramps that will be used as gradient source for colors
during stroking and gradient filling. Still not functional.

Modified Paths:
--------------
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
    
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
    branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py        
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py        
2013-07-31 13:58:55 UTC (rev 58767)
@@ -712,6 +712,10 @@
                 col = layout.column(align=True)
                 col.prop(brush, "color", text="")
                 col.prop(brush, "secondary_color", text="")
+                col.prop(brush, "use_gradient")
+                if brush.use_gradient:
+                    col.prop(brush, "gradient_source")
+                    layout.template_color_ramp(brush, "gradient", expand=True)
                 col = layout.column()
                 col.template_ID(toolsettings, "palette", new="palette.new")
                 if toolsettings.palette:

Modified: 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py   
    2013-07-31 13:56:46 UTC (rev 58766)
+++ 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py   
    2013-07-31 13:58:55 UTC (rev 58767)
@@ -689,6 +689,10 @@
                 col = layout.column(align=True)
                 col.prop(brush, "color", text="")
                 col.prop(brush, "secondary_color", text="")
+                col.prop(brush, "use_gradient")
+                if brush.use_gradient:
+                    col.prop(brush, "gradient_source")
+                    layout.template_color_ramp(brush, "gradient", expand=True)
                 col = layout.column()
                 col.template_ID(settings, "palette", new="palette.new")
                 if settings.palette:

Modified: branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c    
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c    
2013-07-31 13:58:55 UTC (rev 58767)
@@ -198,6 +198,9 @@
        BKE_previewimg_free(&(brush->preview));
 
        curvemapping_free(brush->curve);
+
+       if (brush->gradient)
+               MEM_freeN(brush->gradient);
 }
 
 static void extern_local_brush(Brush *brush)

Modified: branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c 
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c 
2013-07-31 13:58:55 UTC (rev 58767)
@@ -1830,6 +1830,8 @@
 
        /* fallof curve */
        brush->curve = newdataadr(fd, brush->curve);
+       brush->gradient = newdataadr(fd, brush->gradient);
+
        if (brush->curve)
                direct_link_curvemapping(fd, brush->curve);
        else

Modified: branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c        
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c        
2013-07-31 13:58:55 UTC (rev 58767)
@@ -2851,6 +2851,8 @@
                        
                        if (brush->curve)
                                write_curvemapping(wd, brush->curve);
+                       if (brush->curve)
+                               writestruct(wd, DATA, "ColorBand", 1, 
brush->gradient);
                }
        }
 }

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h   
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h   
2013-07-31 13:58:55 UTC (rev 58767)
@@ -62,6 +62,7 @@
 
        struct ImBuf *icon_imbuf;
        PreviewImage *preview;
+       struct ColorBand *gradient;     /* color gradient */
        char icon_filepath[1024]; /* 1024 = FILE_MAX */
 
        float normal_weight;
@@ -90,7 +91,7 @@
        float plane_offset;     /* offset for plane brushes (clay, flatten, 
fill, scrape) */
 
        float gravity_factor;   /* gravity factor for sculpting */
-       int pad;
+       int gradient_source;    /* source for color gradient application */
 
        char sculpt_tool;       /* active sculpt tool */
        char vertexpaint_tool;  /* active vertex/weight paint blend mode 
(poorly named) */
@@ -141,6 +142,12 @@
        int pad;
 } Palette;
 
+/* Brush.gradient_source */
+typedef enum BrushGradientSource {
+       BRUSH_GRADIENT_PRESSURE = 0, /* gradient from pressure */
+       BRUSH_GRADIENT_SPACING = 1 /* gradient from spacing */
+} BrushGradientSource;
+
 /* Brush.flag */
 typedef enum BrushFlags {
        BRUSH_AIRBRUSH = (1 << 0),
@@ -163,7 +170,7 @@
        BRUSH_SPACE_ATTEN = (1 << 18),
        BRUSH_ADAPTIVE_SPACE = (1 << 19),
        BRUSH_LOCK_SIZE = (1 << 20),
-//     BRUSH_TEXTURE_OVERLAY = (1 << 21), /* obsolete, use overlay_flags |= 
BRUSH_OVERLAY_PRIMARY instead */
+       BRUSH_USE_GRADIENT = (1 << 21),
        BRUSH_EDGE_TO_EDGE = (1 << 22),
        BRUSH_DRAG_DOT = (1 << 23),
        BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c  
2013-07-31 13:56:46 UTC (rev 58766)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c  
2013-07-31 13:58:55 UTC (rev 58767)
@@ -401,6 +401,17 @@
        brush->size = value;
 }
 
+static void rna_Brush_use_gradient_set(PointerRNA *ptr, int value)
+{
+       Brush *br = (Brush *)ptr->data;
+
+       if (value) br->flag |= BRUSH_USE_GRADIENT;
+       else br->flag &= ~BRUSH_USE_GRADIENT;
+
+       if ((br->flag & BRUSH_USE_GRADIENT) && br->gradient == NULL)
+               br->gradient = add_colorband(false);
+}
+
 static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
 {
        Brush *brush = ptr->data;
@@ -724,6 +735,12 @@
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem brush_gradient_items[] = {
+               {BRUSH_GRADIENT_PRESSURE, "PRESSURE", 0, "Pressure", ""},
+               {BRUSH_GRADIENT_SPACING, "SPACING", 0, "Spacing", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        static EnumPropertyItem brush_mask_pressure_items[] = {
                {0, "NONE", 0, "Off", ""},
                {BRUSH_MASK_PRESSURE_RAMP, "RAMP", ICON_STYLUS_PRESSURE, 
"Ramp", ""},
@@ -996,7 +1013,13 @@
        RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
        RNA_def_property_ui_text(prop, "Size Pressure", "Enable tablet pressure 
sensitivity for size");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
-       
+
+       prop = RNA_def_property(srna, "use_gradient", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_USE_GRADIENT);
+       RNA_def_property_boolean_funcs(prop, NULL, 
"rna_Brush_use_gradient_set");
+       RNA_def_property_ui_text(prop, "Use Gradient", "Use Gradient by 
utilizing a sampling method");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
+
        prop = RNA_def_property(srna, "use_pressure_jitter", PROP_BOOLEAN, 
PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", 
BRUSH_JITTER_PRESSURE);
        RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
@@ -1117,6 +1140,18 @@
        RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+       prop = RNA_def_property(srna, "gradient", PROP_POINTER, 
PROP_NEVER_NULL);
+       RNA_def_property_pointer_sdna(prop, NULL, "gradient");
+       RNA_def_property_struct_type(prop, "ColorRamp");
+       RNA_def_property_ui_text(prop, "Gradient", "");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
+
+       /* gradient source */
+       prop = RNA_def_property(srna, "gradient_source", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, brush_gradient_items);
+       RNA_def_property_ui_text(prop, "Gradient Source", "");
+       RNA_def_property_update(prop, 0, "rna_Brush_update");
+
        /* overlay flags */
        prop = RNA_def_property(srna, "use_primary_overlay", PROP_BOOLEAN, 
PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", 
BRUSH_OVERLAY_PRIMARY);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to