Browse Source

Add filters to patch open/save dialogs

tags/v0.6.1
Andrew Belt 6 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
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:
git clean -fdx


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

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


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


struct ModuleContainer : Widget {
void draw(NVGcontext *vg) override {
// Draw shadows behind each ModuleWidget first, so the shadow doesn't overlap the front.
@@ -77,12 +80,14 @@ void RackWidget::openDialog() {
else {
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) {
loadPatch(path);
lastPath = path;
free(path);
}
osdialog_filters_free(filters);
}

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

void RackWidget::saveAsDialog() {
std::string dir;
std::string filename;
if (lastPath.empty()) {
dir = assetLocal("patches");
systemCreateDirectory(dir);
}
else {
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) {
std::string pathStr = path;
@@ -116,6 +124,7 @@ void RackWidget::saveAsDialog() {
savePatch(pathStr);
lastPath = pathStr;
}
osdialog_filters_free(filters);
}

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


Loading…
Cancel
Save