MCPcopy Create free account
hub / github.com/VCVRack/Rack / requestModulePos

Method requestModulePos

src/app/RackWidget.cpp:731–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731bool 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
750static math::Vec eachNearestGridPos(math::Vec pos, std::function<bool(math::Vec pos)> f) {
751 math::Vec leftPos = (pos / RACK_GRID_SIZE).round();

Callers 1

onDragMoveMethod · 0.80

Calls 3

RectClass · 0.85
intersectsMethod · 0.80
setPositionMethod · 0.80

Tested by

no test coverage detected