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.

55 lines
1.1KB

  1. #pragma once
  2. #include <map>
  3. #include <app/common.hpp>
  4. #include <widget/Widget.hpp>
  5. #include <app/PortWidget.hpp>
  6. #include <engine/Cable.hpp>
  7. namespace rack {
  8. namespace app {
  9. struct PlugWidget;
  10. struct CableWidget : widget::Widget {
  11. struct Internal;
  12. Internal* internal;
  13. /** Owned. */
  14. engine::Cable* cable = NULL;
  15. NVGcolor color;
  16. PlugWidget* inputPlug;
  17. PlugWidget* outputPlug;
  18. PortWidget* inputPort = NULL;
  19. PortWidget* outputPort = NULL;
  20. PortWidget* hoveredInputPort = NULL;
  21. PortWidget* hoveredOutputPort = NULL;
  22. CableWidget();
  23. ~CableWidget();
  24. void setNextCableColor();
  25. bool isComplete();
  26. /** Based on the input/output ports, re-creates the cable and removes/adds it to the Engine. */
  27. void updateCable();
  28. /** From a cable, sets the input/output ports.
  29. Cable must already be added to the Engine.
  30. Adopts ownership.
  31. */
  32. void setCable(engine::Cable* cable);
  33. engine::Cable* getCable();
  34. math::Vec getInputPos();
  35. math::Vec getOutputPos();
  36. void mergeJson(json_t* rootJ);
  37. void fromJson(json_t* rootJ);
  38. void step() override;
  39. void draw(const DrawArgs& args) override;
  40. engine::Cable* releaseCable();
  41. };
  42. } // namespace app
  43. } // namespace rack