libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.76k stars 1.81k forks source link

SDL3: cannot set file dialog caption #11133

Open d-musique opened 1 week ago

d-musique commented 1 week ago

The new file dialog API does not allow the title of the dialog to be set. This would be good to have, if only to be able to make property localized applications. (The Linux titles are hardcoded.)

SDL 3.1.3

slouken commented 1 week ago

Good point. @Semphriss, can you find a way to fix this without changing the ABI? Maybe add a property-based dialog creation function?

Semphriss commented 1 week ago

IIRC, there were a few options to change the appearance of file dialogs, including the title, buttons' labels, and more, but their availability varied greatly between platforms, so I initially left anything cosmetic out of the (already quite long) functions.

I can make a function like SDL_ShowFileDialogWithProperties that could support more options; is there anything else other than the title that I should add? I can try to see what different platforms support and propose what's available.

slouken commented 1 week ago

IIRC, there were a few options to change the appearance of file dialogs, including the title, buttons' labels, and more, but their availability varied greatly between platforms, so I initially left anything cosmetic out of the (already quite long) functions.

That makes sense. A properties based API has more flexibility, because it can ignore anything that isn't supported on the platform.

I can try to see what different platforms support and propose what's available.

Sure, that would be great.

d-musique commented 1 week ago

+1 for properties API

Concerning my particular use case, only the title has importance, because other labels are already localized by OS.

The portal has its title harcoded around here; for information, I already tried replacing it with an empty string, hoping the portal might provide a default localized name in its place, but the dialog just came up with an empty title.

https://github.com/libsdl-org/SDL/blob/02f3a96476c46e4a03a2e06d5edd1d8f7aa69d4f/src/dialog/unix/SDL_portaldialog.c#L430

Semphriss commented 1 week ago

@slouken I would need advice for a design decision: I noticed that some functions which accept properties have their mandatory arguments separate from the properties. For file dialogs, the only really mandatory option is the callback function. Should I:

slouken commented 1 week ago

Good question. Let's have the function and userdata as separate parameters.