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.

135 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  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. // touch block buttons
  61. velocitySensitivity,
  62. glideSensitivity,
  63. slideSensitivity,
  64. pressSensitivity,
  65. liftSensitivity,
  66. fixedVelocity,
  67. glideLock,
  68. pianoMode
  69. };
  70. /** Returns the button's type. */
  71. virtual ButtonFunction getType() const = 0;
  72. /** Returns the button's description. */
  73. virtual juce::String getName() const = 0;
  74. /** Returns the position of this button on the device, in device units.
  75. For buttons that are on the side of the device, this may want to return a value that
  76. is beyond the phyiscal block size.
  77. */
  78. virtual float getPositionX() const = 0;
  79. /** Returns the position of this button on the device, in device units.
  80. For buttons that are on the side of the device, this may want to return a value that
  81. is beyond the phyiscal block size.
  82. */
  83. virtual float getPositionY() const = 0;
  84. /** Returns true if this button has a controllable light. */
  85. virtual bool hasLight() const = 0;
  86. /** If the button can light-up, this sets its colour. */
  87. virtual bool setLightColour (LEDColour newColour) = 0;
  88. /** A listener that can be attached to a ControlButton object so that it
  89. gets called when the button is pushed or released.
  90. */
  91. struct Listener
  92. {
  93. virtual ~Listener();
  94. /** */
  95. virtual void buttonPressed (ControlButton&, Block::Timestamp) = 0;
  96. virtual void buttonReleased (ControlButton&, Block::Timestamp) = 0;
  97. };
  98. /** */
  99. void addListener (Listener*);
  100. /** */
  101. void removeListener (Listener*);
  102. /** */
  103. Block& block;
  104. protected:
  105. juce::ListenerList<Listener> listeners;
  106. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton)
  107. };