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.2KB

  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. bool isComplete();
  25. /** Based on the input/output ports, re-creates the cable and removes/adds it to the Engine. */
  26. void updateCable();
  27. /** From a cable, sets the input/output ports.
  28. Cable must already be added to the Engine.
  29. Adopts ownership.
  30. */
  31. void setCable(engine::Cable* cable);
  32. engine::Cable* getCable();
  33. math::Vec getInputPos();
  34. math::Vec getOutputPos();
  35. void mergeJson(json_t* rootJ);
  36. void fromJson(json_t* rootJ);
  37. void step() override;
  38. void draw(const DrawArgs& args) override;
  39. void drawLayer(const DrawArgs& args, int layer) override;
  40. engine::Cable* releaseCable();
  41. };
  42. } // namespace app
  43. } // namespace rack