@@ -95,9 +95,9 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
*/ | */ | ||||
virtual void appendContextMenu(ui::Menu* menu) {} | virtual void appendContextMenu(ui::Menu* menu) {} | ||||
math::Vec& dragPos(); | |||||
math::Vec& oldPos(); | |||||
engine::Module* releaseModule(); | |||||
PRIVATE math::Vec& dragPos(); | |||||
PRIVATE math::Vec& oldPos(); | |||||
PRIVATE engine::Module* releaseModule(); | |||||
}; | }; | ||||
@@ -230,7 +230,7 @@ struct ModelBox : widget::OpaqueWidget { | |||||
// Set the drag position at the center of the module | // Set the drag position at the center of the module | ||||
// TODO This doesn't work because ModuleWidget::onDragStart, which is called afterwards, overwrites this. | // TODO This doesn't work because ModuleWidget::onDragStart, which is called afterwards, overwrites this. | ||||
// mw->dragPos() = mw->box.size.div(2); | |||||
mw->dragPos() = mw->box.size.div(2); | |||||
} | } | ||||
} | } | ||||
@@ -485,6 +485,11 @@ void ModuleWidget::onButton(const event::Button& e) { | |||||
else | else | ||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
// Set starting drag position even if we don't consume it | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||||
internal->dragPos = e.pos; | |||||
} | |||||
if (e.isConsumed()) | if (e.isConsumed()) | ||||
return; | return; | ||||
@@ -540,8 +545,6 @@ void ModuleWidget::onHoverKey(const event::HoverKey& e) { | |||||
void ModuleWidget::onDragStart(const event::DragStart& e) { | void ModuleWidget::onDragStart(const event::DragStart& e) { | ||||
if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
internal->dragPos = APP->scene->rack->mousePos.minus(box.pos); | |||||
DEBUG("drag (%f, %f)", VEC_ARGS(internal->dragPos)); | |||||
APP->scene->rack->updateModuleOldPositions(); | APP->scene->rack->updateModuleOldPositions(); | ||||
} | } | ||||
} | } | ||||