diff --git a/include/app/RackWidget.hpp b/include/app/RackWidget.hpp index 212af7a0..5a962744 100644 --- a/include/app/RackWidget.hpp +++ b/include/app/RackWidget.hpp @@ -14,10 +14,10 @@ namespace app { /** Container for ModuleWidget and CableWidget. */ struct RackWidget : widget::OpaqueWidget { - widget::FramebufferWidget *rails; widget::Widget *moduleContainer; widget::Widget *cableContainer; CableWidget *incompleteCable = NULL; + widget::FramebufferWidget *railFb; /** The last mouse position in the RackWidget */ math::Vec mousePos; ParamWidget *touchedParam = NULL; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 6ecba782..998cfc75 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -75,15 +75,15 @@ struct CableContainer : widget::TransparentWidget { RackWidget::RackWidget() { - rails = new widget::FramebufferWidget; - rails->box.size = math::Vec(); - rails->oversample = 1.0; + railFb = new widget::FramebufferWidget; + railFb->box.size = math::Vec(); + railFb->oversample = 1.0; { RackRail *rail = new RackRail; rail->box.size = math::Vec(); - rails->addChild(rail); + railFb->addChild(rail); } - addChild(rails); + addChild(railFb); moduleContainer = new ModuleContainer; addChild(moduleContainer); @@ -97,16 +97,16 @@ RackWidget::~RackWidget() { } void RackWidget::step() { - // Adjust size and position of rails + // Adjust size and position of railFb math::Rect bound = getViewport(math::Rect(math::Vec(), box.size)); - if (!rails->box.isContaining(bound)) { - math::Vec cellMargin = math::Vec(20, 1); - rails->box.pos = bound.pos.div(RACK_GRID_SIZE).floor().minus(cellMargin).mult(RACK_GRID_SIZE); - rails->box.size = bound.size.plus(cellMargin.mult(RACK_GRID_SIZE).mult(2)); - rails->dirty = true; - - RackRail *rail = rails->getFirstDescendantOfType(); - rail->box.size = rails->box.size; + if (!railFb->box.isContaining(bound)) { + math::Vec margin = math::Vec(200, 200); + railFb->box.pos = bound.pos.minus(margin).div(RACK_GRID_SIZE).floor().mult(RACK_GRID_SIZE); + railFb->box.size = bound.size.plus(margin.mult(2)); + railFb->dirty = true; + + RackRail *rail = railFb->getFirstDescendantOfType(); + rail->box.size = railFb->box.size; } OpaqueWidget::step();