[mutter] clutter/align-constraint: Don't take source actors position into account



commit 77d359cdc3a7f8c822e0134e70ce3c00d9259823
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Thu Jun 4 19:44:45 2020 +0200

    clutter/align-constraint: Don't take source actors position into account
    
    ClutterAlignConstraint currently assumes the source actor is positioned
    in the same coordinate system as the actor it's attached to and
    automatically offsets the adjusted allocation by the origin of the
    source actor.
    
    This behavior is only valid though in case the source actor is a sibling
    of the constraint actor. If the source actor is somewhere else in the
    actor tree, the behavior gets annoying because the constraint actor is
    offset by (seemingly) random positions.
    
    To fix this, stop offsetting the constraint actors allocation by the
    position of the source.
    
    To still make it possible to align the constraint actors origin with the
    origin of the source, no longer override the origin of the allocation
    in the AlignConstraint. This allows users to align the origin using a
    BindConstraint, binding the actor position to the position of the
    source, which is more flexible and also more elegant.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/737

 clutter/clutter/clutter-align-constraint.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/clutter/clutter/clutter-align-constraint.c b/clutter/clutter/clutter-align-constraint.c
index 21e9ef5eac..46cf44073b 100644
--- a/clutter/clutter/clutter-align-constraint.c
+++ b/clutter/clutter/clutter-align-constraint.c
@@ -135,7 +135,6 @@ clutter_align_constraint_update_allocation (ClutterConstraint *constraint,
   ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (constraint);
   gfloat source_width, source_height;
   gfloat actor_width, actor_height;
-  gfloat source_x, source_y;
   gfloat offset_x_start, offset_y_start;
   gfloat pivot_x, pivot_y;
 
@@ -144,7 +143,6 @@ clutter_align_constraint_update_allocation (ClutterConstraint *constraint,
 
   clutter_actor_box_get_size (allocation, &actor_width, &actor_height);
 
-  clutter_actor_get_position (align->source, &source_x, &source_y);
   clutter_actor_get_size (align->source, &source_width, &source_height);
 
   pivot_x = align->pivot.x == -1.f
@@ -160,18 +158,18 @@ clutter_align_constraint_update_allocation (ClutterConstraint *constraint,
   switch (align->align_axis)
     {
     case CLUTTER_ALIGN_X_AXIS:
-      allocation->x1 = source_x + offset_x_start + (source_width * align->factor);
+      allocation->x1 += offset_x_start + (source_width * align->factor);
       allocation->x2 = allocation->x1 + actor_width;
       break;
 
     case CLUTTER_ALIGN_Y_AXIS:
-      allocation->y1 = source_y + offset_y_start + (source_height * align->factor);
+      allocation->y1 += offset_y_start + (source_height * align->factor);
       allocation->y2 = allocation->y1 + actor_height;
       break;
 
     case CLUTTER_ALIGN_BOTH:
-      allocation->x1 = source_x + offset_x_start + (source_width * align->factor);
-      allocation->y1 = source_y + offset_y_start + (source_height * align->factor);
+      allocation->x1 += offset_x_start + (source_width * align->factor);
+      allocation->y1 += offset_y_start + (source_height * align->factor);
       allocation->x2 = allocation->x1 + actor_width;
       allocation->y2 = allocation->y1 + actor_height;
       break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]