Browse Source

Add DGL_FILE_BROWSER_DISABLED to optionaly disable file browser

pull/32/head
falkTX 7 years ago
parent
commit
0393d1e429
6 changed files with 29 additions and 3 deletions
  1. +6
    -0
      dgl/Window.hpp
  2. +11
    -3
      dgl/src/Window.cpp
  3. +6
    -0
      dgl/src/pugl/pugl_x11.c
  4. +2
    -0
      distrho/DistrhoUI.hpp
  5. +2
    -0
      distrho/src/DistrhoUI.cpp
  6. +2
    -0
      distrho/src/DistrhoUIInternal.hpp

+ 6
- 0
dgl/Window.hpp View File

@@ -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;


+ 11
- 3
dgl/src/Window.cpp View File

@@ -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)
{


+ 6
- 0
dgl/src/pugl/pugl_x11.c View File

@@ -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)) {


+ 2
- 0
distrho/DistrhoUI.hpp View File

@@ -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.


+ 2
- 0
distrho/src/DistrhoUI.cpp View File

@@ -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)
{


+ 2
- 0
distrho/src/DistrhoUIInternal.hpp View File

@@ -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;


Loading…
Cancel
Save