Browse Source

Add vst gui stuff (DPF related)

Signed-off-by: falkTX <falktx@gmail.com>
vstgui
falkTX 5 years ago
parent
commit
fce17fbfcd
Signed by: falkTX <falktx@gmail.com> GPG Key ID: 2D3445A829213837
5 changed files with 365 additions and 2 deletions
  1. +5
    -0
      Makefile.plugins.mk
  2. +7
    -1
      dgl/Makefile
  3. +110
    -0
      dgl/VstGuiWidget.hpp
  4. +239
    -0
      dgl/src/VstGui.cpp
  5. +4
    -1
      distrho/DistrhoUI.hpp

+ 5
- 0
Makefile.plugins.mk View File

@@ -76,6 +76,11 @@ all:
# ---------------------------------------------------------------------------------------------------------------------
# Common

$(BUILD_DIR)/%.S.o: %.S
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@

$(BUILD_DIR)/%.c.o: %.c
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"


+ 7
- 1
dgl/Makefile View File

@@ -27,7 +27,8 @@ OBJS = \
../build/dgl/ImageWidgets.cpp.o \
../build/dgl/NanoVG.cpp.o \
../build/dgl/Resources.cpp.o \
../build/dgl/Widget.cpp.o
../build/dgl/Widget.cpp.o \
../build/dgl/VstGui.cpp.o

ifeq ($(MACOS),true)
OBJS += ../build/dgl/Window.mm.o
@@ -71,6 +72,11 @@ all: $(TARGET)
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@

../build/dgl/VstGui.cpp.o: src/VstGui.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags cairo freetype2) -w -DDebugPrint={} -c -o $@

# ---------------------------------------------------------------------------------------------------------------------

clean:


+ 110
- 0
dgl/VstGuiWidget.hpp View File

@@ -0,0 +1,110 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 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
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_VSTGUI_HPP_INCLUDED
#define DISTRHO_VSTGUI_HPP_INCLUDED

#include "Base.hpp"
#include "../distrho/extra/String.hpp"

START_NAMESPACE_DGL

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

class VstGuiWidget
{
public:
VstGuiWidget(const uint w = 1, const uint h = 1, const char* const t = "")
: width(w),
height(h),
title(t),
transientWinId(0),
visible(false) {}

virtual ~VstGuiWidget()
{
}

uint getWidth() const noexcept
{
return width;
}

uint getHeight() const noexcept
{
return height;
}

const char* getTitle() const noexcept
{
return title;
}

uintptr_t getTransientWinId() const noexcept
{
return transientWinId;
}

bool isVisible() const noexcept
{
return visible;
}

bool isRunning() noexcept
{
return visible;
}

virtual void idle() {}

virtual void setSize(uint w, uint h)
{
width = w;
height = h;
}

virtual void setTitle(const char* const t)
{
title = t;
}

virtual void setTransientWinId(const uintptr_t winId)
{
transientWinId = winId;
}

virtual void setVisible(const bool yesNo)
{
visible = yesNo;
}

void terminateAndWaitForProcess()
{
}

private:
uint width;
uint height;
DISTRHO_NAMESPACE::String title;
uintptr_t transientWinId;
bool visible;
};

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

END_NAMESPACE_DGL

#endif // DISTRHO_VSTGUI_HPP_INCLUDED

+ 239
- 0
dgl/src/VstGui.cpp View File

@@ -0,0 +1,239 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 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
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

// #include "../../vstgui/vstgui/standalone/source/platform/gdk/gdkrunloop.h"
#include "../../vstgui/vstgui/vstgui_linux.cpp"
#include "../../vstgui/vstgui/plugin-bindings/plugguieditor.h"

namespace VSTGUI {
void* soHandle = nullptr;
};

//------------------------------------------------------------------------
class RunLoop : public VSTGUI::X11::IRunLoop
{
public:
using IEventHandler = VSTGUI::X11::IEventHandler;
using ITimerHandler = VSTGUI::X11::ITimerHandler;

static RunLoop& instance ();

RunLoop ();
~RunLoop () noexcept;

bool registerEventHandler (int fd, IEventHandler* handler) override;
bool unregisterEventHandler (IEventHandler* handler) override;

bool registerTimer (uint64_t interval, ITimerHandler* handler) override;
bool unregisterTimer (ITimerHandler* handler) override;

void forget () override {}
void remember () override {}

private:
struct Impl;
std::unique_ptr<Impl> impl;
};

static VSTGUI::X11::ITimerHandler* timer1 = nullptr;
static VSTGUI::X11::ITimerHandler* timer2 = nullptr;
static VSTGUI::X11::ITimerHandler* timer3 = nullptr;
static VSTGUI::X11::IEventHandler* event1 = nullptr;
static VSTGUI::X11::IEventHandler* event2 = nullptr;

//------------------------------------------------------------------------
RunLoop& RunLoop::instance ()
{
static RunLoop instance;
return instance;
}

