mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
[animation] Interval::compute_value should return a boolean
If the computation of the interval value depending on the progress was not successful, ClutterInterval::compute_value() should return this information to the caller.
This commit is contained in:
parent
854cf5d499
commit
ff48c3ef7c
@ -683,9 +683,9 @@ on_alpha_notify (GObject *gobject,
|
||||
g_value_init (&value, clutter_interval_get_value_type (interval));
|
||||
|
||||
factor = (gdouble) alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
|
||||
clutter_interval_compute_value (interval, factor, &value);
|
||||
|
||||
g_object_set_property (G_OBJECT (priv->actor), p_name, &value);
|
||||
if (clutter_interval_compute_value (interval, factor, &value))
|
||||
g_object_set_property (G_OBJECT (priv->actor), p_name, &value);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
@ -172,13 +172,14 @@ clutter_interval_real_validate (ClutterInterval *interval,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
gdouble factor,
|
||||
GValue *value)
|
||||
{
|
||||
GValue *initial, *final;
|
||||
GType value_type;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
initial = clutter_interval_peek_initial_value (interval);
|
||||
final = clutter_interval_peek_final_value (interval);
|
||||
@ -197,6 +198,8 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
res = (factor * (ib - ia)) + ia;
|
||||
|
||||
g_value_set_int (value, res);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -210,6 +213,8 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
res = (factor * (ib - (gdouble) ia)) + ia;
|
||||
|
||||
g_value_set_uint (value, res);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -223,6 +228,8 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
res = (factor * (ib - (gdouble) ia)) + ia;
|
||||
|
||||
g_value_set_uchar (value, res);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -240,6 +247,8 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
g_value_set_double (value, res);
|
||||
else
|
||||
g_value_set_float (value, res);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -248,6 +257,8 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
g_value_set_boolean (value, TRUE);
|
||||
else
|
||||
g_value_set_boolean (value, FALSE);
|
||||
|
||||
retval = TRUE;
|
||||
break;
|
||||
|
||||
case G_TYPE_BOXED:
|
||||
@ -265,12 +276,16 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
|
||||
res.alpha = (factor * (ib->alpha - (gdouble) ia->alpha)) + ia->alpha;
|
||||
|
||||
clutter_value_set_color (value, &res);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -837,19 +852,21 @@ clutter_interval_validate (ClutterInterval *interval,
|
||||
* Computes the value between the @interval boundaries given the
|
||||
* progress @factor and puts it into @value.
|
||||
*
|
||||
* Return value: %TRUE if the operation was successful
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void
|
||||
gboolean
|
||||
clutter_interval_compute_value (ClutterInterval *interval,
|
||||
gdouble factor,
|
||||
GValue *value)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_INTERVAL (interval));
|
||||
g_return_if_fail (value != NULL);
|
||||
g_return_val_if_fail (CLUTTER_IS_INTERVAL (interval), FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
factor = CLAMP (factor, 0.0, 1.0);
|
||||
|
||||
CLUTTER_INTERVAL_GET_CLASS (interval)->compute_value (interval,
|
||||
factor,
|
||||
value);
|
||||
return CLUTTER_INTERVAL_GET_CLASS (interval)->compute_value (interval,
|
||||
factor,
|
||||
value);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ struct _ClutterIntervalClass
|
||||
/*< public >*/
|
||||
gboolean (* validate) (ClutterInterval *interval,
|
||||
GParamSpec *pspec);
|
||||
void (* compute_value) (ClutterInterval *interval,
|
||||
gboolean (* compute_value) (ClutterInterval *interval,
|
||||
gdouble factor,
|
||||
GValue *value);
|
||||
|
||||
@ -122,7 +122,7 @@ void clutter_interval_get_interval (ClutterInterval *interval,
|
||||
|
||||
gboolean clutter_interval_validate (ClutterInterval *interval,
|
||||
GParamSpec *pspec);
|
||||
void clutter_interval_compute_value (ClutterInterval *interval,
|
||||
gboolean clutter_interval_compute_value (ClutterInterval *interval,
|
||||
gdouble factor,
|
||||
GValue *value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user