SDL Open File Dialog options
Mar. 2nd, 2020 12:36 pmWas looking for a cross-platform open file dialog for SDL that I could use to select files if one isn't provided via command line. There are lots of options but finding a solution isn't as easy as I would like.
There are SDL programs like Bard and Milkytracker that have this sort of functionality. The code for the file dialog functionality is integrated with the programs, so it would be hard to remove it and use it as a library for other programs.
One could integrate SDL with other GUI toolkits. There are some interesting articles on how to do just that. However, I'd like to avoid the overhead of the heavier toolkits.
Nuklear has a file browser example. The basic Nuklear backend uses OpenGL instead of SDL. One would need SDL_gpu or a similar solution to use Nuklear with a SDL backend.
otk has a file browser example ( http://otk.sourceforge.net/tutorials.html ). It also uses OpenGL instead of SDL, but it needs less dependencies than Nuklear to build. It's worth considering, but it's not quite as ergonomic as other options.
The dialog program which can be built with ncurses, pdcurses or other versions of curses has a directory selection dialog. Applications built with pdcurses can use a SDL backend. However, that would mean adding a pdcurses dependency to projects. Plus, dialog is a program and it's not really designed to be called as a library. There are other options that will build with pdcurses and are designed to be called as a library such as CDK.
A similar option to the dialog solution would be to use BSD libform and pdcurses. One would need to write the rest of the dialog functionality though.
Some small projects use tiny file dialogs ( https://sourceforge.net/projects/tinyfiledialogs/ ). It can use native Windows or conio options on Windows. However, on Linux systems it would need some help from tools like dialog or zenity or similar tools.
When searching for SDL file browsers, I ran across this code:
https://www.omnimaga.org/ti-nspire-projects/sdl-file-browser/
It has a GNU GPL 3 license. It's written for SDL 1.2.
There's also the Jlime project's fileselector code. It works well enough and it's fairly readable. It has a GNU GPL 2 license. It's written for SDL 1.2. So, a port for SDL 2.x would be needed. Plus, I needed to add some support on Windows to use the GetCurrentDirectory in place of getcwd in order to build it successfully.
Those are the options I've found so far. I'd love to track down some other possibilities. Have any other SDL based suggestions? Please share them.
There are SDL programs like Bard and Milkytracker that have this sort of functionality. The code for the file dialog functionality is integrated with the programs, so it would be hard to remove it and use it as a library for other programs.
One could integrate SDL with other GUI toolkits. There are some interesting articles on how to do just that. However, I'd like to avoid the overhead of the heavier toolkits.
Nuklear has a file browser example. The basic Nuklear backend uses OpenGL instead of SDL. One would need SDL_gpu or a similar solution to use Nuklear with a SDL backend.
otk has a file browser example ( http://otk.sourceforge.net/tutorials.html ). It also uses OpenGL instead of SDL, but it needs less dependencies than Nuklear to build. It's worth considering, but it's not quite as ergonomic as other options.
The dialog program which can be built with ncurses, pdcurses or other versions of curses has a directory selection dialog. Applications built with pdcurses can use a SDL backend. However, that would mean adding a pdcurses dependency to projects. Plus, dialog is a program and it's not really designed to be called as a library. There are other options that will build with pdcurses and are designed to be called as a library such as CDK.
A similar option to the dialog solution would be to use BSD libform and pdcurses. One would need to write the rest of the dialog functionality though.
Some small projects use tiny file dialogs ( https://sourceforge.net/projects/tinyfiledialogs/ ). It can use native Windows or conio options on Windows. However, on Linux systems it would need some help from tools like dialog or zenity or similar tools.
When searching for SDL file browsers, I ran across this code:
https://www.omnimaga.org/ti-nspire-projects/sdl-file-browser/
It has a GNU GPL 3 license. It's written for SDL 1.2.
There's also the Jlime project's fileselector code. It works well enough and it's fairly readable. It has a GNU GPL 2 license. It's written for SDL 1.2. So, a port for SDL 2.x would be needed. Plus, I needed to add some support on Windows to use the GetCurrentDirectory in place of getcwd in order to build it successfully.
Those are the options I've found so far. I'd love to track down some other possibilities. Have any other SDL based suggestions? Please share them.