Signed-off-by: falkTX <falktx@falktx.com>pull/457/head
| @@ -28,7 +28,8 @@ | |||
| # USE_OPENGL3=true | |||
| # USE_NANOVG_FBO=true | |||
| # USE_NANOVG_FREETYPE=true | |||
| # USE_WEBVIEW=true | |||
| # USE_FILE_BROWSER=true | |||
| # USE_WEB_VIEW=true | |||
| # STATIC_BUILD=true | |||
| # Tweak build to be able to generate fully static builds (e.g. skip use of libdl) | |||
| @@ -234,6 +235,27 @@ ifeq ($(MACOS),true) | |||
| UNIX = true | |||
| endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Compatibility checks | |||
| ifeq ($(FILE_BROWSER_DISABLED),true) | |||
| $(error FILE_BROWSER_DISABLED has been replaced by USE_FILE_BROWSER (opt-in vs opt-out)) | |||
| endif | |||
| ifeq ($(USE_FILEBROWSER),true) | |||
| $(error typo detected use USE_FILE_BROWSER instead of USE_FILEBROWSER) | |||
| endif | |||
| ifeq ($(USE_WEBVIEW),true) | |||
| $(error typo detected use USE_WEB_VIEW instead of USE_WEBVIEW) | |||
| endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Set optional flags | |||
| USE_FILE_BROWSER ?= true | |||
| USE_WEB_VIEW ?= false | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Set build and link flags | |||
| @@ -440,7 +462,7 @@ else ifeq ($(MACOS),true) | |||
| DGL_SYSTEM_LIBS += -framework Cocoa | |||
| DGL_SYSTEM_LIBS += -framework CoreVideo | |||
| ifeq ($(USE_WEBVIEW),true) | |||
| ifeq ($(USE_WEB_VIEW),true) | |||
| DGL_SYSTEM_LIBS += -framework WebKit | |||
| endif | |||
| @@ -457,7 +479,7 @@ DGL_SYSTEM_LIBS += -lcomdlg32 | |||
| DGL_SYSTEM_LIBS += -ldwmapi | |||
| DGL_SYSTEM_LIBS += -lgdi32 | |||
| # DGL_SYSTEM_LIBS += -lole32 | |||
| ifeq ($(USE_WEBVIEW),true) | |||
| ifeq ($(USE_WEB_VIEW),true) | |||
| DGL_SYSTEM_LIBS += -lole32 | |||
| DGL_SYSTEM_LIBS += -luuid | |||
| endif | |||
| @@ -486,7 +508,7 @@ ifeq ($(HAVE_XRANDR),true) | |||
| DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xrandr) -DHAVE_XRANDR | |||
| DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xrandr) | |||
| endif | |||
| ifeq ($(USE_WEBVIEW),true) | |||
| ifeq ($(USE_WEB_VIEW),true) | |||
| DGL_FLAGS += -pthread | |||
| DGL_SYSTEM_LIBS += -pthread -lrt | |||
| endif | |||
| @@ -630,10 +652,6 @@ ifneq ($(NVG_FONT_TEXTURE_FLAGS),) | |||
| BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS) | |||
| endif | |||
| ifeq ($(FILE_BROWSER_DISABLED),true) | |||
| BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED | |||
| endif | |||
| ifneq ($(WINDOWS_ICON_ID),) | |||
| BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID) | |||
| endif | |||
| @@ -670,8 +688,12 @@ ifeq ($(USE_RGBA),true) | |||
| BUILD_CXX_FLAGS += -DDGL_USE_RGBA | |||
| endif | |||
| ifeq ($(USE_WEBVIEW),true) | |||
| BUILD_CXX_FLAGS += -DDGL_USE_WEBVIEW | |||
| ifeq ($(USE_FILE_BROWSER),true) | |||
| BUILD_CXX_FLAGS += -DDGL_USE_FILE_BROWSER | |||
| endif | |||
| ifeq ($(USE_WEB_VIEW),true) | |||
| BUILD_CXX_FLAGS += -DDGL_USE_WEB_VIEW | |||
| endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| @@ -255,10 +255,10 @@ ifeq ($(UI_TYPE),web) | |||
| DGL_FLAGS += -DDGL_WEB -DHAVE_DGL | |||
| DGL_LIB = $(DGL_BUILD_DIR)/libdgl-stub.a | |||
| HAVE_DGL = true | |||
| USE_WEBVIEW = true | |||
| USE_WEB_VIEW = true | |||
| endif | |||
| ifeq ($(HAVE_DGL)$(LINUX)$(USE_WEBVIEW),truetruetrue) | |||
| ifeq ($(HAVE_DGL)$(LINUX)$(USE_WEB_VIEW),truetruetrue) | |||
| DGL_LIB_SHARED = $(shell $(CC) -print-file-name=Scrt1.o) | |||
| endif | |||
| @@ -20,6 +20,35 @@ | |||
| #include "../distrho/extra/LeakDetector.hpp" | |||
| #include "../distrho/extra/ScopedPointer.hpp" | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // Compatibility checks | |||
| #if defined(DGL_CAIRO) && defined(DGL_EXTERNAL) | |||
| # error invalid build config: trying to build for both cairo and external at the same time | |||
| #elif defined(DGL_CAIRO) && defined(DGL_OPENGL) | |||
| # error invalid build config: trying to build for both cairo and opengl at the same time | |||
| #elif defined(DGL_CAIRO) && defined(DGL_VULKAN) | |||
| # error invalid build config: trying to build for both cairo and vulkan at the same time | |||
| #elif defined(DGL_EXTERNAL) && defined(DGL_OPENGL) | |||
| # error invalid build config: trying to build for both external and opengl at the same time | |||
| #elif defined(DGL_EXTERNAL) && defined(DGL_VULKAN) | |||
| # error invalid build config: trying to build for both external and vulkan at the same time | |||
| #elif defined(DGL_OPENGL) && defined(DGL_VULKAN) | |||
| # error invalid build config: trying to build for both opengl and vulkan at the same time | |||
| #endif | |||
| #ifdef DGL_USE_FILEBROWSER | |||
| # error typo detected use DGL_USE_FILE_BROWSER instead of DGL_USE_FILEBROWSER | |||
| #endif | |||
| #ifdef DGL_UI_USE_WEBVIEW | |||
| # error typo detected use DGL_UI_USE_WEB_VIEW instead of DGL_UI_USE_WEBVIEW | |||
| #endif | |||
| #if defined(DGL_FILE_BROWSER_DISABLED) | |||
| # error DGL_FILE_BROWSER_DISABLED has been replaced by DGL_USE_FILE_BROWSER (opt-in vs opt-out) | |||
| #endif | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // Define namespace | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2012-2024 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 | |||
| @@ -19,7 +19,7 @@ | |||
| #include "Geometry.hpp" | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| # include "FileBrowserDialog.hpp" | |||
| #endif | |||
| @@ -394,7 +394,7 @@ public: | |||
| */ | |||
| void focus(); | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| /** | |||
| Open a file browser dialog with this window as transient parent. | |||
| A few options can be specified to setup the dialog. | |||
| @@ -405,7 +405,7 @@ public: | |||
| This function does not block the event loop. | |||
| */ | |||
| bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options = FileBrowserOptions()); | |||
| #endif | |||
| #endif | |||
| /** | |||
| Request repaint of this window, for the entire area. | |||
| @@ -517,7 +517,7 @@ protected: | |||
| */ | |||
| virtual void onScaleFactorChanged(double scaleFactor); | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| /** | |||
| A function called when a path is selected by the user, as triggered by openFileBrowser(). | |||
| This action happens after the user confirms the action, so the file browser dialog will be closed at this point. | |||
| @@ -528,7 +528,7 @@ protected: | |||
| /** DEPRECATED Use onFileSelected(). */ | |||
| DISTRHO_DEPRECATED_BY("onFileSelected(const char*)") | |||
| inline virtual void fileBrowserSelected(const char* filename) { return onFileSelected(filename); } | |||
| #endif | |||
| #endif | |||
| private: | |||
| PrivateData* const pData; | |||
| @@ -414,7 +414,7 @@ void Window::focus() | |||
| pData->focus(); | |||
| } | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| bool Window::openFileBrowser(const FileBrowserOptions& options) | |||
| { | |||
| return pData->openFileBrowser(options); | |||
| @@ -574,7 +574,7 @@ void Window::onScaleFactorChanged(double) | |||
| { | |||
| } | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| void Window::onFileSelected(const char*) | |||
| { | |||
| } | |||
| @@ -128,7 +128,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) | |||
| waitingForClipboardEvents(false), | |||
| clipboardTypeId(0), | |||
| filenameToRenderInto(nullptr), | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| fileBrowserHandle(nullptr), | |||
| #endif | |||
| modal() | |||
| @@ -158,7 +158,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, PrivateData* c | |||
| waitingForClipboardEvents(false), | |||
| clipboardTypeId(0), | |||
| filenameToRenderInto(nullptr), | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| fileBrowserHandle(nullptr), | |||
| #endif | |||
| modal(ppData) | |||
| @@ -190,7 +190,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||
| waitingForClipboardEvents(false), | |||
| clipboardTypeId(0), | |||
| filenameToRenderInto(nullptr), | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| fileBrowserHandle(nullptr), | |||
| #endif | |||
| modal() | |||
| @@ -225,7 +225,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||
| waitingForClipboardEvents(false), | |||
| clipboardTypeId(0), | |||
| filenameToRenderInto(nullptr), | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| fileBrowserHandle(nullptr), | |||
| #endif | |||
| modal() | |||
| @@ -244,7 +244,7 @@ Window::PrivateData::~PrivateData() | |||
| if (isEmbed) | |||
| { | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| if (fileBrowserHandle != nullptr) | |||
| fileBrowserClose(fileBrowserHandle); | |||
| #endif | |||
| @@ -394,7 +394,7 @@ void Window::PrivateData::hide() | |||
| if (modal.enabled) | |||
| stopModal(); | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| if (fileBrowserHandle != nullptr) | |||
| { | |||
| fileBrowserClose(fileBrowserHandle); | |||
| @@ -435,7 +435,7 @@ void Window::PrivateData::setResizable(const bool resizable) | |||
| void Window::PrivateData::idleCallback() | |||
| { | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| if (fileBrowserHandle != nullptr && fileBrowserIdle(fileBrowserHandle)) | |||
| { | |||
| self->onFileSelected(fileBrowserGetPath(fileBrowserHandle)); | |||
| @@ -477,7 +477,7 @@ bool Window::PrivateData::removeIdleCallback(IdleCallback* const callback) | |||
| return puglStopTimer(view, (uintptr_t)callback) == PUGL_SUCCESS; | |||
| } | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| // ----------------------------------------------------------------------- | |||
| // file handling | |||
| @@ -498,7 +498,7 @@ bool Window::PrivateData::openFileBrowser(const FileBrowserOptions& options) | |||
| return fileBrowserHandle != nullptr; | |||
| } | |||
| #endif // ! DGL_FILE_BROWSER_DISABLED | |||
| #endif // DGL_USE_FILE_BROWSER | |||
| // ----------------------------------------------------------------------- | |||
| // modal handling | |||
| @@ -90,7 +90,7 @@ struct Window::PrivateData : IdleCallback { | |||
| /** Render to a picture file when non-null, automatically free+unset after saving. */ | |||
| char* filenameToRenderInto; | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| /** Handle for file browser dialog operations. */ | |||
| DGL_NAMESPACE::FileBrowserHandle fileBrowserHandle; | |||
| #endif | |||
| @@ -168,7 +168,7 @@ struct Window::PrivateData : IdleCallback { | |||
| bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs); | |||
| bool removeIdleCallback(IdleCallback* callback); | |||
| #ifndef DGL_FILE_BROWSER_DISABLED | |||
| #ifdef DGL_USE_FILE_BROWSER | |||
| // file handling | |||
| bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options); | |||
| #endif | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2012-2024 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 | |||
| @@ -18,6 +18,10 @@ | |||
| # error bad include | |||
| #endif | |||
| #if !defined(DGL_USE_FILE_BROWSER) && defined(DISTRHO_UI_FILE_BROWSER) && DISTRHO_UI_FILE_BROWSER == 0 | |||
| # error To use File Browser in DPF plugins please set DISTRHO_UI_FILE_BROWSER to 1 | |||
| #endif | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // File Browser Dialog stuff | |||
| @@ -18,7 +18,7 @@ | |||
| # error bad include | |||
| #endif | |||
| #if defined(DISTRHO_UI_WEB_VIEW) && DISTRHO_UI_WEB_VIEW == 0 | |||
| #if !defined(DGL_UI_USE_WEB_VIEW) && defined(DISTRHO_UI_WEB_VIEW) && DISTRHO_UI_WEB_VIEW == 0 | |||
| # error To use WebViews in DPF plugins please set DISTRHO_UI_WEB_VIEW to 1 | |||
| #endif | |||
| @@ -121,14 +121,14 @@ | |||
| # define DISTRHO_UI_USE_NANOVG 0 | |||
| #endif | |||
| #ifndef DISTRHO_UI_USE_WEBVIEW | |||
| # define DISTRHO_UI_USE_WEBVIEW 0 | |||
| #ifndef DISTRHO_UI_USE_WEB_VIEW | |||
| # define DISTRHO_UI_USE_WEB_VIEW 0 | |||
| #endif | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // Define DISTRHO_UI_WEB_VIEW if needed | |||
| #if DISTRHO_UI_USE_WEBVIEW && !DISTRHO_UI_WEB_VIEW | |||
| #if DISTRHO_UI_USE_WEB_VIEW && !DISTRHO_UI_WEB_VIEW | |||
| # undef DISTRHO_UI_WEB_VIEW | |||
| # define DISTRHO_UI_WEB_VIEW 1 | |||
| #endif | |||
| @@ -151,20 +151,20 @@ | |||
| # error DISTRHO_PLUGIN_HAS_EXTERNAL_UI has been replaced by DISTRHO_UI_USE_EXTERNAL | |||
| #endif | |||
| #if defined(DGL_CAIRO) && defined(DGL_OPENGL) | |||
| # error invalid build config: trying to build for both cairo and opengl at the same time | |||
| #elif defined(DGL_EXTERNAL) && defined(DGL_CAIRO) | |||
| # error invalid build config: trying to build for both external and cairo at the same time | |||
| #elif defined(DGL_EXTERNAL) && defined(DGL_OPENGL) | |||
| # error invalid build config: trying to build for both external and opengl at the same time | |||
| #ifdef DISTRHO_UI_FILEBROWSER | |||
| # error typo detected use DGL_USE_FILE_BROWSER instead of DISTRHO_UI_FILEBROWSER | |||
| #endif | |||
| #if DISTRHO_UI_FILE_BROWSER && defined(DGL_FILE_BROWSER_DISABLED) | |||
| # error invalid build config: file browser requested but `FILE_BROWSER_DISABLED` build option is set | |||
| #ifdef DISTRHO_UI_USE_WEBVIEW | |||
| # error typo detected use DISTRHO_UI_USE_WEB_VIEW instead of DISTRHO_UI_USE_WEBVIEW | |||
| #endif | |||
| #if DISTRHO_UI_USE_WEBVIEW && !defined(DGL_USE_WEBVIEW) | |||
| # error invalid build config: web view requested but `USE_WEBVIEW` build option is not set | |||
| #if DISTRHO_UI_FILE_BROWSER && !defined(DGL_USE_FILE_BROWSER) | |||
| # error invalid build config: file browser requested but `USE_FILE_BROWSER` build option is not set | |||
| #endif | |||
| #if DISTRHO_UI_USE_WEB_VIEW && !defined(DGL_UI_USE_WEB_VIEW) | |||
| # error invalid build config: web view requested but `USE_WEB_VIEW` build option is not set | |||
| #endif | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| @@ -30,7 +30,9 @@ | |||
| # include <winsock2.h> | |||
| # include <windows.h> | |||
| #elif defined(HAVE_X11) | |||
| # define Window X11Window | |||
| # include <X11/Xresource.h> | |||
| # undef Window | |||
| #endif | |||
| #if DISTRHO_UI_FILE_BROWSER && !defined(DISTRHO_OS_MAC) | |||
| @@ -57,7 +59,9 @@ | |||
| START_NAMESPACE_DISTRHO | |||
| # include "../extra/FileBrowserDialogImpl.hpp" | |||
| END_NAMESPACE_DISTRHO | |||
| # define Window X11Window | |||
| # include "../extra/FileBrowserDialogImpl.cpp" | |||
| # undef Window | |||
| #endif | |||
| #if DISTRHO_UI_WEB_VIEW && !defined(DISTRHO_OS_MAC) | |||
| @@ -67,7 +71,9 @@ END_NAMESPACE_DISTRHO | |||
| START_NAMESPACE_DISTRHO | |||
| # include "../extra/WebViewImpl.hpp" | |||
| END_NAMESPACE_DISTRHO | |||
| # define Window X11Window | |||
| # include "../extra/WebViewImpl.cpp" | |||
| # undef Window | |||
| #endif | |||
| #include "src/TopLevelWidgetPrivateData.hpp" | |||
| @@ -21,7 +21,7 @@ FILES_UI = \ | |||
| # -------------------------------------------------------------- | |||
| # Do some magic | |||
| USE_WEBVIEW = true | |||
| USE_WEB_VIEW = true | |||
| UI_TYPE = external | |||
| include ../../Makefile.plugins.mk | |||
| @@ -22,6 +22,7 @@ FILES_UI = \ | |||
| # -------------------------------------------------------------- | |||
| # Do some magic | |||
| USE_FILE_BROWSER = true | |||
| include ../../Makefile.plugins.mk | |||
| # -------------------------------------------------------------- | |||