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.

133 lines
4.2KB

  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. #ifndef DISTRHO_UI_HPP_INCLUDED
  17. #define DISTRHO_UI_HPP_INCLUDED
  18. #include "extra/d_leakdetector.hpp"
  19. #include "src/DistrhoPluginChecks.h"
  20. #if DISTRHO_UI_USE_NTK
  21. # include "../dgl/ntk/NtkWidget.hpp"
  22. typedef DGL::NtkWidget UIWidget;
  23. #elif DISTRHO_UI_USE_NANOVG
  24. # include "../dgl/NanoVG.hpp"
  25. typedef DGL::NanoWidget UIWidget;
  26. # else
  27. # include "../dgl/Widget.hpp"
  28. typedef DGL::Widget UIWidget;
  29. #endif
  30. START_NAMESPACE_DISTRHO
  31. // -----------------------------------------------------------------------
  32. // UI
  33. class UI : public UIWidget
  34. {
  35. public:
  36. UI();
  37. virtual ~UI();
  38. // -------------------------------------------------------------------
  39. // Host DSP State
  40. double d_getSampleRate() const noexcept;
  41. void d_editParameter(const uint32_t index, const bool started);
  42. void d_setParameterValue(const uint32_t index, const float value);
  43. #if DISTRHO_PLUGIN_WANT_STATE
  44. void d_setState(const char* const key, const char* const value);
  45. #endif
  46. #if DISTRHO_PLUGIN_IS_SYNTH
  47. void d_sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity);
  48. #endif
  49. // -------------------------------------------------------------------
  50. // Host UI State
  51. void d_setSize(const uint width, const uint height);
  52. #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  53. // -------------------------------------------------------------------
  54. // Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!!
  55. void* d_getPluginInstancePointer() const noexcept;
  56. #endif
  57. protected:
  58. // -------------------------------------------------------------------
  59. // Basic Information
  60. virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; }
  61. virtual uint d_getWidth() const noexcept = 0;
  62. virtual uint d_getHeight() const noexcept = 0;
  63. // -------------------------------------------------------------------
  64. // DSP Callbacks
  65. virtual void d_parameterChanged(uint32_t index, float value) = 0;
  66. #if DISTRHO_PLUGIN_WANT_PROGRAMS
  67. virtual void d_programChanged(uint32_t index) = 0;
  68. #endif
  69. #if DISTRHO_PLUGIN_WANT_STATE
  70. virtual void d_stateChanged(const char* key, const char* value) = 0;
  71. #endif
  72. // -------------------------------------------------------------------
  73. // DSP Callbacks (optional)
  74. virtual void d_sampleRateChanged(double newSampleRate);
  75. // -------------------------------------------------------------------
  76. // UI Callbacks (optional)
  77. virtual void d_uiIdle() {}
  78. #if ! DISTRHO_UI_USE_NTK
  79. // updates window openGL state
  80. virtual void d_uiReshape(int width, int height);
  81. #endif
  82. // -------------------------------------------------------------------
  83. private:
  84. struct PrivateData;
  85. PrivateData* const pData;
  86. friend class UIExporter;
  87. friend class UIExporterWindow;
  88. // these should not be used
  89. void position(int, int) noexcept {}
  90. void setAbsoluteX(int) const noexcept {}
  91. void setAbsoluteY(int) const noexcept {}
  92. void setAbsolutePos(int, int) const noexcept {}
  93. void setAbsolutePos(const DGL::Point<int>&) const noexcept {}
  94. void setNeedsFullViewport(bool) const noexcept {}
  95. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI)
  96. };
  97. // -----------------------------------------------------------------------
  98. // Create UI, entry point
  99. extern UI* createUI();
  100. // -----------------------------------------------------------------------
  101. END_NAMESPACE_DISTRHO
  102. #endif // DISTRHO_UI_HPP_INCLUDED