You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
912B

  1. #include "Rack.hpp"
  2. namespace rack {
  3. void InputPort::draw(NVGcontext *vg) {
  4. SpriteWidget::draw(vg);
  5. if (gRackWidget->activeWire && gRackWidget->activeWire->inputPort) {
  6. Port::drawGlow(vg);
  7. }
  8. }
  9. void InputPort::onDragStart() {
  10. if (connectedWire) {
  11. // Disconnect wire from this port, but set it as the active wire
  12. connectedWire->inputPort = NULL;
  13. connectedWire->updateWire();
  14. gRackWidget->activeWire = connectedWire;
  15. connectedWire = NULL;
  16. }
  17. else {
  18. connectedWire = new WireWidget();
  19. connectedWire->inputPort = this;
  20. gRackWidget->wireContainer->addChild(connectedWire);
  21. gRackWidget->activeWire = connectedWire;
  22. }
  23. }
  24. void InputPort::onDragDrop(Widget *origin) {
  25. if (connectedWire) return;
  26. if (gRackWidget->activeWire) {
  27. if (gRackWidget->activeWire->inputPort) return;
  28. gRackWidget->activeWire->inputPort = this;
  29. connectedWire = gRackWidget->activeWire;
  30. }
  31. }
  32. } // namespace rack