DISTRHO Plugin Framework
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.

128 lines
3.9KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "DistrhoUIInternal.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // --------------------------------------------------------------------------------------------------------------------
  19. #if ! DISTRHO_PLUGIN_WANT_STATE
  20. static constexpr const setStateFunc setStateCallback = nullptr;
  21. #endif
  22. #if ! DISTRHO_PLUGIN_WANT_MIDI_INPUT
  23. static constexpr const sendNoteFunc sendNoteCallback = nullptr;
  24. #endif
  25. // --------------------------------------------------------------------------------------------------------------------
  26. /**
  27. * Stub UI class, does nothing but serving as example code for other implementations.
  28. */
  29. class UIStub
  30. {
  31. public:
  32. UIStub(const intptr_t winId,
  33. const double sampleRate,
  34. const char* const bundlePath,
  35. void* const dspPtr,
  36. const float scaleFactor)
  37. : fUI(this, winId, sampleRate,
  38. editParameterCallback,
  39. setParameterCallback,
  40. setStateCallback,
  41. sendNoteCallback,
  42. setSizeCallback,
  43. fileRequestCallback,
  44. bundlePath, dspPtr, scaleFactor)
  45. {
  46. }
  47. // ----------------------------------------------------------------------------------------------------------------
  48. private:
  49. // Stub stuff here
  50. // Plugin UI (after Stub stuff so the UI can call into us during its constructor)
  51. UIExporter fUI;
  52. // ----------------------------------------------------------------------------------------------------------------
  53. // DPF callbacks
  54. void editParameter(uint32_t, bool) const
  55. {
  56. }
  57. static void editParameterCallback(void* const ptr, const uint32_t rindex, const bool started)
  58. {
  59. static_cast<UIStub*>(ptr)->editParameter(rindex, started);
  60. }
  61. void setParameterValue(uint32_t, float)
  62. {
  63. }
  64. static void setParameterCallback(void* const ptr, const uint32_t rindex, const float value)
  65. {
  66. static_cast<UIStub*>(ptr)->setParameterValue(rindex, value);
  67. }
  68. void setSize(uint, uint)
  69. {
  70. }
  71. static void setSizeCallback(void* const ptr, const uint width, const uint height)
  72. {
  73. static_cast<UIStub*>(ptr)->setSize(width, height);
  74. }
  75. #if DISTRHO_PLUGIN_WANT_STATE
  76. void setState(const char*, const char*)
  77. {
  78. }
  79. static void setStateCallback(void* const ptr, const char* key, const char* value)
  80. {
  81. static_cast<UIStub*>(ptr)->setState(key, value);
  82. }
  83. #endif
  84. #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
  85. void sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity)
  86. {
  87. }
  88. static void sendNoteCallback(void* const ptr, const uint8_t channel, const uint8_t note, const uint8_t velocity)
  89. {
  90. static_cast<UIStub*>(ptr)->sendNote(channel, note, velocity);
  91. }
  92. #endif
  93. bool fileRequest(const char*)
  94. {
  95. return true;
  96. }
  97. static bool fileRequestCallback(void* const ptr, const char* const key)
  98. {
  99. return static_cast<UIStub*>(ptr)->fileRequest(key);
  100. }
  101. };
  102. // --------------------------------------------------------------------------------------------------------------------
  103. END_NAMESPACE_DISTRHO