[clutter/clutter-1.10] actor: Finally fix RESIZE_ASPECT content gravity



commit aeadbe70ea89914e520fa9fa6a9959b7c761dd46
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue May 29 15:39:59 2012 +0100

    actor: Finally fix RESIZE_ASPECT content gravity
    
    Ensure that resizing transitions smoothly when switching between major
    axis; the allocation aspect ratio is not important: it's the size of the
    allocation that dictates the major axis.
    (cherry picked from commit b9533cb397d1b272c7975c6e904fcd46894022fa)
    
    Signed-off-by: Emmanuele Bassi <ebassi gnome org>

 clutter/clutter-actor.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 1e2fd85..c3faff7 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -18054,17 +18054,16 @@ clutter_actor_get_content_box (ClutterActor    *self,
     case CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT:
       {
         double r_c = content_w / content_h;
-        double r_a = alloc_w / alloc_h;
 
         if (r_c >= 1.0)
           {
-            if (r_a >= 1.0)
+            if ((alloc_w / r_c) > alloc_h)
               {
                 box->x1 = 0.f;
                 box->x2 = alloc_w;
 
-                box->y1 = (alloc_h - (alloc_w * r_c)) / 2.0f;
-                box->y2 = box->y1 + (alloc_w * r_c);
+                box->y1 = (alloc_h - (alloc_w / r_c)) / 2.0f;
+                box->y2 = box->y1 + (alloc_w / r_c);
               }
             else
               {
@@ -18077,7 +18076,7 @@ clutter_actor_get_content_box (ClutterActor    *self,
           }
         else
           {
-            if (r_a >= 1.0)
+            if ((alloc_w / r_c) > alloc_h)
               {
                 box->y1 = 0.f;
                 box->y2 = alloc_h;
@@ -18090,10 +18089,19 @@ clutter_actor_get_content_box (ClutterActor    *self,
                 box->x1 = 0.f;
                 box->x2 = alloc_w;
 
-                box->y1 = (alloc_h - (alloc_w * r_c)) / 2.0f;
-                box->y2 = box->y1 + (alloc_w * r_c);
+                box->y1 = (alloc_h - (alloc_w / r_c)) / 2.0f;
+                box->y2 = box->y1 + (alloc_w / r_c);
               }
           }
+
+        CLUTTER_NOTE (LAYOUT,
+                      "r_c: %.3f, r_a: %.3f\t"
+                      "a: [%.2fx%.2f], c: [%.2fx%.2f]\t"
+                      "b: [%.2f, %.2f, %.2f, %.2f]",
+                      r_c, alloc_w / alloc_h,
+                      alloc_w, alloc_h,
+                      content_w, content_h,
+                      box->x1, box->y1, box->x2, box->y2);
       }
       break;
     }



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