[gnome-shell] st-shadow: Parse the 'inset' keyword
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-shadow: Parse the 'inset' keyword
- Date: Mon, 21 Feb 2011 16:54:53 +0000 (UTC)
commit 2b90be77b3988494457ff6e733e9d72125159836
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Feb 14 02:07:14 2011 +0100
st-shadow: Parse the 'inset' keyword
The box-shadow property in the CSS3 draft[0] supports the optional
'inset' keyword for inner shadows cast onto the background. Add
support for the keyword to the shadow parsing code.
[0] http://www.w3.org/TR/css3-background/#box-shadow
https://bugzilla.gnome.org/show_bug.cgi?id=642334
src/st/st-icon.c | 7 ++++++
src/st/st-shadow.c | 19 +++++++++++++++-
src/st/st-shadow.h | 4 ++-
src/st/st-theme-node.c | 54 +++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 76 insertions(+), 8 deletions(-)
---
diff --git a/src/st/st-icon.c b/src/st/st-icon.c
index d1210f1..f93eff5 100644
--- a/src/st/st-icon.c
+++ b/src/st/st-icon.c
@@ -291,6 +291,13 @@ st_icon_style_changed (StWidget *widget)
}
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
+ if (priv->shadow_spec && priv->shadow_spec->inset)
+ {
+ g_warning ("The icon-shadow property does not support inset shadows");
+ st_shadow_unref (priv->shadow_spec);
+ priv->shadow_spec = NULL;
+ }
+
priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
st_icon_update_icon_size (self);
st_icon_update (self);
diff --git a/src/st/st-shadow.c b/src/st/st-shadow.c
index 78cf3de..335e496 100644
--- a/src/st/st-shadow.c
+++ b/src/st/st-shadow.c
@@ -39,6 +39,7 @@
* @yoffset: vertical offset
* @blur: blur radius
* @spread: spread radius
+ * @inset: whether the shadow should be inset
*
* Creates a new #StShadow
*
@@ -49,7 +50,8 @@ st_shadow_new (ClutterColor *color,
gdouble xoffset,
gdouble yoffset,
gdouble blur,
- gdouble spread)
+ gdouble spread,
+ gboolean inset)
{
StShadow *shadow;
@@ -60,6 +62,7 @@ st_shadow_new (ClutterColor *color,
shadow->yoffset = yoffset;
shadow->blur = blur;
shadow->spread = spread;
+ shadow->inset = inset;
shadow->ref_count = 1;
return shadow;
@@ -129,7 +132,8 @@ st_shadow_equal (StShadow *shadow,
shadow->xoffset == other->xoffset &&
shadow->yoffset == other->yoffset &&
shadow->blur == other->blur &&
- shadow->spread == other->spread);
+ shadow->spread == other->spread &&
+ shadow->inset == other->inset);
}
/**
@@ -150,6 +154,17 @@ st_shadow_get_box (StShadow *shadow,
g_return_if_fail (actor_box != NULL);
g_return_if_fail (shadow_box != NULL);
+ /* Inset shadows are drawn below the border, so returning
+ * the original box is not actually correct; still, it's
+ * good enough for the purpose of determing additional space
+ * required outside the actor box.
+ */
+ if (shadow->inset)
+ {
+ *shadow_box = *actor_box;
+ return;
+ }
+
shadow_box->x1 = actor_box->x1 + shadow->xoffset
- shadow->blur - shadow->spread;
shadow_box->x2 = actor_box->x2 + shadow->xoffset
diff --git a/src/st/st-shadow.h b/src/st/st-shadow.h
index 1a057c3..3523cdd 100644
--- a/src/st/st-shadow.h
+++ b/src/st/st-shadow.h
@@ -48,6 +48,7 @@ struct _StShadow {
gdouble yoffset;
gdouble blur;
gdouble spread;
+ gboolean inset;
volatile int ref_count;
};
@@ -57,7 +58,8 @@ StShadow *st_shadow_new (ClutterColor *color,
gdouble xoffset,
gdouble yoffset,
gdouble blur,
- gdouble spread);
+ gdouble spread,
+ gboolean inset);
StShadow *st_shadow_ref (StShadow *shadow);
void st_shadow_unref (StShadow *shadow);
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index fd3b89d..f7f922d 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -2649,9 +2649,9 @@ parse_shadow_property (StThemeNode *node,
gdouble *xoffset,
gdouble *yoffset,
gdouble *blur,
- gdouble *spread)
+ gdouble *spread,
+ gboolean *inset)
{
- /* Set value for width/color/blur in any order */
GetFromTermResult result;
CRTerm *term;
int n_offsets = 0;
@@ -2662,7 +2662,17 @@ parse_shadow_property (StThemeNode *node,
*yoffset = 0.;
*blur = 0.;
*spread = 0.;
-
+ *inset = FALSE;
+
+ /* The CSS3 draft of the box-shadow property[0] is a lot stricter
+ * regarding the order of terms:
+ * If the 'inset' keyword is specified, it has to be first or last,
+ * and the color may not be mixed with the lengths; while we parse
+ * length values in the correct order, we allow for arbitrary
+ * placement of the color and 'inset' keyword.
+ *
+ * [0] http://www.w3.org/TR/css3-background/#box-shadow
+ */
for (term = decl->value; term; term = term->next)
{
if (term->type == TERM_NUMBER)
@@ -2707,6 +2717,12 @@ parse_shadow_property (StThemeNode *node,
continue;
}
}
+ else if (term->type == TERM_IDENT &&
+ strcmp (term->content.str->stryng->str, "inset") == 0)
+ {
+ *inset = TRUE;
+ continue;
+ }
result = get_color_from_term (node, term, color);
@@ -2766,6 +2782,7 @@ st_theme_node_lookup_shadow (StThemeNode *node,
gdouble yoffset = 0.;
gdouble blur = 0.;
gdouble spread = 0.;
+ gboolean inset = FALSE;
int i;
@@ -2783,10 +2800,14 @@ st_theme_node_lookup_shadow (StThemeNode *node,
&xoffset,
&yoffset,
&blur,
- &spread);
+ &spread,
+ &inset);
if (result == VALUE_FOUND)
{
- *shadow = st_shadow_new (&color, xoffset, yoffset, blur, spread);
+ *shadow = st_shadow_new (&color,
+ xoffset, yoffset,
+ blur, spread,
+ inset);
return TRUE;
}
else if (result == VALUE_INHERIT)
@@ -2865,6 +2886,14 @@ st_theme_node_get_box_shadow (StThemeNode *node)
FALSE,
&shadow))
{
+ if (shadow->inset)
+ {
+ g_warning ("Inset shadows are not implemented for the box-shadow "
+ "property");
+ st_shadow_unref (shadow);
+ shadow = NULL;
+ }
+
node->box_shadow = shadow;
return node->box_shadow;
@@ -2898,6 +2927,14 @@ st_theme_node_get_background_image_shadow (StThemeNode *node)
FALSE,
&shadow))
{
+ if (shadow->inset)
+ {
+ g_warning ("The -st-background-image-shadow property does not "
+ "support inset shadows");
+ st_shadow_unref (shadow);
+ shadow = NULL;
+ }
+
node->background_image_shadow = shadow;
return node->background_image_shadow;
@@ -2938,6 +2975,13 @@ st_theme_node_get_text_shadow (StThemeNode *node)
}
}
+ if (result && result->inset)
+ {
+ g_warning ("The text-shadow property does not support inset shadows");
+ st_shadow_unref (result);
+ result = NULL;
+ }
+
node->text_shadow = result;
node->text_shadow_computed = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]