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.

44 lines
1016B

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