summaryrefslogtreecommitdiff
path: root/gui/src/threadedSystemDialogs.cpp
blob: 597312fa69a81b72c5fa908d3052fccd92ca2a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#include "threadedSystemDialogs.h"
#include "ofMain.h"

void threadedSystemLoadDialog::load(std::string _caption,std::function<bool(std::string)> _callback){ //bool (*_callback)(std::string filename)){
	caption=_caption;
	load_callback=_callback;
	startThread();
}

void threadedSystemLoadDialog::threadedFunction() {
	setThreadName("threadedSystemLoadDialog " + ofToString(thread.get_id()));
	ofFileDialogResult openFileResult= ofSystemLoadDialog(caption); 

	//Check if the user opened a file
	if (openFileResult.bSuccess){
		
		
		bool success=load_callback(openFileResult.fileName);

		ofLogVerbose("Load %s %s\n",
			openFileResult.filePath.c_str(),
			success?"succeeded":"failed");
		
		
	}else {
		ofLogVerbose("User hit cancel");
	}
}