mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
state: add clutter_state_set_state and clutter_state_warp_to_state
Replaced clutter_state_change with a boolean argument for animating the transition or not with two separate argument-less methods.
This commit is contained in:
parent
f87e4037a8
commit
9e730727ca
@ -443,23 +443,7 @@ clutter_state_new_frame (ClutterTimeline *timeline,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* clutter_state_change:
|
||||
* @state: a #ClutterState
|
||||
* @target_state_name: the state to transition to
|
||||
* @animate: whether we should animate the transition or not
|
||||
*
|
||||
* Change the current state of #ClutterState to @target_state_name
|
||||
*
|
||||
* If @animate is %FALSE, the state transition will happen immediately;
|
||||
* otherwise, the state transition will be animated over the duration
|
||||
* set using clutter_state_set_duration()
|
||||
*
|
||||
* Return value: the #ClutterTimeline that drives the state transition
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
ClutterTimeline *
|
||||
static ClutterTimeline *
|
||||
clutter_state_change (ClutterState *state,
|
||||
const gchar *target_state_name,
|
||||
gboolean animate)
|
||||
@ -561,6 +545,47 @@ clutter_state_change (ClutterState *state,
|
||||
return priv->timeline;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_state_set_state:
|
||||
* @state: a #ClutterState
|
||||
* @target_state_name: the state to transition to
|
||||
*
|
||||
* Change the current state of #ClutterState to @target_state_name
|
||||
*
|
||||
* The state will animate during its transition, see
|
||||
* #clutter_state_warp_to_state for animation-free state switching.
|
||||
*
|
||||
* Return value: the #ClutterTimeline that drives the state transition
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
ClutterTimeline *
|
||||
clutter_state_set_state (ClutterState *state,
|
||||
const gchar *target_state_name)
|
||||
{
|
||||
return clutter_state_change (state, target_state_name, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_state_warp_to_state:
|
||||
* @state: a #ClutterState
|
||||
* @target_state_name: the state to transition to
|
||||
*
|
||||
* Change the current state of #ClutterState to @target_state_name
|
||||
*
|
||||
* Change to the specified target state immediately with no animation.
|
||||
*
|
||||
* Return value: the #ClutterTimeline that drives the state transition
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
ClutterTimeline *
|
||||
clutter_state_warp_to_state (ClutterState *state,
|
||||
const gchar *target_state_name)
|
||||
{
|
||||
return clutter_state_change (state, target_state_name, TRUE);
|
||||
}
|
||||
|
||||
static GParamSpec *
|
||||
get_property_from_object (GObject *gobject,
|
||||
const gchar *property_name)
|
||||
@ -1061,7 +1086,7 @@ clutter_state_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STATE:
|
||||
clutter_state_change (state, g_value_get_string (value), TRUE);
|
||||
clutter_state_set_state (state, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_DURATION:
|
||||
state->priv->duration = g_value_get_uint (value);
|
||||
|
@ -91,9 +91,10 @@ GType clutter_state_get_type (void) G_GNUC_CONST;
|
||||
ClutterState *clutter_state_new (void);
|
||||
|
||||
|
||||
ClutterTimeline * clutter_state_change (ClutterState *state,
|
||||
const gchar *target_state_name,
|
||||
gboolean animate);
|
||||
ClutterTimeline * clutter_state_set_state (ClutterState *state,
|
||||
const gchar *target_state_name);
|
||||
ClutterTimeline * clutter_state_warp_to_state (ClutterState *state,
|
||||
const gchar *target_state_name);
|
||||
ClutterState * clutter_state_set_key (ClutterState *state,
|
||||
const gchar *source_state_name,
|
||||
const gchar *target_state_name,
|
||||
|
@ -2250,8 +2250,9 @@ clutter_align_constraint_get_type
|
||||
ClutterState
|
||||
ClutterStateClass
|
||||
clutter_state_new
|
||||
clutter_state_change
|
||||
clutter_state_set_state
|
||||
clutter_state_get_state
|
||||
clutter_state_warp_to_state
|
||||
clutter_state_set
|
||||
clutter_state_set_key
|
||||
clutter_state_set_duration
|
||||
|
@ -11,7 +11,7 @@ static gboolean press_event (ClutterActor *actor,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_grab_pointer (actor);
|
||||
clutter_state_change (state, "end", TRUE);
|
||||
clutter_state_set_state (state, "end");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ static gboolean release_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_state_change (state, "start", TRUE);
|
||||
clutter_state_set_state (state, "start");
|
||||
clutter_ungrab_pointer ();
|
||||
return TRUE;
|
||||
}
|
||||
@ -125,7 +125,7 @@ test_state_animator_main (gint argc,
|
||||
g_object_unref (animator);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
clutter_state_change (state, "start", TRUE);
|
||||
clutter_state_set_state (state, "start");
|
||||
|
||||
clutter_main ();
|
||||
g_object_unref (state);
|
||||
|
@ -19,7 +19,7 @@ static gboolean press_event (ClutterActor *actor,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_change (state, "right", TRUE);
|
||||
clutter_state_set_state (state, "right");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ static gboolean release_event (ClutterActor *actor,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_change (state, "active", TRUE);
|
||||
clutter_state_set_state (state, "active");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ static gboolean enter_event (ClutterActor *actor,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_change (state, "hover", TRUE);
|
||||
clutter_state_set_state (state, "hover");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ static gboolean leave_event (ClutterActor *actor,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_change (state, "normal", TRUE);
|
||||
clutter_state_set_state (state, "normal");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ static void completed (ClutterState *state,
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_change (state, "left", FALSE);
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,8 +177,9 @@ test_state_main (gint argc,
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
clutter_state_change (layout_state, "left", FALSE);
|
||||
clutter_state_change (layout_state, "active", TRUE);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_main ();
|
||||
g_object_unref (layout_state);
|
||||
|
Loading…
Reference in New Issue
Block a user