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.

142 lines
5.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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. namespace juce
  18. {
  19. /**
  20. Represents a button on a block device.
  21. @tags{Blocks}
  22. */
  23. class ControlButton
  24. {
  25. public:
  26. ControlButton (Block&);
  27. /** Destructor. */
  28. virtual ~ControlButton();
  29. /** These are all known types of control buttons.
  30. You can find out which buttons a device has by calling getButtons(),
  31. and can get the name of a button type with getButtonName().
  32. */
  33. enum ButtonFunction
  34. {
  35. mode, /**< The side button on a lightpad block and the first button on a live/loop block. */
  36. volume, /**< The volume button on a live/loop block. */
  37. // common to all types of block
  38. up, /**< The up button on a control block. */
  39. down, /**< The down button on a control block. */
  40. // live block buttons
  41. scale, /**< The scale button on a live block. */
  42. chord, /**< The chord button on a live block. */
  43. arp, /**< The arp button on a live block. */
  44. sustain, /**< The sustain button on a live block. */
  45. octave, /**< The octave button on a live block. */
  46. love, /**< The love button on a live block. */
  47. // loop block buttons
  48. click, /**< The click button on a loop block. */
  49. snap, /**< The snap button on a loop block. */
  50. back, /**< The back button on a loop block. */
  51. playOrPause, /**< The play or pause button on a loop block. */
  52. record, /**< The record button on a loop block. */
  53. learn, /**< The learn button on a loop block. */
  54. // developer block buttons
  55. button0, /**< Button 0 on a developer block. */
  56. button1, /**< Button 1 on a developer block. */
  57. button2, /**< Button 2 on a developer block. */
  58. button3, /**< Button 3 on a developer block. */
  59. button4, /**< Button 4 on a developer block. */
  60. button5, /**< Button 5 on a developer block. */
  61. button6, /**< Button 6 on a developer block. */
  62. button7, /**< Button 7 on a developer block. */
  63. // touch block buttons
  64. velocitySensitivity, /**< The velocity sensitivity button on a touch block. */
  65. glideSensitivity, /**< The glide sensitivity button on a touch block. */
  66. slideSensitivity, /**< The slide sensitivity button on a touch block. */
  67. pressSensitivity, /**< The press sensitivity button on a touch block. */
  68. liftSensitivity, /**< The lift sensitivity button on a touch block. */
  69. fixedVelocity, /**< The fixed velocity button on a touch block. */
  70. glideLock, /**< The glide lock button on a touch block. */
  71. pianoMode /**< The piano mode button on a touch block. */
  72. };
  73. /** Returns the button's type. */
  74. virtual ButtonFunction getType() const = 0;
  75. /** Returns the button's description. */
  76. virtual String getName() const = 0;
  77. /** Returns the position of this button on the device, in device units.
  78. For buttons that are on the side of the device, this may want to return a value that
  79. is beyond the physical block size.
  80. */
  81. virtual float getPositionX() const = 0;
  82. /** Returns the position of this button on the device, in device units.
  83. For buttons that are on the side of the device, this may want to return a value that
  84. is beyond the physical block size.
  85. */
  86. virtual float getPositionY() const = 0;
  87. /** Returns true if this button has a controllable light. */
  88. virtual bool hasLight() const = 0;
  89. /** If the button can light-up, this sets its colour. */
  90. virtual bool setLightColour (LEDColour newColour) = 0;
  91. /** A listener that can be attached to a ControlButton object so that it
  92. gets called when the button is pushed or released.
  93. */
  94. struct Listener
  95. {
  96. virtual ~Listener();
  97. /** Called when the button is pressed. */
  98. virtual void buttonPressed (ControlButton&, Block::Timestamp) = 0;
  99. /** Called when the button is released. */
  100. virtual void buttonReleased (ControlButton&, Block::Timestamp) = 0;
  101. };
  102. /** Adds a listener to the control button. */
  103. void addListener (Listener*);
  104. /** Removes a listener from the control button. */
  105. void removeListener (Listener*);
  106. /** The control block that this button belongs to. */
  107. Block& block;
  108. protected:
  109. ListenerList<Listener> listeners;
  110. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton)
  111. };
  112. } // namespace juce