Browse Source

Clean up RackWidget and ModuleWidget members.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
2a5180f101
9 changed files with 88 additions and 65 deletions
  1. +5
    -7
      include/app/ModuleWidget.hpp
  2. +4
    -5
      include/app/RackWidget.hpp
  3. +1
    -1
      include/helpers.hpp
  4. +2
    -2
      src/app/CableWidget.cpp
  5. +14
    -6
      src/app/ModuleWidget.cpp
  6. +1
    -1
      src/app/RackScrollWidget.cpp
  7. +55
    -37
      src/app/RackWidget.cpp
  8. +2
    -2
      src/core/Blank.cpp
  9. +4
    -4
      src/history.cpp

+ 5
- 7
include/app/ModuleWidget.hpp View File

@@ -18,7 +18,7 @@ struct ModuleWidget : widget::OpaqueWidget {
Internal* internal; Internal* internal;


plugin::Model* model = NULL; plugin::Model* model = NULL;
/** Owned. */
/** Owned */
engine::Module* module = NULL; engine::Module* module = NULL;


ModuleWidget(); ModuleWidget();
@@ -27,17 +27,15 @@ struct ModuleWidget : widget::OpaqueWidget {
} }
~ModuleWidget(); ~ModuleWidget();


plugin::Model* getModel() {
return model;
}
engine::Module* getModule() {
return module;
}
plugin::Model* getModel();
void setModel(plugin::Model* model);


engine::Module* getModule();
/** Associates this ModuleWidget with the Module. /** Associates this ModuleWidget with the Module.
Transfers ownership. Transfers ownership.
*/ */
void setModule(engine::Module* module); void setModule(engine::Module* module);

/** Sets the panel and sets the size of the ModuleWidget from the panel. /** Sets the panel and sets the size of the ModuleWidget from the panel.
Transfers ownership. Transfers ownership.
*/ */


+ 4
- 5
include/app/RackWidget.hpp View File

@@ -21,12 +21,7 @@ struct RackWidget : widget::OpaqueWidget {
struct Internal; struct Internal;
Internal* internal; Internal* internal;


RailWidget* rail;
widget::Widget* moduleContainer;
widget::Widget* cableContainer;
CableWidget* incompleteCable = NULL; CableWidget* incompleteCable = NULL;
/** The last mouse position in the RackWidget */
math::Vec mousePos;
ParamWidget* touchedParam = NULL; ParamWidget* touchedParam = NULL;
int nextCableColorId = 0; int nextCableColorId = 0;


@@ -45,6 +40,10 @@ struct RackWidget : widget::OpaqueWidget {


// Rack methods // Rack methods


widget::Widget* getModuleContainer();
widget::Widget* getCableContainer();
math::Vec getMousePos();

/** Completely clear the rack's modules and cables */ /** Completely clear the rack's modules and cables */
void clear(); void clear();
void mergeJson(json_t* rootJ); void mergeJson(json_t* rootJ);


+ 1
- 1
include/helpers.hpp View File

@@ -34,7 +34,7 @@ plugin::Model* createModel(const std::string& slug) {
tm = dynamic_cast<TModule*>(m); tm = dynamic_cast<TModule*>(m);
} }
app::ModuleWidget* mw = new TModuleWidget(tm); app::ModuleWidget* mw = new TModuleWidget(tm);
mw->model = this;
mw->setModel(this);
return mw; return mw;
} }
}; };


+ 2
- 2
src/app/CableWidget.cpp View File

@@ -193,7 +193,7 @@ math::Vec CableWidget::getInputPos() {
return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), APP->scene->rack); return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), APP->scene->rack);
} }
else { else {
return APP->scene->rack->mousePos;
return APP->scene->rack->getMousePos();
} }
} }


@@ -205,7 +205,7 @@ math::Vec CableWidget::getOutputPos() {
return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), APP->scene->rack); return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), APP->scene->rack);
} }
else { else {
return APP->scene->rack->mousePos;
return APP->scene->rack->getMousePos();
} }
} }




+ 14
- 6
src/app/ModuleWidget.cpp View File

@@ -434,6 +434,19 @@ ModuleWidget::~ModuleWidget() {
delete internal; delete internal;
} }


