Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cross platform native open/save file dialogs

Tags:

I'm writing a UI for my program using opengl with SDL in a combination of Lua and C++

What I need now is some library that will allow me to call a function that presents the user with a file select dialog for opening/saving a file. But if the OS offers native functionality for such a dialog, then I want to use that dialog (eg Window's GetOpenFileName).

The only platforms I need to support are Windows and Linux, but I want to be able to still use most of the SDL & openGL code I've already written.

What options are available?

like image 848
Ponkadoodle Avatar asked May 26 '11 22:05

Ponkadoodle


2 Answers

tinyfiledialogs offers many modal dialogs and popup notifications (both for graphic and console modes). It is a cross-platform C file (with a header) to add to your C or C++ project. It aims to be extremely easy to use, has no init, no main loop, and no external dependencies. It is used by hundreds of projects on GitHub and of course, I am the author. Get it here: http://tinyfiledialogs.sourceforge.net

Usage example:

    char const * selection = tinyfd_openFileDialog( // there is also a wchar_t version         "Select file", // title         "C:\\", // optional initial directory         2, // number of filter patterns         lFilterPatterns, // char const * lFilterPatterns[2] = { "*.txt", "*.jpg" };         NULL, // optional filter description         0 // forbid multiple selections         );  
like image 135
tinyfiledialogs Avatar answered Oct 01 '22 07:10

tinyfiledialogs


You should take a good look at Native File Dialog. It is a small, portable C library that lets you use load and save dialogs in a cross platform manner without linking huge dependencies like qt or wxWidgets.

I am the author, and I use it with SDL2 and OpenGL on Linux, Mac and Windows.

https://github.com/mlabbe/nativefiledialog

like image 31
Michael Labbé Avatar answered Oct 01 '22 05:10

Michael Labbé