@@ -258,22 +258,6 @@ inline bool active() { return run_mode() != RunMode::Stopped; }
258258 */
259259extern NANOGUI_EXPORT void async (const std::function<void ()> &func);
260260
261- /* *
262- * \brief Open a native file open/save dialog.
263- *
264- * \param filetypes
265- * Pairs of permissible formats with descriptions like
266- * ``("png", "Portable Network Graphics")``.
267- *
268- * \param save
269- * Set to ``true`` if you would like subsequent file dialogs to open
270- * at whatever folder they were in when they close this one.
271- */
272- extern NANOGUI_EXPORT std::string
273- file_dialog (const std::vector<std::pair<std::string, std::string>> &filetypes,
274- bool save);
275-
276-
277261/* *
278262 * \brief Check for the availability of displays with 10-bit color and/or
279263 * extended dynamic range (EDR), i.e. the ability to reproduce intensities
@@ -289,24 +273,51 @@ file_dialog(const std::vector<std::pair<std::string, std::string>> &filetypes,
289273 */
290274extern NANOGUI_EXPORT std::pair<bool , bool > test_10bit_edr_support ();
291275
276+ // / Selection of file/folder dialog types supported by file_dialog()
277+ enum class FileDialogType {
278+ // / Open a single file
279+ Open,
280+
281+ // / Open multiple files
282+ OpenMultiple,
283+
284+ // / Save a single file
285+ Save,
286+
287+ // / Pick a single folder (``filters`` not supported)
288+ PickFolder,
289+
290+ // / Pick multiple folders (``filters`` argument must be empty)
291+ PickFolderMultiple
292+ };
293+
292294/* *
293- * \brief Open a native file open dialog, which allows multiple selection.
295+ * \brief Open a native file/folder dialog
296+ *
297+ * This function can instantiate variety of file dialogs using native UI
298+ * widgets. This functionality is bsaed on the bundled
299+ * ``nativefiledialog-extended`` [1] library.
300+ *
301+ * [1] https://github.com/btzy/nativefiledialog-extended
294302 *
295- * \param filetypes
296- * Pairs of permissible formats with descriptions like
297- * ``("png", "Portable Network Graphics")``.
303+ * \param type
304+ * The type of dialog. For \ref FileDialogType::Open, \ref FileDialogType::Save,
305+ * and \ref FileDialogType::PickFolder, the output array contains at most one
306+ * entry.
298307 *
299- * \param save
300- * Set to ``true`` if you would like subsequent file dialogs to open
301- * at whatever folder they were in when they close this one .
308+ * \param filter
309+ * Specify file formats with descriptions to indicate a preference for specific
310+ * file types .
302311 *
303- * \param multiple
304- * Set to ``true`` if you would like to be able to select multiple
305- * files at once. May not be simultaneously true with \p save .
312+ * \param default_path
313+ * If specified, the OS dialog will show files/folders at a specified starting
314+ * location .
306315 */
307316extern NANOGUI_EXPORT std::vector<std::string>
308- file_dialog (const std::vector<std::pair<std::string, std::string>> &filetypes,
309- bool save, bool multiple);
317+ file_dialog (Widget *parent,
318+ FileDialogType type,
319+ const std::vector<std::pair<std::string, std::string>> &filters = {},
320+ const std::string &default_path = {});
310321
311322#if defined(__APPLE__) || defined(DOXYGEN_DOCUMENTATION_BUILD)
312323/* *
0 commit comments