Add progress bar support for Windows (#12530)

This commit is contained in:
Rémy Tassoux
2025-03-22 16:04:10 +01:00
committed by GitHub
parent 6b13d69105
commit 7a10fcdccc
19 changed files with 239 additions and 2 deletions

View File

@@ -87,6 +87,8 @@ typedef struct
const char *window_icon;
SDL_WindowFlags window_flags;
bool flash_on_focus_loss;
SDL_ProgressState progress_state;
float progress_value;
int window_x;
int window_y;
int window_w;

View File

@@ -307,6 +307,20 @@ typedef enum SDL_FlashOperation
SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
} SDL_FlashOperation;
/**
* Window progress state
*
* \since This enum is available since SDL 3.2.8.
*/
typedef enum SDL_ProgressState
{
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_ProgressState;
/**
* An opaque handle to an OpenGL context.
*
@@ -2806,6 +2820,34 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surf
*/
extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
/**
* Sets the state of the progress bar for the given windows taskbar icon.
*
* \param window the window whose progress state is to be modified.
* \param state the progress state.
* \returns true on success or false 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.2.8.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state);
/**
* Sets the value of the progress bar for the given windows taskbar icon.
*
* \param window the window whose progress value is to be modified.
* \param value the progress value (0.0f - start, 1.0f - end).
* \returns true on success or false 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.2.8.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value);
/**
* Destroy a window.
*

View File

@@ -225,6 +225,7 @@
#cmakedefine HAVE_TPCSHRD_H 1
#cmakedefine HAVE_ROAPI_H 1
#cmakedefine HAVE_SHELLSCALINGAPI_H 1
#cmakedefine HAVE_SHOBJIDL_CORE_H 1
#cmakedefine USE_POSIX_SPAWN 1

View File

@@ -95,6 +95,9 @@ typedef unsigned int uintptr_t;
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
#define HAVE_SHELLSCALINGAPI_H 1
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0601 /* Windows 7 SDK */
#define HAVE_SHOBJIDL_CORE_H 1
#endif
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_TPCSHRD_H 1

View File

@@ -43,6 +43,7 @@
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
#define HAVE_SHELLSCALINGAPI_H 1
#define HAVE_SHOBJIDL_CORE_H 1
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_TPCSHRD_H 1

View File

@@ -41,6 +41,7 @@
/*#define HAVE_WINDOWS_GAMING_INPUT_H 1*/
/*#define HAVE_ROAPI_H 1*/
/*#define HAVE_SHELLSCALINGAPI_H 1*/
/*#define HAVE_SHOBJIDL_CORE_H 1*/
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
/*#define HAVE_TPCSHRD_H 1*/