//------------------------------------------------------------------------
struct ExternalEventHandler
{
VSTGUI::X11::IEventHandler* eventHandler{nullptr};
// GSource* source{nullptr};
// GIOChannel* ioChannel{nullptr};
};

//------------------------------------------------------------------------
struct ExternalTimerHandler
{
VSTGUI::X11::ITimerHandler* timerHandler{nullptr};
// GSource* source{nullptr};
};

//------------------------------------------------------------------------
struct RunLoop::Impl
{
using EventHandlerVector = std::vector<std::unique_ptr<ExternalEventHandler>>;
using TimerHandlerVector = std::vector<std::unique_ptr<ExternalTimerHandler>>;

// GMainContext * mainContext{nullptr};
EventHandlerVector eventHandlers;
TimerHandlerVector timerHandlers;
};

//------------------------------------------------------------------------
RunLoop::RunLoop ()
{
impl = std::unique_ptr<Impl> (new Impl);
// impl->mainContext = g_main_context_ref (g_main_context_default ());
}

//------------------------------------------------------------------------
RunLoop::~RunLoop () noexcept
{
printf("%s\n", __func__);
}

//------------------------------------------------------------------------
bool RunLoop::registerEventHandler (int fd, IEventHandler* handler)
{
printf("%s\n", __func__);
if (event1 == nullptr)
{
event1 = handler;
return true;
}
if (event2 == nullptr)
{
event2 = handler;
return true;
}
return true;
}

//------------------------------------------------------------------------
bool RunLoop::unregisterEventHandler (IEventHandler* handler)
{
printf("%s\n", __func__);
return false;
}

//------------------------------------------------------------------------
bool RunLoop::registerTimer (uint64_t interval, ITimerHandler* handler)
{
printf("%s\n", __func__);
if (timer1 == nullptr)
{
timer1 = handler;
return true;
}
if (timer2 == nullptr)
{
timer2 = handler;
return true;
}
if (timer3 == nullptr)
{
timer3 = handler;
return true;
}
return false;
}

//------------------------------------------------------------------------
bool RunLoop::unregisterTimer (ITimerHandler* handler)
{
printf("%s\n", __func__);
return false;
}

PluginGUIEditor::PluginGUIEditor (void *pEffect)
: effect (pEffect)
{
systemWindow = 0;
lLastTicks = getTicks ();
}

//-----------------------------------------------------------------------------
PluginGUIEditor::~PluginGUIEditor ()
{
}

//-----------------------------------------------------------------------------
void PluginGUIEditor::draw (ERect *ppErect)
{
}

//-----------------------------------------------------------------------------
bool PluginGUIEditor::open (void *ptr)
{
frame = new CFrame (CRect (0, 0, 0, 0), this);
getFrame ()->setTransparency (true);

IPlatformFrameConfig* config = nullptr;
X11::FrameConfig x11config;
x11config.runLoop = owned (new RunLoop ());
config = &x11config;

printf("%s %p %p\n", __func__, frame, ptr);
getFrame ()->open (ptr, kDefaultNative, config);

systemWindow = ptr;
return true;
}

//-----------------------------------------------------------------------------
void PluginGUIEditor::idle ()
{
if (frame)
frame->idle ();
if (timer1 != nullptr)
timer1->onTimer();
if (timer2 != nullptr)
timer2->onTimer();
if (timer3 != nullptr)
timer3->onTimer();
if (event1 != nullptr)
event1->onEvent();
if (event2 != nullptr)
event2->onEvent();
}

//-----------------------------------------------------------------------------
int32_t PluginGUIEditor::knobMode = kCircularMode;

//-----------------------------------------------------------------------------
int32_t PluginGUIEditor::setKnobMode (int32_t val)
{
PluginGUIEditor::knobMode = val;
return 1;
}

//-----------------------------------------------------------------------------
void PluginGUIEditor::wait (uint32_t ms)
{
}

//-----------------------------------------------------------------------------
uint32_t PluginGUIEditor::getTicks ()
{
return 0;
}

//-----------------------------------------------------------------------------
void PluginGUIEditor::doIdleStuff ()
{
}

//-----------------------------------------------------------------------------
bool PluginGUIEditor::getRect (ERect **ppErect)
{
*ppErect = &rect;
return true;
}

+ 4
- 1
distrho/DistrhoUI.hpp View File

@@ -20,7 +20,10 @@
#include "extra/LeakDetector.hpp"
#include "src/DistrhoPluginChecks.h"

#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
#if DISTRHO_UI_USE_VSTGUI
# include "../dgl/VstGuiWidget.hpp"
typedef DGL_NAMESPACE::VstGuiWidget UIWidget;
#elif DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# include "../dgl/Base.hpp"
# include "extra/ExternalWindow.hpp"
typedef DISTRHO_NAMESPACE::ExternalWindow UIWidget;


Loading…
Cancel
Save