| @@ -1,292 +0,0 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2014 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 DGL_NTK_APP_HPP_INCLUDED | |||
| #define DGL_NTK_APP_HPP_INCLUDED | |||
| #include "../Base.hpp" | |||
| #include "../../distrho/DistrhoUI.hpp" | |||
| #include "../../distrho/extra/d_thread.hpp" | |||
| #ifdef override | |||
| # define override_defined | |||
| # undef override | |||
| #endif | |||
| #include <list> | |||
| #include <FL/Fl.H> | |||
| #include <FL/Fl_Double_Window.H> | |||
| #include <FL/Fl_Shared_Image.H> | |||
| #include <FL/x.H> | |||
| #ifdef override_defined | |||
| # define override | |||
| # undef override_defined | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| namespace DISTRHO_NAMESPACE { | |||
| class UI; | |||
| } | |||
| struct FlScopedLock { | |||
| FlScopedLock() { Fl::lock(); } | |||
| ~FlScopedLock() { Fl::unlock(); } | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| START_NAMESPACE_DGL | |||
| class NtkWindow; | |||
| typedef DISTRHO_NAMESPACE::Mutex d_Mutex; | |||
| typedef DISTRHO_NAMESPACE::MutexLocker d_MutexLocker; | |||
| typedef DISTRHO_NAMESPACE::Thread d_Thread; | |||
| typedef DISTRHO_NAMESPACE::UI d_UI; | |||
| // ----------------------------------------------------------------------- | |||
| /** | |||
| DGL compatible App class that uses NTK instead of OpenGL. | |||
| @see App | |||
| */ | |||
| class NtkApp : d_Thread | |||
| { | |||
| public: | |||
| /** | |||
| Constructor. | |||
| */ | |||
| NtkApp() | |||
| : d_Thread("NtkApp"), | |||
| fWindows(), | |||
| fWindowMutex(), | |||
| fNextUI(), | |||
| fDoNextUI(false), | |||
| fThreadInitialized(false) | |||
| { | |||
| #ifdef DISTRHO_OS_LINUX | |||
| XInitThreads(); | |||
| #endif | |||
| startThread(); | |||
| for (; ! fThreadInitialized;) | |||
| d_msleep(10); | |||
| } | |||
| /** | |||
| Destructor. | |||
| */ | |||
| ~NtkApp() | |||
| { | |||
| stopThread(-1); | |||
| fWindows.clear(); | |||
| } | |||
| /** | |||
| Idle function. | |||
| This calls does nothing. | |||
| */ | |||
| void idle() {} | |||
| /** | |||
| Run the application event-loop until all Windows are closed. | |||
| @note: This function is meant for standalones only, *never* call this from plugins. | |||
| */ | |||
| void exec() | |||
| { | |||
| while (isThreadRunning() && ! shouldThreadExit()) | |||
| d_sleep(1); | |||
| } | |||
| /** | |||
| Quit the application. | |||
| This stops the event-loop and closes all Windows. | |||
| */ | |||
| void quit() | |||
| { | |||
| signalThreadShouldExit(); | |||
| } | |||
| /** | |||
| Check if the application is about to quit. | |||
| Returning true means there's no event-loop running at the moment. | |||
| */ | |||
| bool isQuiting() const noexcept | |||
| { | |||
| if (isThreadRunning() && ! shouldThreadExit()) | |||
| return false; | |||
| return true; | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| /** | |||
| Create UI on our separate thread. | |||
| Blocks until the UI is created and returns it. | |||
| */ | |||
| d_UI* createUI(void* const func) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(isThreadRunning(), nullptr); | |||
| DISTRHO_SAFE_ASSERT_RETURN(! fDoNextUI, nullptr); | |||
| fNextUI.create = true; | |||
| fNextUI.func = (NextUI::UiFunc)func; | |||
| fDoNextUI = true; | |||
| if (isThreadRunning() && ! shouldThreadExit()) | |||
| { | |||
| for (; fDoNextUI;) | |||
| d_msleep(10); | |||
| } | |||
| else | |||
| { | |||
| fNextUI.run(); | |||
| fDoNextUI = false; | |||
| } | |||
| return fNextUI.ui; | |||
| } | |||
| /** | |||
| Delete UI on our separate thread. | |||
| Blocks until the UI is deleted. | |||
| */ | |||
| void deleteUI(d_UI* const ui) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(! fDoNextUI,); | |||
| fNextUI.create = false; | |||
| fNextUI.ui = ui; | |||
| fDoNextUI = true; | |||
| if (isThreadRunning() && ! shouldThreadExit()) | |||
| { | |||
| for (; fDoNextUI;) | |||
| d_msleep(10); | |||
| } | |||
| else | |||
| { | |||
| fNextUI.run(); | |||
| fDoNextUI = false; | |||
| } | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| private: | |||
| struct NextUI { | |||
| typedef d_UI* (*UiFunc)(); | |||
| bool create; | |||
| union { | |||
| UiFunc func; | |||
| d_UI* ui; | |||
| }; | |||
| NextUI() | |||
| : create(false), | |||
| func(nullptr) {} | |||
| void run(); | |||
| }; | |||
| std::list<Fl_Double_Window*> fWindows; | |||
| d_Mutex fWindowMutex; | |||
| NextUI fNextUI; | |||
| volatile bool fDoNextUI; | |||
| volatile bool fThreadInitialized; | |||
| /** @internal used by NtkWindow. */ | |||
| void addWindow(Fl_Double_Window* const window) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(window != nullptr,); | |||
| if (fWindows.size() == 0 && ! isThreadRunning()) | |||
| startThread(); | |||
| const d_MutexLocker cml(fWindowMutex); | |||
| fWindows.push_back(window); | |||
| } | |||
| /** @internal used by NtkWindow. */ | |||
| void removeWindow(Fl_Double_Window* const window) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(window != nullptr,); | |||
| const d_MutexLocker cml(fWindowMutex); | |||
| fWindows.remove(window); | |||
| if (fWindows.size() == 0) | |||
| signalThreadShouldExit(); | |||
| } | |||
| /** @internal */ | |||
| void run() override | |||
| { | |||
| static bool initialized = false; | |||
| if (! initialized) | |||
| { | |||
| initialized = true; | |||
| fl_register_images(); | |||
| #ifdef DISTRHO_OS_LINUX | |||
| fl_open_display(); | |||
| #endif | |||
| } | |||
| fThreadInitialized = true; | |||
| for (; ! shouldThreadExit();) | |||
| { | |||
| { | |||
| const FlScopedLock csl; | |||
| if (fDoNextUI) | |||
| { | |||
| fNextUI.run(); | |||
| fDoNextUI = false; | |||
| } | |||
| Fl::check(); | |||
| Fl::flush(); | |||
| } | |||
| d_msleep(20); | |||
| } | |||
| const FlScopedLock csl; | |||
| const d_MutexLocker cml(fWindowMutex); | |||
| for (std::list<Fl_Double_Window*>::reverse_iterator rit = fWindows.rbegin(), rite = fWindows.rend(); rit != rite; ++rit) | |||
| { | |||
| Fl_Double_Window* const window(*rit); | |||
| window->hide(); | |||
| } | |||
| } | |||
| friend class NtkWindow; | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NtkApp) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| #endif // DGL_NTK_APP_HPP_INCLUDED | |||
| @@ -1,202 +0,0 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2014 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 DGL_NTK_WIDGET_HPP_INCLUDED | |||
| #define DGL_NTK_WIDGET_HPP_INCLUDED | |||
| #include "NtkWindow.hpp" | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| /** | |||
| DGL compatible Widget class that uses NTK instead of OpenGL. | |||
| @see Widget | |||
| */ | |||
| class NtkWidget : public Fl_Double_Window | |||
| { | |||
| public: | |||
| /** | |||
| Constructor. | |||
| */ | |||
| explicit NtkWidget(NtkWindow& parent) | |||
| : Fl_Double_Window(100, 100), | |||
| fParent(parent) | |||
| { | |||
| fParent.add(this); | |||
| show(); | |||
| } | |||
| /** | |||
| Destructor. | |||
| */ | |||
| ~NtkWidget() override | |||
| { | |||
| hide(); | |||
| fParent.remove(this); | |||
| } | |||
| /** | |||
| Check if this widget is visible within its parent window. | |||
| Invisible widgets do not receive events except resize. | |||
| */ | |||
| bool isVisible() const | |||
| { | |||
| return visible(); | |||
| } | |||
| /** | |||
| Set widget visible (or not) according to @a yesNo. | |||
| */ | |||
| void setVisible(bool yesNo) | |||
| { | |||
| if (yesNo) | |||
| show(); | |||
| else | |||
| hide(); | |||
| } | |||
| /** | |||
| Get width. | |||
| */ | |||
| int getWidth() const | |||
| { | |||
| return w(); | |||
| } | |||
| /** | |||
| Get height. | |||
| */ | |||
| int getHeight() const | |||
| { | |||
| return h(); | |||
| } | |||
| /** | |||
| Set width. | |||
| */ | |||
| void setWidth(int width) | |||
| { | |||
| resize(x(), y(), width, h()); | |||
| } | |||
| /** | |||
| Set height. | |||
| */ | |||
| void setHeight(int height) | |||
| { | |||
| resize(x(), y(), w(), height); | |||
| } | |||
| /** | |||
| Set size using @a width and @a height values. | |||
| */ | |||
| void setSize(int width, int height) | |||
| { | |||
| resize(x(), y(), width, height); | |||
| } | |||
| /** | |||
| Get absolute X. | |||
| */ | |||
| int getAbsoluteX() const | |||
| { | |||
| return x(); | |||
| } | |||
| /** | |||
| Get absolute Y. | |||
| */ | |||
| int getAbsoluteY() const | |||
| { | |||
| return y(); | |||
| } | |||
| /** | |||
| Set absolute X. | |||
| */ | |||
| void setAbsoluteX(int x) | |||
| { | |||
| resize(x, y(), w(), h()); | |||
| } | |||
| /** | |||
| Set absolute Y. | |||
| */ | |||
| void setAbsoluteY(int y) | |||
| { | |||
| resize(x(), y, w(), h()); | |||
| } | |||
| /** | |||
| Set absolute position using @a x and @a y values. | |||
| */ | |||
| void setAbsolutePos(int x, int y) | |||
| { | |||
| resize(x, y, w(), h()); | |||
| } | |||
| /** | |||
| Get this widget's window application. | |||
| Same as calling getParentWindow().getApp(). | |||
| */ | |||
| NtkApp& getParentApp() const noexcept | |||
| { | |||
| return fParent.getApp(); | |||
| } | |||
| /** | |||
| Get parent window, as passed in the constructor. | |||
| */ | |||
| NtkWindow& getParentWindow() const noexcept | |||
| { | |||
| return fParent; | |||
| } | |||
| /** | |||
| Check if this widget contains the point defined by @a x and @a y. | |||
| */ | |||
| bool contains(int x, int y) const | |||
| { | |||
| return (x >= 0 && y >= 0 && x < w() && y < h()); | |||
| } | |||
| /** | |||
| Tell this widget's window to repaint itself. | |||
| */ | |||
| void repaint() | |||
| { | |||
| redraw(); | |||
| } | |||
| protected: | |||
| /** @internal used for DGL compatibility. */ | |||
| void setNeedsFullViewport(bool) noexcept {} | |||
| /** @internal used for DGL compatibility. */ | |||
| void setNeedsScaling(bool) noexcept {} | |||
| private: | |||
| NtkWindow& fParent; | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NtkWidget) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| #endif // DGL_NTK_WIDGET_HPP_INCLUDED | |||
| @@ -1,221 +0,0 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2014 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 DGL_NTK_WINDOW_HPP_INCLUDED | |||
| #define DGL_NTK_WINDOW_HPP_INCLUDED | |||
| #include "NtkApp.hpp" | |||
| START_NAMESPACE_DGL | |||
| class NtkWidget; | |||
| // ----------------------------------------------------------------------- | |||
| class NtkWindow : public Fl_Double_Window | |||
| { | |||
| public: | |||
| explicit NtkWindow(NtkApp& app) | |||
| : Fl_Double_Window(100, 100), | |||
| fApp(app), | |||
| fIsVisible(false), | |||
| fUsingEmbed(false), | |||
| fParent(nullptr) {} | |||
| explicit NtkWindow(NtkApp& app, NtkWindow& parent) | |||
| : Fl_Double_Window(100, 100), | |||
| fApp(app), | |||
| fIsVisible(false), | |||
| fUsingEmbed(false), | |||
| fParent(&parent) {} | |||
| explicit NtkWindow(NtkApp& app, intptr_t parentId) | |||
| : Fl_Double_Window(100, 100), | |||
| fApp(app), | |||
| fIsVisible(parentId != 0), | |||
| fUsingEmbed(parentId != 0), | |||
| fParent(nullptr) | |||
| { | |||
| if (fUsingEmbed) | |||
| { | |||
| fl_embed(this, (Window)parentId); | |||
| Fl_Double_Window::show(); | |||
| fApp.addWindow(this); | |||
| } | |||
| } | |||
| ~NtkWindow() override | |||
| { | |||
| if (fUsingEmbed) | |||
| { | |||
| fApp.removeWindow(this); | |||
| Fl_Double_Window::hide(); | |||
| } | |||
| } | |||
| void show() override | |||
| { | |||
| if (fUsingEmbed || fIsVisible) | |||
| return; | |||
| Fl_Double_Window::show(); | |||
| fApp.addWindow(this); | |||
| fIsVisible = true; | |||
| if (fParent != nullptr) | |||
| setTransientWinId((intptr_t)fl_xid(fParent)); | |||
| } | |||
| void hide() override | |||
| { | |||
| if (fUsingEmbed || ! fIsVisible) | |||
| return; | |||
| fIsVisible = false; | |||
| fApp.removeWindow(this); | |||
| Fl_Double_Window::hide(); | |||
| } | |||
| void close() | |||
| { | |||
| hide(); | |||
| } | |||
| bool isVisible() const | |||
| { | |||
| return visible(); | |||
| } | |||
| void setVisible(bool yesNo) | |||
| { | |||
| if (yesNo) | |||
| show(); | |||
| else | |||
| hide(); | |||
| } | |||
| bool isResizable() const | |||
| { | |||
| // TODO | |||
| return false; | |||
| } | |||
| void setResizable(bool /*yesNo*/) | |||
| { | |||
| // TODO | |||
| } | |||
| int getWidth() const noexcept | |||
| { | |||
| return w(); | |||
| } | |||
| int getHeight() const noexcept | |||
| { | |||
| return h(); | |||
| } | |||
| void setSize(uint width, uint height) | |||
| { | |||
| resize(x(), y(), width, height); | |||
| } | |||
| void setTitle(const char* title) | |||
| { | |||
| label(title); | |||
| } | |||
| void setTransientWinId(intptr_t winId) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(winId != 0,); | |||
| #ifdef DISTRHO_OS_LINUX | |||
| DISTRHO_SAFE_ASSERT_RETURN(fl_display != nullptr,); | |||
| const ::Window ourWindow(fl_xid(this)); | |||
| DISTRHO_SAFE_ASSERT_RETURN(ourWindow != 0,); | |||
| XSetTransientForHint(fl_display, ourWindow, winId); | |||
| #endif | |||
| } | |||
| NtkApp& getApp() const noexcept | |||
| { | |||
| return fApp; | |||
| } | |||
| intptr_t getWindowId() const | |||
| { | |||
| return (intptr_t)fl_xid(this); | |||
| } | |||
| void addIdleCallback(IdleCallback* const callback) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(callback != nullptr,); | |||
| fIdleCallbacks.push_back(callback); | |||
| if (fIdleCallbacks.size() == 1) | |||
| Fl::add_timeout(0.030, _idleHandler, this); | |||
| } | |||
| void removeIdleCallback(IdleCallback* const callback) | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(callback != nullptr,); | |||
| if (fIdleCallbacks.size() == 1) | |||
| Fl::remove_timeout(_idleHandler, this); | |||
| fIdleCallbacks.remove(callback); | |||
| } | |||
| private: | |||
| NtkApp& fApp; | |||
| bool fIsVisible; | |||
| bool fUsingEmbed; | |||
| // transient parent, may be null | |||
| NtkWindow* const fParent; | |||
| std::list<IdleCallback*> fIdleCallbacks; | |||
| friend class NtkWidget; | |||
| void idleHandler() | |||
| { | |||
| for (std::list<IdleCallback*>::iterator it=fIdleCallbacks.begin(), ite=fIdleCallbacks.end(); it != ite; ++it) | |||
| { | |||
| IdleCallback* const idleCallback(*it); | |||
| idleCallback->idleCallback(); | |||
| } | |||
| if (fIdleCallbacks.size() > 0 && ! getApp().isQuiting()) | |||
| Fl::repeat_timeout(0.030, _idleHandler, this); | |||
| } | |||
| static void _idleHandler(void* data) | |||
| { | |||
| ((NtkWindow*)data)->idleHandler(); | |||
| } | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NtkWindow) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| #endif // DGL_NTK_WINDOW_HPP_INCLUDED | |||
| @@ -20,13 +20,10 @@ | |||
| #include "extra/d_leakdetector.hpp" | |||
| #include "src/DistrhoPluginChecks.h" | |||
| #if DISTRHO_UI_USE_NTK | |||
| # include "../dgl/ntk/NtkWidget.hpp" | |||
| typedef DGL::NtkWidget UIWidget; | |||
| #elif DISTRHO_UI_USE_NANOVG | |||
| #if DISTRHO_UI_USE_NANOVG | |||
| # include "../dgl/NanoVG.hpp" | |||
| typedef DGL::NanoWidget UIWidget; | |||
| # else | |||
| #else | |||
| # include "../dgl/Widget.hpp" | |||
| typedef DGL::Widget UIWidget; | |||
| #endif | |||
| @@ -143,32 +140,22 @@ protected: | |||
| */ | |||
| virtual void d_uiIdle() {} | |||
| #if ! DISTRHO_UI_USE_NTK | |||
| /** | |||
| OpenGL window reshape function, called when parent window is resized. | |||
| You can reimplement this function for a custom OpenGL state. | |||
| @see Window::onReshape(uint,uint) | |||
| */ | |||
| virtual void d_uiReshape(uint width, uint height); | |||
| #endif | |||
| /* -------------------------------------------------------------------------------------------------------- | |||
| * UI Resize Handling, internal */ | |||
| #if DISTRHO_UI_USE_NTK | |||
| /** | |||
| NTK widget resize function, called when the widget is resized. | |||
| This is overriden here so the host knows when the UI is resized by you. | |||
| */ | |||
| void resize(int x, int y, int w, int h) override; | |||
| #else | |||
| /** | |||
| OpenGL widget resize function, called when the widget is resized. | |||
| This is overriden here so the host knows when the UI is resized by you. | |||
| @see Widget::onResize(const ResizeEvent&) | |||
| */ | |||
| void onResize(const ResizeEvent& ev) override; | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------- | |||
| @@ -179,14 +166,11 @@ private: | |||
| friend class UIExporterWindow; | |||
| // these should not be used | |||
| void position(int, int) noexcept {} | |||
| void setAbsoluteX(int) const noexcept {} | |||
| void setAbsoluteY(int) const noexcept {} | |||
| void setAbsolutePos(int, int) const noexcept {} | |||
| void setNeedsFullViewport(bool) const noexcept {} | |||
| #if ! DISTRHO_UI_USE_NTK | |||
| void setAbsolutePos(const DGL::Point<int>&) const noexcept {} | |||
| #endif | |||
| void setNeedsFullViewport(bool) const noexcept {} | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI) | |||
| }; | |||
| @@ -27,30 +27,3 @@ | |||
| #elif defined(DISTRHO_PLUGIN_TARGET_VST) | |||
| // nothing | |||
| #endif | |||
| #ifdef DGL_NTK_APP_HPP_INCLUDED | |||
| START_NAMESPACE_DGL | |||
| void NtkApp::NextUI::run() | |||
| { | |||
| const FlScopedLock csl; | |||
| if (create) | |||
| { | |||
| d_stdout("Creating NTK UI in separate thread..."); | |||
| d_UI* const ui2 = (func)(); | |||
| ui = ui2; | |||
| } | |||
| else | |||
| { | |||
| d_stdout("Destroying NTK UI in separate thread..."); | |||
| d_UI* const ui2 = ui; | |||
| ui = nullptr; | |||
| delete ui2; | |||
| } | |||
| } | |||
| END_NAMESPACE_DGL | |||
| #endif | |||
| @@ -93,10 +93,6 @@ | |||
| # define DISTRHO_UI_USE_NANOVG 0 | |||
| #endif | |||
| #ifndef DISTRHO_UI_USE_NTK | |||
| # define DISTRHO_UI_USE_NTK 0 | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // Define DISTRHO_UI_URI if needed | |||
| @@ -21,9 +21,9 @@ START_NAMESPACE_DISTRHO | |||
| /* ------------------------------------------------------------------------------------------------------------ | |||
| * Static data, see DistrhoUIInternal.hpp */ | |||
| double d_lastUiSampleRate = 0.0; | |||
| void* d_lastUiDspPtr = nullptr; | |||
| UIWindow* d_lastUiWindow = nullptr; | |||
| double d_lastUiSampleRate = 0.0; | |||
| void* d_lastUiDspPtr = nullptr; | |||
| Window* d_lastUiWindow = nullptr; | |||
| /* ------------------------------------------------------------------------------------------------------------ | |||
| * UI */ | |||
| @@ -90,7 +90,6 @@ void UI::d_sampleRateChanged(double) {} | |||
| /* ------------------------------------------------------------------------------------------------------------ | |||
| * UI Callbacks (optional) */ | |||
| #if ! DISTRHO_UI_USE_NTK | |||
| void UI::d_uiReshape(uint width, uint height) | |||
| { | |||
| glEnable(GL_BLEND); | |||
| @@ -102,23 +101,14 @@ void UI::d_uiReshape(uint width, uint height) | |||
| glMatrixMode(GL_MODELVIEW); | |||
| glLoadIdentity(); | |||
| } | |||
| #endif | |||
| /* ------------------------------------------------------------------------------------------------------------ | |||
| * UI Resize Handling, internal */ | |||
| #if DISTRHO_UI_USE_NTK | |||
| void UI::resize(int x, int y, int w, int h) | |||
| { | |||
| UIWidget::resize(x, y, w, h); | |||
| pData->setSizeCallback(w, h); | |||
| } | |||
| #else | |||
| void UI::onResize(const ResizeEvent& ev) | |||
| { | |||
| pData->setSizeCallback(ev.size.getWidth(), ev.size.getHeight()); | |||
| } | |||
| #endif | |||
| // ----------------------------------------------------------------------------------------------------------- | |||
| @@ -18,29 +18,21 @@ | |||
| #define DISTRHO_UI_INTERNAL_HPP_INCLUDED | |||
| #include "../DistrhoUI.hpp" | |||
| #include "../../dgl/App.hpp" | |||
| #include "../../dgl/Window.hpp" | |||
| #if DISTRHO_UI_USE_NTK | |||
| # include "../../dgl/ntk/NtkApp.hpp" | |||
| # include "../../dgl/ntk/NtkWindow.hpp" | |||
| typedef DGL::NtkApp App; | |||
| typedef DGL::NtkWindow UIWindow; | |||
| #else | |||
| # include "../../dgl/App.hpp" | |||
| # include "../../dgl/Window.hpp" | |||
| typedef DGL::App App; | |||
| typedef DGL::Window UIWindow; | |||
| #endif | |||
| using DGL::App; | |||
| using DGL::IdleCallback; | |||
| using DGL::Window; | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| // Static data, see DistrhoUI.cpp | |||
| extern double d_lastUiSampleRate; | |||
| extern void* d_lastUiDspPtr; | |||
| extern UIWindow* d_lastUiWindow; | |||
| extern double d_lastUiSampleRate; | |||
| extern void* d_lastUiDspPtr; | |||
| extern Window* d_lastUiWindow; | |||
| // ----------------------------------------------------------------------- | |||
| // UI callbacks | |||
| @@ -137,25 +129,21 @@ struct UI::PrivateData { | |||
| // Plugin Window, needed to take care of resize properly | |||
| static inline | |||
| UI* createUiWrapper(void* const dspPtr, UIWindow* const window) | |||
| UI* createUiWrapper(void* const dspPtr, Window* const window) | |||
| { | |||
| d_lastUiDspPtr = dspPtr; | |||
| d_lastUiWindow = window; | |||
| #if DISTRHO_UI_USE_NTK | |||
| UI* const ret = window->getApp().createUI((void*)createUI); | |||
| #else | |||
| UI* const ret = createUI(); | |||
| #endif | |||
| d_lastUiDspPtr = nullptr; | |||
| d_lastUiWindow = nullptr; | |||
| return ret; | |||
| } | |||
| class UIExporterWindow : public UIWindow | |||
| class UIExporterWindow : public Window | |||
| { | |||
| public: | |||
| UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr) | |||
| : UIWindow(app, winId), | |||
| : Window(app, winId), | |||
| fUI(createUiWrapper(dspPtr, this)), | |||
| fIsReady(false) | |||
| { | |||
| @@ -168,11 +156,7 @@ public: | |||
| ~UIExporterWindow() | |||
| { | |||
| #if DISTRHO_UI_USE_NTK | |||
| getApp().deleteUI(fUI); | |||
| #else | |||
| delete fUI; | |||
| #endif | |||
| } | |||
| UI* getUI() const noexcept | |||
| @@ -185,14 +169,7 @@ public: | |||
| return fIsReady; | |||
| } | |||
| //protected: | |||
| #if DISTRHO_UI_USE_NTK | |||
| void resize(int x, int y, int width, int height) override | |||
| { | |||
| UIWindow::resize(x, y, width, height); | |||
| fIsReady = true; | |||
| } | |||
| #else | |||
| protected: | |||
| void onReshape(uint width, uint height) override | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | |||
| @@ -202,7 +179,6 @@ public: | |||
| fIsReady = true; | |||
| } | |||
| #endif | |||
| private: | |||
| UI* const fUI; | |||