| 729 | } |
| 730 | |
| 731 | bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) { |
| 732 | // Check intersection with other modules |
| 733 | math::Rect mwBox = math::Rect(pos, mw->box.size); |
| 734 | for (widget::Widget* w2 : internal->moduleContainer->children) { |
| 735 | // Don't intersect with self |
| 736 | if (mw == w2) |
| 737 | continue; |
| 738 | // Check intersection |
| 739 | math::Rect w2Box = w2->box; |
| 740 | if (mwBox.intersects(w2Box)) |
| 741 | return false; |
| 742 | } |
| 743 | |
| 744 | // Accept requested position |
| 745 | mw->setPosition(mwBox.pos); |
| 746 | updateExpanders(); |
| 747 | return true; |
| 748 | } |
| 749 | |
| 750 | static math::Vec eachNearestGridPos(math::Vec pos, std::function<bool(math::Vec pos)> f) { |
| 751 | math::Vec leftPos = (pos / RACK_GRID_SIZE).round(); |
no test coverage detected