[gnome-shell] [StShadow] Add support for spread radius



commit 50c453c54dbfff3e2a790682a0a342c94f375dd3
Author: Florian Müllner <fmuellner src gnome org>
Date:   Fri Mar 19 11:34:32 2010 +0100

    [StShadow] Add support for spread radius
    
    The (optional) spread radius allows to make the shadow bigger without
    enlarging the blur value. Mozilla supports this parameter for the
    -moz-box-shadow property.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=613832

 src/st/st-shadow.c             |    5 ++++-
 src/st/st-shadow.h             |    6 +++++-
 src/st/st-theme-node-drawing.c |   12 ++++++++----
 src/st/st-theme-node.c         |   12 +++++++++++-
 4 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/src/st/st-shadow.c b/src/st/st-shadow.c
index 0f11a6c..5add5c7 100644
--- a/src/st/st-shadow.c
+++ b/src/st/st-shadow.c
@@ -19,6 +19,7 @@
  * @xoffset: horizontal offset
  * @yoffset: vertical offset
  * @blur: blur radius
+ * @spread: spread radius
  *
  * Creates a new #StShadow
  *
@@ -28,7 +29,8 @@ StShadow *
 st_shadow_new (ClutterColor *color,
                gdouble       xoffset,
                gdouble       yoffset,
-               gdouble       blur)
+               gdouble       blur,
+               gdouble       spread)
 {
   StShadow *shadow;
 
@@ -38,6 +40,7 @@ st_shadow_new (ClutterColor *color,
   shadow->xoffset = xoffset;
   shadow->yoffset = yoffset;
   shadow->blur    = blur;
+  shadow->spread  = spread;
 
   return shadow;
 }
diff --git a/src/st/st-shadow.h b/src/st/st-shadow.h
index cf5bffb..85fabef 100644
--- a/src/st/st-shadow.h
+++ b/src/st/st-shadow.h
@@ -18,6 +18,8 @@ typedef struct _StShadow StShadow;
  * @yoffset: vertical offset - positive values mean placement below, negative
  *           values placement above the element.
  * @blur: shadow's blur radius - a value of 0.0 will result in a hard shadow.
+ * @spread: shadow's spread radius - grow the shadow without enlarging the
+ *           blur.
  *
  * Attributes of the -st-shadow property.
  */
@@ -26,6 +28,7 @@ struct _StShadow {
     gdouble      xoffset;
     gdouble      yoffset;
     gdouble      blur;
+    gdouble      spread;
 };
 
 GType     st_shadow_get_type (void) G_GNUC_CONST;
@@ -33,7 +36,8 @@ GType     st_shadow_get_type (void) G_GNUC_CONST;
 StShadow *st_shadow_new      (ClutterColor   *color,
                               gdouble         xoffset,
                               gdouble         yoffset,
-                              gdouble         blur);
+                              gdouble         blur,
+                              gdouble         spread);
 StShadow *st_shadow_copy     (const StShadow *shadow);
 void      st_shadow_free     (StShadow       *shadow);
 
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index 5788db9..d202a83 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -1079,10 +1079,14 @@ st_theme_node_paint (StThemeNode           *node,
 
           shadow_spec = node->shadow;
 
-          shadow_box.x1 = background_box.x1 + shadow_spec->xoffset - shadow_spec->blur;
-          shadow_box.y1 = background_box.y1 + shadow_spec->yoffset - shadow_spec->blur;
-          shadow_box.x2 = background_box.x2 + shadow_spec->xoffset + shadow_spec->blur;
-          shadow_box.y2 = background_box.y2 + shadow_spec->yoffset + shadow_spec->blur;
+          shadow_box.x1 = background_box.x1 + shadow_spec->xoffset
+                          - shadow_spec->blur - shadow_spec->spread;
+          shadow_box.y1 = background_box.y1 + shadow_spec->yoffset
+                          - shadow_spec->blur - shadow_spec->spread;
+          shadow_box.x2 = background_box.x2 + shadow_spec->xoffset
+                          + shadow_spec->blur + shadow_spec->spread;
+          shadow_box.y2 = background_box.y2 + shadow_spec->yoffset
+                          + shadow_spec->blur + shadow_spec->spread;
 
           cogl_material_set_color4ub (node->shadow_material,
                                       paint_opacity, paint_opacity, paint_opacity, paint_opacity);
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index d742c6b..dfe629e 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -2220,6 +2220,7 @@ st_theme_node_get_shadow (StThemeNode *node)
           gdouble xoffset = 0.;
           gdouble yoffset = 0.;
           gdouble blur = 0.;
+          gdouble spread = 0.;
           int n_offsets = 0;
 
           for (term = decl->value; term; term = term->next)
@@ -2248,6 +2249,13 @@ st_theme_node_get_shadow (StThemeNode *node)
                               g_warning ("Negative blur values are "
                                          "not allowed");
                           blur = value;
+                          break;
+                        case 3:
+                          if (multiplier < 0)
+                              g_warning ("Negative spread values are "
+                                         "not allowed");
+                          spread = value;
+                          break;
                         }
                       continue;
                     }
@@ -2259,7 +2267,9 @@ st_theme_node_get_shadow (StThemeNode *node)
                   continue;
                 }
             }
-          node->shadow = st_shadow_new (&color, xoffset, yoffset, blur);
+          node->shadow = st_shadow_new (&color,
+                                        xoffset, yoffset,
+                                        blur, spread);
 
           return node->shadow;
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]