summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@gmail.com>2015-02-16 16:07:07 +0000
committerfalkTX <falktx@gmail.com>2015-02-16 16:07:07 +0000
commit8da011deb152227714196f61eab26e1af37a2890 (patch)
treef1add63ce6f3af86340d7e4c93092776b5479b14
parentac360ba166cd58d47467083e4bb9817a3c16f400 (diff)
Implement basic file-browser in ZamSFZ
-rw-r--r--libs/distrho/DistrhoUI.hpp6
-rw-r--r--libs/distrho/src/DistrhoUI.cpp4
-rw-r--r--libs/distrho/src/DistrhoUIInternal.hpp11
-rw-r--r--plugins/ZamSFZ/ZamSFZUI.cpp39
-rw-r--r--plugins/ZamSFZ/ZamSFZUI.hpp3
5 files changed, 35 insertions, 28 deletions
diff --git a/libs/distrho/DistrhoUI.hpp b/libs/distrho/DistrhoUI.hpp
index e6c8311..2832db0 100644
--- a/libs/distrho/DistrhoUI.hpp
+++ b/libs/distrho/DistrhoUI.hpp
@@ -141,6 +141,12 @@ protected:
virtual void d_uiIdle() {}
/**
+ File browser selected function.
+ @see Window::fileBrowserSelected(const char*)
+ */
+ virtual void d_uiFileBrowserSelected(const char* filename);
+
+ /**
OpenGL window reshape function, called when parent window is resized.
You can reimplement this function for a custom OpenGL state.
@see Window::onReshape(uint,uint)
diff --git a/libs/distrho/src/DistrhoUI.cpp b/libs/distrho/src/DistrhoUI.cpp
index 82ea7a5..49e8c3e 100644
--- a/libs/distrho/src/DistrhoUI.cpp
+++ b/libs/distrho/src/DistrhoUI.cpp
@@ -90,6 +90,10 @@ void UI::d_sampleRateChanged(double) {}
/* ------------------------------------------------------------------------------------------------------------
* UI Callbacks (optional) */
+void UI::d_uiFileBrowserSelected(const char*)
+{
+}
+
void UI::d_uiReshape(uint width, uint height)
{
glEnable(GL_BLEND);
diff --git a/libs/distrho/src/DistrhoUIInternal.hpp b/libs/distrho/src/DistrhoUIInternal.hpp
index a17e2aa..a07719c 100644
--- a/libs/distrho/src/DistrhoUIInternal.hpp
+++ b/libs/distrho/src/DistrhoUIInternal.hpp
@@ -170,16 +170,23 @@ public:
}
protected:
+ // custom window reshape
void onReshape(uint width, uint height) override
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
- // custom window reshape
fUI->d_uiReshape(width, height);
-
fIsReady = true;
}
+ // custom file-browser selected
+ void fileBrowserSelected(const char* filename) override
+ {
+ DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
+
+ fUI->d_uiFileBrowserSelected(filename);
+ }
+
private:
UI* const fUI;
bool fIsReady;
diff --git a/plugins/ZamSFZ/ZamSFZUI.cpp b/plugins/ZamSFZ/ZamSFZUI.cpp
index eccdf02..3bb4d69 100644
--- a/plugins/ZamSFZ/ZamSFZUI.cpp
+++ b/plugins/ZamSFZ/ZamSFZUI.cpp
@@ -18,6 +18,8 @@
#include "ZamSFZUI.hpp"
#include "ZamSFZPlugin.hpp"
+#include "Window.hpp"
+
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
@@ -82,6 +84,13 @@ void ZamSFZUI::d_stateChanged(const char* key, const char*)
}
}
+void ZamSFZUI::d_uiFileBrowserSelected(const char* filename)
+{
+ // if a file was selected, tell DSP
+ if (filename != nullptr)
+ d_setState("filepath", filename);
+}
+
// -----------------------------------------------------------------------
// Widget Callbacks
@@ -105,33 +114,11 @@ void ZamSFZUI::imageKnobValueChanged(ImageKnob* knob, float value)
void ZamSFZUI::imageButtonClicked(ImageButton*, int)
{
-/*
- GtkWidget* dialog = gtk_file_chooser_dialog_new(
- "Load SFZ",
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- if (filepath) {
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filepath);
- }
+ DGL::Window::FileBrowserOptions opts;
+ opts.title = "Load SFZ";
+ //opts.filters = "sfz;";
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
- gtk_widget_destroy(dialog);
- return;
- }
-
- if (filepath) {
- g_free(filepath);
- }
- filepath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-
- gtk_widget_destroy(dialog);
-*/
-// d_setState("filepath", "/home/damien/Music/rhodes-nord/rhodes-nord.sfz");
- d_setState("filepath", "/home/damien/Music/sfz/sfz LatelyBass/TX_LatelyBass.sfz");
+ getParentWindow().openFileBrowser(opts);
}
void ZamSFZUI::onDisplay()
diff --git a/plugins/ZamSFZ/ZamSFZUI.hpp b/plugins/ZamSFZ/ZamSFZUI.hpp
index f0d1047..e82f406 100644
--- a/plugins/ZamSFZ/ZamSFZUI.hpp
+++ b/plugins/ZamSFZ/ZamSFZUI.hpp
@@ -46,6 +46,8 @@ protected:
void d_programChanged(uint32_t index) override;
void d_stateChanged(const char* key, const char* value) override;
+ void d_uiFileBrowserSelected(const char* filename) override;
+
// -------------------------------------------------------------------
// Widget Callbacks
@@ -55,6 +57,7 @@ protected:
void imageButtonClicked(ImageButton*, int) override;
void onDisplay() override;
+
private:
Image fImgBackground;
ScopedPointer<ImageKnob> fKnobGain;