Browse Source

Fixed most mouse alignment issues

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
243aa8308a
6 changed files with 17 additions and 8 deletions
  1. +4
    -1
      .gitignore
  2. +2
    -0
      include/app.hpp
  3. +2
    -2
      src/app/ModuleWidget.cpp
  4. +6
    -2
      src/app/RackWidget.cpp
  5. +1
    -1
      src/app/Toolbar.cpp
  6. +2
    -2
      src/app/WireWidget.cpp

+ 4
- 1
.gitignore View File

@@ -4,4 +4,7 @@
/settings.json /settings.json
/plugins /plugins
/build /build
/dep
/dep
*.vcv
/patches
/design

+ 2
- 0
include/app.hpp View File

@@ -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;
}; };




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

@@ -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);
} }




+ 6
- 2
src/app/RackWidget.cpp View File

@@ -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);
} }
} }


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

@@ -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;


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

@@ -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));
} }


Loading…
Cancel
Save