@@ -34,6 +34,7 @@ class StandaloneWindow; | |||||
class Window | class Window | ||||
{ | { | ||||
public: | public: | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
/** | /** | ||||
File browser options. | File browser options. | ||||
*/ | */ | ||||
@@ -70,6 +71,7 @@ public: | |||||
height(0), | height(0), | ||||
buttons() {} | buttons() {} | ||||
}; | }; | ||||
#endif // DGL_FILE_BROWSER_DISABLED | |||||
explicit Window(Application& app); | explicit Window(Application& app); | ||||
explicit Window(Application& app, Window& parent); | explicit Window(Application& app, Window& parent); | ||||
@@ -84,7 +86,9 @@ public: | |||||
void focus(); | void focus(); | ||||
void repaint() noexcept; | void repaint() noexcept; | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
bool openFileBrowser(const FileBrowserOptions& options); | bool openFileBrowser(const FileBrowserOptions& options); | ||||
#endif | |||||
bool isVisible() const noexcept; | bool isVisible() const noexcept; | ||||
void setVisible(bool yesNo); | void setVisible(bool yesNo); | ||||
@@ -115,7 +119,9 @@ protected: | |||||
virtual void onReshape(uint width, uint height); | virtual void onReshape(uint width, uint height); | ||||
virtual void onClose(); | virtual void onClose(); | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
virtual void fileBrowserSelected(const char* filename); | virtual void fileBrowserSelected(const char* filename); | ||||
#endif | |||||
private: | private: | ||||
struct PrivateData; | struct PrivateData; | ||||
@@ -196,7 +196,9 @@ struct Window::PrivateData { | |||||
puglSetSpecialFunc(fView, onSpecialCallback); | puglSetSpecialFunc(fView, onSpecialCallback); | ||||
puglSetReshapeFunc(fView, onReshapeCallback); | puglSetReshapeFunc(fView, onReshapeCallback); | ||||
puglSetCloseFunc(fView, onCloseCallback); | puglSetCloseFunc(fView, onCloseCallback); | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
puglSetFileSelectedFunc(fView, fileBrowserSelectedCallback); | puglSetFileSelectedFunc(fView, fileBrowserSelectedCallback); | ||||
#endif | |||||
puglCreateWindow(fView, nullptr); | puglCreateWindow(fView, nullptr); | ||||
@@ -1022,10 +1024,12 @@ struct Window::PrivateData { | |||||
handlePtr->onPuglClose(); | handlePtr->onPuglClose(); | ||||
} | } | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
static void fileBrowserSelectedCallback(PuglView* view, const char* filename) | static void fileBrowserSelectedCallback(PuglView* view, const char* filename) | ||||
{ | { | ||||
handlePtr->fSelf->fileBrowserSelected(filename); | handlePtr->fSelf->fileBrowserSelected(filename); | ||||
} | } | ||||
#endif | |||||
#undef handlePtr | #undef handlePtr | ||||
@@ -1085,9 +1089,10 @@ void Window::repaint() noexcept | |||||
// (void)name; | // (void)name; | ||||
// } | // } | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
bool Window::openFileBrowser(const FileBrowserOptions& options) | bool Window::openFileBrowser(const FileBrowserOptions& options) | ||||
{ | { | ||||
#ifdef SOFD_HAVE_X11 | |||||
# ifdef SOFD_HAVE_X11 | |||||
using DISTRHO_NAMESPACE::String; | using DISTRHO_NAMESPACE::String; | ||||
// -------------------------------------------------------------------------- | // -------------------------------------------------------------------------- | ||||
@@ -1145,11 +1150,12 @@ bool Window::openFileBrowser(const FileBrowserOptions& options) | |||||
// show | // show | ||||
return (x_fib_show(pData->xDisplay, pData->xWindow, /*options.width*/0, /*options.height*/0) == 0); | return (x_fib_show(pData->xDisplay, pData->xWindow, /*options.width*/0, /*options.height*/0) == 0); | ||||
#else | |||||
# else | |||||
// not implemented | // not implemented | ||||
return false; | return false; | ||||
#endif | |||||
# endif | |||||
} | } | ||||
#endif | |||||
bool Window::isVisible() const noexcept | bool Window::isVisible() const noexcept | ||||
{ | { | ||||
@@ -1280,9 +1286,11 @@ void Window::onClose() | |||||
{ | { | ||||
} | } | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
void Window::fileBrowserSelected(const char*) | void Window::fileBrowserSelected(const char*) | ||||
{ | { | ||||
} | } | ||||
#endif | |||||
bool Window::handlePluginKeyboard(const bool press, const uint key) | bool Window::handlePluginKeyboard(const bool press, const uint key) | ||||
{ | { | ||||
@@ -41,9 +41,11 @@ | |||||
#include "pugl/pugl_internal.h" | #include "pugl/pugl_internal.h" | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
#define SOFD_HAVE_X11 | #define SOFD_HAVE_X11 | ||||
#include "../sofd/libsofd.h" | #include "../sofd/libsofd.h" | ||||
#include "../sofd/libsofd.c" | #include "../sofd/libsofd.c" | ||||
#endif | |||||
struct PuglInternalsImpl { | struct PuglInternalsImpl { | ||||
Display* display; | Display* display; | ||||
@@ -339,7 +341,9 @@ puglDestroy(PuglView* view) | |||||
return; | return; | ||||
} | } | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
x_fib_close(view->impl->display); | x_fib_close(view->impl->display); | ||||
#endif | |||||
destroyContext(view); | destroyContext(view); | ||||
XDestroyWindow(view->impl->display, view->impl->win); | XDestroyWindow(view->impl->display, view->impl->win); | ||||
@@ -477,6 +481,7 @@ puglProcessEvents(PuglView* view) | |||||
while (XPending(view->impl->display) > 0) { | while (XPending(view->impl->display) > 0) { | ||||
XNextEvent(view->impl->display, &event); | XNextEvent(view->impl->display, &event); | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
if (x_fib_handle_events(view->impl->display, &event)) { | if (x_fib_handle_events(view->impl->display, &event)) { | ||||
const int status = x_fib_status(); | const int status = x_fib_status(); | ||||
@@ -495,6 +500,7 @@ puglProcessEvents(PuglView* view) | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
#endif | |||||
if (event.xany.window != view->impl->win && | if (event.xany.window != view->impl->win && | ||||
(view->parent == 0 || event.xany.window != (Window)view->parent)) { | (view->parent == 0 || event.xany.window != (Window)view->parent)) { | ||||
@@ -175,11 +175,13 @@ protected: | |||||
*/ | */ | ||||
virtual void uiIdle() {} | virtual void uiIdle() {} | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
/** | /** | ||||
File browser selected function. | File browser selected function. | ||||
@see Window::fileBrowserSelected(const char*) | @see Window::fileBrowserSelected(const char*) | ||||
*/ | */ | ||||
virtual void uiFileBrowserSelected(const char* filename); | virtual void uiFileBrowserSelected(const char* filename); | ||||
#endif | |||||
/** | /** | ||||
OpenGL window reshape function, called when parent window is resized. | OpenGL window reshape function, called when parent window is resized. | ||||
@@ -125,9 +125,11 @@ void UI::sampleRateChanged(double) {} | |||||
/* ------------------------------------------------------------------------------------------------------------ | /* ------------------------------------------------------------------------------------------------------------ | ||||
* UI Callbacks (optional) */ | * UI Callbacks (optional) */ | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
void UI::uiFileBrowserSelected(const char*) | void UI::uiFileBrowserSelected(const char*) | ||||
{ | { | ||||
} | } | ||||
#endif | |||||
void UI::uiReshape(uint width, uint height) | void UI::uiReshape(uint width, uint height) | ||||
{ | { | ||||
@@ -186,6 +186,7 @@ protected: | |||||
fIsReady = true; | fIsReady = true; | ||||
} | } | ||||
#ifndef DGL_FILE_BROWSER_DISABLED | |||||
// custom file-browser selected | // custom file-browser selected | ||||
void fileBrowserSelected(const char* filename) override | void fileBrowserSelected(const char* filename) override | ||||
{ | { | ||||
@@ -193,6 +194,7 @@ protected: | |||||
fUI->uiFileBrowserSelected(filename); | fUI->uiFileBrowserSelected(filename); | ||||
} | } | ||||
#endif | |||||
private: | private: | ||||
UI* const fUI; | UI* const fUI; | ||||