constraint: Add the ability to update the preferred size

Constraints can only update an existing allocation, which means they
live only halfway through the layout management system used by Clutter;
this limitation makes it impossible, for instance, to query the
preferred size of an actor, if the actor is only using constraints to
manage its own size.
This commit is contained in:
Emmanuele Bassi 2014-12-14 14:30:50 +00:00
parent 82fffaedb6
commit 391f1d8dd4
3 changed files with 43 additions and 1 deletions

View File

@ -30,6 +30,13 @@ gboolean clutter_constraint_update_allocation (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterActorBox *allocation);
void clutter_constraint_update_preferred_size (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterOrientation direction,
float for_size,
float *minimum_size,
float *natural_size);
G_END_DECLS
#endif /* __CLUTTER_CONSTRAINT_PRIVATE_H__ */

View File

@ -151,6 +151,16 @@ constraint_update_allocation (ClutterConstraint *constraint,
{
}
static void
constraint_update_preferred_size (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterOrientation direction,
float for_size,
float *minimum_size,
float *natural_size)
{
}
static void
clutter_constraint_notify (GObject *gobject,
GParamSpec *pspec)
@ -176,6 +186,7 @@ clutter_constraint_class_init (ClutterConstraintClass *klass)
gobject_class->notify = clutter_constraint_notify;
klass->update_allocation = constraint_update_allocation;
klass->update_preferred_size = constraint_update_preferred_size;
}
static void
@ -212,3 +223,21 @@ clutter_constraint_update_allocation (ClutterConstraint *constraint,
return clutter_actor_box_equal (allocation, &old_alloc);
}
void
clutter_constraint_update_preferred_size (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterOrientation direction,
float for_size,
float *minimum_size,
float *natural_size)
{
g_return_if_fail (CLUTTER_IS_CONSTRAINT (constraint));
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
CLUTTER_CONSTRAINT_GET_CLASS (constraint)->update_preferred_size (constraint, actor,
direction,
for_size,
minimum_size,
natural_size);
}

View File

@ -76,6 +76,13 @@ struct _ClutterConstraintClass
ClutterActor *actor,
ClutterActorBox *allocation);
void (* update_preferred_size) (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterOrientation direction,
float for_size,
float *minimum_size,
float *natural_size);
/*< private >*/
void (* _clutter_constraint1) (void);
void (* _clutter_constraint2) (void);
@ -84,7 +91,6 @@ struct _ClutterConstraintClass
void (* _clutter_constraint5) (void);
void (* _clutter_constraint6) (void);
void (* _clutter_constraint7) (void);
void (* _clutter_constraint8) (void);
};
CLUTTER_AVAILABLE_IN_1_4