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.

100 lines
2.6KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 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_DGL
  18. extern Window* dgl_lastUiParent;
  19. END_NAMESPACE_DGL
  20. START_NAMESPACE_DISTRHO
  21. // -----------------------------------------------------------------------
  22. // Static data, see DistrhoUIInternal.hpp
  23. double d_lastUiSampleRate = 0.0;
  24. // -----------------------------------------------------------------------
  25. // UI
  26. UI::UI()
  27. : DGL::Widget(*DGL::dgl_lastUiParent),
  28. pData(new PrivateData())
  29. {
  30. DISTRHO_SAFE_ASSERT(DGL::dgl_lastUiParent != nullptr);
  31. DGL::dgl_lastUiParent = nullptr;
  32. }
  33. UI::~UI()
  34. {
  35. delete pData;
  36. }
  37. // -----------------------------------------------------------------------
  38. // Host DSP State
  39. double UI::d_getSampleRate() const noexcept
  40. {
  41. return pData->sampleRate;
  42. }
  43. void UI::d_editParameter(uint32_t index, bool started)
  44. {
  45. pData->editParamCallback(index + pData->parameterOffset, started);
  46. }
  47. void UI::d_setParameterValue(uint32_t index, float value)
  48. {
  49. pData->setParamCallback(index + pData->parameterOffset, value);
  50. }
  51. #if DISTRHO_PLUGIN_WANT_STATE
  52. void UI::d_setState(const char* key, const char* value)
  53. {
  54. pData->setStateCallback(key, value);
  55. }
  56. #endif
  57. #if DISTRHO_PLUGIN_IS_SYNTH
  58. void UI::d_sendNote(uint8_t channel, uint8_t note, uint8_t velocity)
  59. {
  60. pData->sendNoteCallback(channel, note, velocity);
  61. }
  62. #endif
  63. // -----------------------------------------------------------------------
  64. // Host UI State
  65. void UI::d_uiResize(unsigned int width, unsigned int height)
  66. {
  67. pData->uiResizeCallback(width, height);
  68. }
  69. #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  70. // -----------------------------------------------------------------------
  71. // Direct DSP access
  72. void* UI::d_getPluginInstancePointer() const noexcept
  73. {
  74. return pData->dspPtr;
  75. }
  76. #endif
  77. // -----------------------------------------------------------------------
  78. END_NAMESPACE_DISTRHO