[clutter/clutter-1.22] actor: Update preferred size using constraints
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.22] actor: Update preferred size using constraints
- Date: Tue, 16 Dec 2014 00:47:39 +0000 (UTC)
commit 66d48bcca07b371e3962cfa4b651e7717228db96
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Dec 14 14:44:04 2014 +0000
actor: Update preferred size using constraints
If an actor has any constraint that may affect its preferred size, then
it should query them when computing its preferred size.
clutter/clutter-actor.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 38e454b..43458b8 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9306,6 +9306,46 @@ _clutter_actor_get_cached_size_request (gfloat for_size,
return FALSE;
}
+static void
+clutter_actor_update_preferred_size_for_constraints (ClutterActor *self,
+ ClutterOrientation direction,
+ float for_size,
+ float *minimum_size,
+ float *natural_size)
+{
+ ClutterActorPrivate *priv = self->priv;
+ const GList *constraints, *l;
+
+ if (priv->constraints == NULL)
+ return;
+
+ constraints = _clutter_meta_group_peek_metas (priv->constraints);
+ for (l = constraints; l != NULL; l = l->next)
+ {
+ ClutterConstraint *constraint = l->data;
+ ClutterActorMeta *meta = l->data;
+
+ if (!clutter_actor_meta_get_enabled (meta))
+ continue;
+
+ clutter_constraint_update_preferred_size (constraint, self,
+ direction,
+ for_size,
+ minimum_size,
+ natural_size);
+
+ CLUTTER_NOTE (LAYOUT,
+ "Preferred %s of '%s' after constraint '%s': "
+ "{ min:%.2f, nat:%.2f }",
+ direction == CLUTTER_ORIENTATION_HORIZONTAL
+ ? "width"
+ : "height",
+ _clutter_actor_get_debug_name (self),
+ _clutter_actor_meta_get_debug_name (meta),
+ *minimum_size, *natural_size);
+ }
+}
+
/**
* clutter_actor_get_preferred_width:
* @self: A #ClutterActor
@@ -9404,6 +9444,13 @@ clutter_actor_get_preferred_width (ClutterActor *self,
&minimum_width,
&natural_width);
+ /* adjust for constraints */
+ clutter_actor_update_preferred_size_for_constraints (self,
+ CLUTTER_ORIENTATION_HORIZONTAL,
+ for_height,
+ &minimum_width,
+ &natural_width);
+
/* adjust for the margin */
minimum_width += (info->margin.left + info->margin.right);
natural_width += (info->margin.left + info->margin.right);
@@ -9540,6 +9587,13 @@ clutter_actor_get_preferred_height (ClutterActor *self,
&minimum_height,
&natural_height);
+ /* adjust for constraints */
+ clutter_actor_update_preferred_size_for_constraints (self,
+ CLUTTER_ORIENTATION_VERTICAL,
+ for_width,
+ &minimum_height,
+ &natural_height);
+
/* adjust for margin */
minimum_height += (info->margin.top + info->margin.bottom);
natural_height += (info->margin.top + info->margin.bottom);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]