DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 292bd7e0a5fb16dd56881ce05c4ae484799b20a7
parent 19f82001a2bb6b2287781c9a91dbb496de271eb8
Author: falkTX <falktx@gmail.com>
Date:   Sun, 14 Feb 2016 19:18:39 +0100

Start work torwards external-ui support

Diffstat:
Mdistrho/DistrhoUI.hpp | 44+++++++++++++++++++++++++++++++++-----------
Mdistrho/src/DistrhoPluginChecks.h | 19+++++++++++++++++--
Mdistrho/src/DistrhoPluginJack.cpp | 2+-
Mdistrho/src/DistrhoPluginLV2export.cpp | 5-----
Mdistrho/src/DistrhoPluginVST.cpp | 4++--
Mdistrho/src/DistrhoUI.cpp | 30+++++++++++++++++++++++++-----
Mdistrho/src/DistrhoUIInternal.hpp | 9++++++---
7 files changed, 84 insertions(+), 29 deletions(-)

diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -41,9 +41,8 @@ START_NAMESPACE_DISTRHO /** DPF UI class from where UI instances are created. - TODO. - - must call setSize during construction, + @note You must call setSize during construction, + @TODO Detailed information about this class. */ class UI : public UIWidget { @@ -69,25 +68,29 @@ public: double getSampleRate() const noexcept; /** - TODO: Document this. + editParameter. + @TODO Document this. */ void editParameter(uint32_t index, bool started); /** - TODO: Document this. + setParameterValue. + @TODO Document this. */ void setParameterValue(uint32_t index, float value); #if DISTRHO_PLUGIN_WANT_STATE /** - TODO: Document this. + setState. + @TODO Document this. */ void setState(const char* key, const char* value); #endif #if DISTRHO_PLUGIN_IS_SYNTH /** - TODO: Document this. + sendNote. + @TODO Document this. */ void sendNote(uint8_t channel, uint8_t note, uint8_t velocity); #endif @@ -97,11 +100,24 @@ public: * Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!! */ /** - TODO: Document this. + getPluginInstancePointer. + @TODO Document this. */ void* getPluginInstancePointer() const noexcept; #endif +#if DISTRHO_PLUGIN_HAS_EMBED_UI && DISTRHO_PLUGIN_HAS_EXTERNAL_UI + /* -------------------------------------------------------------------------------------------------------- + * External embeddable UI helpers */ + + /** + Get the Window Id that will be used for the next created window. + @note: This function is only valid during createUI(), + it will return 0 when called from anywhere else. + */ + static uintptr_t getNextWindowId() noexcept; +#endif + protected: /* -------------------------------------------------------------------------------------------------------- * DSP/Plugin Callbacks */ @@ -137,11 +153,13 @@ protected: */ virtual void sampleRateChanged(double newSampleRate); +#ifdef HAVE_DGL /* -------------------------------------------------------------------------------------------------------- * UI Callbacks (optional) */ /** - TODO: Document this. + uiIdle. + @TODO Document this. */ virtual void uiIdle() {} @@ -167,6 +185,7 @@ protected: @see Widget::onResize(const ResizeEvent&) */ void onResize(const ResizeEvent& ev) override; +#endif // ------------------------------------------------------------------------------------------------------- @@ -176,11 +195,13 @@ private: friend class UIExporter; friend class UIExporterWindow; +#ifdef HAVE_DGL // these should not be used void setAbsoluteX(int) const noexcept {} void setAbsoluteY(int) const noexcept {} void setAbsolutePos(int, int) const noexcept {} void setAbsolutePos(const DGL::Point<int>&) const noexcept {} +#endif DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI) }; @@ -196,7 +217,8 @@ private: */ /** - TODO. + createUI. + @TODO Document this. */ extern UI* createUI(); diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h @@ -45,6 +45,10 @@ # define DISTRHO_PLUGIN_HAS_UI 0 #endif +#ifndef DISTRHO_PLUGIN_HAS_EXTERNAL_UI +# define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 0 +#endif + #ifndef DISTRHO_PLUGIN_IS_RT_SAFE # define DISTRHO_PLUGIN_IS_RT_SAFE 0 #endif @@ -86,6 +90,17 @@ #endif // ----------------------------------------------------------------------- +// Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed + +#ifndef DISTRHO_PLUGIN_HAS_EMBED_UI +# ifdef HAVE_DGL +# define DISTRHO_PLUGIN_HAS_EMBED_UI 1 +# else +# define DISTRHO_PLUGIN_HAS_EMBED_UI 0 +# endif +#endif + +// ----------------------------------------------------------------------- // Define DISTRHO_UI_URI if needed #ifndef DISTRHO_UI_URI @@ -117,9 +132,9 @@ #endif // ----------------------------------------------------------------------- -// Disable UI if DGL is not available +// Disable UI if DGL or External UI is not available -#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) +#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_DGL) # undef DISTRHO_PLUGIN_HAS_UI # define DISTRHO_PLUGIN_HAS_UI 0 #endif diff --git a/distrho/src/DistrhoPluginJack.cpp b/distrho/src/DistrhoPluginJack.cpp @@ -16,7 +16,7 @@ #include "DistrhoPluginInternal.hpp" -#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) +#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EMBED_UI # undef DISTRHO_PLUGIN_HAS_UI # define DISTRHO_PLUGIN_HAS_UI 0 #endif diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp @@ -49,11 +49,6 @@ # define DISTRHO_PLUGIN_USES_MODGUI 0 #endif -#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) -# undef DISTRHO_PLUGIN_HAS_UI -# define DISTRHO_PLUGIN_HAS_UI 0 -#endif - #if DISTRHO_PLUGIN_HAS_UI # if DISTRHO_OS_HAIKU # define DISTRHO_LV2_UI_TYPE "BeUI" diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -16,7 +16,7 @@ #include "DistrhoPluginInternal.hpp" -#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) +#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EMBED_UI # undef DISTRHO_PLUGIN_HAS_UI # define DISTRHO_PLUGIN_HAS_UI 0 #endif diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -15,16 +15,22 @@ */ #include "DistrhoUIInternal.hpp" -#include "src/WidgetPrivateData.hpp" + +#ifdef HAVE_DGL +# include "src/WidgetPrivateData.hpp" +#endif START_NAMESPACE_DISTRHO /* ------------------------------------------------------------------------------------------------------------ * Static data, see DistrhoUIInternal.hpp */ -double d_lastUiSampleRate = 0.0; -void* d_lastUiDspPtr = nullptr; -Window* d_lastUiWindow = nullptr; +double d_lastUiSampleRate = 0.0; +void* d_lastUiDspPtr = nullptr; +#ifdef HAVE_DGL +Window* d_lastUiWindow = nullptr; +#endif +uintptr_t g_nextWindowId = 0; /* ------------------------------------------------------------------------------------------------------------ * UI */ @@ -33,7 +39,9 @@ UI::UI(uint width, uint height) : UIWidget(*d_lastUiWindow), pData(new PrivateData()) { +#ifdef HAVE_DGL ((UIWidget*)this)->pData->needsFullViewport = false; +#endif if (width > 0 && height > 0) setSize(width, height); @@ -86,11 +94,22 @@ void* UI::getPluginInstancePointer() const noexcept } #endif +#if DISTRHO_PLUGIN_HAS_EMBED_UI && DISTRHO_PLUGIN_HAS_EXTERNAL_UI +/* ------------------------------------------------------------------------------------------------------------ + * External embeddable UI helpers */ + +uintptr_t UI::getNextWindowId() noexcept +{ + return g_nextWindowId; +} +#endif + /* ------------------------------------------------------------------------------------------------------------ * DSP/Plugin Callbacks (optional) */ void UI::sampleRateChanged(double) {} +#ifdef HAVE_DGL /* ------------------------------------------------------------------------------------------------------------ * UI Callbacks (optional) */ @@ -117,6 +136,7 @@ void UI::onResize(const ResizeEvent& ev) { pData->setSizeCallback(ev.size.getWidth(), ev.size.getHeight()); } +#endif // ----------------------------------------------------------------------------------------------------------- diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -30,9 +30,12 @@ START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- // Static data, see DistrhoUI.cpp -extern double d_lastUiSampleRate; -extern void* d_lastUiDspPtr; -extern Window* d_lastUiWindow; +extern double d_lastUiSampleRate; +extern void* d_lastUiDspPtr; +#ifdef HAVE_DGL +extern Window* d_lastUiWindow; +#endif +extern uintptr_t g_nextWindowId; // ----------------------------------------------------------------------- // UI callbacks