[mutter/gbsneto/bind-preferred-size] bind-constraint: Update the preferred size
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/bind-preferred-size] bind-constraint: Update the preferred size
- Date: Wed, 19 Feb 2020 11:27:16 +0000 (UTC)
commit 4f8e518d42e4f07239a41fc3cef9515b94c59dda
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Dec 14 14:54:35 2014 +0000
bind-constraint: Update the preferred size
Bind the preferred size of an actor using a BindConstraint to the
preferred size of the source of the constraint, depending on the
coordinate of the constraint.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1070
clutter/clutter/clutter-bind-constraint.c | 51 +++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
---
diff --git a/clutter/clutter/clutter-bind-constraint.c b/clutter/clutter/clutter-bind-constraint.c
index 3443599e6..11eb5110e 100644
--- a/clutter/clutter/clutter-bind-constraint.c
+++ b/clutter/clutter/clutter-bind-constraint.c
@@ -144,6 +144,55 @@ source_destroyed (ClutterActor *actor,
bind->source = NULL;
}
+static void
+clutter_bind_constraint_update_preferred_size (ClutterConstraint *constraint,
+ ClutterActor *actor,
+ ClutterOrientation direction,
+ float for_size,
+ float *minimum_size,
+ float *natural_size)
+{
+ ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint);
+ float source_min, source_nat;
+
+ if (bind->source == NULL)
+ return;
+
+ /* only these bindings affect the preferred size */
+ if (!(bind->coordinate == CLUTTER_BIND_WIDTH ||
+ bind->coordinate == CLUTTER_BIND_HEIGHT ||
+ bind->coordinate == CLUTTER_BIND_SIZE ||
+ bind->coordinate == CLUTTER_BIND_ALL))
+ return;
+
+ switch (direction)
+ {
+ case CLUTTER_ORIENTATION_HORIZONTAL:
+ if (bind->coordinate != CLUTTER_BIND_HEIGHT)
+ {
+ clutter_actor_get_preferred_width (bind->source, for_size,
+ &source_min,
+ &source_nat);
+
+ *minimum_size = source_min;
+ *natural_size = source_nat;
+ }
+ break;
+
+ case CLUTTER_ORIENTATION_VERTICAL:
+ if (bind->coordinate != CLUTTER_BIND_WIDTH)
+ {
+ clutter_actor_get_preferred_height (bind->source, for_size,
+ &source_min,
+ &source_nat);
+
+ *minimum_size = source_min;
+ *natural_size = source_nat;
+ }
+ break;
+ }
+}
+
static void
clutter_bind_constraint_update_allocation (ClutterConstraint *constraint,
ClutterActor *actor,
@@ -328,6 +377,8 @@ clutter_bind_constraint_class_init (ClutterBindConstraintClass *klass)
meta_class->set_actor = clutter_bind_constraint_set_actor;
constraint_class->update_allocation = clutter_bind_constraint_update_allocation;
+ constraint_class->update_preferred_size = clutter_bind_constraint_update_preferred_size;
+
/**
* ClutterBindConstraint:source:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]