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.

95 lines
2.0KB

  1. #pragma once
  2. #include "rack.hpp"
  3. #include "WidgetComposite.h"
  4. #include <functional>
  5. /**
  6. * Like Trimpot, but with blue stripe
  7. */
  8. struct BlueTrimmer : SVGKnob {
  9. BlueTrimmer() {
  10. // printf("ctrol of blue trimmer\n"); fflush(stdout);
  11. minAngle = -0.75*M_PI;
  12. maxAngle = 0.75*M_PI;
  13. setSVG(SVG::load(assetPlugin(plugin, "res/BlueTrimmer.svg")));
  14. }
  15. };
  16. /**
  17. * Like Rogan1PSBlue, but smaller.
  18. */
  19. struct Blue30Knob : SVGKnob {
  20. Blue30Knob() {
  21. minAngle = -0.83*M_PI;
  22. maxAngle = 0.83*M_PI;
  23. setSVG(SVG::load(assetPlugin(plugin, "res/Blue30.svg")));
  24. }
  25. };
  26. struct Blue30SnapKnob : Blue30Knob {
  27. Blue30SnapKnob() {
  28. snap = true;
  29. smooth = false;
  30. }
  31. };
  32. struct NKKSmall : SVGSwitch, ToggleSwitch {
  33. NKKSmall() {
  34. addFrame(SVG::load(assetPlugin(plugin, "res/NKKSmall_0.svg")));
  35. addFrame(SVG::load(assetPlugin(plugin, "res/NKKSmall_1.svg")));
  36. addFrame(SVG::load(assetPlugin(plugin, "res/NKKSmall_2.svg")));
  37. }
  38. };
  39. struct BlueToggle : public SVGSwitch, ToggleSwitch {
  40. BlueToggle() {
  41. addFrame(SVG::load(assetPlugin(plugin, "res/BluePush_1.svg")));
  42. addFrame(SVG::load(assetPlugin(plugin, "res/BluePush_0.svg")));
  43. #if 0
  44. setSVGs(
  45. SVG::load(assetPlugin(plugin, "res/BluePush_0.svg")),
  46. SVG::load(assetPlugin(plugin, "res/BluePush_1.svg"))
  47. );
  48. #endif
  49. }
  50. };
  51. /**
  52. * A very basic momentary push button.
  53. */
  54. struct SQPush : SVGButton
  55. {
  56. SQPush()
  57. {
  58. setSVGs(
  59. SVG::load(assetPlugin(plugin, "res/BluePush_0.svg")),
  60. SVG::load(assetPlugin(plugin, "res/BluePush_1.svg"))
  61. );
  62. }
  63. void center(Vec& pos)
  64. {
  65. this->box.pos = pos.minus(this->box.size.div(2));
  66. }
  67. void onDragEnd(EventDragEnd &e) override
  68. {
  69. SVGButton::onDragEnd(e);
  70. if (clickHandler) {
  71. clickHandler();
  72. }
  73. }
  74. /**
  75. * User of button passes in a callback lamba here
  76. */
  77. void onClick(std::function<void(void)> callback)
  78. {
  79. clickHandler = callback;
  80. }
  81. std::function<void(void)> clickHandler;
  82. };