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.

121 lines
3.8KB

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