diff options
author | Sebastian Geerken <devnull@localhost> | 2016-07-09 22:56:10 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-07-09 22:56:10 +0200 |
commit | d0bcff737cb8959e0b5cd6968fd840b3082bb3d6 (patch) | |
tree | a5e1185bad4a906f9a478ebe8ee12237f2c78d51 /dw/ooffloatsmgr.cc | |
parent | 64af298cacd3bd6a4726ab73a0033109825fd0d5 (diff) |
Cleanup OOFFloatsMgr::collidesH().
Diffstat (limited to 'dw/ooffloatsmgr.cc')
-rw-r--r-- | dw/ooffloatsmgr.cc | 41 |
1 files changed, 14 insertions, 27 deletions
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; |