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.

CableWidget.hpp 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /** Owned. */
  12. engine::Cable* cable = NULL;
  13. NVGcolor color;
  14. PortWidget* inputPort = NULL;
  15. PortWidget* outputPort = NULL;
  16. PortWidget* hoveredInputPort = NULL;
  17. PortWidget* hoveredOutputPort = NULL;
  18. CableWidget();
  19. ~CableWidget();
  20. void setNextCableColor();
  21. bool isComplete();
  22. /** Based on the input/output ports, re-creates the cable and removes/adds it to the Engine. */
  23. void updateCable();
  24. /** From a cable, sets the input/output ports.
  25. Cable must already be added to the Engine.
  26. Adopts ownership.
  27. */
  28. void setCable(engine::Cable* cable);
  29. math::Vec getInputPos();
  30. math::Vec getOutputPos();
  31. json_t* toJson();
  32. void fromJson(json_t* rootJ);
  33. void draw(const DrawArgs& args) override;
  34. void drawPlugs(const DrawArgs& args);
  35. };
  36. } // namespace app
  37. } // namespace rack