WindowProgressState API getters and fixes (#12629)

This commit is contained in:
Rémy Tassoux
2025-03-25 16:03:32 +01:00
committed by GitHub
parent b520cde18f
commit 6cc00a31b6
13 changed files with 131 additions and 37 deletions

View File

@@ -314,11 +314,12 @@ typedef enum SDL_FlashOperation
*/
typedef enum SDL_ProgressState
{
SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */
SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */
SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */
SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */
SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */
SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in an error state */
SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */
} SDL_ProgressState;
/**
@@ -2835,13 +2836,22 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOp
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state);
/**
* Get the state of the progress bar for the given windows taskbar icon.
*
* \param window the window to get the current progress state from.
* \returns the progress state, or SDL_PROGRESS_STATE_INVALID on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window);
/**
* Sets the value of the progress bar for the given windows taskbar icon.
*
* If the state is `SDL_PROGRESS_STATE_NONE` or
* `SDL_PROGRESS_STATE_INDETERMINATE`, it gets changed to
* `SDL_PROGRESS_STATE_NORMAL`.
*
* \param window the window whose progress value is to be modified.
* \param value the progress value (0.0f - start, 1.0f - end). If the value is
* outside the valid range, it gets clamped.
@@ -2854,6 +2864,19 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window,
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value);
/**
* Get the value of the progress bar for the given windows taskbar icon.
*
* \param window the window to get the current progress value from.
* \returns the progress value in the range of [0.0 - 1.0], or -1 on
* failure; call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window);
/**
* Destroy a window.
*