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.

41 lines
632B

  1. #include "scene.hpp"
  2. namespace rack {
  3. Port::Port() {
  4. box.size = Vec(20, 20);
  5. }
  6. Port::~Port() {
  7. disconnect();
  8. }
  9. void Port::disconnect() {
  10. if (connectedWire) {
  11. gRackWidget->wireContainer->removeChild(connectedWire);
  12. // On destruction, Wire automatically sets connectedWire to NULL
  13. delete connectedWire;
  14. }
  15. }
  16. void Port::onMouseDown(int button) {
  17. if (button == 1) {
  18. disconnect();
  19. }
  20. }
  21. void Port::onDragEnd() {
  22. WireWidget *w = gRackWidget->activeWire;
  23. assert(w);
  24. w->updateWire();
  25. if (!w->wire) {
  26. gRackWidget->wireContainer->removeChild(w);
  27. delete w;
  28. }
  29. gRackWidget->activeWire = NULL;
  30. }
  31. } // namespace rack