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