diff options
author | Benjamin Otte <otte@redhat.com> | 2012-04-03 15:33:00 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:18 +0200 |
commit | c366b5b8b72cc9d87be4e153c2dfc7eb5551c46a (patch) | |
tree | 34bdca830366c43c37c67008ae63fce18cd1d190 | |
parent | ac6d61f6bb100022ba8db9c0d6896789f7296c3d (diff) | |
download | gtk+-c366b5b8b72cc9d87be4e153c2dfc7eb5551c46a.tar.gz |
shadow: Add equal and transition support
... and enable transitions for the shadow properties.
-rw-r--r-- | gtk/gtkcssshadowsvalue.c | 42 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalue.c | 40 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalueprivate.h | 2 | ||||
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 6 |
4 files changed, 82 insertions, 8 deletions
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c index 41b521fb6d..d4f7655b52 100644 --- a/gtk/gtkcssshadowsvalue.c +++ b/gtk/gtkcssshadowsvalue.c @@ -31,6 +31,9 @@ struct _GtkCssValue { GtkCssValue *values[1]; }; +static GtkCssValue * gtk_css_shadows_value_new (GtkCssValue **values, + guint len); + static void gtk_css_value_shadows_free (GtkCssValue *value) { @@ -69,7 +72,42 @@ gtk_css_value_shadows_transition (GtkCssValue *start, GtkCssValue *end, double progress) { - return NULL; + GtkCssValue *result; + guint i; + + /* catches the important case of 2 none values */ + if (start == end) + return _gtk_css_value_ref (start); + + if (start->len > end->len) + result = gtk_css_shadows_value_new (start->values, start->len); + else + result = gtk_css_shadows_value_new (end->values, end->len); + + for (i = 0; i < MIN (start->len, end->len); i++) + { + result->values[i] = _gtk_css_value_transition (start->values[i], end->values[i], progress); + } + if (start->len > end->len) + { + for (; i < result->len; i++) + { + GtkCssValue *fill = _gtk_css_shadow_value_new_for_transition (start->values[i]); + result->values[i] = _gtk_css_value_transition (start->values[i], fill, progress); + _gtk_css_value_unref (fill); + } + } + else + { + for (; i < result->len; i++) + { + GtkCssValue *fill = _gtk_css_shadow_value_new_for_transition (end->values[i]); + result->values[i] = _gtk_css_value_transition (fill, end->values[i], progress); + _gtk_css_value_unref (fill); + } + } + + return result; } static void @@ -107,7 +145,7 @@ _gtk_css_shadows_value_new_none (void) return _gtk_css_value_ref (&none_singleton); } -GtkCssValue * +static GtkCssValue * gtk_css_shadows_value_new (GtkCssValue **values, guint len) { diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 26806ede9a..e9cbd4db43 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -40,6 +40,13 @@ struct _GtkCssValue { GtkCssValue *color; }; +static GtkCssValue * gtk_css_shadow_value_new (GtkCssValue *hoffset, + GtkCssValue *voffset, + GtkCssValue *radius, + GtkCssValue *spread, + gboolean inset, + GtkCssValue *color); + static void gtk_css_value_shadow_free (GtkCssValue *shadow) { @@ -56,8 +63,12 @@ static gboolean gtk_css_value_shadow_equal (const GtkCssValue *shadow1, const GtkCssValue *shadow2) { - /* FIXME */ - return shadow1 == shadow2; + return shadow1->inset == shadow2->inset + && _gtk_css_value_equal (shadow1->hoffset, shadow2->hoffset) + && _gtk_css_value_equal (shadow1->voffset, shadow2->voffset) + && _gtk_css_value_equal (shadow1->radius, shadow2->radius) + && _gtk_css_value_equal (shadow1->spread, shadow2->spread) + && _gtk_css_value_equal (shadow1->color, shadow2->color); } static GtkCssValue * @@ -65,7 +76,15 @@ gtk_css_value_shadow_transition (GtkCssValue *start, GtkCssValue *end, double progress) { - return NULL; + if (start->inset != end->inset) + return NULL; + + return gtk_css_shadow_value_new (_gtk_css_value_transition (start->hoffset, end->hoffset, progress), + _gtk_css_value_transition (start->voffset, end->voffset, progress), + _gtk_css_value_transition (start->radius, end->radius, progress), + _gtk_css_value_transition (start->spread, end->spread, progress), + start->inset, + _gtk_css_value_transition (start->color, end->color, progress)); } static void @@ -125,6 +144,21 @@ gtk_css_shadow_value_new (GtkCssValue *hoffset, return retval; } +GtkCssValue * +_gtk_css_shadow_value_new_for_transition (GtkCssValue *target) +{ + GdkRGBA transparent = { 0, 0, 0, 0 }; + + g_return_val_if_fail (target->class == >K_CSS_VALUE_SHADOW, NULL); + + return gtk_css_shadow_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX), + _gtk_css_number_value_new (0, GTK_CSS_PX), + _gtk_css_number_value_new (0, GTK_CSS_PX), + _gtk_css_number_value_new (0, GTK_CSS_PX), + target->inset, + _gtk_css_rgba_value_new_from_rgba (&transparent)); +} + static gboolean value_is_done_parsing (GtkCssParser *parser) { diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h index a53badd0b6..3683e11091 100644 --- a/gtk/gtkcssshadowvalueprivate.h +++ b/gtk/gtkcssshadowvalueprivate.h @@ -30,6 +30,8 @@ G_BEGIN_DECLS +GtkCssValue * _gtk_css_shadow_value_new_for_transition (GtkCssValue *target); + GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser); GtkCssValue * _gtk_css_shadow_value_compute (GtkCssValue *shadow, diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index dc814ca604..0fb7127658 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -1330,7 +1330,7 @@ _gtk_css_style_property_init_properties (void) gtk_css_style_property_register ("text-shadow", GTK_CSS_PROPERTY_TEXT_SHADOW, G_TYPE_NONE, - GTK_STYLE_PROPERTY_INHERIT, + GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED, shadow_value_parse, NULL, shadow_value_compute, @@ -1342,7 +1342,7 @@ _gtk_css_style_property_init_properties (void) gtk_css_style_property_register ("icon-shadow", GTK_CSS_PROPERTY_ICON_SHADOW, G_TYPE_NONE, - GTK_STYLE_PROPERTY_INHERIT, + GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED, shadow_value_parse, NULL, shadow_value_compute, @@ -1354,7 +1354,7 @@ _gtk_css_style_property_init_properties (void) gtk_css_style_property_register ("box-shadow", GTK_CSS_PROPERTY_BOX_SHADOW, G_TYPE_NONE, - 0, + GTK_STYLE_PROPERTY_ANIMATED, shadow_value_parse, NULL, shadow_value_compute, |