Add ClutterInterval integration
To be able to animate CLUTTER_TYPE_UNITS properties we need to register the GType and its progress function against the ClutterInterval code. The two ClutterUnits defining the interval can use different units, the resulting unit will always be in pixels, so calculating a progress between 10px and 4cm is valid. http://bugzilla.openedhand.com/show_bug.cgi?id=1844
This commit is contained in:
parent
83b4ec7a12
commit
ee9f8c3bdf
@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
#include "clutter-units.h"
|
#include "clutter-units.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
|
#include "clutter-interval.h"
|
||||||
|
|
||||||
#define DPI_FALLBACK (96.0)
|
#define DPI_FALLBACK (96.0)
|
||||||
|
|
||||||
@ -646,6 +647,31 @@ clutter_units_to_string (const ClutterUnits *units)
|
|||||||
return g_strconcat (buf, " ", unit_name, NULL);
|
return g_strconcat (buf, " ", unit_name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ClutterInterval integration
|
||||||
|
*/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_units_progress (const GValue *a,
|
||||||
|
const GValue *b,
|
||||||
|
gdouble progress,
|
||||||
|
GValue *retval)
|
||||||
|
{
|
||||||
|
ClutterUnits *a_units = (ClutterUnits *) clutter_value_get_units (a);
|
||||||
|
ClutterUnits *b_units = (ClutterUnits *) clutter_value_get_units (b);
|
||||||
|
ClutterUnits res;
|
||||||
|
gfloat a_px, b_px, value;
|
||||||
|
|
||||||
|
a_px = clutter_units_to_pixels (a_units);
|
||||||
|
b_px = clutter_units_to_pixels (b_units);
|
||||||
|
value = progress * (b_px - a_px) + a_px;
|
||||||
|
|
||||||
|
clutter_units_from_pixels (&res, value);
|
||||||
|
clutter_value_set_units (retval, &res);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GValue and GParamSpec integration
|
* GValue and GParamSpec integration
|
||||||
*/
|
*/
|
||||||
@ -731,6 +757,9 @@ clutter_units_get_type (void)
|
|||||||
g_value_register_transform_func (G_TYPE_STRING, clutter_units_type,
|
g_value_register_transform_func (G_TYPE_STRING, clutter_units_type,
|
||||||
clutter_value_transform_string_units);
|
clutter_value_transform_string_units);
|
||||||
|
|
||||||
|
clutter_interval_register_progress_func (clutter_units_type,
|
||||||
|
clutter_units_progress);
|
||||||
|
|
||||||
g_once_init_leave (&clutter_units_type__volatile, clutter_units_type);
|
g_once_init_leave (&clutter_units_type__volatile, clutter_units_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user