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.

54 lines
2.0KB

  1. /**
  2. @page controlling_control_buttons Controlling control buttons
  3. In addition to sending button pressed and button released events, ControlButton objects can allow your application code to change the colour of the LED behind the corresponding physical button on a BLOCKS device.
  4. An array of pointers to the available %ControlButton objects can be obtained from the Block::getButtons() method of a Block --- see the @ref discovering_blocks section for details of how to obtain a %Block object.
  5. Once you have a %ControlButton, the functions involving the LED are ControlButton::hasLight() and ControlButton::setLightColour(), which are descriptively named.
  6. A code snippet showing how to turn all the available buttons of a %Block red is shown below.
  7. @code{.cpp}
  8. class BlockButtonExample
  9. {
  10. void setAllButtonsRed (Block& block)
  11. {
  12. for (auto button : block.getButtons())
  13. if (button->hasLight())
  14. button->setLightColour (LEDColour (0xffff0000));
  15. }
  16. };
  17. @endcode
  18. @section controlling_control_buttons_example_usage Example usage
  19. To add this functionality to the BlockFinder example project, add the above function to the BlockFinder class implementation. Then in the @s_projcode{topologyChanged()} callback, check if the connected %Block is a Control %Block and call the above function as shown below:
  20. @code{.cpp}
  21. void topologyChanged() override
  22. {
  23. //...
  24. for (auto& block : currentTopology.blocks)
  25. {
  26. //...
  27. if (block->getType() == Block::liveBlock || block->getType() == Block::loopBlock
  28. || block->getType() == Block::developerControlBlock || block->getType() == Block::touchBlock)
  29. {
  30. setAllButtonsRed (*block);
  31. }
  32. }
  33. }
  34. @endcode
  35. If you run the application now and connect a Control %Block, you should see the control buttons turn red.
  36. Learn more about other Block methods from the following pages:
  37. @ref getting_touch_events
  38. @ref getting_control_button_events
  39. @ref controlling_led_grids
  40. @ref controlling_led_strips
  41. */