forked from AuroraMiddleware/gtk
cssimage: Implement dynamic values
No image actually implements it yet, but this is the plumbing.
This commit is contained in:
parent
3322599e99
commit
d774406573
@ -96,6 +96,19 @@ gtk_css_image_real_transition (GtkCssImage *start,
|
|||||||
return _gtk_css_image_cross_fade_new (start, end, progress);
|
return _gtk_css_image_cross_fade_new (start, end, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gtk_css_image_real_is_dynamic (GtkCssImage *image)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkCssImage *
|
||||||
|
gtk_css_image_real_get_dynamic_image (GtkCssImage *image,
|
||||||
|
gint64 monotonic_time)
|
||||||
|
{
|
||||||
|
return g_object_ref (image);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gtk_css_image_class_init (GtkCssImageClass *klass)
|
_gtk_css_image_class_init (GtkCssImageClass *klass)
|
||||||
{
|
{
|
||||||
@ -105,6 +118,8 @@ _gtk_css_image_class_init (GtkCssImageClass *klass)
|
|||||||
klass->compute = gtk_css_image_real_compute;
|
klass->compute = gtk_css_image_real_compute;
|
||||||
klass->equal = gtk_css_image_real_equal;
|
klass->equal = gtk_css_image_real_equal;
|
||||||
klass->transition = gtk_css_image_real_transition;
|
klass->transition = gtk_css_image_real_transition;
|
||||||
|
klass->is_dynamic = gtk_css_image_real_is_dynamic;
|
||||||
|
klass->get_dynamic_image = gtk_css_image_real_get_dynamic_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -264,6 +279,31 @@ gtk_css_image_snapshot (GtkCssImage *image,
|
|||||||
klass->snapshot (image, snapshot, width, height);
|
klass->snapshot (image, snapshot, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gtk_css_image_is_dynamic (GtkCssImage *image)
|
||||||
|
{
|
||||||
|
GtkCssImageClass *klass;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), FALSE);
|
||||||
|
|
||||||
|
klass = GTK_CSS_IMAGE_GET_CLASS (image);
|
||||||
|
|
||||||
|
return klass->is_dynamic (image);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkCssImage *
|
||||||
|
gtk_css_image_get_dynamic_image (GtkCssImage *image,
|
||||||
|
gint64 monotonic_time)
|
||||||
|
{
|
||||||
|
GtkCssImageClass *klass;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
|
||||||
|
|
||||||
|
klass = GTK_CSS_IMAGE_GET_CLASS (image);
|
||||||
|
|
||||||
|
return klass->get_dynamic_image (image, monotonic_time);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gtk_css_image_print (GtkCssImage *image,
|
_gtk_css_image_print (GtkCssImage *image,
|
||||||
GString *string)
|
GString *string)
|
||||||
|
@ -75,6 +75,11 @@ struct _GtkCssImageClass
|
|||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot,
|
||||||
double width,
|
double width,
|
||||||
double height);
|
double height);
|
||||||
|
/* does this image change based on timestamp? (optional) */
|
||||||
|
gboolean (* is_dynamic) (GtkCssImage *image);
|
||||||
|
/* get image for given timestamp or @image when not dynamic (optional) */
|
||||||
|
GtkCssImage *(* get_dynamic_image) (GtkCssImage *image,
|
||||||
|
gint64 monotonic_time);
|
||||||
/* parse CSS, return TRUE on success */
|
/* parse CSS, return TRUE on success */
|
||||||
gboolean (* parse) (GtkCssImage *image,
|
gboolean (* parse) (GtkCssImage *image,
|
||||||
GtkCssParser *parser);
|
GtkCssParser *parser);
|
||||||
@ -112,6 +117,9 @@ void gtk_css_image_snapshot (GtkCssImage *
|
|||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot,
|
||||||
double width,
|
double width,
|
||||||
double height);
|
double height);
|
||||||
|
gboolean gtk_css_image_is_dynamic (GtkCssImage *image);
|
||||||
|
GtkCssImage * gtk_css_image_get_dynamic_image (GtkCssImage *image,
|
||||||
|
gint64 monotonic_time);
|
||||||
void _gtk_css_image_print (GtkCssImage *image,
|
void _gtk_css_image_print (GtkCssImage *image,
|
||||||
GString *string);
|
GString *string);
|
||||||
|
|
||||||
|
@ -81,6 +81,37 @@ gtk_css_value_image_transition (GtkCssValue *start,
|
|||||||
return _gtk_css_image_value_new (transition);
|
return _gtk_css_image_value_new (transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gtk_css_value_image_is_dynamic (GtkCssValue *value)
|
||||||
|
{
|
||||||
|
GtkCssImage *image = _gtk_css_image_value_get_image (value);
|
||||||
|
|
||||||
|
if (image == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return gtk_css_image_is_dynamic (image);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkCssValue *
|
||||||
|
gtk_css_value_image_get_dynamic_value (GtkCssValue *value,
|
||||||
|
gint64 monotonic_time)
|
||||||
|
{
|
||||||
|
GtkCssImage *image, *dynamic;
|
||||||
|
|
||||||
|
image = _gtk_css_image_value_get_image (value);
|
||||||
|
if (image == NULL)
|
||||||
|
return gtk_css_value_ref (value);
|
||||||
|
|
||||||
|
dynamic = gtk_css_image_get_dynamic_image (image, monotonic_time);
|
||||||
|
if (dynamic == image)
|
||||||
|
{
|
||||||
|
g_object_unref (dynamic);
|
||||||
|
return gtk_css_value_ref (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _gtk_css_image_value_new (dynamic);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_css_value_image_print (const GtkCssValue *value,
|
gtk_css_value_image_print (const GtkCssValue *value,
|
||||||
GString *string)
|
GString *string)
|
||||||
@ -96,8 +127,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
|
|||||||
gtk_css_value_image_compute,
|
gtk_css_value_image_compute,
|
||||||
gtk_css_value_image_equal,
|
gtk_css_value_image_equal,
|
||||||
gtk_css_value_image_transition,
|
gtk_css_value_image_transition,
|
||||||
NULL,
|
gtk_css_value_image_is_dynamic,
|
||||||
NULL,
|
gtk_css_value_image_get_dynamic_value,
|
||||||
gtk_css_value_image_print
|
gtk_css_value_image_print
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user