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.

127 lines
3.5KB

  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 either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. /**
  18. Represents a button on a block device.
  19. */
  20. class ControlButton
  21. {
  22. public:
  23. ControlButton (Block&);
  24. /** Destructor. */
  25. virtual ~ControlButton();
  26. /** These are all known types of control buttons.
  27. You can find out which buttons a device has by calling getButtons(),
  28. and can get the name of a button type with getButtonName().
  29. */
  30. enum ButtonFunction
  31. {
  32. mode, // The button on the side of a lightpad block and the first button on a live/loop block
  33. volume, // on live + loop blocks
  34. // common to all types of block
  35. up,
  36. down,
  37. // live block buttons
  38. scale,
  39. chord,
  40. arp,
  41. sustain,
  42. octave,
  43. love,
  44. // loop block buttons
  45. click,
  46. snap,
  47. back,
  48. playOrPause,
  49. record,
  50. learn,
  51. // developer block buttons
  52. button0,
  53. button1,
  54. button2,
  55. button3,
  56. button4,
  57. button5,
  58. button6,
  59. button7
  60. };
  61. /** Returns the button's type. */
  62. virtual ButtonFunction getType() const = 0;
  63. /** Returns the button's description. */
  64. virtual juce::String getName() const = 0;
  65. /** Returns the position of this button on the device, in device units.
  66. For buttons that are on the side of the device, this may want to return a value that
  67. is beyond the phyiscal block size.
  68. */
  69. virtual float getPositionX() const = 0;
  70. /** Returns the position of this button on the device, in device units.
  71. For buttons that are on the side of the device, this may want to return a value that
  72. is beyond the phyiscal block size.
  73. */
  74. virtual float getPositionY() const = 0;
  75. /** Returns true if this button has a controllable light. */
  76. virtual bool hasLight() const = 0;
  77. /** If the button can light-up, this sets its colour. */
  78. virtual bool setLightColour (LEDColour newColour) = 0;
  79. /** A listener that can be attached to a ControlButton object so that it
  80. gets called when the button is pushed or released.
  81. */
  82. struct Listener
  83. {
  84. virtual ~Listener();
  85. /** */
  86. virtual void buttonPressed (ControlButton&, Block::Timestamp) = 0;
  87. virtual void buttonReleased (ControlButton&, Block::Timestamp) = 0;
  88. };
  89. /** */
  90. void addListener (Listener*);
  91. /** */
  92. void removeListener (Listener*);
  93. /** */
  94. Block& block;
  95. protected:
  96. juce::ListenerList<Listener> listeners;
  97. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton)
  98. };