mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
shadow: Add equal and transition support
... and enable transitions for the shadow properties.
This commit is contained in:
parent
ac6d61f6bb
commit
c366b5b8b7
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user