File tree Expand file tree Collapse file tree
src/modules/trial-and-error Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,11 +59,20 @@ ModuleWidget* chooseModel(plugin::Model* model, bool hideBrowser) {
5959 // current mouse position because the mouse is now inside the browser UI.
6060 BrowserOverlay* overlay = dynamic_cast <BrowserOverlay*>(APP ->scene ->browser );
6161 if (overlay && overlay->rackMousePosAtOpen .isFinite ()) {
62- math::Vec pos = overlay->rackMousePosAtOpen - moduleWidget->box .size .div (2 );
63- pos.x = std::round (pos.x / RACK_GRID_WIDTH ) * RACK_GRID_WIDTH ;
64- pos.y = std::round (pos.y / RACK_GRID_HEIGHT ) * RACK_GRID_HEIGHT ;
65- moduleWidget->box .pos = pos;
66- APP ->scene ->rack ->addModule (moduleWidget);
62+ if (hideBrowser) {
63+ // Single-click: center on the stored right-click position, snapped to grid.
64+ math::Vec pos = overlay->rackMousePosAtOpen - moduleWidget->box .size .div (2 );
65+ pos.x = std::round (pos.x / RACK_GRID_WIDTH ) * RACK_GRID_WIDTH ;
66+ pos.y = std::round (pos.y / RACK_GRID_HEIGHT ) * RACK_GRID_HEIGHT ;
67+ moduleWidget->box .pos = pos;
68+ APP ->scene ->rack ->addModule (moduleWidget);
69+ }
70+ else {
71+ // Shift-click (browser stays open): use setModulePosForce so each new
72+ // module lands near the right-click position and pushes others aside.
73+ APP ->scene ->rack ->addModule (moduleWidget);
74+ APP ->scene ->rack ->setModulePosForce (moduleWidget, overlay->rackMousePosAtOpen - moduleWidget->box .size .div (2 ));
75+ }
6776 }
6877 else {
6978 APP ->scene ->rack ->addModuleAtMouse (moduleWidget);
You can’t perform that action at this time.
0 commit comments