Signed-off-by: falkTX <falktx@falktx.com>pull/321/head
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -19,6 +19,12 @@ | |||||
#include "Base.hpp" | #include "Base.hpp" | ||||
#ifdef DISTRHO_NAMESPACE | |||||
START_NAMESPACE_DISTRHO | |||||
class PluginApplication; | |||||
END_NAMESPACE_DISTRHO | |||||
#endif | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -116,8 +122,10 @@ public: | |||||
private: | private: | ||||
struct PrivateData; | struct PrivateData; | ||||
PrivateData* const pData; | PrivateData* const pData; | ||||
friend class PluginApplication; | |||||
friend class Window; | friend class Window; | ||||
#ifdef DISTRHO_NAMESPACE | |||||
friend class DISTRHO_NAMESPACE::PluginApplication; | |||||
#endif | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application) | ||||
}; | }; | ||||
@@ -0,0 +1,28 @@ | |||||
/* | |||||
* DISTRHO Plugin Framework (DPF) | |||||
* Copyright (C) 2012-2022 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_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 |
@@ -20,15 +20,20 @@ | |||||
#include "Geometry.hpp" | #include "Geometry.hpp" | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | #ifndef DGL_FILE_BROWSER_DISABLED | ||||
# include "../distrho/extra/FileBrowserDialog.hpp" | |||||
# include "FileBrowserDialog.hpp" | |||||
#endif | #endif | ||||
#include <vector> | #include <vector> | ||||
#ifdef DISTRHO_NAMESPACE | |||||
START_NAMESPACE_DISTRHO | |||||
class PluginWindow; | |||||
END_NAMESPACE_DISTRHO | |||||
#endif | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
class Application; | class Application; | ||||
class PluginWindow; | |||||
class TopLevelWidget; | class TopLevelWidget; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -59,11 +64,6 @@ class DISTRHO_API Window | |||||
struct PrivateData; | struct PrivateData; | ||||
public: | public: | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
typedef DISTRHO_NAMESPACE::FileBrowserHandle FileBrowserHandle; | |||||
typedef DISTRHO_NAMESPACE::FileBrowserOptions FileBrowserOptions; | |||||
#endif | |||||
/** | /** | ||||
Window graphics context as a scoped struct. | Window graphics context as a scoped struct. | ||||
This class gives graphics context drawing time to a window's widgets. | 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. | This function does not block the event loop. | ||||
*/ | */ | ||||
bool openFileBrowser(const FileBrowserOptions& options = FileBrowserOptions()); | |||||
bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options = FileBrowserOptions()); | |||||
#endif | #endif | ||||
/** | /** | ||||
@@ -521,8 +521,10 @@ protected: | |||||
private: | private: | ||||
PrivateData* const pData; | PrivateData* const pData; | ||||
friend class Application; | friend class Application; | ||||
friend class PluginWindow; | |||||
friend class TopLevelWidget; | friend class TopLevelWidget; | ||||
#ifdef DISTRHO_NAMESPACE | |||||
friend class DISTRHO_NAMESPACE::PluginWindow; | |||||
#endif | |||||
/** @internal */ | /** @internal */ | ||||
explicit Window(Application& app, | explicit Window(Application& app, | ||||
@@ -44,9 +44,6 @@ struct Window::PrivateData : IdleCallback { | |||||
/** Pugl view instance. */ | /** Pugl view instance. */ | ||||
PuglView* view; | PuglView* view; | ||||
/** Pugl view instance of the transient parent window. */ | |||||
// PuglView* const transientParentView; | |||||
/** Reserved space for graphics context. */ | /** Reserved space for graphics context. */ | ||||
mutable uint8_t graphicsContext[sizeof(void*)]; | mutable uint8_t graphicsContext[sizeof(void*)]; | ||||
@@ -91,7 +88,7 @@ struct Window::PrivateData : IdleCallback { | |||||
#ifndef DGL_FILE_BROWSER_DISABLED | #ifndef DGL_FILE_BROWSER_DISABLED | ||||
/** Handle for file browser dialog operations. */ | /** Handle for file browser dialog operations. */ | ||||
FileBrowserHandle fileBrowserHandle; | |||||
DGL_NAMESPACE::FileBrowserHandle fileBrowserHandle; | |||||
#endif | #endif | ||||
/** Modal window setup. */ | /** Modal window setup. */ | ||||
@@ -168,7 +165,7 @@ struct Window::PrivateData : IdleCallback { | |||||
#ifndef DGL_FILE_BROWSER_DISABLED | #ifndef DGL_FILE_BROWSER_DISABLED | ||||
// file handling | // file handling | ||||
bool openFileBrowser(const FileBrowserOptions& options); | |||||
bool openFileBrowser(const DGL_NAMESPACE::FileBrowserOptions& options); | |||||
#endif | #endif | ||||
static void renderToPicture(const char* filename, const GraphicsContext& context, uint width, uint height); | static void renderToPicture(const char* filename, const GraphicsContext& context, uint width, uint height); | ||||
@@ -101,10 +101,12 @@ | |||||
#endif | #endif | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | #ifndef DGL_FILE_BROWSER_DISABLED | ||||
# define FILE_BROWSER_DIALOG_DGL_NAMESPACE | |||||
# include "../FileBrowserDialog.hpp" | |||||
# ifdef DISTRHO_OS_MAC | # ifdef DISTRHO_OS_MAC | ||||
# import "../../distrho/extra/FileBrowserDialog.cpp" | |||||
# import "../../distrho/extra/FileBrowserDialogImpl.cpp" | |||||
# else | # else | ||||
# include "../../distrho/extra/FileBrowserDialog.cpp" | |||||
# include "../../distrho/extra/FileBrowserDialogImpl.cpp" | |||||
# endif | # endif | ||||
#endif | #endif | ||||
@@ -48,16 +48,14 @@ typedef DGL_NAMESPACE::NanoTopLevelWidget UIWidget; | |||||
typedef DGL_NAMESPACE::TopLevelWidget UIWidget; | typedef DGL_NAMESPACE::TopLevelWidget UIWidget; | ||||
#endif | #endif | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
#if DISTRHO_UI_FILE_BROWSER | |||||
# include "extra/FileBrowserDialog.hpp" | # include "extra/FileBrowserDialog.hpp" | ||||
#endif | #endif | ||||
START_NAMESPACE_DGL | |||||
class PluginWindow; | |||||
END_NAMESPACE_DGL | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
class PluginWindow; | |||||
/* ------------------------------------------------------------------------------------------------------------ | /* ------------------------------------------------------------------------------------------------------------ | ||||
* DPF UI */ | * DPF UI */ | ||||
@@ -185,7 +183,7 @@ public: | |||||
void sendNote(uint8_t channel, uint8_t note, uint8_t velocity); | void sendNote(uint8_t channel, uint8_t note, uint8_t velocity); | ||||
#endif | #endif | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
#if DISTRHO_UI_FILE_BROWSER | |||||
/** | /** | ||||
Open a file browser dialog with this window as transient parent.@n | Open a file browser dialog with this window as transient parent.@n | ||||
A few options can be specified to setup the dialog. | 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, | @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. | 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 | #endif | ||||
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | ||||
@@ -334,7 +332,7 @@ protected: | |||||
virtual void uiReshape(uint width, uint height); | virtual void uiReshape(uint width, uint height); | ||||
#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #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(). | 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*). | This function is for plugin UIs to be able to override Window::onFileSelected(const char*). | ||||
@@ -371,7 +369,7 @@ protected: | |||||
private: | private: | ||||
struct PrivateData; | struct PrivateData; | ||||
PrivateData* const uiData; | PrivateData* const uiData; | ||||
friend class DGL_NAMESPACE::PluginWindow; | |||||
friend class PluginWindow; | |||||
friend class UIExporter; | friend class UIExporter; | ||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
/** @internal */ | /** @internal */ | ||||
@@ -26,7 +26,7 @@ | |||||
# import <Cocoa/Cocoa.h> | # import <Cocoa/Cocoa.h> | ||||
# include <algorithm> | # include <algorithm> | ||||
# include <cmath> | # include <cmath> | ||||
# ifndef DGL_FILE_BROWSER_DISABLED | |||||
# if DISTRHO_UI_FILE_BROWSER | |||||
# import "extra/FileBrowserDialog.cpp" | # import "extra/FileBrowserDialog.cpp" | ||||
# endif | # endif | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -21,113 +21,7 @@ | |||||
START_NAMESPACE_DISTRHO | 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 | END_NAMESPACE_DISTRHO | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * 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. | * 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 "ScopedPointer.hpp" | ||||
#include "String.hpp" | #include "String.hpp" | ||||
@@ -40,7 +46,11 @@ | |||||
# include "sofd/libsofd.c" | # include "sofd/libsofd.c" | ||||
#endif | #endif | ||||
#ifdef FILE_BROWSER_DIALOG_DGL_NAMESPACE | |||||
START_NAMESPACE_DGL | |||||
#else | |||||
START_NAMESPACE_DISTRHO | 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, | FileBrowserHandle fileBrowserCreate(const bool isEmbed, | ||||
const uintptr_t windowId, | const uintptr_t windowId, | ||||
const double scaleFactor, | 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 | #endif | ||||
END_NAMESPACE_DISTRHO | |||||
#undef FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE | |||||
#undef FILE_BROWSER_DIALOG_DGL_NAMESPACE |
@@ -0,0 +1,117 @@ | |||||
/* | |||||
* DISTRHO Plugin Framework (DPF) | |||||
* Copyright (C) 2012-2022 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. | |||||
*/ | |||||
#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); | |||||
// -------------------------------------------------------------------------------------------------------------------- |
@@ -90,6 +90,14 @@ | |||||
# define DISTRHO_PLUGIN_WANT_TIMEPOS 0 | # define DISTRHO_PLUGIN_WANT_TIMEPOS 0 | ||||
#endif | #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 | #ifndef DISTRHO_UI_USER_RESIZABLE | ||||
# define DISTRHO_UI_USER_RESIZABLE 0 | # define DISTRHO_UI_USER_RESIZABLE 0 | ||||
#endif | #endif | ||||
@@ -154,7 +162,16 @@ | |||||
#endif | #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)) | #if (defined(DGL_CAIRO) && ! defined(HAVE_CAIRO)) || (defined(DGL_OPENGL) && ! defined(HAVE_OPENGL)) | ||||
# undef DISTRHO_PLUGIN_HAS_EMBED_UI | # undef DISTRHO_PLUGIN_HAS_EMBED_UI | ||||
@@ -17,26 +17,27 @@ | |||||
#include "src/DistrhoPluginChecks.h" | #include "src/DistrhoPluginChecks.h" | ||||
#include "src/DistrhoDefines.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_HELPER(NS, SEP, FUNCTION) NS ## SEP ## FUNCTION | ||||
# define DISTRHO_PUGL_NAMESPACE_MACRO(NS, FUNCTION) DISTRHO_PUGL_NAMESPACE_MACRO_HELPER(NS, _, 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 | #endif | ||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
@@ -278,16 +279,10 @@ void UI::sendNote(uint8_t channel, uint8_t note, uint8_t velocity) | |||||
} | } | ||||
#endif | #endif | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
#if DISTRHO_UI_FILE_BROWSER | |||||
bool UI::openFileBrowser(const FileBrowserOptions& options) | 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 | #endif | ||||
@@ -368,7 +363,7 @@ void UI::uiReshape(uint, uint) | |||||
} | } | ||||
#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
#if DISTRHO_UI_FILE_BROWSER | |||||
void UI::uiFileBrowserSelected(const char*) | void UI::uiFileBrowserSelected(const char*) | ||||
{ | { | ||||
} | } | ||||
@@ -48,13 +48,7 @@ | |||||
# define DISTRHO_UI_USER_RESIZABLE 0 | # define DISTRHO_UI_USER_RESIZABLE 0 | ||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | |||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
#else | |||||
START_NAMESPACE_DGL | |||||
#endif | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Plugin Application, will set class name based on plugin details | // Plugin Application, will set class name based on plugin details | ||||
@@ -107,11 +101,11 @@ struct PluginApplication | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginApplication) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginApplication) | ||||
}; | }; | ||||
#else | #else | ||||
class PluginApplication : public Application | |||||
class PluginApplication : public DGL_NAMESPACE::Application | |||||
{ | { | ||||
public: | public: | ||||
explicit PluginApplication() | explicit PluginApplication() | ||||
: Application(DISTRHO_UI_IS_STANDALONE) | |||||
: DGL_NAMESPACE::Application(DISTRHO_UI_IS_STANDALONE) | |||||
{ | { | ||||
const char* const className = ( | const char* const className = ( | ||||
#ifdef DISTRHO_PLUGIN_BRAND | #ifdef DISTRHO_PLUGIN_BRAND | ||||
@@ -172,14 +166,14 @@ public: | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow) | ||||
}; | }; | ||||
#else // DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #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 initializing; | ||||
bool receivedReshapeDuringInit; | bool receivedReshapeDuringInit; | ||||
public: | public: | ||||
explicit PluginWindow(DISTRHO_NAMESPACE::UI* const uiPtr, | |||||
explicit PluginWindow(UI* const uiPtr, | |||||
PluginApplication& app, | PluginApplication& app, | ||||
const uintptr_t parentWindowHandle, | const uintptr_t parentWindowHandle, | ||||
const uint width, | const uint width, | ||||
@@ -238,7 +232,7 @@ public: | |||||
} | } | ||||
#endif | #endif | ||||
std::vector<ClipboardDataOffer> getClipboardDataOfferTypes() | |||||
std::vector<DGL_NAMESPACE::ClipboardDataOffer> getClipboardDataOfferTypes() | |||||
{ | { | ||||
return Window::getClipboardDataOfferTypes(); | return Window::getClipboardDataOfferTypes(); | ||||
} | } | ||||
@@ -287,7 +281,7 @@ protected: | |||||
ui->uiScaleFactorChanged(scaleFactor); | ui->uiScaleFactorChanged(scaleFactor); | ||||
} | } | ||||
# ifndef DGL_FILE_BROWSER_DISABLED | |||||
# if DISTRHO_UI_FILE_BROWSER | |||||
void onFileSelected(const char* filename) override; | void onFileSelected(const char* filename) override; | ||||
# endif | # endif | ||||
@@ -295,21 +289,6 @@ protected: | |||||
}; | }; | ||||
#endif // DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #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 | // 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); | snprintf(title, sizeof(title)-1u, DISTRHO_PLUGIN_NAME ": %s", key); | ||||
title[sizeof(title)-1u] = '\0'; | title[sizeof(title)-1u] = '\0'; | ||||
FileBrowserOptions opts; | |||||
DGL_NAMESPACE::FileBrowserOptions opts; | |||||
opts.title = title; | opts.title = title; | ||||
return window->openFileBrowser(opts); | return window->openFileBrowser(opts); | ||||
#endif | #endif | ||||
@@ -473,14 +452,10 @@ inline bool UI::PrivateData::fileRequestCallback(const char* const key) | |||||
return false; | return false; | ||||
} | } | ||||
END_NAMESPACE_DISTRHO | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// PluginWindow onFileSelected that require UI::PrivateData definitions | // 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) | inline void PluginWindow::onFileSelected(const char* const filename) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); | ||||
@@ -488,7 +463,7 @@ inline void PluginWindow::onFileSelected(const char* const filename) | |||||
if (initializing) | if (initializing) | ||||
return; | return; | ||||
# if DISTRHO_PLUGIN_WANT_STATE | |||||
#if DISTRHO_PLUGIN_WANT_STATE | |||||
if (char* const key = ui->uiData->uiStateFileKeyRequest) | if (char* const key = ui->uiData->uiStateFileKeyRequest) | ||||
{ | { | ||||
ui->uiData->uiStateFileKeyRequest = nullptr; | ui->uiData->uiStateFileKeyRequest = nullptr; | ||||
@@ -502,14 +477,14 @@ inline void PluginWindow::onFileSelected(const char* const filename) | |||||
std::free(key); | std::free(key); | ||||
return; | return; | ||||
} | } | ||||
# endif | |||||
#endif | |||||
ui->uiFileBrowserSelected(filename); | ui->uiFileBrowserSelected(filename); | ||||
} | } | ||||
END_NAMESPACE_DGL | |||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
END_NAMESPACE_DISTRHO | |||||
#endif // DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED | #endif // DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED |
@@ -26,6 +26,7 @@ | |||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2 | #define DISTRHO_PLUGIN_NUM_INPUTS 2 | ||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | ||||
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1 | #define DISTRHO_PLUGIN_WANT_TIMEPOS 1 | ||||
#define DISTRHO_UI_FILE_BROWSER 0 | |||||
#define DISTRHO_UI_USER_RESIZABLE 1 | #define DISTRHO_UI_USER_RESIZABLE 1 | ||||
#define DISTRHO_UI_USE_NANOVG 1 | #define DISTRHO_UI_USE_NANOVG 1 | ||||
@@ -1,6 +1,5 @@ | |||||
puglClearMinSize needed? | puglClearMinSize needed? | ||||
puglSetWindowSize was used on first show, still 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 | update distrhoui.cpp get scale factor to match new parent request setup and pugl |