Browse Source

Start work torwards external-ui support

pull/6/head
falkTX 9 years ago
parent
commit
292bd7e0a5
7 changed files with 84 additions and 29 deletions
  1. +33
    -11
      distrho/DistrhoUI.hpp
  2. +17
    -2
      distrho/src/DistrhoPluginChecks.h
  3. +1
    -1
      distrho/src/DistrhoPluginJack.cpp
  4. +0
    -5
      distrho/src/DistrhoPluginLV2export.cpp
  5. +2
    -2
      distrho/src/DistrhoPluginVST.cpp
  6. +25
    -5
      distrho/src/DistrhoUI.cpp
  7. +6
    -3
      distrho/src/DistrhoUIInternal.hpp

+ 33
- 11
distrho/DistrhoUI.hpp View File

@@ -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();



+ 17
- 2
distrho/src/DistrhoPluginChecks.h View File

@@ -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
@@ -85,6 +89,17 @@
# define DISTRHO_UI_USE_NANOVG 0
#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

@@ -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


+ 1
- 1
distrho/src/DistrhoPluginJack.cpp View File

@@ -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


+ 0
- 5
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -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"


+ 2
- 2
distrho/src/DistrhoPluginVST.cpp View File

@@ -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


+ 25
- 5
distrho/src/DistrhoUI.cpp View File

@@ -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

// -----------------------------------------------------------------------------------------------------------



+ 6
- 3
distrho/src/DistrhoUIInternal.hpp View File

@@ -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


Loading…
Cancel
Save