future: Fix version boundaries for comparison
This commit is contained in:
parent
a5210c45dd
commit
e59f2cafe4
|
@ -5270,6 +5270,9 @@ clutter_actor_finalize (GObject *object)
|
|||
priv->id,
|
||||
g_type_name (G_OBJECT_TYPE (object)));
|
||||
|
||||
if (clutter_future_is_enabled (CLUTTER_FUTURE_DEFAULT_EASING_STATE))
|
||||
clutter_actor_restore_easing_state (CLUTTER_ACTOR (object));
|
||||
|
||||
_clutter_context_release_id (priv->id);
|
||||
|
||||
g_free (priv->name);
|
||||
|
@ -7379,6 +7382,9 @@ clutter_actor_init (ClutterActor *self)
|
|||
* when building up a scene.
|
||||
*/
|
||||
priv->needs_compute_expand = FALSE;
|
||||
|
||||
if (clutter_future_is_enabled (CLUTTER_FUTURE_DEFAULT_EASING_STATE))
|
||||
clutter_actor_save_easing_state (self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1239,6 +1239,8 @@ typedef enum { /*< prefix=CLUTTER_SCROLL >*/
|
|||
|
||||
/**
|
||||
* ClutterFutureFeature:
|
||||
* @CLUTTER_FUTURE_DEFAULT_EASING_STATE: Enables a default easing state
|
||||
* on #ClutterActor. Optional since 1.12, mandatory since 2.0
|
||||
* @CLUTTER_FUTURE_N_FEATURES: The number of available future features
|
||||
*
|
||||
* A set of future features that can be enabled when using Clutter.
|
||||
|
@ -1251,6 +1253,8 @@ typedef enum { /*< prefix=CLUTTER_SCROLL >*/
|
|||
* Since: 1.12
|
||||
*/
|
||||
typedef enum { /*< prefix=CLUTTER_FEATURE >*/
|
||||
CLUTTER_FUTURE_DEFAULT_EASING_STATE,
|
||||
|
||||
CLUTTER_FUTURE_N_FEATURES
|
||||
} ClutterFutureFeature;
|
||||
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
_Mandatory, \
|
||||
}
|
||||
|
||||
static const ClutterFuture __clutter_futures[] = {
|
||||
CLUTTER_DEFINE_FUTURE ("Last/Sentinel", CLUTTER_VERSION_1_0, CLUTTER_VERSION_1_0),
|
||||
static const ClutterFuture __clutter_futures[CLUTTER_FUTURE_N_FEATURES] = {
|
||||
CLUTTER_DEFINE_FUTURE ("default-easing-state",
|
||||
G_ENCODE_VERSION (1, 11),
|
||||
G_ENCODE_VERSION (2, 0)),
|
||||
};
|
||||
|
||||
static gboolean __clutter_enabled_futures[1] = { FALSE, };
|
||||
static gboolean __clutter_enabled_futures[CLUTTER_FUTURE_N_FEATURES] = { FALSE, };
|
||||
|
||||
const char *
|
||||
clutter_future_get_name (ClutterFutureFeature feature)
|
||||
|
@ -42,12 +44,16 @@ clutter_future_get_mandatory_version (ClutterFutureFeature feature)
|
|||
gboolean
|
||||
clutter_future_is_enabled (ClutterFutureFeature feature)
|
||||
{
|
||||
guint version;
|
||||
|
||||
g_assert (feature < CLUTTER_FUTURE_N_FEATURES);
|
||||
|
||||
if (__clutter_futures[feature].optional_version > CLUTTER_VERSION_HEX)
|
||||
version = G_ENCODE_VERSION (CLUTTER_MAJOR_VERSION, CLUTTER_MINOR_VERSION);
|
||||
|
||||
if (__clutter_futures[feature].optional_version > version)
|
||||
return FALSE;
|
||||
|
||||
if (__clutter_futures[feature].mandatory_version <= CLUTTER_VERSION_HEX)
|
||||
if (__clutter_futures[feature].mandatory_version <= version)
|
||||
return TRUE;
|
||||
|
||||
return __clutter_enabled_futures[feature];
|
||||
|
@ -56,5 +62,7 @@ clutter_future_is_enabled (ClutterFutureFeature feature)
|
|||
void
|
||||
clutter_future_enable (ClutterFutureFeature feature)
|
||||
{
|
||||
g_assert (feature < CLUTTER_FUTURE_N_FEATURES);
|
||||
|
||||
__clutter_enabled_futures[feature] = TRUE;
|
||||
}
|
||||
|
|
|
@ -3904,5 +3904,9 @@ clutter_enable_future (ClutterFutureFeature feature)
|
|||
return;
|
||||
}
|
||||
|
||||
CLUTTER_NOTE (MISC, "Enabling feature '%s' [%d]",
|
||||
clutter_future_get_name (feature),
|
||||
feature);
|
||||
|
||||
clutter_future_enable (feature);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,11 @@ on_button_press (ClutterActor *actor,
|
|||
}
|
||||
else if (event->button == CLUTTER_BUTTON_MIDDLE)
|
||||
{
|
||||
/* middle click jumps to position */
|
||||
clutter_actor_save_easing_state (rectangle);
|
||||
clutter_actor_set_easing_duration (rectangle, 0);
|
||||
clutter_actor_set_position (rectangle, event->x, event->y);
|
||||
clutter_actor_restore_easing_state (rectangle);
|
||||
}
|
||||
else if (event->button == CLUTTER_BUTTON_PRIMARY)
|
||||
{
|
||||
|
@ -85,15 +89,8 @@ on_button_press (ClutterActor *actor,
|
|||
|
||||
cur_mode = easing_modes[current_mode].mode;
|
||||
|
||||
clutter_actor_save_easing_state (rectangle);
|
||||
|
||||
/* tween the actor using the current easing mode */
|
||||
clutter_actor_set_easing_mode (rectangle, cur_mode);
|
||||
clutter_actor_set_easing_duration (rectangle, duration * 1000);
|
||||
|
||||
clutter_actor_set_position (rectangle, event->x, event->y);
|
||||
|
||||
clutter_actor_restore_easing_state (rectangle);
|
||||
}
|
||||
|
||||
return CLUTTER_EVENT_STOP;
|
||||
|
@ -187,6 +184,8 @@ main (int argc, char *argv[])
|
|||
gfloat stage_width, stage_height;
|
||||
GError *error = NULL;
|
||||
|
||||
clutter_enable_future (CLUTTER_FUTURE_DEFAULT_EASING_STATE);
|
||||
|
||||
if (clutter_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
test_easing_entries,
|
||||
|
@ -204,8 +203,8 @@ main (int argc, char *argv[])
|
|||
|
||||
/* create the actor that we want to tween */
|
||||
rect = make_bouncer (50, 50);
|
||||
clutter_actor_add_child (stage, rect);
|
||||
clutter_actor_set_position (rect, stage_width / 2, stage_height / 2);
|
||||
clutter_actor_add_child (stage, rect);
|
||||
|
||||
text = g_strdup_printf (HELP_TEXT,
|
||||
easing_modes[current_mode].name,
|
||||
|
@ -218,6 +217,7 @@ main (int argc, char *argv[])
|
|||
clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_RIGHT);
|
||||
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.95));
|
||||
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.95));
|
||||
clutter_actor_add_child (stage, label);
|
||||
easing_mode_label = label;
|
||||
|
||||
g_free (text);
|
||||
|
|
Loading…
Reference in New Issue