@@ -129,3 +129,109 @@ void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void *userdata, S
129
129
SDL_DestroyProperties (props );
130
130
#endif
131
131
}
132
+
133
+ // TODO: Dialogs after this should be implemented with XDG Portals
134
+
135
+ void SDL_ShowInputDialogWithProperties (SDL_DialogInputCallback callback , void * userdata , SDL_PropertiesID props )
136
+ {
137
+ if (!callback ) {
138
+ return ;
139
+ }
140
+ #ifdef SDL_DIALOG_DISABLED
141
+ SDL_SetError ("SDL not built with dialog support" );
142
+ callback (userdata , NULL , SDL_DIALOGRESULT_ERROR );
143
+ #else
144
+ SDL_SYS_ShowInputDialogWithProperties (callback , userdata , props );
145
+ #endif
146
+ }
147
+
148
+ SDL_ProgressDialog * SDL_ShowProgressDialogWithProperties (SDL_DialogProgressCallback callback , void * userdata , SDL_PropertiesID props )
149
+ {
150
+ if (!callback ) {
151
+ return NULL ;
152
+ }
153
+ #ifdef SDL_DIALOG_DISABLED
154
+ SDL_SetError ("SDL not built with dialog support" );
155
+ callback (userdata , NULL , SDL_DIALOGRESULT_ERROR );
156
+ return NULL ;
157
+ #else
158
+ return SDL_SYS_ShowProgressDialogWithProperties (callback , userdata , props );
159
+ #endif
160
+ }
161
+
162
+ void SDL_UpdateProgressDialog (SDL_ProgressDialog * dialog , float progress , const char * new_prompt )
163
+ {
164
+ #ifdef SDL_DIALOG_DISABLED
165
+ SDL_SetError ("SDL not built with dialog support" );
166
+ #else
167
+ if (!dialog ) {
168
+ SDL_InvalidParamError ("dialog" );
169
+ return ;
170
+ }
171
+ if (progress < 0.0f || progress > 1.0f ) {
172
+ SDL_InvalidParamError ("progress" );
173
+ return ;
174
+ }
175
+ SDL_SYS_UpdateProgressDialog (dialog , progress , new_prompt );
176
+ #endif
177
+ }
178
+
179
+ void SDL_DestroyProgressDialog (SDL_ProgressDialog * dialog )
180
+ {
181
+ #ifdef SDL_DIALOG_DISABLED
182
+ SDL_SetError ("SDL not built with dialog support" );
183
+ #else
184
+ if (!dialog ) {
185
+ SDL_InvalidParamError ("dialog" );
186
+ return ;
187
+ }
188
+ SDL_SYS_DestroyProgressDialog (dialog );
189
+ #endif
190
+ }
191
+
192
+ void SDL_ShowColorPickerDialogWithProperties (SDL_DialogColorCallback callback , void * userdata , SDL_PropertiesID props )
193
+ {
194
+ if (!callback ) {
195
+ return ;
196
+ }
197
+
198
+ #ifdef SDL_DIALOG_DISABLED
199
+ SDL_Color c ;
200
+ c .r = 0 ;
201
+ c .g = 0 ;
202
+ c .b = 0 ;
203
+ c .a = 0 ;
204
+
205
+ SDL_SetError ("SDL not built with dialog support" );
206
+ callback (userdata , c , SDL_DIALOGRESULT_ERROR );
207
+ #else
208
+ SDL_SYS_ShowColorPickerDialogWithProperties (callback , userdata , props );
209
+ #endif
210
+ }
211
+
212
+ void SDL_ShowDatePickerDialogWithProperties (SDL_DialogDateCallback callback , void * userdata , SDL_PropertiesID props )
213
+ {
214
+ if (!callback ) {
215
+ return ;
216
+ }
217
+
218
+ SDL_Date d ;
219
+ d .y = 0 ;
220
+ d .m = 0 ;
221
+ d .d = 0 ;
222
+
223
+ #ifdef SDL_DIALOG_DISABLED
224
+ SDL_SetError ("SDL not built with dialog support" );
225
+ callback (userdata , d , SDL_DIALOGRESULT_ERROR );
226
+ #else
227
+ SDL_Date * date = SDL_GetPointerProperty (props , SDL_PROP_DATE_DIALOG_DEFAULT_POINTER , NULL );
228
+
229
+ // A value of 0 is "null" for that field
230
+ if (date && (date -> y > 9999 || date -> m > 12 || date -> d > 31 )) {
231
+ SDL_SetError ("Invalid default date: %d-%d-%d" , date -> y , date -> m , date -> d );
232
+ callback (userdata , d , SDL_DIALOGRESULT_ERROR );
233
+ }
234
+
235
+ SDL_SYS_ShowDatePickerDialogWithProperties (callback , userdata , props );
236
+ #endif
237
+ }
0 commit comments