Browse Source

Fix RackWidget::requestModulePos() after Rect::intersects() was made

inclusive.
tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
63b424afcb
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/app/RackWidget.cpp

+ 3
- 2
src/app/RackWidget.cpp View File

@@ -437,7 +437,8 @@ void RackWidget::removeModule(ModuleWidget* m) {
bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) { bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) {
// Check intersection with other modules // Check intersection with other modules
math::Rect mwBox = math::Rect(pos, mw->box.size); math::Rect mwBox = math::Rect(pos, mw->box.size);
mwBox.size.x -= 0.01;
// Since `Rect::intersects()` is inclusive, subtract an infinitesimal from the size.
mwBox.size = mwBox.size.minus(math::Vec(0.01, 0.01));
for (widget::Widget* w2 : moduleContainer->children) { for (widget::Widget* w2 : moduleContainer->children) {
// Don't intersect with self // Don't intersect with self
if (mw == w2) if (mw == w2)
@@ -447,7 +448,7 @@ bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) {
continue; continue;
// Check intersection // Check intersection
math::Rect w2Box = w2->box; math::Rect w2Box = w2->box;
w2Box.size.x -= 0.01;
w2Box.size = w2Box.size.minus(math::Vec(0.01, 0.01));
if (mwBox.intersects(w2Box)) if (mwBox.intersects(w2Box))
return false; return false;
} }


Loading…
Cancel
Save