Dialog: Add filter number, remove NULL termination

This commit is contained in:
Semphris authored and Sam Lantinga committed 2024-06-03 18:22:26 -07:00
1 parent 3e70964ae2
commit 8c8ee2174d
17 files changed
+144 -147

No files matched your search

+5 -5
View File
@@ -15,11 +15,10 @@
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_test.h>
const SDL_DialogFileFilter filters[4] = {
const SDL_DialogFileFilter filters[3] = {
{ "All files", "*" },
{ "JPG images", "jpg;jpeg" },
{ "PNG images", "png" },
{ NULL, NULL }
{ "PNG images", "png" }
};
static void SDLCALL callback(void* userdata, const char* const* files, int filter) {
@@ -54,6 +53,7 @@ int main(int argc, char *argv[]) {
const SDL_FRect open_folder_rect = { 370, 50, 220, 140 };
int i;
char *initial_path = NULL;
const int nfilters = sizeof(filters) / sizeof(*filters);
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, 0);
@@ -114,11 +114,11 @@ int main(int argc, char *argv[]) {
* - Nonzero if the user is allowed to choose multiple entries (not for SDL_ShowSaveFileDialog)
*/
if (SDL_PointInRectFloat(&p, &open_file_rect)) {
SDL_ShowOpenFileDialog(callback, NULL, w, filters, initial_path, 1);
SDL_ShowOpenFileDialog(callback, NULL, w, filters, nfilters, initial_path, 1);
} else if (SDL_PointInRectFloat(&p, &open_folder_rect)) {
SDL_ShowOpenFolderDialog(callback, NULL, w, initial_path, 1);
} else if (SDL_PointInRectFloat(&p, &save_file_rect)) {
SDL_ShowSaveFileDialog(callback, NULL, w, filters, initial_path);
SDL_ShowSaveFileDialog(callback, NULL, w, filters, nfilters, initial_path);
}
}
}