The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

133 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. /**
  24. Represents a button on a block device.
  25. */
  26. class ControlButton
  27. {
  28. public:
  29. ControlButton (Block&);
  30. /** Destructor. */
  31. virtual ~ControlButton();
  32. /** These are all known types of control buttons.
  33. You can find out which buttons a device has by calling getButtons(),
  34. and can get the name of a button type with getButtonName().
  35. */
  36. enum ButtonFunction
  37. {
  38. mode, // The button on the side of a lightpad block and the first button on a live/loop block
  39. volume, // on live + loop blocks
  40. // common to all types of block
  41. up,
  42. down,
  43. // live block buttons
  44. scale,
  45. chord,
  46. arp,
  47. sustain,
  48. octave,
  49. love,
  50. // loop block buttons
  51. click,
  52. snap,
  53. back,
  54. playOrPause,
  55. record,
  56. learn,
  57. // developer block buttons
  58. button0,
  59. button1,
  60. button2,
  61. button3,
  62. button4,
  63. button5,
  64. button6,
  65. button7
  66. };
  67. /** Returns the button's type. */
  68. virtual ButtonFunction getType() const = 0;
  69. /** Returns the button's description. */
  70. virtual juce::String getName() const = 0;
  71. /** Returns the position of this button on the device, in device units.
  72. For buttons that are on the side of the device, this may want to return a value that
  73. is beyond the phyiscal block size.
  74. */
  75. virtual float getPositionX() const = 0;
  76. /** Returns the position of this button on the device, in device units.
  77. For buttons that are on the side of the device, this may want to return a value that
  78. is beyond the phyiscal block size.
  79. */
  80. virtual float getPositionY() const = 0;
  81. /** Returns true if this button has a controllable light. */
  82. virtual bool hasLight() const = 0;
  83. /** If the button can light-up, this sets its colour. */
  84. virtual bool setLightColour (LEDColour newColour) = 0;
  85. /** A listener that can be attached to a ControlButton object so that it
  86. gets called when the button is pushed or released.
  87. */
  88. struct Listener
  89. {
  90. virtual ~Listener();
  91. /** */
  92. virtual void buttonPressed (ControlButton&, Block::Timestamp) = 0;
  93. virtual void buttonReleased (ControlButton&, Block::Timestamp) = 0;
  94. };
  95. /** */
  96. void addListener (Listener*);
  97. /** */
  98. void removeListener (Listener*);
  99. /** */
  100. Block& block;
  101. protected:
  102. juce::ListenerList<Listener> listeners;
  103. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton)
  104. };