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.

129 lines
4.9KB

  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. static Block::UID getBlockUIDFromSerialNumber (const uint8* serial) noexcept
  20. {
  21. Block::UID n = {};
  22. for (int i = 0; i < int (BlocksProtocol::BlockSerialNumber::maxLength); ++i)
  23. n += n * 127 + serial[i];
  24. return n;
  25. }
  26. static Block::UID getBlockUIDFromSerialNumber (const BlocksProtocol::BlockSerialNumber& serial) noexcept
  27. {
  28. return getBlockUIDFromSerialNumber (serial.data);
  29. }
  30. static Block::UID getBlockUIDFromSerialNumber (const String& serial) noexcept
  31. {
  32. if (serial.length() < int (BlocksProtocol::BlockSerialNumber::maxLength))
  33. {
  34. jassertfalse;
  35. return getBlockUIDFromSerialNumber (serial.paddedRight ('0', BlocksProtocol::BlockSerialNumber::maxLength));
  36. }
  37. return getBlockUIDFromSerialNumber ((const uint8*) serial.toRawUTF8());
  38. }
  39. Block::Block (const String& serial)
  40. : serialNumber (serial), uid (getBlockUIDFromSerialNumber (serial))
  41. {
  42. }
  43. Block::Block (const String& serial, const String& version, const String& blockName)
  44. : serialNumber (serial), versionNumber (version), name (blockName), uid (getBlockUIDFromSerialNumber (serial))
  45. {
  46. }
  47. Block::~Block() {}
  48. bool Block::isControlBlock() const
  49. {
  50. return isControlBlock (getType());
  51. }
  52. bool Block::isControlBlock (Block::Type type)
  53. {
  54. return type == Block::Type::liveBlock
  55. || type == Block::Type::loopBlock
  56. || type == Block::Type::touchBlock
  57. || type == Block::Type::developerControlBlock;
  58. }
  59. void Block::addProgramLoadedListener (ProgramLoadedListener* listener) { programLoadedListeners.add (listener); }
  60. void Block::removeProgramLoadedListener (ProgramLoadedListener* listener) { programLoadedListeners.remove (listener); }
  61. void Block::addDataInputPortListener (DataInputPortListener* listener) { dataInputPortListeners.add (listener); }
  62. void Block::removeDataInputPortListener (DataInputPortListener* listener) { dataInputPortListeners.remove (listener); }
  63. void Block::addConfigItemListener (ConfigItemListener* listener) { configItemListeners.add (listener); }
  64. void Block::removeConfigItemListener (ConfigItemListener* listener) { configItemListeners.remove (listener); }
  65. void Block::addProgramEventListener (ProgramEventListener* listener) { programEventListeners.add (listener); }
  66. void Block::removeProgramEventListener (ProgramEventListener* listener) { programEventListeners.remove (listener); }
  67. bool Block::ConnectionPort::operator== (const ConnectionPort& other) const noexcept { return edge == other.edge && index == other.index; }
  68. bool Block::ConnectionPort::operator!= (const ConnectionPort& other) const noexcept { return ! operator== (other); }
  69. Block::Program::Program (Block& b) : block (b) {}
  70. //==============================================================================
  71. TouchSurface::TouchSurface (Block& b) : block (b) {}
  72. TouchSurface::~TouchSurface() {}
  73. TouchSurface::Listener::~Listener() {}
  74. void TouchSurface::addListener (Listener* l) { listeners.add (l); }
  75. void TouchSurface::removeListener (Listener* l) { listeners.remove (l); }
  76. //==============================================================================
  77. ControlButton::ControlButton (Block& b) : block (b) {}
  78. ControlButton::~ControlButton() {}
  79. ControlButton::Listener::~Listener() {}
  80. void ControlButton::addListener (Listener* l) { listeners.add (l); }
  81. void ControlButton::removeListener (Listener* l) { listeners.remove (l); }
  82. //==============================================================================
  83. LEDGrid::LEDGrid (Block& b) : block (b) {}
  84. LEDGrid::~LEDGrid() {}
  85. LEDGrid::Renderer::~Renderer() {}
  86. //==============================================================================
  87. LEDRow::LEDRow (Block& b) : block (b) {}
  88. LEDRow::~LEDRow() {}
  89. //==============================================================================
  90. StatusLight::StatusLight (Block& b) : block (b) {}
  91. StatusLight::~StatusLight() {}
  92. } // namespace juce