Browse Source

Add filters to patch open/save dialogs

tags/v0.6.1
Andrew Belt 7 years ago
parent
commit
4e41c35395
2 changed files with 19 additions and 10 deletions
  1. +8
    -8
      dep/Makefile
  2. +11
    -2
      src/app/RackWidget.cpp

+ 8
- 8
dep/Makefile View File

@@ -146,17 +146,17 @@ $(rtaudio):
# For some reason, it doesn't install the static library # For some reason, it doesn't install the static library
cp rtaudio/build/librtaudio_static.a lib/librtaudio.a cp rtaudio/build/librtaudio_static.a lib/librtaudio.a


$(nanovg):
cp nanovg/src/*.h include/
$(nanovg): $(wildcard nanovg/src/*.h)
cp $^ include/


$(nanosvg):
cp nanosvg/src/*.h include/
$(nanosvg): $(wildcard nanosvg/src/*.h)
cp $^ include/


$(oui-blendish):
cp oui-blendish/*.h include/
$(oui-blendish): $(wildcard blendish/*.h)
cp $^ include/


$(osdialog):
cp osdialog/*.h include/
$(osdialog): $(wildcard osdialog/*.h)
cp $^ include/


clean: clean:
git clean -fdx git clean -fdx


+ 11
- 2
src/app/RackWidget.cpp View File

@@ -12,6 +12,9 @@
namespace rack { namespace rack {




static const char *FILTERS = "VCV Rack patch (.vcv):*.vcv";


struct ModuleContainer : Widget { struct ModuleContainer : Widget {
void draw(NVGcontext *vg) override { void draw(NVGcontext *vg) override {
// Draw shadows behind each ModuleWidget first, so the shadow doesn't overlap the front. // Draw shadows behind each ModuleWidget first, so the shadow doesn't overlap the front.
@@ -77,12 +80,14 @@ void RackWidget::openDialog() {
else { else {
dir = stringDirectory(lastPath); dir = stringDirectory(lastPath);
} }
char *path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, NULL);
osdialog_filters *filters = osdialog_filters_parse(FILTERS);
char *path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters);
if (path) { if (path) {
loadPatch(path); loadPatch(path);
lastPath = path; lastPath = path;
free(path); free(path);
} }
osdialog_filters_free(filters);
} }


void RackWidget::saveDialog() { void RackWidget::saveDialog() {
@@ -96,14 +101,17 @@ void RackWidget::saveDialog() {


void RackWidget::saveAsDialog() { void RackWidget::saveAsDialog() {
std::string dir; std::string dir;
std::string filename;
if (lastPath.empty()) { if (lastPath.empty()) {
dir = assetLocal("patches"); dir = assetLocal("patches");
systemCreateDirectory(dir); systemCreateDirectory(dir);
} }
else { else {
dir = stringDirectory(lastPath); dir = stringDirectory(lastPath);
filename = stringFilename(lastPath);
} }
char *path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), "Untitled.vcv", NULL);
osdialog_filters *filters = osdialog_filters_parse(FILTERS);
char *path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), filters);


if (path) { if (path) {
std::string pathStr = path; std::string pathStr = path;
@@ -116,6 +124,7 @@ void RackWidget::saveAsDialog() {
savePatch(pathStr); savePatch(pathStr);
lastPath = pathStr; lastPath = pathStr;
} }
osdialog_filters_free(filters);
} }


void RackWidget::savePatch(std::string path) { void RackWidget::savePatch(std::string path) {


Loading…
Cancel
Save