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.

43 lines
979B

  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. /** From input/output ports, re-creates a cable and 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. */
  26. void setCable(engine::Cable* cable);
  27. math::Vec getInputPos();
  28. math::Vec getOutputPos();
  29. json_t* toJson();
  30. void fromJson(json_t* rootJ);
  31. void draw(const DrawArgs& args) override;
  32. void drawPlugs(const DrawArgs& args);
  33. };
  34. } // namespace app
  35. } // namespace rack