Browse Source

Remove ModuleWidget::oldPos, store old module positions in RackWidget::Internal.

tags/v2.1.0
Andrew Belt 2 years ago
parent
commit
6a7bd37389
3 changed files with 7 additions and 14 deletions
  1. +0
    -1
      include/app/ModuleWidget.hpp
  2. +0
    -10
      src/app/ModuleWidget.cpp
  3. +7
    -3
      src/app/RackWidget.cpp

+ 0
- 1
include/app/ModuleWidget.hpp View File

@@ -118,7 +118,6 @@ struct ModuleWidget : widget::OpaqueWidget {

PRIVATE math::Vec& dragOffset();
PRIVATE bool& dragEnabled();
PRIVATE math::Vec& oldPos();
PRIVATE engine::Module* releaseModule();
};



+ 0
- 10
src/app/ModuleWidget.cpp View File

@@ -36,12 +36,6 @@ struct ModuleWidget::Internal {
math::Vec dragRackPos;
bool dragEnabled = true;

/** The position in the RackWidget when dragging began.
Used for history::ModuleMove.
Set by RackWidget::updateModuleOldPositions() when *any* module begins dragging, since force-dragging can move other modules around.
*/
math::Vec oldPos;

widget::Widget* panel = NULL;
};

@@ -1044,10 +1038,6 @@ bool& ModuleWidget::dragEnabled() {
return internal->dragEnabled;
}

math::Vec& ModuleWidget::oldPos() {
return internal->oldPos;
}

engine::Module* ModuleWidget::releaseModule() {
engine::Module* module = this->module;
this->module = NULL;


+ 7
- 3
src/app/RackWidget.cpp View File

@@ -36,6 +36,7 @@ struct RackWidget::Internal {
math::Vec selectionStart;
math::Vec selectionEnd;
std::set<ModuleWidget*> selectedModules;
std::map<ModuleWidget*, math::Vec> moduleOldPositions;
};


@@ -800,9 +801,9 @@ bool RackWidget::hasModules() {
}

void RackWidget::updateModuleOldPositions() {
// Set all modules' oldPos field from their current position.
internal->moduleOldPositions.clear();
for (ModuleWidget* mw : getModules()) {
mw->oldPos() = mw->box.pos;
internal->moduleOldPositions[mw] = mw->getPosition();
}
}

@@ -812,7 +813,10 @@ history::ComplexAction* RackWidget::getModuleDragAction() {

for (ModuleWidget* mw : getModules()) {
// Create ModuleMove action if the module was moved.
math::Vec oldPos = mw->oldPos();
auto it = internal->moduleOldPositions.find(mw);
if (it == internal->moduleOldPositions.end())
continue;
math::Vec oldPos = it->second;
if (!oldPos.equals(mw->box.pos)) {
history::ModuleMove* mmh = new history::ModuleMove;
mmh->moduleId = mw->module->id;


Loading…
Cancel
Save