diff --git a/dgl/Application.hpp b/dgl/Application.hpp index 28404e39..37a91b76 100644 --- a/dgl/Application.hpp +++ b/dgl/Application.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2022 Filipe Coelho * * 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,6 +19,12 @@ #include "Base.hpp" +#ifdef DISTRHO_NAMESPACE +START_NAMESPACE_DISTRHO +class PluginApplication; +END_NAMESPACE_DISTRHO +#endif + START_NAMESPACE_DGL // -------------------------------------------------------------------------------------------------------------------- @@ -116,8 +122,10 @@ public: private: struct PrivateData; PrivateData* const pData; - friend class PluginApplication; friend class Window; + #ifdef DISTRHO_NAMESPACE + friend class DISTRHO_NAMESPACE::PluginApplication; + #endif DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application) }; diff --git a/dgl/FileBrowserDialog.hpp b/dgl/FileBrowserDialog.hpp new file mode 100644 index 00000000..05c53e04 --- /dev/null +++ b/dgl/FileBrowserDialog.hpp @@ -0,0 +1,28 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2022 Filipe Coelho + * + * 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_FILE_BROWSER_DIALOG_HPP_INCLUDED +#define DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED + +#include "Base.hpp" + +START_NAMESPACE_DGL + +#include "../distrho/extra/FileBrowserDialogImpl.hpp" + +END_NAMESPACE_DGL + +#endif // DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED diff --git a/dgl/Window.hpp b/dgl/Window.hpp index bc9df247..2d5804f4 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -20,15 +20,20 @@ #include "Geometry.hpp" #ifndef DGL_FILE_BROWSER_DISABLED -# include "../distrho/extra/FileBrowserDialog.hpp" +# include "FileBrowserDialog.hpp" #endif #include +#ifdef DISTRHO_NAMESPACE +START_NAMESPACE_DISTRHO +class PluginWindow; +END_NAMESPACE_DISTRHO +#endif + START_NAMESPACE_DGL class Application; -class PluginWindow; class TopLevelWidget; // ----------------------------------------------------------------------- @@ -59,11 +64,6 @@ class DISTRHO_API Window struct PrivateData; public: -#ifndef DGL_FILE_BROWSER_DISABLED - typedef DISTRHO_NAMESPACE::FileBrowserHandle FileBrowserHandle; - typedef DISTRHO_NAMESPACE::FileBrowserOptions FileBrowserOptions; -#endif - /** Window graphics context as a scoped struct. This class gives graphics context drawing time to a window's widgets. @@ -400,7 +400,7 @@ public: This function does not block the event loop. */ - bool openFileBrowser(const FileBrowserOptions& options = FileBrowserOptions()); + bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options = FileBrowserOptions()); #endif /** @@ -521,8 +521,10 @@ protected: private: PrivateData* const pData; friend class Application; - friend class PluginWindow; friend class TopLevelWidget; + #ifdef DISTRHO_NAMESPACE + friend class DISTRHO_NAMESPACE::PluginWindow; + #endif /** @internal */ explicit Window(Application& app, diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp index f4912cab..c204f7a5 100644 --- a/dgl/src/WindowPrivateData.hpp +++ b/dgl/src/WindowPrivateData.hpp @@ -44,9 +44,6 @@ struct Window::PrivateData : IdleCallback { /** Pugl view instance. */ PuglView* view; - /** Pugl view instance of the transient parent window. */ -// PuglView* const transientParentView; - /** Reserved space for graphics context. */ mutable uint8_t graphicsContext[sizeof(void*)]; @@ -91,7 +88,7 @@ struct Window::PrivateData : IdleCallback { #ifndef DGL_FILE_BROWSER_DISABLED /** Handle for file browser dialog operations. */ - FileBrowserHandle fileBrowserHandle; + DGL_NAMESPACE::FileBrowserHandle fileBrowserHandle; #endif /** Modal window setup. */ @@ -168,7 +165,7 @@ struct Window::PrivateData : IdleCallback { #ifndef DGL_FILE_BROWSER_DISABLED // file handling - bool openFileBrowser(const FileBrowserOptions& options); + bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options); #endif static void renderToPicture(const char* filename, const GraphicsContext& context, uint width, uint height); diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp index c62e0f11..b33eeb96 100644 --- a/dgl/src/pugl.cpp +++ b/dgl/src/pugl.cpp @@ -101,10 +101,12 @@ #endif #ifndef DGL_FILE_BROWSER_DISABLED +# define FILE_BROWSER_DIALOG_DGL_NAMESPACE +# include "../FileBrowserDialog.hpp" # ifdef DISTRHO_OS_MAC -# import "../../distrho/extra/FileBrowserDialog.cpp" +# import "../../distrho/extra/FileBrowserDialogImpl.cpp" # else -# include "../../distrho/extra/FileBrowserDialog.cpp" +# include "../../distrho/extra/FileBrowserDialogImpl.cpp" # endif #endif diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 7b0dafda..950077ba 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -48,16 +48,14 @@ typedef DGL_NAMESPACE::NanoTopLevelWidget UIWidget; typedef DGL_NAMESPACE::TopLevelWidget UIWidget; #endif -#ifndef DGL_FILE_BROWSER_DISABLED +#if DISTRHO_UI_FILE_BROWSER # include "extra/FileBrowserDialog.hpp" #endif -START_NAMESPACE_DGL -class PluginWindow; -END_NAMESPACE_DGL - START_NAMESPACE_DISTRHO +class PluginWindow; + /* ------------------------------------------------------------------------------------------------------------ * DPF UI */ @@ -185,7 +183,7 @@ public: void sendNote(uint8_t channel, uint8_t note, uint8_t velocity); #endif -#ifndef DGL_FILE_BROWSER_DISABLED +#if DISTRHO_UI_FILE_BROWSER /** Open a file browser dialog with this window as transient parent.@n A few options can be specified to setup the dialog. @@ -198,7 +196,7 @@ public: @note This is exactly the same API as provided by the Window class, but redeclared here so that non-embed/DGL based UIs can still use file browser related functions. */ - bool openFileBrowser(const FileBrowserOptions& options = FileBrowserOptions()); + bool openFileBrowser(const DISTRHO_NAMESPACE::FileBrowserOptions& options = FileBrowserOptions()); #endif #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS @@ -334,7 +332,7 @@ protected: virtual void uiReshape(uint width, uint height); #endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI -#ifndef DGL_FILE_BROWSER_DISABLED +#if DISTRHO_UI_FILE_BROWSER /** Window file selected function, called when a path is selected by the user, as triggered by openFileBrowser(). This function is for plugin UIs to be able to override Window::onFileSelected(const char*). @@ -371,7 +369,7 @@ protected: private: struct PrivateData; PrivateData* const uiData; - friend class DGL_NAMESPACE::PluginWindow; + friend class PluginWindow; friend class UIExporter; #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI /** @internal */ diff --git a/distrho/DistrhoUI_macOS.mm b/distrho/DistrhoUI_macOS.mm index 24f24f37..dc44083c 100644 --- a/distrho/DistrhoUI_macOS.mm +++ b/distrho/DistrhoUI_macOS.mm @@ -26,7 +26,7 @@ # import # include # include -# ifndef DGL_FILE_BROWSER_DISABLED +# if DISTRHO_UI_FILE_BROWSER # import "extra/FileBrowserDialog.cpp" # endif diff --git a/distrho/extra/FileBrowserDialog.hpp b/distrho/extra/FileBrowserDialog.hpp index 2074e4cb..786f2804 100644 --- a/distrho/extra/FileBrowserDialog.hpp +++ b/distrho/extra/FileBrowserDialog.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2022 Filipe Coelho * * 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 @@ -21,113 +21,7 @@ START_NAMESPACE_DISTRHO -// -------------------------------------------------------------------------------------------------------------------- -// File Browser Dialog stuff - -struct FileBrowserData; -typedef FileBrowserData* FileBrowserHandle; - -// -------------------------------------------------------------------------------------------------------------------- - -/** - File browser options, for customizing the file browser dialog.@n - By default the file browser dialog will be work as "open file" in the current working directory. -*/ -struct FileBrowserOptions { - /** Whether we are saving, opening files otherwise (default) */ - bool saving; - - /** Start directory, uses current working directory if null */ - const char* startDir; - - /** File browser dialog window title, uses "FileBrowser" if null */ - const char* title; - - // TODO file filter - - /** - File browser button state. - This allows to customize the behaviour of the file browse dialog buttons. - Note these are merely hints, not all systems support them. - */ - enum ButtonState { - kButtonInvisible, - kButtonVisibleUnchecked, - kButtonVisibleChecked, - }; - - /** - File browser buttons. - */ - struct Buttons { - /** Whether to list all files vs only those with matching file extension */ - ButtonState listAllFiles; - /** Whether to show hidden files */ - ButtonState showHidden; - /** Whether to show list of places (bookmarks) */ - ButtonState showPlaces; - - /** Constructor for default values */ - Buttons() - : listAllFiles(kButtonVisibleChecked), - showHidden(kButtonVisibleUnchecked), - showPlaces(kButtonVisibleChecked) {} - } buttons; - - /** Constructor for default values */ - FileBrowserOptions() - : saving(false), - startDir(nullptr), - title(nullptr), - buttons() {} -}; - -// -------------------------------------------------------------------------------------------------------------------- - -#ifdef DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE -namespace DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE { -#endif - -/** - Create a new file browser dialog. - - @p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows) - @p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*) - @p scaleFactor: Scale factor to use (only used on X11) - @p options: Extra options, optional - By default the file browser dialog will be work as "open file" in the current working directory. -*/ -FileBrowserHandle fileBrowserCreate(bool isEmbed, - uintptr_t windowId, - double scaleFactor, - const FileBrowserOptions& options = FileBrowserOptions()); - -/** - Idle the file browser dialog handle.@n - Returns true if dialog was closed (with or without a file selection), - in which case the handle must not be used afterwards. - You can then call fileBrowserGetPath to know the selected file (or null if cancelled). -*/ -bool fileBrowserIdle(const FileBrowserHandle handle); - -/** - Close the file browser dialog, handle must not be used afterwards. -*/ -void fileBrowserClose(const FileBrowserHandle handle); - -/** - Get the path chosen by the user or null.@n - Should only be called after fileBrowserIdle returns true. -*/ -const char* fileBrowserGetPath(const FileBrowserHandle handle); - -// -------------------------------------------------------------------------------------------------------------------- - -#ifdef DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE -} -#endif - -// -------------------------------------------------------------------------------------------------------------------- +#include "FileBrowserDialogImpl.hpp" END_NAMESPACE_DISTRHO diff --git a/distrho/extra/FileBrowserDialog.cpp b/distrho/extra/FileBrowserDialogImpl.cpp similarity index 97% rename from distrho/extra/FileBrowserDialog.cpp rename to distrho/extra/FileBrowserDialogImpl.cpp index df109341..a1b73737 100644 --- a/distrho/extra/FileBrowserDialog.cpp +++ b/distrho/extra/FileBrowserDialogImpl.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2022 Filipe Coelho * * 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 @@ -14,7 +14,13 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "FileBrowserDialog.hpp" +#if !defined(DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED) && !defined(DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED) +# error bad include +#endif +#if !defined(FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE) && !defined(FILE_BROWSER_DIALOG_DGL_NAMESPACE) +# error bad usage +#endif + #include "ScopedPointer.hpp" #include "String.hpp" @@ -40,7 +46,11 @@ # include "sofd/libsofd.c" #endif +#ifdef FILE_BROWSER_DIALOG_DGL_NAMESPACE +START_NAMESPACE_DGL +#else START_NAMESPACE_DISTRHO +#endif // -------------------------------------------------------------------------------------------------------------------- @@ -260,12 +270,6 @@ struct FileBrowserData { // -------------------------------------------------------------------------------------------------------------------- -#ifdef DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE -namespace DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE { -#endif - -// -------------------------------------------------------------------------------------------------------------------- - FileBrowserHandle fileBrowserCreate(const bool isEmbed, const uintptr_t windowId, const double scaleFactor, @@ -629,8 +633,11 @@ const char* fileBrowserGetPath(const FileBrowserHandle handle) // -------------------------------------------------------------------------------------------------------------------- -#ifdef DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE -} +#ifdef FILE_BROWSER_DIALOG_DGL_NAMESPACE +END_NAMESPACE_DGL +#else +END_NAMESPACE_DISTRHO #endif -END_NAMESPACE_DISTRHO +#undef FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE +#undef FILE_BROWSER_DIALOG_DGL_NAMESPACE diff --git a/distrho/extra/FileBrowserDialogImpl.hpp b/distrho/extra/FileBrowserDialogImpl.hpp new file mode 100644 index 00000000..e15cfef0 --- /dev/null +++ b/distrho/extra/FileBrowserDialogImpl.hpp @@ -0,0 +1,117 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2022 Filipe Coelho + * + * 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. + */ + +#if !defined(DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED) && !defined(DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED) +# error bad include +#endif + +// -------------------------------------------------------------------------------------------------------------------- +// File Browser Dialog stuff + +struct FileBrowserData; +typedef FileBrowserData* FileBrowserHandle; + +// -------------------------------------------------------------------------------------------------------------------- + +/** + File browser options, for customizing the file browser dialog.@n + By default the file browser dialog will be work as "open file" in the current working directory. +*/ +struct FileBrowserOptions { + /** Whether we are saving, opening files otherwise (default) */ + bool saving; + + /** Start directory, uses current working directory if null */ + const char* startDir; + + /** File browser dialog window title, uses "FileBrowser" if null */ + const char* title; + + // TODO file filter + + /** + File browser button state. + This allows to customize the behaviour of the file browse dialog buttons. + Note these are merely hints, not all systems support them. + */ + enum ButtonState { + kButtonInvisible, + kButtonVisibleUnchecked, + kButtonVisibleChecked, + }; + + /** + File browser buttons. + */ + struct Buttons { + /** Whether to list all files vs only those with matching file extension */ + ButtonState listAllFiles; + /** Whether to show hidden files */ + ButtonState showHidden; + /** Whether to show list of places (bookmarks) */ + ButtonState showPlaces; + + /** Constructor for default values */ + Buttons() + : listAllFiles(kButtonVisibleChecked), + showHidden(kButtonVisibleUnchecked), + showPlaces(kButtonVisibleChecked) {} + } buttons; + + /** Constructor for default values */ + FileBrowserOptions() + : saving(false), + startDir(nullptr), + title(nullptr), + buttons() {} +}; + +// -------------------------------------------------------------------------------------------------------------------- + +/** + Create a new file browser dialog. + + @p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows) + @p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*) + @p scaleFactor: Scale factor to use (only used on X11) + @p options: Extra options, optional + By default the file browser dialog will be work as "open file" in the current working directory. +*/ +FileBrowserHandle fileBrowserCreate(bool isEmbed, + uintptr_t windowId, + double scaleFactor, + const FileBrowserOptions& options = FileBrowserOptions()); + +/** + Idle the file browser dialog handle.@n + Returns true if dialog was closed (with or without a file selection), + in which case the handle must not be used afterwards. + You can then call fileBrowserGetPath to know the selected file (or null if cancelled). +*/ +bool fileBrowserIdle(const FileBrowserHandle handle); + +/** + Close the file browser dialog, handle must not be used afterwards. +*/ +void fileBrowserClose(const FileBrowserHandle handle); + +/** + Get the path chosen by the user or null.@n + Should only be called after fileBrowserIdle returns true. +*/ +const char* fileBrowserGetPath(const FileBrowserHandle handle); + +// -------------------------------------------------------------------------------------------------------------------- diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h index d3d4b174..d2df9f89 100644 --- a/distrho/src/DistrhoPluginChecks.h +++ b/distrho/src/DistrhoPluginChecks.h @@ -90,6 +90,14 @@ # define DISTRHO_PLUGIN_WANT_TIMEPOS 0 #endif +#ifndef DISTRHO_UI_FILE_BROWSER +# if defined(DGL_FILE_BROWSER_DISABLED) || DISTRHO_PLUGIN_HAS_EXTERNAL_UI +# define DISTRHO_UI_FILE_BROWSER 0 +# else +# define DISTRHO_UI_FILE_BROWSER 1 +# endif +#endif + #ifndef DISTRHO_UI_USER_RESIZABLE # define DISTRHO_UI_USER_RESIZABLE 0 #endif @@ -154,7 +162,16 @@ #endif // ----------------------------------------------------------------------- -// Disable UI if DGL or External UI is not available +// Disable file browser if using external UI + +#if DISTRHO_UI_FILE_BROWSER && DISTRHO_PLUGIN_HAS_EXTERNAL_UI +# warning file browser APIs do not work for external UIs +# undef DISTRHO_UI_FILE_BROWSER 0 +# define DISTRHO_UI_FILE_BROWSER 0 +#endif + +// ----------------------------------------------------------------------- +// Disable UI if DGL or external UI is not available #if (defined(DGL_CAIRO) && ! defined(HAVE_CAIRO)) || (defined(DGL_OPENGL) && ! defined(HAVE_OPENGL)) # undef DISTRHO_PLUGIN_HAS_EMBED_UI diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 8d0f3403..87788eb1 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -17,26 +17,27 @@ #include "src/DistrhoPluginChecks.h" #include "src/DistrhoDefines.h" -#if !defined(DGL_FILE_BROWSER_DISABLED) && !defined(DISTRHO_UI_FILE_BROWSER) && !defined(DISTRHO_OS_MAC) +#if DISTRHO_UI_FILE_BROWSER && !defined(DISTRHO_OS_MAC) # define DISTRHO_PUGL_NAMESPACE_MACRO_HELPER(NS, SEP, FUNCTION) NS ## SEP ## FUNCTION # define DISTRHO_PUGL_NAMESPACE_MACRO(NS, FUNCTION) DISTRHO_PUGL_NAMESPACE_MACRO_HELPER(NS, _, FUNCTION) -# define DISTRHO_FILE_BROWSER_DIALOG_EXTRA_NAMESPACE Plugin -# define x_fib_add_recent DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_add_recent) -# define x_fib_cfg_buttons DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_cfg_buttons) -# define x_fib_cfg_filter_callback DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_cfg_filter_callback) -# define x_fib_close DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_close) -# define x_fib_configure DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_configure) -# define x_fib_filename DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_filename) -# define x_fib_free_recent DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_free_recent) -# define x_fib_handle_events DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_handle_events) -# define x_fib_load_recent DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_load_recent) -# define x_fib_recent_at DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_recent_at) -# define x_fib_recent_count DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_recent_count) -# define x_fib_recent_file DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_recent_file) -# define x_fib_save_recent DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_save_recent) -# define x_fib_show DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_show) -# define x_fib_status DISTRHO_PUGL_NAMESPACE_MACRO(Plugin, x_fib_status) -# include "../extra/FileBrowserDialog.cpp" +# define x_fib_add_recent DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_add_recent) +# define x_fib_cfg_buttons DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_cfg_buttons) +# define x_fib_cfg_filter_callback DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_cfg_filter_callback) +# define x_fib_close DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_close) +# define x_fib_configure DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_configure) +# define x_fib_filename DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_filename) +# define x_fib_free_recent DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_free_recent) +# define x_fib_handle_events DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_handle_events) +# define x_fib_load_recent DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_load_recent) +# define x_fib_recent_at DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_recent_at) +# define x_fib_recent_count DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_recent_count) +# define x_fib_recent_file DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_recent_file) +# define x_fib_save_recent DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_save_recent) +# define x_fib_show DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_show) +# define x_fib_status DISTRHO_PUGL_NAMESPACE_MACRO(plugin, x_fib_status) +# define FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE +# include "../extra/FileBrowserDialog.hpp" +# include "../extra/FileBrowserDialogImpl.cpp" #endif #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI @@ -278,16 +279,10 @@ void UI::sendNote(uint8_t channel, uint8_t note, uint8_t velocity) } #endif -#ifndef DGL_FILE_BROWSER_DISABLED +#if DISTRHO_UI_FILE_BROWSER bool UI::openFileBrowser(const FileBrowserOptions& options) { -# if DISTRHO_PLUGIN_HAS_EXTERNAL_UI - // TODO - return false; - (void)options; -# else - return getWindow().openFileBrowser(options); -# endif + return getWindow().openFileBrowser((DGL_NAMESPACE::FileBrowserOptions&)options); } #endif @@ -368,7 +363,7 @@ void UI::uiReshape(uint, uint) } #endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI -#ifndef DGL_FILE_BROWSER_DISABLED +#if DISTRHO_UI_FILE_BROWSER void UI::uiFileBrowserSelected(const char*) { } diff --git a/distrho/src/DistrhoUIPrivateData.hpp b/distrho/src/DistrhoUIPrivateData.hpp index a2cf3084..0ae5a4fb 100644 --- a/distrho/src/DistrhoUIPrivateData.hpp +++ b/distrho/src/DistrhoUIPrivateData.hpp @@ -48,13 +48,7 @@ # define DISTRHO_UI_USER_RESIZABLE 0 #endif -// ----------------------------------------------------------------------- - -#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI START_NAMESPACE_DISTRHO -#else -START_NAMESPACE_DGL -#endif // ----------------------------------------------------------------------- // Plugin Application, will set class name based on plugin details @@ -107,11 +101,11 @@ struct PluginApplication DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginApplication) }; #else -class PluginApplication : public Application +class PluginApplication : public DGL_NAMESPACE::Application { public: explicit PluginApplication() - : Application(DISTRHO_UI_IS_STANDALONE) + : DGL_NAMESPACE::Application(DISTRHO_UI_IS_STANDALONE) { const char* const className = ( #ifdef DISTRHO_PLUGIN_BRAND @@ -172,14 +166,14 @@ public: DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow) }; #else // DISTRHO_PLUGIN_HAS_EXTERNAL_UI -class PluginWindow : public Window +class PluginWindow : public DGL_NAMESPACE::Window { - DISTRHO_NAMESPACE::UI* const ui; + UI* const ui; bool initializing; bool receivedReshapeDuringInit; public: - explicit PluginWindow(DISTRHO_NAMESPACE::UI* const uiPtr, + explicit PluginWindow(UI* const uiPtr, PluginApplication& app, const uintptr_t parentWindowHandle, const uint width, @@ -238,7 +232,7 @@ public: } #endif - std::vector getClipboardDataOfferTypes() + std::vector getClipboardDataOfferTypes() { return Window::getClipboardDataOfferTypes(); } @@ -287,7 +281,7 @@ protected: ui->uiScaleFactorChanged(scaleFactor); } -# ifndef DGL_FILE_BROWSER_DISABLED +# if DISTRHO_UI_FILE_BROWSER void onFileSelected(const char* filename) override; # endif @@ -295,21 +289,6 @@ protected: }; #endif // DISTRHO_PLUGIN_HAS_EXTERNAL_UI -#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI -END_NAMESPACE_DISTRHO -#else -END_NAMESPACE_DGL -#endif - -// ----------------------------------------------------------------------- - -START_NAMESPACE_DISTRHO - -#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI -using DGL_NAMESPACE::PluginApplication; -using DGL_NAMESPACE::PluginWindow; -#endif - // ----------------------------------------------------------------------- // UI callbacks @@ -465,7 +444,7 @@ inline bool UI::PrivateData::fileRequestCallback(const char* const key) snprintf(title, sizeof(title)-1u, DISTRHO_PLUGIN_NAME ": %s", key); title[sizeof(title)-1u] = '\0'; - FileBrowserOptions opts; + DGL_NAMESPACE::FileBrowserOptions opts; opts.title = title; return window->openFileBrowser(opts); #endif @@ -473,14 +452,10 @@ inline bool UI::PrivateData::fileRequestCallback(const char* const key) return false; } -END_NAMESPACE_DISTRHO - // ----------------------------------------------------------------------- // PluginWindow onFileSelected that require UI::PrivateData definitions -#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) -START_NAMESPACE_DGL - +#if DISTRHO_UI_FILE_BROWSER inline void PluginWindow::onFileSelected(const char* const filename) { DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); @@ -488,7 +463,7 @@ inline void PluginWindow::onFileSelected(const char* const filename) if (initializing) return; -# if DISTRHO_PLUGIN_WANT_STATE + #if DISTRHO_PLUGIN_WANT_STATE if (char* const key = ui->uiData->uiStateFileKeyRequest) { ui->uiData->uiStateFileKeyRequest = nullptr; @@ -502,14 +477,14 @@ inline void PluginWindow::onFileSelected(const char* const filename) std::free(key); return; } -# endif + #endif ui->uiFileBrowserSelected(filename); } - -END_NAMESPACE_DGL #endif // ----------------------------------------------------------------------- +END_NAMESPACE_DISTRHO + #endif // DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED diff --git a/examples/Info/DistrhoPluginInfo.h b/examples/Info/DistrhoPluginInfo.h index 4c22069e..6a1096b1 100644 --- a/examples/Info/DistrhoPluginInfo.h +++ b/examples/Info/DistrhoPluginInfo.h @@ -26,6 +26,7 @@ #define DISTRHO_PLUGIN_NUM_INPUTS 2 #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 #define DISTRHO_PLUGIN_WANT_TIMEPOS 1 +#define DISTRHO_UI_FILE_BROWSER 0 #define DISTRHO_UI_USER_RESIZABLE 1 #define DISTRHO_UI_USE_NANOVG 1 diff --git a/pugl-updates-notes.txt b/pugl-updates-notes.txt index e33b6a0e..3cf480ae 100644 --- a/pugl-updates-notes.txt +++ b/pugl-updates-notes.txt @@ -1,6 +1,5 @@ puglClearMinSize needed? puglSetWindowSize was used on first show, still needed? -transientParentView needed? remove from WindowPrivateData update distrhoui.cpp get scale factor to match new parent request setup and pugl