mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 23:13:01 +00:00
GUI: add ability to open files by drag-and-drop
This commit is contained in:
parent
5ec8c8aa07
commit
34a68751e1
2 changed files with 21 additions and 1 deletions
|
@ -4663,6 +4663,19 @@ bool FurnaceGUI::loop() {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SDL_DROPFILE:
|
||||
if (ev.drop.file!=NULL) {
|
||||
if (modified) {
|
||||
nextFile=ev.drop.file;
|
||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN_DROP);
|
||||
} else {
|
||||
if (load(ev.drop.file)>0) {
|
||||
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||
}
|
||||
}
|
||||
SDL_free(ev.drop.file);
|
||||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
if (modified) {
|
||||
showWarning("Unsaved changes! Are you sure you want to quit?",GUI_WARN_QUIT);
|
||||
|
@ -5251,6 +5264,12 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_WARN_OPEN:
|
||||
openFileDialog(GUI_FILE_OPEN);
|
||||
break;
|
||||
case GUI_WARN_OPEN_DROP:
|
||||
if (load(nextFile)>0) {
|
||||
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||
}
|
||||
nextFile="";
|
||||
break;
|
||||
case GUI_WARN_GENERIC:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ enum FurnaceGUIWarnings {
|
|||
GUI_WARN_QUIT,
|
||||
GUI_WARN_NEW,
|
||||
GUI_WARN_OPEN,
|
||||
GUI_WARN_OPEN_DROP,
|
||||
GUI_WARN_GENERIC
|
||||
};
|
||||
|
||||
|
@ -166,7 +167,7 @@ class FurnaceGUI {
|
|||
SDL_Window* sdlWin;
|
||||
SDL_Renderer* sdlRend;
|
||||
|
||||
String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName;
|
||||
String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName, nextFile;
|
||||
String mmlString[12];
|
||||
String mmlStringW;
|
||||
|
||||
|
|
Loading…
Reference in a new issue