mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 02:40:07 +00:00
cssimage: Make image transition a vfunc
This commit is contained in:
parent
25271fe781
commit
558ffc24c2
@ -69,6 +69,15 @@ gtk_css_image_real_compute (GtkCssImage *image,
|
|||||||
return g_object_ref (image);
|
return g_object_ref (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkCssImage *
|
||||||
|
gtk_css_image_real_transition (GtkCssImage *start,
|
||||||
|
GtkCssImage *end,
|
||||||
|
guint property_id,
|
||||||
|
double progress)
|
||||||
|
{
|
||||||
|
return _gtk_css_image_cross_fade_new (start, end, progress);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gtk_css_image_class_init (GtkCssImageClass *klass)
|
_gtk_css_image_class_init (GtkCssImageClass *klass)
|
||||||
{
|
{
|
||||||
@ -76,6 +85,7 @@ _gtk_css_image_class_init (GtkCssImageClass *klass)
|
|||||||
klass->get_height = gtk_css_image_real_get_height;
|
klass->get_height = gtk_css_image_real_get_height;
|
||||||
klass->get_aspect_ratio = gtk_css_image_real_get_aspect_ratio;
|
klass->get_aspect_ratio = gtk_css_image_real_get_aspect_ratio;
|
||||||
klass->compute = gtk_css_image_real_compute;
|
klass->compute = gtk_css_image_real_compute;
|
||||||
|
klass->transition = gtk_css_image_real_transition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -143,6 +153,36 @@ _gtk_css_image_compute (GtkCssImage *image,
|
|||||||
return klass->compute (image, property_id, provider, values, parent_values, dependencies);
|
return klass->compute (image, property_id, provider, values, parent_values, dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkCssImage *
|
||||||
|
_gtk_css_image_transition (GtkCssImage *start,
|
||||||
|
GtkCssImage *end,
|
||||||
|
guint property_id,
|
||||||
|
double progress)
|
||||||
|
{
|
||||||
|
GtkCssImageClass *klass;
|
||||||
|
|
||||||
|
g_return_val_if_fail (start == NULL || GTK_IS_CSS_IMAGE (start), NULL);
|
||||||
|
g_return_val_if_fail (end == NULL || GTK_IS_CSS_IMAGE (end), NULL);
|
||||||
|
|
||||||
|
progress = CLAMP (progress, 0.0, 1.0);
|
||||||
|
|
||||||
|
if (start == NULL)
|
||||||
|
{
|
||||||
|
if (end == NULL)
|
||||||
|
return NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
start = end;
|
||||||
|
end = NULL;
|
||||||
|
progress = 1.0 - progress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
klass = GTK_CSS_IMAGE_GET_CLASS (start);
|
||||||
|
|
||||||
|
return klass->transition (start, end, property_id, progress);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gtk_css_image_draw (GtkCssImage *image,
|
_gtk_css_image_draw (GtkCssImage *image,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
|
@ -114,6 +114,9 @@ gtk_css_image_cross_fade_draw (GtkCssImage *image,
|
|||||||
|
|
||||||
cairo_push_group (cr);
|
cairo_push_group (cr);
|
||||||
|
|
||||||
|
/* performance trick */
|
||||||
|
cairo_reset_clip (cr);
|
||||||
|
|
||||||
_gtk_css_image_draw (cross_fade->start, cr, width, height);
|
_gtk_css_image_draw (cross_fade->start, cr, width, height);
|
||||||
|
|
||||||
cairo_push_group (cr);
|
cairo_push_group (cr);
|
||||||
|
@ -61,6 +61,11 @@ struct _GtkCssImageClass
|
|||||||
GtkCssComputedValues *values,
|
GtkCssComputedValues *values,
|
||||||
GtkCssComputedValues *parent_values,
|
GtkCssComputedValues *parent_values,
|
||||||
GtkCssDependencies *dependencies);
|
GtkCssDependencies *dependencies);
|
||||||
|
/* transition between start and end image (end may be NULL), returns new reference */
|
||||||
|
GtkCssImage *(* transition) (GtkCssImage *start,
|
||||||
|
GtkCssImage *end,
|
||||||
|
guint property_id,
|
||||||
|
double progress);
|
||||||
|
|
||||||
/* draw to 0,0 with the given width and height */
|
/* draw to 0,0 with the given width and height */
|
||||||
void (* draw) (GtkCssImage *image,
|
void (* draw) (GtkCssImage *image,
|
||||||
@ -90,6 +95,10 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
|
|||||||
GtkCssComputedValues *values,
|
GtkCssComputedValues *values,
|
||||||
GtkCssComputedValues *parent_values,
|
GtkCssComputedValues *parent_values,
|
||||||
GtkCssDependencies *dependencies);
|
GtkCssDependencies *dependencies);
|
||||||
|
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
|
||||||
|
GtkCssImage *end,
|
||||||
|
guint property_id,
|
||||||
|
double progress);
|
||||||
|
|
||||||
void _gtk_css_image_draw (GtkCssImage *image,
|
void _gtk_css_image_draw (GtkCssImage *image,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
|
@ -72,13 +72,14 @@ gtk_css_value_image_transition (GtkCssValue *start,
|
|||||||
guint property_id,
|
guint property_id,
|
||||||
double progress)
|
double progress)
|
||||||
{
|
{
|
||||||
GtkCssImage *fade;
|
GtkCssImage *transition;
|
||||||
|
|
||||||
fade = _gtk_css_image_cross_fade_new (_gtk_css_image_value_get_image (start),
|
transition = _gtk_css_image_transition (_gtk_css_image_value_get_image (start),
|
||||||
_gtk_css_image_value_get_image (end),
|
_gtk_css_image_value_get_image (end),
|
||||||
|
property_id,
|
||||||
progress);
|
progress);
|
||||||
|
|
||||||
return _gtk_css_image_value_new (fade);
|
return _gtk_css_image_value_new (transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user