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.

49 lines
1.1KB

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