From d0bcff737cb8959e0b5cd6968fd840b3082bb3d6 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Sat, 9 Jul 2016 22:56:10 +0200 Subject: Cleanup OOFFloatsMgr::collidesH(). --- dw/ooffloatsmgr.cc | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'dw') diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index 59a2a4bc..0557e1da 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -861,35 +861,22 @@ bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, int *yReal) 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); - - // 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; - } + 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 + 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; -- cgit v1.2.3