diff --git a/source/backend/native/3bandeq/DistrhoUI3BandEQ.cpp b/source/backend/native/3bandeq/DistrhoUI3BandEQ.cpp index 5a1f4491a..ac6990b18 100644 --- a/source/backend/native/3bandeq/DistrhoUI3BandEQ.cpp +++ b/source/backend/native/3bandeq/DistrhoUI3BandEQ.cpp @@ -73,8 +73,11 @@ DistrhoUI3BandEQ::DistrhoUI3BandEQ() fKnobLowMid->setCallback(this); // knob Mid-High - fKnobMidHigh = new ImageKnob(*fKnobLowMid); + fKnobMidHigh = new ImageKnob(win, knobImage); fKnobMidHigh->setPos(160, 270); + fKnobMidHigh->setRange(1000.0f, 20000.0f); + fKnobMidHigh->setValue(2000.0f); + fKnobMidHigh->setCallback(this); // about button Image aboutImageNormal(DistrhoArtwork3BandEQ::aboutButtonNormalData, DistrhoArtwork3BandEQ::aboutButtonNormalWidth, DistrhoArtwork3BandEQ::aboutButtonNormalHeight); @@ -210,6 +213,11 @@ void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value) d_setParameterValue(DistrhoPlugin3BandEQ::paramMaster, value); } +void DistrhoUI3BandEQ::onDisplay() +{ + fImgBackground.draw(); +} + // ------------------------------------------------- UI* createUI() diff --git a/source/backend/native/3bandeq/DistrhoUI3BandEQ.hpp b/source/backend/native/3bandeq/DistrhoUI3BandEQ.hpp index b96ff700e..244a3d20b 100644 --- a/source/backend/native/3bandeq/DistrhoUI3BandEQ.hpp +++ b/source/backend/native/3bandeq/DistrhoUI3BandEQ.hpp @@ -70,6 +70,8 @@ protected: void imageSliderDragFinished(ImageSlider* slider); void imageSliderValueChanged(ImageSlider* slider, float value); + void onDisplay(); + private: Image fImgBackground; diff --git a/source/backend/native/Makefile b/source/backend/native/Makefile index 31ea2d300..ba21723ee 100644 --- a/source/backend/native/Makefile +++ b/source/backend/native/Makefile @@ -83,16 +83,16 @@ $(STATIC): $(OBJS) # -------------------------------------------------------------- -distrho-3bandeq.cpp.o: distrho-3bandeq.cpp +distrho-3bandeq.cpp.o: distrho-3bandeq.cpp 3bandeq/DistrhoArtwork3BandEQ.cpp 3bandeq/DistrhoPlugin3BandEQ.cpp 3bandeq/DistrhoUI3BandEQ.cpp distrho/DistrhoPluginCarla.cpp $(CXX) $< $(BUILD_CXX_FLAGS) -I3bandeq -DDISTRHO_NAMESPACE=DISTRHO_3BandEQ -c -o $@ -distrho-3bandsplitter.cpp.o: distrho-3bandsplitter.cpp +distrho-3bandsplitter.cpp.o: distrho-3bandsplitter.cpp distrho/DistrhoPluginCarla.cpp $(CXX) $< $(BUILD_CXX_FLAGS) -I3bandsplitter -DDISTRHO_NAMESPACE=DISTRHO_3BandSplitter -c -o $@ -distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp +distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp distrho/DistrhoPluginCarla.cpp $(CXX) $< $(BUILD_CXX_FLAGS) -Ipingpongpan -DDISTRHO_NAMESPACE=DISTRHO_PingPongPan -c -o $@ -distrho-notes.cpp.o: distrho-notes.cpp moc_DistrhoUINotes.cpp moc_ParamProgressBar.cpp +distrho-notes.cpp.o: distrho-notes.cpp distrho/DistrhoPluginCarla.cpp moc_DistrhoUINotes.cpp moc_ParamProgressBar.cpp $(CXX) $< $(BUILD_CXX_FLAGS) -Inotes -DDISTRHO_NAMESPACE=DISTRHO_Notes -c -o $@ zynaddsubfx.cpp.o: zynaddsubfx.cpp diff --git a/source/backend/native/distrho/DistrhoPluginCarla.cpp b/source/backend/native/distrho/DistrhoPluginCarla.cpp index 7b0822d99..c4a469a52 100644 --- a/source/backend/native/distrho/DistrhoPluginCarla.cpp +++ b/source/backend/native/distrho/DistrhoPluginCarla.cpp @@ -19,9 +19,6 @@ #include "DistrhoPluginMain.cpp" -// TODO -//#undef DISTRHO_PLUGIN_HAS_UI - #if DISTRHO_PLUGIN_HAS_UI #include #include "DistrhoUIMain.cpp" @@ -46,8 +43,9 @@ public: fUi(this, (intptr_t)fWidget.winId(), editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback) { setCentralWidget(&fWidget); - setFixedSize(fUi.width(), fUi.height()); - setWindowTitle(fUi.name()); + setWindowTitle(QString("%1 (GUI)").arg(fUi.name())); + + uiResize(fUi.width(), fUi.height()); } ~UICarla() @@ -119,6 +117,7 @@ protected: void uiResize(unsigned int width, unsigned int height) { + fWidget.setFixedSize(width, height); setFixedSize(width, height); } @@ -223,7 +222,7 @@ protected: param.scalePoints = nullptr; { - int nativeParamHints = 0; + int nativeParamHints = ::PARAMETER_IS_ENABLED; const uint32_t paramHints = fPlugin.parameterHints(index); if (paramHints & PARAMETER_IS_AUTOMABLE) diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index 46cba12db..12817bad2 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -1526,6 +1526,82 @@ public: } } + // ------------------------------------------------------------------- + // Post-poned events + + void uiParameterChange(const uint32_t index, const float value) + { + CARLA_ASSERT(fDescriptor != nullptr); + CARLA_ASSERT(fHandle != nullptr); + CARLA_ASSERT(index < kData->param.count); + + if (! fIsUiVisible) + return; + if (fDescriptor == nullptr || fHandle == nullptr) + return; + if (index >= kData->param.count) + return; + + fDescriptor->ui_set_parameter_value(fHandle, index, value); + } + + void uiMidiProgramChange(const uint32_t index) + { + CARLA_ASSERT(fDescriptor != nullptr); + CARLA_ASSERT(fHandle != nullptr); + CARLA_ASSERT(index < kData->midiprog.count); + + if (! fIsUiVisible) + return; + if (fDescriptor == nullptr || fHandle == nullptr) + return; + if (index >= kData->midiprog.count) + return; + + fDescriptor->ui_set_parameter_value(fHandle, kData->midiprog.data[index].bank, kData->midiprog.data[index].program); + } + + void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) + { + CARLA_ASSERT(fDescriptor != nullptr); + CARLA_ASSERT(fHandle != nullptr); + CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); + CARLA_ASSERT(note < MAX_MIDI_NOTE); + CARLA_ASSERT(velo > 0 && velo < MAX_MIDI_VALUE); + + if (! fIsUiVisible) + return; + if (fDescriptor == nullptr || fHandle == nullptr) + return; + if (channel >= MAX_MIDI_CHANNELS) + return; + if (note >= MAX_MIDI_NOTE) + return; + if (velo >= MAX_MIDI_VALUE) + return; + + // TODO + } + + void uiNoteOff(const uint8_t channel, const uint8_t note) + { + CARLA_ASSERT(fDescriptor != nullptr); + CARLA_ASSERT(fHandle != nullptr); + CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); + CARLA_ASSERT(note < MAX_MIDI_NOTE); + + if (! fIsUiVisible) + return; + if (fDescriptor == nullptr || fHandle == nullptr) + return; + if (channel >= MAX_MIDI_CHANNELS) + return; + if (note >= MAX_MIDI_NOTE) + return; + + // TODO + } + // ------------------------------------------------------------------- // Cleanup diff --git a/source/libs/Makefile b/source/libs/Makefile index 016c7ab28..bb1e94e92 100644 --- a/source/libs/Makefile +++ b/source/libs/Makefile @@ -45,6 +45,6 @@ rtmempool_%.a: clean: rm -f *.a *.def *.dll *.so - $(MAKE) clean -C dgl + $(MAKE) clean -C distrho/dgl $(MAKE) clean -C lilv $(MAKE) clean -C rtmempool diff --git a/source/libs/distrho/dgl/src/App.cpp b/source/libs/distrho/dgl/src/App.cpp index d6d2fab31..8bcf8af38 100644 --- a/source/libs/distrho/dgl/src/App.cpp +++ b/source/libs/distrho/dgl/src/App.cpp @@ -17,7 +17,6 @@ #include "AppPrivate.hpp" #include "../Window.hpp" -#include "../../DistrhoUtils.hpp" START_NAMESPACE_DGL diff --git a/source/libs/distrho/dgl/src/ImageSlider.cpp b/source/libs/distrho/dgl/src/ImageSlider.cpp index d4e54ab8a..883b39cdb 100644 --- a/source/libs/distrho/dgl/src/ImageSlider.cpp +++ b/source/libs/distrho/dgl/src/ImageSlider.cpp @@ -122,11 +122,11 @@ void ImageSlider::onDisplay() if (fStartPos.getX() == fEndPos.getX()) { x = fStartPos.getX(); - y = fStartPos.getY() + normValue*(fEndPos.getY()-fStartPos.getY()); + y = fEndPos.getY() - normValue*(fEndPos.getY()-fStartPos.getY()); } else if (fStartPos.getY() == fEndPos.getY()) { - x = fStartPos.getX() + normValue*(fEndPos.getX()-fStartPos.getX()); + x = fEndPos.getX() - normValue*(fEndPos.getX()-fStartPos.getX()); y = fStartPos.getY(); } else @@ -160,7 +160,7 @@ bool ImageSlider::onMouse(int button, bool press, int x, int y) else return false; - float value = vper * (fMaximum - fMinimum) + fMinimum; + float value = fMaximum - vper * (fMaximum - fMinimum); if (value < fMinimum) value = fMinimum; @@ -212,7 +212,7 @@ bool ImageSlider::onMotion(int x, int y) vper = float(y - fSliderArea.getY()) / float(fSliderArea.getHeight()); } - float value = vper * (fMaximum - fMinimum) + fMinimum; + float value = fMaximum - vper * (fMaximum - fMinimum); if (value < fMinimum) value = fMinimum; @@ -223,11 +223,11 @@ bool ImageSlider::onMotion(int x, int y) } else if (y < fSliderArea.getY()) { - setValue(horizontal ? fMaximum : fMinimum, true); + setValue(fMaximum, true); } else { - setValue(horizontal ? fMinimum : fMaximum, true); + setValue(fMinimum, true); } return true; diff --git a/source/libs/distrho/dgl/src/Widget.cpp b/source/libs/distrho/dgl/src/Widget.cpp index a8fb688ee..960d8d2ab 100644 --- a/source/libs/distrho/dgl/src/Widget.cpp +++ b/source/libs/distrho/dgl/src/Widget.cpp @@ -18,6 +18,7 @@ #include "../Widget.hpp" #include "../Window.hpp" +#include #include START_NAMESPACE_DGL @@ -29,11 +30,14 @@ Widget::Widget(Window* parent) : fParent(parent), fVisible(true) { + assert(parent != nullptr); + parent->addWidget(this); } Widget::~Widget() { + fParent->removeWidget(this); } bool Widget::isVisible() @@ -212,6 +216,7 @@ bool Widget::onSpecial(bool, Key) void Widget::onReshape(int width, int height) { + printf("Reshape(%i, %i)\n", width, height); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); diff --git a/source/libs/distrho/dgl/src/Window.cpp b/source/libs/distrho/dgl/src/Window.cpp index 33b0a6ddd..3b4b57f51 100644 --- a/source/libs/distrho/dgl/src/Window.cpp +++ b/source/libs/distrho/dgl/src/Window.cpp @@ -39,6 +39,8 @@ START_NAMESPACE_DGL +Window* dgl_lastUiParent = nullptr; + // ------------------------------------------------- // Window Private @@ -49,10 +51,10 @@ public: : kApp(app), kAppPriv(appPriv), kSelf(self), - kView(puglCreate(parentId, "Window", 600, 500, false, false)), + kView(puglCreate(parentId, "Window", 600, 500, (parentId != 0), (parentId != 0))), fParent(parent), fChildFocus(nullptr), - fVisible(false), + fVisible((parentId != 0)), fClosed(false), fResizable(false), #if DGL_OS_WINDOWS @@ -491,11 +493,13 @@ private: Window::Window(App* app, Window* parent) : kPrivate(new Private(this, app, app->kPrivate, (parent != nullptr) ? parent->kPrivate : nullptr)) { + dgl_lastUiParent = this; } Window::Window(App* app, intptr_t parentId) : kPrivate(new Private(this, app, app->kPrivate, nullptr, parentId)) { + dgl_lastUiParent = this; } Window::~Window() diff --git a/source/libs/distrho/src/DistrhoUIInternal.hpp b/source/libs/distrho/src/DistrhoUIInternal.hpp index 8c74cba38..abfe25d6e 100644 --- a/source/libs/distrho/src/DistrhoUIInternal.hpp +++ b/source/libs/distrho/src/DistrhoUIInternal.hpp @@ -34,6 +34,8 @@ # endif #endif +#include + START_NAMESPACE_DISTRHO // ------------------------------------------------- @@ -44,10 +46,7 @@ typedef void (*setStateFunc) (void* ptr, const char* key, const char* value); typedef void (*sendNoteFunc) (void* ptr, bool onOff, uint8_t channel, uint8_t note, uint8_t velo); typedef void (*uiResizeFunc) (void* ptr, unsigned int width, unsigned int height); -extern double d_lastUiSampleRate; -#ifdef DISTRHO_UI_OPENGL -extern Window* d_lastUiParent; -#endif +extern double d_lastUiSampleRate; // ------------------------------------------------- @@ -144,7 +143,8 @@ public: : qtGrip(nullptr), qtWidget(nullptr), #else - : glWindow(createWindow(winId)), + : glApp(), + glWindow(&glApp, winId), #endif kUi(createUI()), kData((kUi != nullptr) ? kUi->pData : nullptr) @@ -171,7 +171,9 @@ public: { if (kUi != nullptr) { +#ifdef DISTRHO_UI_QT4 destroyWindow(); +#endif delete kUi; } } @@ -240,10 +242,11 @@ public: void idle() { - assert(kUi != nullptr); - - if (kUi != nullptr) - kUi->d_uiIdle(); +#ifdef DISTRHO_UI_QT4 + kUi->d_uiIdle(); +#else + glApp.idle(); +#endif } intptr_t getWinId() @@ -252,8 +255,7 @@ public: assert(qtWidget != nullptr); return (qtWidget != nullptr) ? qtWidget->winId() : 0; #else - assert(glWindow != nullptr); - return (glWindow != nullptr) ? glWindow->getWindowId() : 0; + return glWindow.getWindowId(); #endif } @@ -264,7 +266,6 @@ public: { assert(kUi != nullptr); assert(kData != nullptr); - assert(kData->widget != nullptr); assert(qtGrip == nullptr); assert(qtWidget == nullptr); @@ -284,7 +285,7 @@ public: // set layout qtWidget->setLayout(new QVBoxLayout(qtWidget)); - qtWidget->layout()->addWidget(kData->widget); + qtWidget->layout()->addWidget(qt4Ui); qtWidget->layout()->setContentsMargins(0, 0, 0, 0); qtWidget->setFixedSize(kUi->d_width(), kUi->d_height()); @@ -310,20 +311,10 @@ public: // show it qtWidget->show(); } -#else - Window* createWindow(intptr_t parent) - { - Window* window = new Window(&glApp, parent); - d_lastUiParent = window; - return window; - } -#endif void destroyWindow() { -#ifdef DISTRHO_UI_QT4 assert(kData != nullptr); - assert(kData->widget != nullptr); assert(qtWidget != nullptr); if (kData == nullptr) @@ -351,20 +342,8 @@ public: delete qtWidget; qtWidget = nullptr; -#else - assert(kData != nullptr); - assert(glWindow != nullptr); - - if (kData == nullptr) - return; - if (glWindow == nullptr) - return; - - glWindow->hide(); - delete glWindow; - glWindow = nullptr; -#endif } +#endif // --------------------------------------------- @@ -373,8 +352,8 @@ private: QSizeGrip* qtGrip; QEmbedWidget* qtWidget; #else - App glApp; - Window* glWindow; + App glApp; + Window glWindow; #endif protected: @@ -386,8 +365,7 @@ protected: { assert(kUi != nullptr); assert(kData != nullptr); - assert(kData->widget != nullptr); - assert(qtGrip != nullptr); + //assert(qtGrip != nullptr); assert(qtWidget != nullptr); if (kUi == nullptr) diff --git a/source/libs/distrho/src/DistrhoUIOpenGL.cpp b/source/libs/distrho/src/DistrhoUIOpenGL.cpp index 9238ab150..cb6506711 100644 --- a/source/libs/distrho/src/DistrhoUIOpenGL.cpp +++ b/source/libs/distrho/src/DistrhoUIOpenGL.cpp @@ -16,21 +16,22 @@ #include "DistrhoUIInternal.hpp" -START_NAMESPACE_DISTRHO - -// ------------------------------------------------- -// Static data +START_NAMESPACE_DGL +extern Window* dgl_lastUiParent; +END_NAMESPACE_DGL -Window* d_lastParent = nullptr; +START_NAMESPACE_DISTRHO // ------------------------------------------------- // OpenGLUI OpenGLUI::OpenGLUI() : UI(), - Widget(d_lastParent) + Widget(dgl_lastUiParent) { - d_lastParent = nullptr; + assert(dgl_lastUiParent != nullptr); + + dgl_lastUiParent = nullptr; } OpenGLUI::~OpenGLUI()