@@ -4,4 +4,7 @@ | |||||
/settings.json | /settings.json | ||||
/plugins | /plugins | ||||
/build | /build | ||||
/dep | |||||
/dep | |||||
*.vcv | |||||
/patches | |||||
/design |
@@ -111,6 +111,7 @@ struct RackWidget : OpaqueWidget { | |||||
// Only put WireWidgets in here | // Only put WireWidgets in here | ||||
WireContainer *wireContainer; | WireContainer *wireContainer; | ||||
std::string lastPath; | std::string lastPath; | ||||
Vec lastMousePos; | |||||
RackWidget(); | RackWidget(); | ||||
~RackWidget(); | ~RackWidget(); | ||||
@@ -138,6 +139,7 @@ struct RackWidget : OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
Widget *onMouseMove(Vec pos, Vec mouseRel) override; | |||||
void onMouseDownOpaque(int button) override; | void onMouseDownOpaque(int button) override; | ||||
}; | }; | ||||
@@ -192,12 +192,12 @@ Widget *ModuleWidget::onHoverKey(Vec pos, int key) { | |||||
} | } | ||||
void ModuleWidget::onDragStart() { | void ModuleWidget::onDragStart() { | ||||
dragPos = gMousePos.minus(getAbsolutePos()); | |||||
dragPos = gRackWidget->lastMousePos.minus(box.pos); | |||||
} | } | ||||
void ModuleWidget::onDragMove(Vec mouseRel) { | void ModuleWidget::onDragMove(Vec mouseRel) { | ||||
Rect newBox = box; | Rect newBox = box; | ||||
newBox.pos = gMousePos.minus(parent->getAbsolutePos()).minus(dragPos); | |||||
newBox.pos = gRackWidget->lastMousePos.minus(dragPos); | |||||
gRackWidget->requestModuleBoxNearest(this, newBox); | gRackWidget->requestModuleBoxNearest(this, newBox); | ||||
} | } | ||||
@@ -475,9 +475,13 @@ struct SearchModuleField : TextField { | |||||
} | } | ||||
}; | }; | ||||
Widget *RackWidget::onMouseMove(Vec pos, Vec mouseRel) { | |||||
lastMousePos = pos; | |||||
return OpaqueWidget::onMouseMove(pos, mouseRel); | |||||
} | |||||
void RackWidget::onMouseDownOpaque(int button) { | void RackWidget::onMouseDownOpaque(int button) { | ||||
if (button == 1) { | if (button == 1) { | ||||
Vec modulePos = gMousePos.minus(getAbsolutePos()); | |||||
Menu *menu = gScene->createMenu(); | Menu *menu = gScene->createMenu(); | ||||
menu->pushChild(construct<MenuLabel>(&MenuLabel::text, "Add module")); | menu->pushChild(construct<MenuLabel>(&MenuLabel::text, "Add module")); | ||||
@@ -503,7 +507,7 @@ void RackWidget::onMouseDownOpaque(int button) { | |||||
AddManufacturerMenuItem *item = new AddManufacturerMenuItem(); | AddManufacturerMenuItem *item = new AddManufacturerMenuItem(); | ||||
item->text = manufacturerName; | item->text = manufacturerName; | ||||
item->manufacturerName = manufacturerName; | item->manufacturerName = manufacturerName; | ||||
item->modulePos = modulePos; | |||||
item->modulePos = lastMousePos; | |||||
menu->pushChild(item); | menu->pushChild(item); | ||||
} | } | ||||
} | } | ||||
@@ -153,7 +153,7 @@ Toolbar::Toolbar() { | |||||
zoomSlider->box.size.x = 150; | zoomSlider->box.size.x = 150; | ||||
zoomSlider->label = "Zoom"; | zoomSlider->label = "Zoom"; | ||||
zoomSlider->unit = "%"; | zoomSlider->unit = "%"; | ||||
zoomSlider->setLimits(50.0, 200.0); | |||||
zoomSlider->setLimits(25.0, 200.0); | |||||
zoomSlider->setDefaultValue(100.0); | zoomSlider->setDefaultValue(100.0); | ||||
addChild(zoomSlider); | addChild(zoomSlider); | ||||
xPos += zoomSlider->box.size.x; | xPos += zoomSlider->box.size.x; | ||||
@@ -132,7 +132,7 @@ Vec WireWidget::getOutputPos() { | |||||
pos = Rect(hoveredOutputPort->getAbsolutePos(), hoveredOutputPort->box.size).getCenter(); | pos = Rect(hoveredOutputPort->getAbsolutePos(), hoveredOutputPort->box.size).getCenter(); | ||||
} | } | ||||
else { | else { | ||||
pos = gMousePos; | |||||
return gRackWidget->lastMousePos; | |||||
} | } | ||||
return pos.minus(getAbsolutePos().minus(box.pos)); | return pos.minus(getAbsolutePos().minus(box.pos)); | ||||
} | } | ||||
@@ -146,7 +146,7 @@ Vec WireWidget::getInputPos() { | |||||
pos = Rect(hoveredInputPort->getAbsolutePos(), hoveredInputPort->box.size).getCenter(); | pos = Rect(hoveredInputPort->getAbsolutePos(), hoveredInputPort->box.size).getCenter(); | ||||
} | } | ||||
else { | else { | ||||
pos = gMousePos; | |||||
return gRackWidget->lastMousePos; | |||||
} | } | ||||
return pos.minus(getAbsolutePos().minus(box.pos)); | return pos.minus(getAbsolutePos().minus(box.pos)); | ||||
} | } | ||||