@@ -696,12 +696,6 @@ public: | |||||
*/ | */ | ||||
virtual void idle(); | virtual void idle(); | ||||
/*! | |||||
* Give the event loop to the engine.\n | |||||
* The function will complete when the last plugin UI is closed. | |||||
*/ | |||||
virtual void exec(); | |||||
/*! | /*! | ||||
* Check if engine is running. | * Check if engine is running. | ||||
*/ | */ | ||||
@@ -30,9 +30,9 @@ CARLA_BACKEND_START_NAMESPACE | |||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
// Engine Helpers | // Engine Helpers | ||||
DGL::App* getEngineApp(CarlaEngine* const engine) | |||||
::QMainWindow* getEngineHostWindow(CarlaEngine* const engine) | |||||
{ | { | ||||
return CarlaEngineProtectedData::getApp(engine); | |||||
return CarlaEngineProtectedData::getHostWindow(engine); | |||||
} | } | ||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
@@ -643,13 +643,6 @@ void CarlaEngine::idle() | |||||
if (plugin != nullptr && plugin->enabled()) | if (plugin != nullptr && plugin->enabled()) | ||||
plugin->idleGui(); | plugin->idleGui(); | ||||
} | } | ||||
kData->app.idle(); | |||||
} | |||||
void CarlaEngine::exec() | |||||
{ | |||||
kData->app.exec(); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -6,8 +6,10 @@ VERSION = 1.0 | |||||
# ------------------------------------------------------- | # ------------------------------------------------------- | ||||
QT = core xml | |||||
CONFIG = debug | CONFIG = debug | ||||
CONFIG += link_pkgconfig shared warn_on | |||||
CONFIG += link_pkgconfig qt shared warn_on | |||||
DEFINES = DEBUG | DEFINES = DEBUG | ||||
DEFINES += QTCREATOR_TEST | DEFINES += QTCREATOR_TEST | ||||
@@ -25,12 +27,13 @@ DEFINES += WANT_JACK_LATENCY | |||||
DEFINES += WANT_JACK_PORT_RENAME | DEFINES += WANT_JACK_PORT_RENAME | ||||
DEFINES += WANT_FLUIDSYNTH | DEFINES += WANT_FLUIDSYNTH | ||||
DEFINES += WANT_LINUXSAMPLER | DEFINES += WANT_LINUXSAMPLER | ||||
DEFINES += WANT_OPENGL | |||||
DEFINES += WANT_AUDIOFILE | DEFINES += WANT_AUDIOFILE | ||||
DEFINES += WANT_ZYNADDSUBFX | DEFINES += WANT_ZYNADDSUBFX | ||||
PKGCONFIG = gl | |||||
DEFINES += WANT_ZYNADDSUBFX_UI | |||||
# Engine | # Engine | ||||
PKGCONFIG += liblo QtCore | |||||
PKGCONFIG += liblo | |||||
# RtAudio | # RtAudio | ||||
DEFINES += HAVE_GETTIMEOFDAY | DEFINES += HAVE_GETTIMEOFDAY | ||||
@@ -89,7 +92,6 @@ HEADERS += \ | |||||
INCLUDEPATH = . .. plugin \ | INCLUDEPATH = . .. plugin \ | ||||
../../includes \ | ../../includes \ | ||||
../../libs \ | ../../libs \ | ||||
../../libs/distrho \ | |||||
../../utils | ../../utils | ||||
# RtAudio/RtMidi | # RtAudio/RtMidi | ||||
@@ -24,12 +24,12 @@ | |||||
#include "CarlaPlugin.hpp" | #include "CarlaPlugin.hpp" | ||||
#include "RtList.hpp" | #include "RtList.hpp" | ||||
#include "dgl/App.hpp" | |||||
#ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
# include <QtCore/QProcessEnvironment> | # include <QtCore/QProcessEnvironment> | ||||
#endif | #endif | ||||
class QMainWindow; | |||||
CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
@@ -120,8 +120,6 @@ struct EnginePluginData { | |||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
struct CarlaEngineProtectedData { | struct CarlaEngineProtectedData { | ||||
DGL::App app; | |||||
CarlaEngineOsc osc; | CarlaEngineOsc osc; | ||||
CarlaEngineThread thread; | CarlaEngineThread thread; | ||||
@@ -134,6 +132,7 @@ struct CarlaEngineProtectedData { | |||||
#ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
QProcessEnvironment procEnv; | QProcessEnvironment procEnv; | ||||
QMainWindow* hostWindow; | |||||
#endif | #endif | ||||
bool aboutToClose; // don't re-activate thread if true | bool aboutToClose; // don't re-activate thread if true | ||||
@@ -182,23 +181,28 @@ struct CarlaEngineProtectedData { | |||||
oscData(nullptr), | oscData(nullptr), | ||||
callback(nullptr), | callback(nullptr), | ||||
callbackPtr(nullptr), | callbackPtr(nullptr), | ||||
#ifndef BUILD_BRIDGE | |||||
hostWindow(nullptr), | |||||
#endif | |||||
aboutToClose(false), | aboutToClose(false), | ||||
curPluginCount(0), | curPluginCount(0), | ||||
maxPluginNumber(0), | maxPluginNumber(0), | ||||
plugins(nullptr) {} | plugins(nullptr) {} | ||||
~CarlaEngineProtectedData() | |||||
{ | |||||
//plugins.clear(); | |||||
} | |||||
CarlaEngineProtectedData() = delete; | CarlaEngineProtectedData() = delete; | ||||
CarlaEngineProtectedData(CarlaEngineProtectedData&) = delete; | CarlaEngineProtectedData(CarlaEngineProtectedData&) = delete; | ||||
CarlaEngineProtectedData(const CarlaEngineProtectedData&) = delete; | CarlaEngineProtectedData(const CarlaEngineProtectedData&) = delete; | ||||
static DGL::App* getApp(CarlaEngine* const engine) | |||||
static ::QMainWindow* getHostWindow(CarlaEngine* const engine) | |||||
{ | { | ||||
return &engine->kData->app; | |||||
#ifndef BUILD_BRIDGE | |||||
return engine->kData->hostWindow; | |||||
#else | |||||
return nullptr; | |||||
// unused | |||||
(void)engine; | |||||
#endif | |||||
} | } | ||||
}; | }; | ||||
@@ -8,8 +8,8 @@ include ../Makefile.mk | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore) | |||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore QtXml) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore QtXml) | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -8,7 +8,8 @@ include ../Makefile.mk | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore QtGui) -I../../widgets | |||||
BUILD_CXX_FLAGS += -I. -I../../libs/distrho -I../../widgets | |||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore QtGui) | |||||
LINK_FLAGS += $(shell pkg-config --libs QtCore QtGui) | LINK_FLAGS += $(shell pkg-config --libs QtCore QtGui) | ||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -165,13 +166,13 @@ distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp pingpongpan/DistrhoArtworkPin | |||||
distrho-notes.cpp.o: distrho-notes.cpp notes/DistrhoPluginNotes.cpp notes/DistrhoUINotes.cpp distrho/DistrhoPluginCarla.cpp moc_DistrhoUINotes.cpp | distrho-notes.cpp.o: distrho-notes.cpp notes/DistrhoPluginNotes.cpp notes/DistrhoUINotes.cpp distrho/DistrhoPluginCarla.cpp moc_DistrhoUINotes.cpp | ||||
$(CXX) $< $(BUILD_CXX_FLAGS) -Inotes -DDISTRHO_NAMESPACE=DISTRHO_Notes -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) -Inotes -DDISTRHO_NAMESPACE=DISTRHO_Notes -c -o $@ | ||||
zynaddsubfx.cpp.o: zynaddsubfx.cpp $(ZYN_UI_FILES) | |||||
zynaddsubfx.cpp.o: zynaddsubfx.cpp $(ZYN_UI_FILES_CPP) | |||||
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | $(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | ||||
zynaddsubfx-src.cpp.o: zynaddsubfx-src.cpp | zynaddsubfx-src.cpp.o: zynaddsubfx-src.cpp | ||||
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | $(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | ||||
zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES) | |||||
zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES_CPP) | |||||
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | $(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ | ||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -19,10 +19,13 @@ | |||||
#include "CarlaLibUtils.hpp" | #include "CarlaLibUtils.hpp" | ||||
#include "CarlaMIDI.h" | #include "CarlaMIDI.h" | ||||
#include "dgl/App.hpp" | |||||
#include <QtCore/QFile> | #include <QtCore/QFile> | ||||
#include <QtCore/QTextStream> | #include <QtCore/QTextStream> | ||||
#include <QtGui/QCloseEvent> | |||||
#ifdef Q_WS_X11 | |||||
# include <QtGui/QX11EmbedContainer> | |||||
#endif | |||||
CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
@@ -1972,38 +1975,89 @@ CarlaPlugin::ScopedProcessLocker::~ScopedProcessLocker() | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// CarlaPluginGUI | // CarlaPluginGUI | ||||
CarlaPluginGUI::CarlaPluginGUI(DGL::App* const app, Callback* const callback) | |||||
: DGL::Window(app), | |||||
kCallback(callback) | |||||
CarlaPluginGUI::CarlaPluginGUI(QWidget* const parent, Callback* const callback) | |||||
: QMainWindow(parent), | |||||
kCallback(callback), | |||||
fContainer(nullptr), | |||||
fNextWidth(0), | |||||
fNextHeight(0) | |||||
{ | { | ||||
carla_debug("CarlaPluginGUI::CarlaPluginGUI(%p, %p)", app, callback); | |||||
CARLA_ASSERT(app != nullptr); | |||||
CARLA_ASSERT(callback != nullptr); | CARLA_ASSERT(callback != nullptr); | ||||
hide(); | |||||
carla_debug("CarlaPluginGUI::CarlaPluginGUI(%p, %p)", parent, callback); | |||||
} | } | ||||
CarlaPluginGUI::~CarlaPluginGUI() | CarlaPluginGUI::~CarlaPluginGUI() | ||||
{ | { | ||||
carla_debug("CarlaPluginGUI::~CarlaPluginGUI()"); | carla_debug("CarlaPluginGUI::~CarlaPluginGUI()"); | ||||
closeContainer(); | |||||
} | |||||
void CarlaPluginGUI::idle() | |||||
{ | |||||
if (fNextWidth > 0 && fNextHeight > 0) | |||||
{ | |||||
setFixedSize(fNextWidth, fNextHeight); | |||||
fNextWidth = 0; | |||||
fNextHeight = 0; | |||||
} | |||||
} | |||||
void CarlaPluginGUI::resizeLater(int width, int height) | |||||
{ | |||||
fNextWidth = width; | |||||
fNextHeight = height; | |||||
} | |||||
void* CarlaPluginGUI::getContainerWinId() | |||||
{ | |||||
carla_debug("CarlaPluginGUI::getContainerWinId()"); | |||||
if (fContainer == nullptr) | |||||
{ | |||||
#ifdef Q_WS_X11 | |||||
QX11EmbedContainer* container(new QX11EmbedContainer(this)); | |||||
#else | |||||
QWidget* container(new QWidget(this)); | |||||
#endif | |||||
setCentralWidget(container); | |||||
fContainer = container; | |||||
} | |||||
return (void*)winId(); | |||||
} | } | ||||
// void CarlaPluginGUI::closeEvent(QCloseEvent* const event) | |||||
// { | |||||
// carla_debug("CarlaPluginGUI::closeEvent(%p)", event); | |||||
// CARLA_ASSERT(event != nullptr); | |||||
// | |||||
// if (! event->spontaneous()) | |||||
// { | |||||
// event->ignore(); | |||||
// return; | |||||
// } | |||||
// | |||||
// if (kCallback != nullptr) | |||||
// kCallback->guiClosedCallback(); | |||||
// | |||||
// QMainWindow::closeEvent(event); | |||||
// } | |||||
void CarlaPluginGUI::closeContainer() | |||||
{ | |||||
carla_debug("CarlaPluginGUI::closeContainer()"); | |||||
if (fContainer != nullptr) | |||||
{ | |||||
#ifdef Q_WS_X11 | |||||
delete (QX11EmbedContainer*)fContainer; | |||||
#else | |||||
delete (QWidget*)fContainer; | |||||
#endif | |||||
fContainer = nullptr; | |||||
} | |||||
} | |||||
void CarlaPluginGUI::closeEvent(QCloseEvent* const event) | |||||
{ | |||||
carla_debug("CarlaPluginGUI::closeEvent(%p)", event); | |||||
CARLA_ASSERT(event != nullptr); | |||||
if (! event->spontaneous()) | |||||
{ | |||||
event->ignore(); | |||||
return; | |||||
} | |||||
if (kCallback != nullptr) | |||||
kCallback->guiClosedCallback(); | |||||
QMainWindow::closeEvent(event); | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -6,8 +6,10 @@ VERSION = 1.0 | |||||
# ------------------------------------------------------- | # ------------------------------------------------------- | ||||
QT = core gui xml | |||||
CONFIG = debug | CONFIG = debug | ||||
CONFIG += link_pkgconfig shared warn_on | |||||
CONFIG += link_pkgconfig qt shared warn_on | |||||
DEFINES = DEBUG | DEFINES = DEBUG | ||||
DEFINES += QTCREATOR_TEST | DEFINES += QTCREATOR_TEST | ||||
@@ -25,12 +27,13 @@ DEFINES += WANT_JACK_LATENCY | |||||
DEFINES += WANT_JACK_PORT_RENAME | DEFINES += WANT_JACK_PORT_RENAME | ||||
DEFINES += WANT_FLUIDSYNTH | DEFINES += WANT_FLUIDSYNTH | ||||
DEFINES += WANT_LINUXSAMPLER | DEFINES += WANT_LINUXSAMPLER | ||||
DEFINES += WANT_OPENGL | |||||
DEFINES += WANT_AUDIOFILE | DEFINES += WANT_AUDIOFILE | ||||
DEFINES += WANT_ZYNADDSUBFX | DEFINES += WANT_ZYNADDSUBFX | ||||
PKGCONFIG = gl | |||||
DEFINES += WANT_ZYNADDSUBFX_UI | |||||
# Plugin | # Plugin | ||||
PKGCONFIG += liblo QtCore | |||||
PKGCONFIG += liblo | |||||
# FluidSynth | # FluidSynth | ||||
PKGCONFIG += fluidsynth linuxsampler | PKGCONFIG += fluidsynth linuxsampler | ||||
@@ -75,7 +78,6 @@ HEADERS += \ | |||||
INCLUDEPATH = . .. \ | INCLUDEPATH = . .. \ | ||||
../../includes \ | ../../includes \ | ||||
../../libs \ | ../../libs \ | ||||
../../libs/distrho \ | |||||
../../utils | ../../utils | ||||
QMAKE_CXXFLAGS += -std=c++0x | QMAKE_CXXFLAGS += -std=c++0x |
@@ -26,9 +26,9 @@ | |||||
#include "CarlaStateUtils.hpp" | #include "CarlaStateUtils.hpp" | ||||
#include "CarlaMutex.hpp" | #include "CarlaMutex.hpp" | ||||
#include "CarlaMIDI.h" | #include "CarlaMIDI.h" | ||||
#include "RtList.hpp" | #include "RtList.hpp" | ||||
#include "dgl/Window.hpp" | |||||
#include <QtGui/QMainWindow> | |||||
#define CARLA_DECLARE_NON_COPY_STRUCT(structName) \ | #define CARLA_DECLARE_NON_COPY_STRUCT(structName) \ | ||||
structName(structName&) = delete; \ | structName(structName&) = delete; \ | ||||
@@ -386,7 +386,13 @@ struct ExternalMidiNote { | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
class CarlaPluginGUI : public DGL::Window | |||||
enum CarlaPluginGuiType { | |||||
PLUGIN_GUI_NULL, | |||||
PLUGIN_GUI_PARENT, | |||||
PLUGIN_GUI_QT | |||||
}; | |||||
class CarlaPluginGUI : public QMainWindow | |||||
{ | { | ||||
public: | public: | ||||
class Callback | class Callback | ||||
@@ -396,14 +402,27 @@ public: | |||||
virtual void guiClosedCallback() = 0; | virtual void guiClosedCallback() = 0; | ||||
}; | }; | ||||
CarlaPluginGUI(DGL::App* const app, Callback* const callback); | |||||
CarlaPluginGUI(QWidget* const parent, Callback* const callback); | |||||
~CarlaPluginGUI(); | ~CarlaPluginGUI(); | ||||
//protected: | |||||
//void closeEvent(QCloseEvent* const event); | |||||
void idle(); | |||||
void resizeLater(int width, int height); | |||||
// Parent UIs | |||||
void* getContainerWinId(); | |||||
void closeContainer(); | |||||
// Qt4 UIs, TODO | |||||
protected: | |||||
void closeEvent(QCloseEvent* const event); | |||||
private: | private: | ||||
Callback* const kCallback; | Callback* const kCallback; | ||||
QWidget* fContainer; | |||||
int fNextWidth; | |||||
int fNextHeight; | |||||
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginGUI) | CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginGUI) | ||||
}; | }; | ||||
@@ -411,7 +430,7 @@ private: | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Engine Helpers, defined in CarlaEngine.cpp | // Engine Helpers, defined in CarlaEngine.cpp | ||||
extern DGL::App* getEngineApp(CarlaEngine* const engine); | |||||
extern ::QMainWindow* getEngineHostWindow(CarlaEngine* const engine); | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -571,7 +590,7 @@ struct CarlaPluginProtectedData { | |||||
if (gui != nullptr) | if (gui != nullptr) | ||||
return; | return; | ||||
gui = new CarlaPluginGUI(getEngineApp(engine), callback); | |||||
gui = new CarlaPluginGUI(getEngineHostWindow(engine), callback); | |||||
} | } | ||||
void destroyUiIfNeeded() | void destroyUiIfNeeded() | ||||
@@ -579,11 +598,19 @@ struct CarlaPluginProtectedData { | |||||
if (gui == nullptr) | if (gui == nullptr) | ||||
return; | return; | ||||
gui->hide(); | |||||
gui->close(); | |||||
delete gui; | delete gui; | ||||
gui = nullptr; | gui = nullptr; | ||||
} | } | ||||
void resizeUiLater(int width, int height) | |||||
{ | |||||
if (gui == nullptr) | |||||
return; | |||||
gui->resizeLater(width, height); | |||||
} | |||||
static CarlaEngine* getEngine(CarlaPlugin* const plugin) | static CarlaEngine* getEngine(CarlaPlugin* const plugin) | ||||
{ | { | ||||
return plugin->kData->engine; | return plugin->kData->engine; | ||||
@@ -8,8 +8,8 @@ include ../Makefile.mk | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore QtGui) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore QtGui) | |||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore QtGui QtXml) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore QtGui QtXml) | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -33,17 +33,21 @@ void carla_register_all_plugins() | |||||
carla_register_native_plugin_midiTranspose(); | carla_register_native_plugin_midiTranspose(); | ||||
carla_register_native_plugin_nekofilter(); | carla_register_native_plugin_nekofilter(); | ||||
// DISTRHO plugins | |||||
carla_register_native_plugin_3BandEQ(); | |||||
carla_register_native_plugin_3BandSplitter(); | |||||
carla_register_native_plugin_PingPongPan(); | |||||
carla_register_native_plugin_Notes(); | |||||
#ifdef WANT_AUDIOFILE | #ifdef WANT_AUDIOFILE | ||||
// AudioFile | // AudioFile | ||||
carla_register_native_plugin_audiofile(); | carla_register_native_plugin_audiofile(); | ||||
#endif | #endif | ||||
#ifdef WANT_OPENGL | |||||
// DISTRHO plugins (OpenGL) | |||||
carla_register_native_plugin_3BandEQ(); | |||||
carla_register_native_plugin_3BandSplitter(); | |||||
carla_register_native_plugin_PingPongPan(); | |||||
#endif | |||||
// DISTRHO plugins (Qt) | |||||
carla_register_native_plugin_Notes(); | |||||
#ifdef WANT_ZYNADDSUBFX | #ifdef WANT_ZYNADDSUBFX | ||||
// ZynAddSubFX | // ZynAddSubFX | ||||
carla_register_native_plugin_zynaddsubfx(); | carla_register_native_plugin_zynaddsubfx(); | ||||
@@ -1881,30 +1885,22 @@ protected: | |||||
const char* handleUiOpenFile(const bool isDir, const char* const title, const char* const filter) | const char* handleUiOpenFile(const bool isDir, const char* const title, const char* const filter) | ||||
{ | { | ||||
#ifdef BUILD_BRIDGE | |||||
return nullptr; | |||||
#else | |||||
static CarlaString retStr; | static CarlaString retStr; | ||||
QFileDialog::Options options(isDir ? QFileDialog::ShowDirsOnly : 0x0); | QFileDialog::Options options(isDir ? QFileDialog::ShowDirsOnly : 0x0); | ||||
retStr = QFileDialog::getOpenFileName(nullptr, title, "", filter, nullptr, options).toUtf8().constData(); | retStr = QFileDialog::getOpenFileName(nullptr, title, "", filter, nullptr, options).toUtf8().constData(); | ||||
return retStr.isNotEmpty() ? (const char*)retStr : nullptr; | return retStr.isNotEmpty() ? (const char*)retStr : nullptr; | ||||
#endif | |||||
} | } | ||||
const char* handleUiSaveFile(const bool isDir, const char* const title, const char* const filter) | const char* handleUiSaveFile(const bool isDir, const char* const title, const char* const filter) | ||||
{ | { | ||||
#ifdef BUILD_BRIDGE | |||||
return nullptr; | |||||
#else | |||||
static CarlaString retStr; | static CarlaString retStr; | ||||
QFileDialog::Options options(isDir ? QFileDialog::ShowDirsOnly : 0x0); | QFileDialog::Options options(isDir ? QFileDialog::ShowDirsOnly : 0x0); | ||||
retStr = QFileDialog::getSaveFileName(nullptr, title, "", filter, nullptr, options).toUtf8().constData(); | retStr = QFileDialog::getSaveFileName(nullptr, title, "", filter, nullptr, options).toUtf8().constData(); | ||||
return (const char*)retStr; | |||||
#endif | |||||
return retStr.isNotEmpty() ? (const char*)retStr : nullptr; | |||||
} | } | ||||
public: | public: | ||||
@@ -361,7 +361,7 @@ public: | |||||
#ifdef Q_WS_X11 | #ifdef Q_WS_X11 | ||||
//value = (intptr_t)QX11Info::display(); | //value = (intptr_t)QX11Info::display(); | ||||
#endif | #endif | ||||
void* const ptr = (void*)kData->gui->getWindowId(); | |||||
void* const ptr = kData->gui->getContainerWinId(); | |||||
if (dispatcher(effEditOpen, 0, value, ptr, 0.0f) != 0) | if (dispatcher(effEditOpen, 0, value, ptr, 0.0f) != 0) | ||||
{ | { | ||||
@@ -376,7 +376,7 @@ public: | |||||
if (width > 0 && height > 0) | if (width > 0 && height > 0) | ||||
{ | { | ||||
kData->gui->setSize(width, height); | |||||
kData->gui->setFixedSize(width, height); | |||||
} | } | ||||
} | } | ||||
@@ -391,7 +391,7 @@ public: | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
else if (fGui.isVisible) | |||||
else | |||||
{ | { | ||||
dispatcher(effEditClose, 0, 0, nullptr, 0.0f); | dispatcher(effEditClose, 0, 0, nullptr, 0.0f); | ||||
kData->destroyUiIfNeeded(); | kData->destroyUiIfNeeded(); | ||||
@@ -412,7 +412,7 @@ public: | |||||
if (fNeedIdle) | if (fNeedIdle) | ||||
dispatcher(effIdle, 0, 0, nullptr, 0.0f); | dispatcher(effIdle, 0, 0, nullptr, 0.0f); | ||||
if (! fGui.isOsc && fGui.isVisible) | |||||
if (fGui.isVisible && ! fGui.isOsc) | |||||
{ | { | ||||
dispatcher(effEditIdle, 0, 0, nullptr, 0.0f); | dispatcher(effEditIdle, 0, 0, nullptr, 0.0f); | ||||
kData->gui->idle(); | kData->gui->idle(); | ||||
@@ -1737,19 +1737,21 @@ protected: | |||||
#endif | #endif | ||||
break; | break; | ||||
#if 0 | |||||
case audioMasterProcessEvents: | case audioMasterProcessEvents: | ||||
CARLA_ASSERT(fEnabled); | |||||
CARLA_ASSERT(fIsProcessing); | |||||
CARLA_ASSERT(kData->event.portOut != nullptr); | |||||
CARLA_ASSERT(ptr != nullptr); | CARLA_ASSERT(ptr != nullptr); | ||||
CARLA_ASSERT(m_enabled); | |||||
CARLA_ASSERT(midi.portMout); | |||||
CARLA_ASSERT(isProcessing); | |||||
if (! m_enabled) | |||||
if (! fEnabled) | |||||
return 0; | return 0; | ||||
if (! midi.portMout) | |||||
if (! fIsProcessing) | |||||
return 0; | return 0; | ||||
if (kData->event.portOut == nullptr) | |||||
return 0; | |||||
if (ptr == nullptr) | |||||
return 0; | |||||
#if 0 | |||||
if (! isProcessing) | if (! isProcessing) | ||||
{ | { | ||||
carla_stderr2("VstPlugin::handleAudioMasterProcessEvents(%p) - received MIDI out events outside audio thread, ignoring", vstEvents); | carla_stderr2("VstPlugin::handleAudioMasterProcessEvents(%p) - received MIDI out events outside audio thread, ignoring", vstEvents); | ||||
@@ -1766,10 +1768,9 @@ protected: | |||||
if (vstMidiEvent->type == kVstMidiType) | if (vstMidiEvent->type == kVstMidiType) | ||||
memcpy(&midiEvents[events.numEvents++], vstMidiEvent, sizeof(VstMidiEvent)); | memcpy(&midiEvents[events.numEvents++], vstMidiEvent, sizeof(VstMidiEvent)); | ||||
} | } | ||||
#endif | |||||
ret = 1; | ret = 1; | ||||
break; | break; | ||||
#endif | |||||
#if ! VST_FORCE_DEPRECATED | #if ! VST_FORCE_DEPRECATED | ||||
case audioMasterSetTime: | case audioMasterSetTime: | ||||
@@ -1842,12 +1843,7 @@ protected: | |||||
break; | break; | ||||
case audioMasterSizeWindow: | case audioMasterSizeWindow: | ||||
CARLA_ASSERT(kData->gui != nullptr); | |||||
// FIXME - ensure thread safe | |||||
//if (kData->gui != nullptr) | |||||
// kData->gui->setFixedSize(index, value); | |||||
kData->resizeUiLater(index, value); | |||||
ret = 1; | ret = 1; | ||||
break; | break; | ||||
@@ -24,12 +24,16 @@ | |||||
#include "CarlaEngine.hpp" | #include "CarlaEngine.hpp" | ||||
#include "CarlaPlugin.hpp" | #include "CarlaPlugin.hpp" | ||||
#include "dgl/App.hpp" | |||||
#include <QtCore/QDir> | #include <QtCore/QDir> | ||||
#include <QtCore/QFile> | #include <QtCore/QFile> | ||||
#include <QtCore/QTextStream> | #include <QtCore/QTextStream> | ||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |||||
# include <QtWidgets/QApplication> | |||||
#else | |||||
# include <QtGui/QApplication> | |||||
#endif | |||||
#ifdef CARLA_OS_UNIX | #ifdef CARLA_OS_UNIX | ||||
# include <signal.h> | # include <signal.h> | ||||
#endif | #endif | ||||
@@ -107,14 +111,18 @@ CARLA_BRIDGE_START_NAMESPACE | |||||
// ------------------------------------------------------------------------- | // ------------------------------------------------------------------------- | ||||
class CarlaPluginClient : public CarlaBridgeClient | |||||
class CarlaPluginClient : public CarlaBridgeClient, | |||||
public QObject | |||||
{ | { | ||||
public: | public: | ||||
CarlaPluginClient(const char* const name) | CarlaPluginClient(const char* const name) | ||||
: CarlaBridgeClient(nullptr), | : CarlaBridgeClient(nullptr), | ||||
QObject(nullptr), | |||||
fEngine(nullptr), | fEngine(nullptr), | ||||
fPlugin(nullptr) | |||||
fPlugin(nullptr), | |||||
fTimerId(0) | |||||
{ | { | ||||
CARLA_ASSERT(name != nullptr); | |||||
carla_debug("CarlaPluginClient::CarlaPluginClient()"); | carla_debug("CarlaPluginClient::CarlaPluginClient()"); | ||||
carla_engine_init("JACK", name); | carla_engine_init("JACK", name); | ||||
@@ -123,15 +131,21 @@ public: | |||||
~CarlaPluginClient() | ~CarlaPluginClient() | ||||
{ | { | ||||
CARLA_ASSERT(fTimerId == 0); | |||||
carla_debug("CarlaPluginClient::~CarlaPluginClient()"); | carla_debug("CarlaPluginClient::~CarlaPluginClient()"); | ||||
carla_set_engine_about_to_close(); | carla_set_engine_about_to_close(); | ||||
carla_engine_close(); | carla_engine_close(); | ||||
} | } | ||||
void ready() | void ready() | ||||
{ | { | ||||
CARLA_ASSERT(fTimerId == 0); | |||||
fEngine = carla_get_standalone_engine(); | fEngine = carla_get_standalone_engine(); | ||||
fPlugin = fEngine->getPlugin(0); | fPlugin = fEngine->getPlugin(0); | ||||
fTimerId = startTimer(50); | |||||
} | } | ||||
void idle() | void idle() | ||||
@@ -146,6 +160,21 @@ public: | |||||
// TODO | // TODO | ||||
gSaveNow = false; | gSaveNow = false; | ||||
} | } | ||||
if (gCloseNow) | |||||
{ | |||||
if (fTimerId != 0) | |||||
{ | |||||
killTimer(fTimerId); | |||||
fTimerId = 0; | |||||
} | |||||
if (QApplication* const app = qApp) | |||||
{ | |||||
if (! app->closingDown()) | |||||
app->quit(); | |||||
} | |||||
} | |||||
} | } | ||||
void exec() | void exec() | ||||
@@ -324,7 +353,15 @@ private: | |||||
CarlaBackend::CarlaEngine* fEngine; | CarlaBackend::CarlaEngine* fEngine; | ||||
CarlaBackend::CarlaPlugin* fPlugin; | CarlaBackend::CarlaPlugin* fPlugin; | ||||
bool fClosed; | |||||
int fTimerId; | |||||
void timerEvent(QTimerEvent* const event) | |||||
{ | |||||
if (event->timerId() == fTimerId) | |||||
idle(); | |||||
QObject::timerEvent(event); | |||||
} | |||||
static void callback(void* ptr, CarlaBackend::CallbackType action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr) | static void callback(void* ptr, CarlaBackend::CallbackType action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr) | ||||
{ | { | ||||
@@ -471,6 +508,9 @@ int main(int argc, char* argv[]) | |||||
return 1; | return 1; | ||||
} | } | ||||
QApplication app(argc, argv, true); | |||||
app.setQuitOnLastWindowClosed(false); | |||||
// Init Plugin client | // Init Plugin client | ||||
CarlaPluginClient client(name ? name : label); | CarlaPluginClient client(name ? name : label); | ||||
@@ -487,7 +527,7 @@ int main(int argc, char* argv[]) | |||||
extraStuff = CarlaBackend::findDSSIGUI(filename, label); | extraStuff = CarlaBackend::findDSSIGUI(filename, label); | ||||
// Init plugin | // Init plugin | ||||
int ret = 0; | |||||
int ret; | |||||
if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, extraStuff)) | if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, extraStuff)) | ||||
{ | { | ||||
@@ -503,7 +543,8 @@ int main(int argc, char* argv[]) | |||||
} | } | ||||
client.ready(); | client.ready(); | ||||
client.exec(); | |||||
ret = app.exec(); | |||||
carla_remove_plugin(0); | carla_remove_plugin(0); | ||||
} | } | ||||
@@ -11,17 +11,6 @@ include ../Makefile.mk | |||||
HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true) | HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true) | ||||
HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true) | HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true) | ||||
# -------------------------------------------------------------- | |||||
BUILD_CXX_FLAGS += -DBUILD_BRIDGE -pthread | |||||
BUILD_CXX_FLAGS += -I. -I../backend -I../includes -I../utils | |||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore QtXml) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore QtXml) -lpthread | |||||
ifeq ($(CARLA_PLUGIN_SUPPORT),true) | |||||
BUILD_CXX_FLAGS += -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST | |||||
endif | |||||
ifeq ($(HAVE_QT5),true) | ifeq ($(HAVE_QT5),true) | ||||
QT_UI_FLAGS = $(shell pkg-config --cflags QtWidgets) | QT_UI_FLAGS = $(shell pkg-config --cflags QtWidgets) | ||||
QT_UI_LIBS = $(shell pkg-config --libs QtWidgets) | QT_UI_LIBS = $(shell pkg-config --libs QtWidgets) | ||||
@@ -30,40 +19,77 @@ QT_UI_FLAGS = $(shell pkg-config --cflags QtGui) | |||||
QT_UI_LIBS = $(shell pkg-config --libs QtGui) | QT_UI_LIBS = $(shell pkg-config --libs QtGui) | ||||
endif | endif | ||||
# -------------------------------------------------------------- | |||||
BUILD_CXX_FLAGS += -DBUILD_BRIDGE | |||||
BUILD_CXX_FLAGS += -I. -I../backend -I../includes -I../utils | |||||
BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore) | |||||
LINK_FLAGS += $(shell pkg-config --libs liblo QtCore) | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
# Plugin bridges | # Plugin bridges | ||||
BUILD_PLUGIN_FLAGS = $(BUILD_CXX_FLAGS) | BUILD_PLUGIN_FLAGS = $(BUILD_CXX_FLAGS) | ||||
BUILD_PLUGIN_FLAGS += -DBUILD_BRIDGE_PLUGIN -DBRIDGE_PLUGIN -DWANT_JACK | BUILD_PLUGIN_FLAGS += -DBUILD_BRIDGE_PLUGIN -DBRIDGE_PLUGIN -DWANT_JACK | ||||
BUILD_PLUGIN_FLAGS += -I../backend/engine -I../backend/plugin -I../libs -I../libs/distrho | |||||
BUILD_PLUGIN_FLAGS += $(shell pkg-config --cflags gl) | |||||
BUILD_PLUGIN_FLAGS += -I../backend/engine -I../backend/plugin -I../libs | |||||
BUILD_PLUGIN_FLAGS += $(shell pkg-config --cflags QtGui QtXml) | |||||
LINK_PLUGIN_FLAGS = $(LINK_FLAGS) | LINK_PLUGIN_FLAGS = $(LINK_FLAGS) | ||||
LINK_PLUGIN_FLAGS += $(shell pkg-config --libs gl) | |||||
NATIVE_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) $(shell pkg-config --cflags jack QtGui) -DWANT_NATIVE | |||||
NATIVE_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) $(shell pkg-config --libs jack QtGui) -ldl | |||||
LINK_PLUGIN_FLAGS += $(shell pkg-config --libs QtGui QtXml) -lpthread | |||||
ifeq ($(HAVE_AF_DEPS),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_AUDIOFILE | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat sndfile) | |||||
ifeq ($(CARLA_PLUGIN_SUPPORT),true) | |||||
BUILD_PLUGIN_FLAGS += -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST | |||||
endif | endif | ||||
ifeq ($(HAVE_ZYN_DEPS),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_ZYNADDSUBFX | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib) | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs ntk ntk_images) | |||||
endif | |||||
# -------------------------------------------------------------- | |||||
# Plugin bridges (POSIX) | |||||
POSIX_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) | POSIX_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) | ||||
POSIX_32BIT_FLAGS = $(32BIT_FLAGS) -L/usr/lib32 -L/usr/lib/i386-linux-gnu | POSIX_32BIT_FLAGS = $(32BIT_FLAGS) -L/usr/lib32 -L/usr/lib/i386-linux-gnu | ||||
POSIX_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu | POSIX_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu | ||||
POSIX_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) $(shell pkg-config --libs jack) -ldl | POSIX_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) $(shell pkg-config --libs jack) -ldl | ||||
# -------------------------------------------------------------- | |||||
# Plugin bridges (Windows) | |||||
WIN_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) -DJACKBRIDGE_EXPORT -DPTW32_STATIC_LIB -I../libs/jackbridge | WIN_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) -DJACKBRIDGE_EXPORT -DPTW32_STATIC_LIB -I../libs/jackbridge | ||||
WIN_32BIT_FLAGS = $(32BIT_FLAGS) | WIN_32BIT_FLAGS = $(32BIT_FLAGS) | ||||
WIN_64BIT_FLAGS = $(64BIT_FLAGS) | WIN_64BIT_FLAGS = $(64BIT_FLAGS) | ||||
WIN_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) -mwindows -L../libs -lpthread -lwinspool -lole32 -luuid -limm32 -lshell32 -lws2_32 | |||||
WIN_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) -mwindows -lwinspool -lole32 -luuid -limm32 -lshell32 -lws2_32 -L../libs | |||||
# -------------------------------------------------------------- | |||||
# Plugin bridges (Native) | |||||
NATIVE_BUILD_FLAGS = $(POSIX_BUILD_FLAGS) | |||||
NATIVE_LINK_FLAGS = $(POSIX_LINK_FLAGS) | |||||
ifeq ($(HAVE_FLUIDSYNTH),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_FLUIDSYNTH | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs fluidsynth) | |||||
endif | |||||
ifeq ($(HAVE_LINUXSAMPLER),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_LINUXSAMPLER | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs linuxsampler) | |||||
endif | |||||
ifeq ($(HAVE_OPENGL),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_OPENGL | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs gl) | |||||
endif | |||||
ifeq ($(HAVE_AF_DEPS),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_AUDIOFILE | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat sndfile) | |||||
endif | |||||
ifeq ($(HAVE_ZYN_DEPS),true) | |||||
NATIVE_BUILD_FLAGS += -DWANT_ZYNADDSUBFX | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib) | |||||
ifeq ($(HAVE_ZYN_UI_DEPS),true) | |||||
NATIVE_LINK_FLAGS += $(shell pkg-config --libs ntk ntk_images) | |||||
endif | |||||
endif | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
# UI bridges | # UI bridges | ||||