mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Merge(#3): Finalized progress API
This commit is contained in:
parent
9f17a69a67
commit
ef4d722b76
@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
|
||||
|
||||
project(GLFW VERSION 3.4.0 LANGUAGES C)
|
||||
|
||||
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
|
||||
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0069)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
@ -18,9 +12,7 @@ endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(GLFW_STANDALONE TRUE)
|
||||
endif()
|
||||
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} GLFW_STANDALONE)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
|
||||
|
@ -189,6 +189,7 @@ video tutorials.
|
||||
- pthom
|
||||
- Martin Pulec
|
||||
- Guillaume Racicot
|
||||
- Juan Ramos
|
||||
- Christian Rauch
|
||||
- Philip Rideout
|
||||
- Eddie Ringle
|
||||
|
@ -121,7 +121,7 @@ information on what to include when reporting a bug.
|
||||
|
||||
## Changelog
|
||||
|
||||
- Added `glfwSetWindowTaskbarProgress` allowing to display progress on the taskbar (#2286,#1183)
|
||||
- Added `glfwSetWindowProgressIndicator` for displaying progress on the dock or taskbar (#2286,#1183)
|
||||
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
||||
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||
|
@ -1159,21 +1159,21 @@ not supported, the application as a whole. Once the user has given it
|
||||
attention, the system will automatically end the request.
|
||||
|
||||
|
||||
@subsection window_taskbar_progress Window taskbar progress
|
||||
@subsection window_progress_indicator Window progress indicator
|
||||
|
||||
If you wish to display the progress of some action on the taskbar, you can
|
||||
do this with @ref glfwSetWindowTaskbarProgress.
|
||||
If you wish to display the progress of some action on the Dock icon or task bar, you can
|
||||
do this with @ref glfwSetWindowProgressIndicator.
|
||||
|
||||
@code
|
||||
glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_NORMAL, 50);
|
||||
glfwSetWindowProgressIndicator(window, GLFW_PROGRESS_INDICATOR_NORMAL, 0.5);
|
||||
@endcode
|
||||
|
||||
There are different taskbar progress states available for you to use:
|
||||
- @ref GLFW_TASKBAR_PROGRESS_DISABLED
|
||||
- @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE
|
||||
- @ref GLFW_TASKBAR_PROGRESS_NORMAL
|
||||
- @ref GLFW_TASKBAR_PROGRESS_ERROR
|
||||
- @ref GLFW_TASKBAR_PROGRESS_PAUSED
|
||||
There are different progress states available for you to use:
|
||||
- @ref GLFW_PROGRESS_INDICATOR_DISABLED
|
||||
- @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE
|
||||
- @ref GLFW_PROGRESS_INDICATOR_NORMAL
|
||||
- @ref GLFW_PROGRESS_INDICATOR_ERROR
|
||||
- @ref GLFW_PROGRESS_INDICATOR_PAUSED
|
||||
|
||||
The last argument is the progress percentage to display.
|
||||
It has a valid range of 0.0 to 1.0.
|
||||
|
@ -1278,51 +1278,51 @@ extern "C" {
|
||||
*
|
||||
* Disable the progress bar.
|
||||
*
|
||||
* Used by @ref window_taskbar_progress.
|
||||
* Used by @ref window_progress_indicator.
|
||||
*/
|
||||
#define GLFW_TASKBAR_PROGRESS_DISABLED 0
|
||||
#define GLFW_PROGRESS_INDICATOR_DISABLED 0
|
||||
/*! @brief Display the progress bar in an indeterminate state.
|
||||
*
|
||||
* Display the progress bar in an indeterminate state.
|
||||
*
|
||||
* @remark @win32 This displays the progress bar animation cycling repeatedly.
|
||||
*
|
||||
* @remark @x11 @wayland This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL.
|
||||
* @remark @x11 @wayland This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
|
||||
*
|
||||
* @remark @macos This displays a standard indeterminate `NSProgressIndicator`.
|
||||
*
|
||||
* Used by @ref window_taskbar_progress.
|
||||
* Used by @ref window_progress_indicator.
|
||||
*/
|
||||
#define GLFW_TASKBAR_PROGRESS_INDETERMINATE 1
|
||||
#define GLFW_PROGRESS_INDICATOR_INDETERMINATE 1
|
||||
/*! @brief Display the normal progress bar.
|
||||
*
|
||||
* Display the normal progress bar.
|
||||
*
|
||||
* Used by @ref window_taskbar_progress.
|
||||
* Used by @ref window_progress_indicator.
|
||||
*/
|
||||
#define GLFW_TASKBAR_PROGRESS_NORMAL 2
|
||||
#define GLFW_PROGRESS_INDICATOR_NORMAL 2
|
||||
/*! @brief Display the progress bar in an error state.
|
||||
*
|
||||
* Display the progress bar in an error state.
|
||||
*
|
||||
* @remark @win32 This displays a red progress bar.
|
||||
*
|
||||
* @remark @x11 @wayland @macos This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL.
|
||||
* @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
|
||||
*
|
||||
* Used by @ref window_taskbar_progress.
|
||||
* Used by @ref window_progress_indicator.
|
||||
*/
|
||||
#define GLFW_TASKBAR_PROGRESS_ERROR 3
|
||||
#define GLFW_PROGRESS_INDICATOR_ERROR 3
|
||||
/*! @brief Display the progress bar in a paused state.
|
||||
*
|
||||
* Display the progress bar in a paused state.
|
||||
*
|
||||
* @remark @win32 This displays a yellow progress bar.
|
||||
*
|
||||
* @remark @x11 @wayland @macos This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL.
|
||||
* @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
|
||||
*
|
||||
* Used by @ref window_taskbar_progress.
|
||||
* Used by @ref window_progress_indicator.
|
||||
*/
|
||||
#define GLFW_TASKBAR_PROGRESS_PAUSED 4
|
||||
#define GLFW_PROGRESS_INDICATOR_PAUSED 4
|
||||
/*! @} */
|
||||
|
||||
#define GLFW_CONNECTED 0x00040001
|
||||
@ -3357,43 +3357,45 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
||||
*/
|
||||
GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
|
||||
|
||||
/*! @brief Sets the taskbar progress for the specified window.
|
||||
/*! @brief Sets the dock or taskbar progress indicator for the specified window.
|
||||
*
|
||||
* This function sets the taskbar progress of the specified window.
|
||||
* This function sets the dock or taskbar progress indicator of the specified window.
|
||||
*
|
||||
* @param[in] window The window whose taskbar progress to set.
|
||||
* @param[in] progressState State of the progress to be displayed in the taskbar. Valid values are:
|
||||
* @ref GLFW_TASKBAR_PROGRESS_DISABLED, @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE,
|
||||
* @ref GLFW_TASKBAR_PROGRESS_NORMAL, @ref GLFW_TASKBAR_PROGRESS_ERROR
|
||||
* and @ref GLFW_TASKBAR_PROGRESS_PAUSED.
|
||||
* @param[in] window The window whose progress to set.
|
||||
* @param[in] progressState The state of the progress to be displayed in the dock
|
||||
* or taskbar. Valid values are: @ref GLFW_PROGRESS_INDICATOR_DISABLED,
|
||||
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_NORMAL,
|
||||
* @ref GLFW_PROGRESS_INDICATOR_ERROR and @ref GLFW_PROGRESS_INDICATOR_PAUSED.
|
||||
* @param[in] value The amount of completed progress to set. Valid range is 0.0 to 1.0.
|
||||
* This is ignored if progressState is set to @ref GLFW_TASKBAR_PROGRESS_DISABLED.
|
||||
* This is ignored if progressState is set to @ref GLFW_PROGRESS_INDICATOR_DISABLED.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR,
|
||||
* @ref GLFW_FEATURE_UNIMPLEMENTED and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @win32 On Windows Vista and earlier, this function will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
* @remark @win32 On Windows Vista and earlier, this function will emit
|
||||
* @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @remark @macos There exists only one Dock icon progress bar, and this
|
||||
* displays the combined values of all the windows.
|
||||
*
|
||||
* @remark @x11 @wayland Requires a valid application desktop file with the same name
|
||||
* as the compiled executable. Due to limitations in the Unity Launcher API
|
||||
* @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE, @ref GLFW_TASKBAR_PROGRESS_ERROR and @ref GLFW_TASKBAR_PROGRESS_PAUSED
|
||||
* have the same behaviour as @ref GLFW_TASKBAR_PROGRESS_NORMAL. The Unity Launcher API is only known
|
||||
* to be supported on the Unity and KDE desktop environments, on other desktop environments this
|
||||
* function may do nothing.
|
||||
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_ERROR
|
||||
* and @ref GLFW_PROGRESS_INDICATOR_PAUSED have the same behaviour as
|
||||
* @ref GLFW_PROGRESS_INDICATOR_NORMAL. The Unity Launcher API is only known
|
||||
* to be supported on the Unity and KDE desktop environments; on other desktop
|
||||
* environments this function may do nothing.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_taskbar_progress
|
||||
* @sa @ref window_progress_indicator
|
||||
*
|
||||
* @since Added in version 3.4.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* window, int progressState, double value);
|
||||
GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* window, int progressState, double value);
|
||||
|
||||
/*! @brief Retrieves the position of the content area of the specified window.
|
||||
*
|
||||
|
@ -528,7 +528,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowCocoa,
|
||||
_glfwSetWindowTitleCocoa,
|
||||
_glfwSetWindowIconCocoa,
|
||||
_glfwSetWindowTaskbarProgressCocoa,
|
||||
_glfwSetWindowProgressIndicatorCocoa,
|
||||
_glfwGetWindowPosCocoa,
|
||||
_glfwSetWindowPosCocoa,
|
||||
_glfwGetWindowSizeCocoa,
|
||||
|
@ -230,7 +230,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndco
|
||||
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
|
||||
|
@ -248,7 +248,7 @@ static void setDockProgressIndicator(int progressState, double value)
|
||||
// The bug is caused by NSProgressIndicator not immediately updating its value when it's increasing.
|
||||
// This code illustrates the exact same problem, but this time from NORMAL, PAUSED and ERROR to INDETERMINATE:
|
||||
//
|
||||
// if (progressState == GLFW_TASKBAR_PROGRESS_INDETERMINATE)
|
||||
// if (progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
|
||||
// [progressIndicator setDoubleValue:0.75];
|
||||
// else
|
||||
// [progressIndicator setDoubleValue:0.25];
|
||||
@ -268,8 +268,8 @@ static void setDockProgressIndicator(int progressState, double value)
|
||||
indicator = createProgressIndicator(dockTile);
|
||||
}
|
||||
|
||||
[indicator setIndeterminate:progressState == GLFW_TASKBAR_PROGRESS_INDETERMINATE];
|
||||
[indicator setHidden:progressState == GLFW_TASKBAR_PROGRESS_DISABLED];
|
||||
[indicator setIndeterminate:progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE];
|
||||
[indicator setHidden:progressState == GLFW_PROGRESS_INDICATOR_DISABLED];
|
||||
[indicator setDoubleValue:value];
|
||||
|
||||
[dockTile display];
|
||||
@ -1064,7 +1064,7 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
_glfwSetWindowTaskbarProgressCocoa(window, GLFW_TASKBAR_PROGRESS_DISABLED, 0.0);
|
||||
_glfwSetWindowProgressIndicatorCocoa(window, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
|
||||
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
_glfw.ns.disabledCursorWindow = NULL;
|
||||
@ -1111,10 +1111,10 @@ void _glfwSetWindowIconCocoa(_GLFWwindow* window,
|
||||
"Cocoa: Regular windows do not have icons on macOS");
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value)
|
||||
{
|
||||
if (progressState == GLFW_TASKBAR_PROGRESS_ERROR || progressState == GLFW_TASKBAR_PROGRESS_PAUSED)
|
||||
progressState = GLFW_TASKBAR_PROGRESS_NORMAL;
|
||||
if (progressState == GLFW_PROGRESS_INDICATOR_ERROR || progressState == GLFW_PROGRESS_INDICATOR_PAUSED)
|
||||
progressState = GLFW_PROGRESS_INDICATOR_NORMAL;
|
||||
|
||||
const int oldState = window->ns.dockProgressIndicator.state;
|
||||
const int state = progressState;
|
||||
@ -1123,8 +1123,8 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
|
||||
|
||||
if (oldState == state)
|
||||
{
|
||||
if (state == GLFW_TASKBAR_PROGRESS_DISABLED ||
|
||||
state == GLFW_TASKBAR_PROGRESS_INDETERMINATE ||
|
||||
if (state == GLFW_PROGRESS_INDICATOR_DISABLED ||
|
||||
state == GLFW_PROGRESS_INDICATOR_INDETERMINATE ||
|
||||
oldValue == value)
|
||||
return;
|
||||
}
|
||||
@ -1132,36 +1132,36 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
|
||||
if (oldState != state)
|
||||
{
|
||||
// Reset
|
||||
if (oldState == GLFW_TASKBAR_PROGRESS_INDETERMINATE)
|
||||
if (oldState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
|
||||
--_glfw.ns.dockProgressIndicator.indeterminateCount;
|
||||
if (oldState != GLFW_TASKBAR_PROGRESS_DISABLED)
|
||||
if (oldState != GLFW_PROGRESS_INDICATOR_DISABLED)
|
||||
{
|
||||
--_glfw.ns.dockProgressIndicator.windowCount;
|
||||
_glfw.ns.dockProgressIndicator.totalValue -= oldValue;
|
||||
}
|
||||
|
||||
// Set
|
||||
if (state == GLFW_TASKBAR_PROGRESS_INDETERMINATE)
|
||||
if (state == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
|
||||
++_glfw.ns.dockProgressIndicator.indeterminateCount;
|
||||
if (state != GLFW_TASKBAR_PROGRESS_DISABLED)
|
||||
if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
|
||||
{
|
||||
++_glfw.ns.dockProgressIndicator.windowCount;
|
||||
_glfw.ns.dockProgressIndicator.totalValue += value;
|
||||
}
|
||||
}
|
||||
else if (state != GLFW_TASKBAR_PROGRESS_DISABLED)
|
||||
else if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
|
||||
_glfw.ns.dockProgressIndicator.totalValue += (value - oldValue);
|
||||
|
||||
|
||||
if (_glfw.ns.dockProgressIndicator.windowCount > _glfw.ns.dockProgressIndicator.indeterminateCount)
|
||||
{
|
||||
const double finalValue = _glfw.ns.dockProgressIndicator.totalValue / _glfw.ns.dockProgressIndicator.windowCount;
|
||||
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_NORMAL, finalValue);
|
||||
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_NORMAL, finalValue);
|
||||
}
|
||||
else if (_glfw.ns.dockProgressIndicator.indeterminateCount > 0)
|
||||
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_INDETERMINATE, 0.0f);
|
||||
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_INDETERMINATE, 0.0f);
|
||||
else
|
||||
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_DISABLED, 0.0f);
|
||||
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_DISABLED, 0.0f);
|
||||
|
||||
window->ns.dockProgressIndicator.state = state;
|
||||
window->ns.dockProgressIndicator.value = value;
|
||||
|
@ -706,7 +706,7 @@ struct _GLFWplatform
|
||||
void (*destroyWindow)(_GLFWwindow*);
|
||||
void (*setWindowTitle)(_GLFWwindow*,const char*);
|
||||
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
||||
void (*setWindowTaskbarProgress)(_GLFWwindow*,const int,double);
|
||||
void (*setWindowProgressIndicator)(_GLFWwindow*,const int,double);
|
||||
void (*getWindowPos)(_GLFWwindow*,int*,int*);
|
||||
void (*setWindowPos)(_GLFWwindow*,int,int);
|
||||
void (*getWindowSize)(_GLFWwindow*,int*,int*);
|
||||
|
@ -73,7 +73,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowNull,
|
||||
_glfwSetWindowTitleNull,
|
||||
_glfwSetWindowIconNull,
|
||||
_glfwSetWindowTaskbarProgressNull,
|
||||
_glfwSetWindowProgressIndicatorNull,
|
||||
_glfwGetWindowPosNull,
|
||||
_glfwSetWindowPosNull,
|
||||
_glfwGetWindowSizeNull,
|
||||
|
@ -89,7 +89,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndcon
|
||||
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
||||
|
@ -187,7 +187,7 @@ void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* ima
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -110,7 +110,7 @@ void _glfwInitDBusPOSIX(void)
|
||||
{
|
||||
//Window NULL is safe here because it won't get
|
||||
//used inside the SetWindowTaskbarProgress function
|
||||
_glfw.platform.setWindowTaskbarProgress(NULL, GLFW_TASKBAR_PROGRESS_DISABLED, 0);
|
||||
_glfw.platform.setWindowProgressIndicator(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -638,7 +638,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowWin32,
|
||||
_glfwSetWindowTitleWin32,
|
||||
_glfwSetWindowIconWin32,
|
||||
_glfwSetWindowTaskbarProgressWin32,
|
||||
_glfwSetWindowProgressIndicatorWin32,
|
||||
_glfwGetWindowPosWin32,
|
||||
_glfwSetWindowPosWin32,
|
||||
_glfwGetWindowSizeWin32,
|
||||
|
@ -618,7 +618,7 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndco
|
||||
void _glfwDestroyWindowWin32(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||
|
@ -1596,7 +1596,7 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value)
|
||||
{
|
||||
HRESULT res = S_OK;
|
||||
int winProgressState = 0;
|
||||
@ -1620,22 +1620,22 @@ void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState,
|
||||
|
||||
switch(progressState)
|
||||
{
|
||||
case 1:
|
||||
winProgressState = TBPF_INDETERMINATE;
|
||||
break;
|
||||
case 2:
|
||||
winProgressState = TBPF_NORMAL;
|
||||
break;
|
||||
case 3:
|
||||
winProgressState = TBPF_ERROR;
|
||||
break;
|
||||
case 4:
|
||||
winProgressState = TBPF_PAUSED;
|
||||
break;
|
||||
case GLFW_PROGRESS_INDICATOR_INDETERMINATE:
|
||||
winProgressState = TBPF_INDETERMINATE;
|
||||
break;
|
||||
case GLFW_PROGRESS_INDICATOR_NORMAL:
|
||||
winProgressState = TBPF_NORMAL;
|
||||
break;
|
||||
case GLFW_PROGRESS_INDICATOR_ERROR:
|
||||
winProgressState = TBPF_ERROR;
|
||||
break;
|
||||
case GLFW_PROGRESS_INDICATOR_PAUSED:
|
||||
winProgressState = TBPF_PAUSED;
|
||||
break;
|
||||
|
||||
default:
|
||||
winProgressState = TBPF_NOPROGRESS;
|
||||
break;
|
||||
default:
|
||||
winProgressState = TBPF_NOPROGRESS;
|
||||
break;
|
||||
}
|
||||
|
||||
res = window->win32.taskbarList->lpVtbl->SetProgressState(window->win32.taskbarList, window->win32.handle, winProgressState);
|
||||
|
12
src/window.c
12
src/window.c
@ -558,7 +558,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
||||
_glfw.platform.setWindowIcon(window, count, images);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, int progressState, double value)
|
||||
GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* handle, int progressState, double value)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
@ -568,19 +568,19 @@ GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, int progressState,
|
||||
|
||||
if (value < 0.0 || value > 1.0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window taskbar progress");
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window progress indicator");
|
||||
return;
|
||||
}
|
||||
|
||||
if (progressState != GLFW_TASKBAR_PROGRESS_DISABLED && progressState != GLFW_TASKBAR_PROGRESS_INDETERMINATE &&
|
||||
progressState != GLFW_TASKBAR_PROGRESS_NORMAL && progressState != GLFW_TASKBAR_PROGRESS_ERROR &&
|
||||
progressState != GLFW_TASKBAR_PROGRESS_PAUSED)
|
||||
if (progressState != GLFW_PROGRESS_INDICATOR_DISABLED && progressState != GLFW_PROGRESS_INDICATOR_INDETERMINATE &&
|
||||
progressState != GLFW_PROGRESS_INDICATOR_NORMAL && progressState != GLFW_PROGRESS_INDICATOR_ERROR &&
|
||||
progressState != GLFW_PROGRESS_INDICATOR_PAUSED)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid progress state 0x%08X", progressState);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfw.platform.setWindowTaskbarProgress(window, progressState, value);
|
||||
_glfw.platform.setWindowProgressIndicator(window, progressState, value);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||
|
@ -419,7 +419,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowWayland,
|
||||
_glfwSetWindowTitleWayland,
|
||||
_glfwSetWindowIconWayland,
|
||||
_glfwSetWindowTaskbarProgressWayland,
|
||||
_glfwSetWindowProgressIndicatorWayland,
|
||||
_glfwGetWindowPosWayland,
|
||||
_glfwSetWindowPosWayland,
|
||||
_glfwGetWindowSizeWayland,
|
||||
|
@ -446,7 +446,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wnd
|
||||
void _glfwDestroyWindowWayland(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||
|
@ -1902,11 +1902,11 @@ void _glfwSetWindowIconWayland(_GLFWwindow* window,
|
||||
"Wayland: The platform does not support setting the window icon");
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, const int progressState, double value)
|
||||
{
|
||||
(void)window;
|
||||
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_TASKBAR_PROGRESS_DISABLED);
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
|
||||
|
||||
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowX11,
|
||||
_glfwSetWindowTitleX11,
|
||||
_glfwSetWindowIconX11,
|
||||
_glfwSetWindowTaskbarProgressX11,
|
||||
_glfwSetWindowProgressIndicatorX11,
|
||||
_glfwGetWindowPosX11,
|
||||
_glfwSetWindowPosX11,
|
||||
_glfwGetWindowSizeX11,
|
||||
|
@ -905,7 +905,7 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconf
|
||||
void _glfwDestroyWindowX11(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height);
|
||||
|
@ -2152,11 +2152,11 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value)
|
||||
{
|
||||
(void)window;
|
||||
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_TASKBAR_PROGRESS_DISABLED);
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
|
||||
|
||||
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
|
||||
}
|
||||
|
@ -414,26 +414,26 @@ int main(int argc, char** argv)
|
||||
|
||||
nk_layout_row_dynamic(nk, 30, 1);
|
||||
|
||||
nk_label(nk, "Taskbar Progress", NK_TEXT_CENTERED);
|
||||
nk_label(nk, "Window Progress indicator", NK_TEXT_CENTERED);
|
||||
|
||||
nk_layout_row_dynamic(nk, 30, 5);
|
||||
|
||||
static int state = GLFW_TASKBAR_PROGRESS_DISABLED;
|
||||
static int state = GLFW_PROGRESS_INDICATOR_DISABLED;
|
||||
static float progress = 0;
|
||||
if(nk_button_label(nk, "No progress"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_DISABLED, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_DISABLED, (double) progress);
|
||||
if (nk_button_label(nk, "Indeterminate"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_INDETERMINATE, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_INDETERMINATE, (double) progress);
|
||||
if (nk_button_label(nk, "Normal"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_NORMAL, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_NORMAL, (double) progress);
|
||||
if (nk_button_label(nk, "Error"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_ERROR, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_ERROR, (double) progress);
|
||||
if (nk_button_label(nk, "Paused"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_PAUSED, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_PAUSED, (double) progress);
|
||||
|
||||
nk_label(nk, "Progress: ", NK_TEXT_ALIGN_LEFT);
|
||||
if (nk_slider_float(nk, 0.0f, &progress, 1.0f, 0.05f))
|
||||
glfwSetWindowTaskbarProgress(window, state, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state, (double) progress);
|
||||
}
|
||||
nk_end(nk);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user