[gtk+/wip/cssvalue: 110/141] shadow: Add equal and transition support
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 110/141] shadow: Add equal and transition support
- Date: Sat, 7 Apr 2012 17:55:23 +0000 (UTC)
commit 919fd74a17ca3946dc81e9903d9d5f8699b1b0a7
Author: Benjamin Otte <otte redhat com>
Date: Tue Apr 3 15:33:00 2012 +0200
shadow: Add equal and transition support
... and enable transitions for the shadow properties.
gtk/gtkcssshadowsvalue.c | 42 ++++++++++++++++++++++++++++++++++++++-
gtk/gtkcssshadowvalue.c | 40 +++++++++++++++++++++++++++++++++++--
gtk/gtkcssshadowvalueprivate.h | 2 +
gtk/gtkcssstylepropertyimpl.c | 6 ++--
4 files changed, 82 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index 41b521f..d4f7655 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 26806ed..e9cbd4d 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 a53badd..3683e11 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 bccff16..f55c1d5 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -1320,7 +1320,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,
@@ -1332,7 +1332,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,
@@ -1344,7 +1344,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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]