Add SDL_ShowFileDialogWithProperties with some more options
Description
- I've added a new function to create dialogs with properties: SDL_ShowFileDialogWithProperties. There is only one function for all dialog types; I've added an enum called SDL_FileDialogType instead.
- The old functions are now wrappers around SDL_ShowFileDialogWithProperties. This significantly simplifies the implementation on multiple platforms, which basically just regrouped all functions into one with different parameters.
- I've added three new options: setting the dialog's title, the accept button's label and the cancel button's label.
- I've fixed a few bugs and cleaned up the code a bit:
- Zenity does, in fact, support modal dialogs. One just has to check the extended help for more options and discover the amazing(-ly poorly documented)
--attachoption. The only issue is that it supports only X11, so no Wayland support still. - Some code turned ugly with the boolean changes (think "if (mybool == true) { return true; } else { return false; }") so I cleaned that up where I saw it ("return mybool;").
- I fixed up the documentation, specifically about threading and object lifetime.
- Zenity now asks for confirmation before overwriting a file.
- Zenity does, in fact, support modal dialogs. One just has to check the extended help for more options and discover the amazing(-ly poorly documented)
While deciding the names of the properties, I noticed that some boolean properties are typed as SDL_PROP_..._BOOL and others as SDL_PROP_..._BOOLEAN (RIP about the ABI freeze). I followed the second format, which seems to be more common.
Existing Issue(s)
Closes #11133
I'd like to commend the only platform that supports every dialog option: Haiku (!). A close second is Zenity (!!), which managed to find the way to support everything as well, even modal dialogs, but only partially because it lacks Wayland support so I count it as half a point. Every other platform lacks at least one option completely: macOS and XDG Portals don't allow labeling the cancel button, Windows doesn't (I believe) allow labeling either button, and Android neither buttons nor dialog title, and no folder support at all as well (though those are probably not just relevant to the platform).
It seems that the only build issues that remain are platform-specific build files. Are there instructions on how to update/refresh them? If possible, I'd like to learn the steps, so that I don't have to ask someone else to do it for me each time.
@Semphriss, can you rebase this PR? We'd like to merge it for 3.2.0.
Thanks!
Done!
It looks like you need to update Android.mk and the Visual Studio projects?
Indeed; are there instructions on how to do that? I must admit I've never done that for any PR until today...
Edit Android.mk, add the new file in the sorted list. Grep for another similar source file in the VisualC* directories and add it sorted to the places you find there. Here's an example of places you'd need to update for the VisualC directories: https://github.com/libsdl-org/SDL/commit/a92377197803a04f008bf66ccc995e8c6a4140cc
For XCode, is there a specific pattern for the magic numbers to use?
For XCode, is there a specific pattern for the magic numbers to use?
No, I usually use Xcode to update the project. If you don't have access to it, we can merge as-is, and I can add the file afterwards.
Pushed; I don't have access to XCode for the moment so I'll leave it as-is for now.
Merged, thanks!
I've updated the Xcode project as well.