plugin::Model* ModuleWidget::getModel() {
return model;
}

void ModuleWidget::setModel(plugin::Model* model) {
assert(!this->model);
this->model = model;
}

engine::Module* ModuleWidget::getModule() {
return module;
}

void ModuleWidget::setModule(engine::Module* module) { void ModuleWidget::setModule(engine::Module* module) {
if (this->module) { if (this->module) {
APP->engine->removeModule(this->module); APP->engine->removeModule(this->module);
@@ -720,7 +733,7 @@ void ModuleWidget::onDragEnd(const DragEndEvent& e) {
void ModuleWidget::onDragMove(const DragMoveEvent& e) { void ModuleWidget::onDragMove(const DragMoveEvent& e) {
if (e.button == GLFW_MOUSE_BUTTON_LEFT) { if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
if (!settings::lockModules) { if (!settings::lockModules) {
math::Vec mousePos = APP->scene->rack->mousePos;
math::Vec mousePos = APP->scene->rack->getMousePos();


if (!internal->dragEnabled) { if (!internal->dragEnabled) {
// Set dragRackPos on the first time after dragging // Set dragRackPos on the first time after dragging
@@ -1200,29 +1213,24 @@ void ModuleWidget::createContextMenu() {
appendContextMenu(menu); appendContextMenu(menu);
} }



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



bool& ModuleWidget::dragEnabled() { bool& ModuleWidget::dragEnabled() {
return internal->dragEnabled; return internal->dragEnabled;
} }



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



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



bool& ModuleWidget::selected() { bool& ModuleWidget::selected() {
return internal->selected; return internal->selected;
} }


+ 1
- 1
src/app/RackScrollWidget.cpp View File

@@ -56,7 +56,7 @@ void RackScrollWidget::step() {
internal->zoomPos = box.size.div(2); internal->zoomPos = box.size.div(2);


// Compute module bounding box // Compute module bounding box
math::Rect moduleBox = rackWidget->moduleContainer->getChildrenBoundingBox();
math::Rect moduleBox = rackWidget->getModuleContainer()->getChildrenBoundingBox();
if (!moduleBox.size.isFinite()) if (!moduleBox.size.isFinite())
moduleBox = math::Rect(RACK_OFFSET, math::Vec(0, 0)); moduleBox = math::Rect(RACK_OFFSET, math::Vec(0, 0));




+ 55
- 37
src/app/RackWidget.cpp View File

@@ -73,6 +73,12 @@ struct CableContainer : widget::TransparentWidget {




struct RackWidget::Internal { struct RackWidget::Internal {
RailWidget* rail = NULL;
widget::Widget* moduleContainer = NULL;
widget::Widget* cableContainer = NULL;
/** The last mouse position in the RackWidget */
math::Vec mousePos;

bool selecting = false; bool selecting = false;
math::Vec selectionStart; math::Vec selectionStart;
math::Vec selectionEnd; math::Vec selectionEnd;
@@ -82,14 +88,14 @@ struct RackWidget::Internal {
RackWidget::RackWidget() { RackWidget::RackWidget() {
internal = new Internal; internal = new Internal;


rail = new RailWidget;
addChild(rail);
internal->rail = new RailWidget;
addChild(internal->rail);


moduleContainer = new ModuleContainer;
addChild(moduleContainer);
internal->moduleContainer = new ModuleContainer;
addChild(internal->moduleContainer);


cableContainer = new CableContainer;
addChild(cableContainer);
internal->cableContainer = new CableContainer;
addChild(internal->cableContainer);
} }


RackWidget::~RackWidget() { RackWidget::~RackWidget() {
@@ -123,7 +129,7 @@ void RackWidget::draw(const DrawArgs& args) {


void RackWidget::onHover(const HoverEvent& e) { void RackWidget::onHover(const HoverEvent& e) {
// Set before calling children's onHover() // Set before calling children's onHover()
mousePos = e.pos;
internal->mousePos = e.pos;


OpaqueWidget::onHover(e); OpaqueWidget::onHover(e);
} }
@@ -161,8 +167,8 @@ void RackWidget::onDragStart(const DragStartEvent& e) {
// Deselect all modules // Deselect all modules
updateModuleSelections(); updateModuleSelections();
internal->selecting = true; internal->selecting = true;
internal->selectionStart = mousePos;
internal->selectionEnd = mousePos;
internal->selectionStart = internal->mousePos;
internal->selectionEnd = internal->mousePos;
} }
} }


@@ -174,21 +180,33 @@ void RackWidget::onDragEnd(const DragEndEvent& e) {


void RackWidget::onDragHover(const DragHoverEvent& e) { void RackWidget::onDragHover(const DragHoverEvent& e) {
// Set before calling children's onDragHover() // Set before calling children's onDragHover()
mousePos = e.pos;
internal->mousePos = e.pos;


if (internal->selecting) { if (internal->selecting) {
internal->selectionEnd = mousePos;
internal->selectionEnd = internal->mousePos;
updateModuleSelections(); updateModuleSelections();
} }


OpaqueWidget::onDragHover(e); OpaqueWidget::onDragHover(e);
} }


widget::Widget* RackWidget::getModuleContainer() {
return internal->moduleContainer;
}

widget::Widget* RackWidget::getCableContainer() {
return internal->cableContainer;
}

math::Vec RackWidget::getMousePos() {
return internal->mousePos;
}

void RackWidget::clear() { void RackWidget::clear() {
// This isn't required because removing all ModuleWidgets should remove all cables, but do it just in case. // This isn't required because removing all ModuleWidgets should remove all cables, but do it just in case.
clearCables(); clearCables();
// Remove ModuleWidgets // Remove ModuleWidgets
std::list<widget::Widget*> widgets = moduleContainer->children;
std::list<widget::Widget*> widgets = internal->moduleContainer->children;
for (widget::Widget* w : widgets) { for (widget::Widget* w : widgets) {
ModuleWidget* moduleWidget = dynamic_cast<ModuleWidget*>(w); ModuleWidget* moduleWidget = dynamic_cast<ModuleWidget*>(w);
assert(moduleWidget); assert(moduleWidget);
@@ -200,10 +218,10 @@ void RackWidget::clear() {
void RackWidget::mergeJson(json_t* rootJ) { void RackWidget::mergeJson(json_t* rootJ) {
// Get module offset so modules are aligned to (0, 0) when the patch is loaded. // Get module offset so modules are aligned to (0, 0) when the patch is loaded.
math::Vec moduleOffset = math::Vec(INFINITY, INFINITY); math::Vec moduleOffset = math::Vec(INFINITY, INFINITY);
for (widget::Widget* w : moduleContainer->children) {
for (widget::Widget* w : internal->moduleContainer->children) {
moduleOffset = moduleOffset.min(w->box.pos); moduleOffset = moduleOffset.min(w->box.pos);
} }
if (moduleContainer->children.empty()) {
if (internal->moduleContainer->children.empty()) {
moduleOffset = RACK_OFFSET; moduleOffset = RACK_OFFSET;
} }


@@ -392,14 +410,14 @@ void RackWidget::pastePresetClipboardAction() {
} }


static void RackWidget_updateExpanders(RackWidget* that) { static void RackWidget_updateExpanders(RackWidget* that) {
for (widget::Widget* w : that->moduleContainer->children) {
for (widget::Widget* w : that->internal->moduleContainer->children) {
math::Vec pLeft = w->box.pos.div(RACK_GRID_SIZE).round(); math::Vec pLeft = w->box.pos.div(RACK_GRID_SIZE).round();
math::Vec pRight = w->box.getTopRight().div(RACK_GRID_SIZE).round(); math::Vec pRight = w->box.getTopRight().div(RACK_GRID_SIZE).round();
ModuleWidget* mwLeft = NULL; ModuleWidget* mwLeft = NULL;
ModuleWidget* mwRight = NULL; ModuleWidget* mwRight = NULL;


// Find adjacent modules // Find adjacent modules
for (widget::Widget* w2 : that->moduleContainer->children) {
for (widget::Widget* w2 : that->internal->moduleContainer->children) {
if (w2 == w) if (w2 == w)
continue; continue;


@@ -433,7 +451,7 @@ void RackWidget::addModule(ModuleWidget* m) {
if (m->box.size.y != RACK_GRID_HEIGHT) if (m->box.size.y != RACK_GRID_HEIGHT)
throw Exception("Module %s height is %g px, must be %g px", m->model->getFullName().c_str(), m->box.size.y, RACK_GRID_HEIGHT); throw Exception("Module %s height is %g px, must be %g px", m->model->getFullName().c_str(), m->box.size.y, RACK_GRID_HEIGHT);


moduleContainer->addChild(m);
internal->moduleContainer->addChild(m);


RackWidget_updateExpanders(this); RackWidget_updateExpanders(this);
} }
@@ -441,7 +459,7 @@ void RackWidget::addModule(ModuleWidget* m) {
void RackWidget::addModuleAtMouse(ModuleWidget* mw) { void RackWidget::addModuleAtMouse(ModuleWidget* mw) {
assert(mw); assert(mw);
// Move module nearest to the mouse position // Move module nearest to the mouse position
math::Vec pos = mousePos.minus(mw->box.size.div(2));
math::Vec pos = internal->mousePos.minus(mw->box.size.div(2));
setModulePosNearest(mw, pos); setModulePosNearest(mw, pos);
addModule(mw); addModule(mw);
} }
@@ -458,13 +476,13 @@ void RackWidget::removeModule(ModuleWidget* m) {
m->disconnect(); m->disconnect();


// Remove module from ModuleContainer // Remove module from ModuleContainer
moduleContainer->removeChild(m);
internal->moduleContainer->removeChild(m);
} }


bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) { bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) {
// Check intersection with other modules // Check intersection with other modules
math::Rect mwBox = math::Rect(pos, mw->box.size); math::Rect mwBox = math::Rect(pos, mw->box.size);
for (widget::Widget* w2 : moduleContainer->children) {
for (widget::Widget* w2 : internal->moduleContainer->children) {
// Don't intersect with self // Don't intersect with self
if (mw == w2) if (mw == w2)
continue; continue;
@@ -543,7 +561,7 @@ void RackWidget::setModulePosForce(ModuleWidget* mw, math::Vec pos) {
// Collect modules to the left and right of `mw` // Collect modules to the left and right of `mw`
std::set<widget::Widget*, decltype(cmp)> leftModules(cmp); std::set<widget::Widget*, decltype(cmp)> leftModules(cmp);
std::set<widget::Widget*, decltype(cmp)> rightModules(cmp); std::set<widget::Widget*, decltype(cmp)> rightModules(cmp);
for (widget::Widget* w2 : moduleContainer->children) {
for (widget::Widget* w2 : internal->moduleContainer->children) {
if (w2 == mw) if (w2 == mw)
continue; continue;
// Modules must be on the same row as `mw` // Modules must be on the same row as `mw`
@@ -585,7 +603,7 @@ void RackWidget::setModulePosForce(ModuleWidget* mw, math::Vec pos) {
} }


ModuleWidget* RackWidget::getModule(int64_t moduleId) { ModuleWidget* RackWidget::getModule(int64_t moduleId) {
for (widget::Widget* w : moduleContainer->children) {
for (widget::Widget* w : internal->moduleContainer->children) {
ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w); ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w);
assert(mw); assert(mw);
if (mw->module->id == moduleId) if (mw->module->id == moduleId)
@@ -595,12 +613,12 @@ ModuleWidget* RackWidget::getModule(int64_t moduleId) {
} }


bool RackWidget::isEmpty() { bool RackWidget::isEmpty() {
return moduleContainer->children.empty();
return internal->moduleContainer->children.empty();
} }


void RackWidget::updateModuleOldPositions() { void RackWidget::updateModuleOldPositions() {
// Set all modules' oldPos field from their current position. // Set all modules' oldPos field from their current position.
for (widget::Widget* w : moduleContainer->children) {
for (widget::Widget* w : internal->moduleContainer->children) {
ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w); ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w);
assert(mw); assert(mw);
mw->oldPos() = mw->box.pos; mw->oldPos() = mw->box.pos;
@@ -610,7 +628,7 @@ void RackWidget::updateModuleOldPositions() {
history::ComplexAction* RackWidget::getModuleDragAction() { history::ComplexAction* RackWidget::getModuleDragAction() {
history::ComplexAction* h = new history::ComplexAction; history::ComplexAction* h = new history::ComplexAction;


for (widget::Widget* w : moduleContainer->children) {
for (widget::Widget* w : internal->moduleContainer->children) {
ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w); ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w);
assert(mw); assert(mw);
// Create ModuleMove action if the module was moved. // Create ModuleMove action if the module was moved.
@@ -633,7 +651,7 @@ history::ComplexAction* RackWidget::getModuleDragAction() {


void RackWidget::updateModuleSelections() { void RackWidget::updateModuleSelections() {
math::Rect selectionBox = math::Rect::fromCorners(internal->selectionStart, internal->selectionEnd); math::Rect selectionBox = math::Rect::fromCorners(internal->selectionStart, internal->selectionEnd);
for (widget::Widget* w : moduleContainer->children) {
for (widget::Widget* w : internal->moduleContainer->children) {
ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w); ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w);
assert(mw); assert(mw);
bool selected = internal->selecting && selectionBox.intersects(mw->box); bool selected = internal->selecting && selectionBox.intersects(mw->box);
@@ -643,7 +661,7 @@ void RackWidget::updateModuleSelections() {


void RackWidget::clearCables() { void RackWidget::clearCables() {
incompleteCable = NULL; incompleteCable = NULL;
cableContainer->clearChildren();
internal->cableContainer->clearChildren();
} }


void RackWidget::clearCablesAction() { void RackWidget::clearCablesAction() {
@@ -651,7 +669,7 @@ void RackWidget::clearCablesAction() {
history::ComplexAction* complexAction = new history::ComplexAction; history::ComplexAction* complexAction = new history::ComplexAction;
complexAction->name = "clear cables"; complexAction->name = "clear cables";


for (widget::Widget* w : cableContainer->children) {
for (widget::Widget* w : internal->cableContainer->children) {
CableWidget* cw = dynamic_cast<CableWidget*>(w); CableWidget* cw = dynamic_cast<CableWidget*>(w);
assert(cw); assert(cw);
if (!cw->isComplete()) if (!cw->isComplete())
@@ -675,7 +693,7 @@ void RackWidget::clearCablesOnPort(PortWidget* port) {
// Check if cable is connected to port // Check if cable is connected to port
if (cw == incompleteCable) { if (cw == incompleteCable) {
incompleteCable = NULL; incompleteCable = NULL;
cableContainer->removeChild(cw);
internal->cableContainer->removeChild(cw);
} }
else { else {
removeCable(cw); removeCable(cw);
@@ -686,22 +704,22 @@ void RackWidget::clearCablesOnPort(PortWidget* port) {


void RackWidget::addCable(CableWidget* cw) { void RackWidget::addCable(CableWidget* cw) {
assert(cw->isComplete()); assert(cw->isComplete());
cableContainer->addChild(cw);
internal->cableContainer->addChild(cw);
} }


void RackWidget::removeCable(CableWidget* cw) { void RackWidget::removeCable(CableWidget* cw) {
assert(cw->isComplete()); assert(cw->isComplete());
cableContainer->removeChild(cw);
internal->cableContainer->removeChild(cw);
} }


void RackWidget::setIncompleteCable(CableWidget* cw) { void RackWidget::setIncompleteCable(CableWidget* cw) {
if (incompleteCable) { if (incompleteCable) {
cableContainer->removeChild(incompleteCable);
internal->cableContainer->removeChild(incompleteCable);
delete incompleteCable; delete incompleteCable;
incompleteCable = NULL; incompleteCable = NULL;
} }
if (cw) { if (cw) {
cableContainer->addChild(cw);
internal->cableContainer->addChild(cw);
incompleteCable = cw; incompleteCable = cw;
} }
} }
@@ -711,13 +729,13 @@ CableWidget* RackWidget::releaseIncompleteCable() {
return NULL; return NULL;


CableWidget* cw = incompleteCable; CableWidget* cw = incompleteCable;
cableContainer->removeChild(incompleteCable);
internal->cableContainer->removeChild(incompleteCable);
incompleteCable = NULL; incompleteCable = NULL;
return cw; return cw;
} }


CableWidget* RackWidget::getTopCable(PortWidget* port) { CableWidget* RackWidget::getTopCable(PortWidget* port) {
for (auto it = cableContainer->children.rbegin(); it != cableContainer->children.rend(); it++) {
for (auto it = internal->cableContainer->children.rbegin(); it != internal->cableContainer->children.rend(); it++) {
CableWidget* cw = dynamic_cast<CableWidget*>(*it); CableWidget* cw = dynamic_cast<CableWidget*>(*it);
assert(cw); assert(cw);
if (cw->inputPort == port || cw->outputPort == port) if (cw->inputPort == port || cw->outputPort == port)
@@ -727,7 +745,7 @@ CableWidget* RackWidget::getTopCable(PortWidget* port) {
} }


CableWidget* RackWidget::getCable(int64_t cableId) { CableWidget* RackWidget::getCable(int64_t cableId) {
for (widget::Widget* w : cableContainer->children) {
for (widget::Widget* w : internal->cableContainer->children) {
CableWidget* cw = dynamic_cast<CableWidget*>(w); CableWidget* cw = dynamic_cast<CableWidget*>(w);
assert(cw); assert(cw);
if (!cw->cable) if (!cw->cable)
@@ -741,7 +759,7 @@ CableWidget* RackWidget::getCable(int64_t cableId) {
std::list<CableWidget*> RackWidget::getCablesOnPort(PortWidget* port) { std::list<CableWidget*> RackWidget::getCablesOnPort(PortWidget* port) {
assert(port); assert(port);
std::list<CableWidget*> cws; std::list<CableWidget*> cws;
for (widget::Widget* w : cableContainer->children) {
for (widget::Widget* w : internal->cableContainer->children) {
CableWidget* cw = dynamic_cast<CableWidget*>(w); CableWidget* cw = dynamic_cast<CableWidget*>(w);
assert(cw); assert(cw);
if (cw->inputPort == port || cw->outputPort == port) { if (cw->inputPort == port || cw->outputPort == port) {


+ 2
- 2
src/core/Blank.cpp View File

@@ -68,7 +68,7 @@ struct ModuleResizeHandle : OpaqueWidget {
if (e.button != GLFW_MOUSE_BUTTON_LEFT) if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return; return;


dragPos = APP->scene->rack->mousePos;
dragPos = APP->scene->rack->getMousePos();
ModuleWidget* mw = getAncestorOfType<ModuleWidget>(); ModuleWidget* mw = getAncestorOfType<ModuleWidget>();
assert(mw); assert(mw);
originalBox = mw->box; originalBox = mw->box;
@@ -78,7 +78,7 @@ struct ModuleResizeHandle : OpaqueWidget {
ModuleWidget* mw = getAncestorOfType<ModuleWidget>(); ModuleWidget* mw = getAncestorOfType<ModuleWidget>();
assert(mw); assert(mw);


Vec newDragPos = APP->scene->rack->mousePos;
Vec newDragPos = APP->scene->rack->getMousePos();
float deltaX = newDragPos.x - dragPos.x; float deltaX = newDragPos.x - dragPos.x;


Rect newBox = originalBox; Rect newBox = originalBox;


+ 4
- 4
src/history.cpp View File

@@ -43,13 +43,13 @@ ModuleAdd::~ModuleAdd() {


void ModuleAdd::setModule(app::ModuleWidget* mw) { void ModuleAdd::setModule(app::ModuleWidget* mw) {
assert(mw); assert(mw);
model = mw->model;
assert(mw->module);
moduleId = mw->module->id;
model = mw->getModel();
assert(mw->getModule());
moduleId = mw->getModule()->id;
pos = mw->box.pos; pos = mw->box.pos;
// ModuleAdd doesn't *really* need the state to be serialized, although ModuleRemove certainly does. // ModuleAdd doesn't *really* need the state to be serialized, although ModuleRemove certainly does.
// However, creating a module may give it a nondeterministic initial state for whatever reason, so serialize anyway. // However, creating a module may give it a nondeterministic initial state for whatever reason, so serialize anyway.
moduleJ = APP->engine->moduleToJson(mw->module);
moduleJ = APP->engine->moduleToJson(mw->getModule());
} }


void ModuleAdd::undo() { void ModuleAdd::undo() {


Loading…
Cancel
Save