changeset 4636:bb7a38a8e7bf

Cleanup OOFFloatsMgr::collidesH().
author Sebastian Geerken
date Sa, 09 Jul 2016 22:56:10 +0200
parents 6562a0dbf236
children 11315ccf3aee
files dw/ooffloatsmgr.cc
diffstat 1 files changed, 13 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/dw/ooffloatsmgr.cc	Sa Jul 09 02:26:12 2016 +0000
+++ b/dw/ooffloatsmgr.cc	Sa Jul 09 22:56:10 2016 +0200
@@ -861,35 +861,22 @@
 
 bool OOFFloatsMgr::collidesH (Float *vloat, Float *other)
 {
-   // Only checks horizontal collision. For a complete test, use
-   // collidesV (...) && collidesH (...).
+   // Only checks horizontal collision. For a complete test, use collidesV (...)
+   // && collidesH (...).
    bool collidesH;
 
-   if (vloat->generator == other->generator)
-      collidesH = vloat->size.width + other->size.width
-         + vloat->generator->boxDiffWidth()
-         > vloat->generator->getGeneratorWidth ();
-   else {
-      // Again, if the other float is not allocated, there is no
-      // collision. Compare to collidesV. (But vloat->size is used
-      // here.)
-      if (!other->getWidget()->wasAllocated ())
-         collidesH = false;
-      else {
-         int vloatX = calcFloatX (vloat);
+   int vloatX = calcFloatX (vloat), otherX = calcFloatX (other);
 
-         // Generally: right border of the left float > left border of
-         // the right float (all in canvas coordinates).
-         if (vloat->getWidget()->getStyle()->vloat == FLOAT_LEFT)
-            // "vloat" is left, "other" is right
-            collidesH = vloatX + vloat->size.width
-               > other->getWidget()->getAllocation()->x;
-         else
-            // "other" is left, "vloat" is right
-            collidesH = other->getWidget()->getAllocation()->x
-               + other->getWidget()->getAllocation()->width
-               > vloatX;
-      }
+   // Generally: right border of the left float > left border of the right float
+   // (all in canvas coordinates).
+   if (vloat->getWidget()->getStyle()->vloat == FLOAT_LEFT) {
+      // "vloat" is left, "other" is right
+      ensureFloatSize (vloat);
+      collidesH = vloatX + vloat->size.width > otherX;
+   } else {
+      // "other" is left, "vloat" is right
+      ensureFloatSize (other);
+      collidesH = otherX + other->size.width > vloatX;
    }
 
    return collidesH;