mirror of
https://github.com/glfw/glfw.git
synced 2026-01-11 23:33:16 +01:00
Add more standard cursors
This adds the standard cursors for diagonal and omnidirectional resize/move and operation-not-allowed. It also adds new (better?) names for the horizontal and vertical resize/move and pointing hand cursors. References: - https://developer.apple.com/documentation/appkit/nscursor - https://stackoverflow.com/questions/10733228/ - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor - https://freedesktop.org/wiki/Specifications/cursor-spec/ - https://tronche.com/gui/x/xlib/appendix/b/ Related to #427.
This commit is contained in:
@@ -757,6 +757,17 @@ extern "C" {
|
||||
* @analysis Application programmer error. Fix the offending call.
|
||||
*/
|
||||
#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
|
||||
/*! @brief The specified cursor shape is not available.
|
||||
*
|
||||
* The specified standard cursor shape is not available, either because the
|
||||
* current system cursor theme does not provide it or because it is not
|
||||
* available on the platform.
|
||||
*
|
||||
* @analysis Platform or system settings limitation. Pick another
|
||||
* [standard cursor shape](@ref shapes) or create a
|
||||
* [custom cursor](@ref cursor_custom).
|
||||
*/
|
||||
#define GLFW_CURSOR_UNAVAILABLE 0x0001000B
|
||||
/*! @} */
|
||||
|
||||
/*! @addtogroup window
|
||||
@@ -1039,14 +1050,15 @@ extern "C" {
|
||||
/*! @defgroup shapes Standard cursor shapes
|
||||
* @brief Standard system cursor shapes.
|
||||
*
|
||||
* See [standard cursor creation](@ref cursor_standard) for how these are used.
|
||||
* These are the [standard cursor shapes](@ref cursor_standard) that can be
|
||||
* requested from the window system.
|
||||
*
|
||||
* @ingroup input
|
||||
* @{ */
|
||||
|
||||
/*! @brief The regular arrow cursor shape.
|
||||
*
|
||||
* The regular arrow cursor.
|
||||
* The regular arrow cursor shape.
|
||||
*/
|
||||
#define GLFW_ARROW_CURSOR 0x00036001
|
||||
/*! @brief The text input I-beam cursor shape.
|
||||
@@ -1054,26 +1066,91 @@ extern "C" {
|
||||
* The text input I-beam cursor shape.
|
||||
*/
|
||||
#define GLFW_IBEAM_CURSOR 0x00036002
|
||||
/*! @brief The crosshair shape.
|
||||
/*! @brief The crosshair cursor shape.
|
||||
*
|
||||
* The crosshair shape.
|
||||
* The crosshair cursor shape.
|
||||
*/
|
||||
#define GLFW_CROSSHAIR_CURSOR 0x00036003
|
||||
/*! @brief The hand shape.
|
||||
/*! @brief The pointing hand cursor shape.
|
||||
*
|
||||
* The hand shape.
|
||||
* The pointing hand cursor shape.
|
||||
*/
|
||||
#define GLFW_HAND_CURSOR 0x00036004
|
||||
/*! @brief The horizontal resize arrow shape.
|
||||
#define GLFW_POINTING_HAND_CURSOR 0x00036004
|
||||
/*! @brief The horizontal resize/move arrow shape.
|
||||
*
|
||||
* The horizontal resize arrow shape.
|
||||
* The horizontal resize/move arrow shape. This is usually a horizontal
|
||||
* double-headed arrow.
|
||||
*/
|
||||
#define GLFW_HRESIZE_CURSOR 0x00036005
|
||||
/*! @brief The vertical resize arrow shape.
|
||||
#define GLFW_RESIZE_EW_CURSOR 0x00036005
|
||||
/*! @brief The vertical resize/move arrow shape.
|
||||
*
|
||||
* The vertical resize arrow shape.
|
||||
* The vertical resize/move shape. This is usually a vertical double-headed
|
||||
* arrow.
|
||||
*/
|
||||
#define GLFW_VRESIZE_CURSOR 0x00036006
|
||||
#define GLFW_RESIZE_NS_CURSOR 0x00036006
|
||||
/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
|
||||
*
|
||||
* The top-left to bottom-right diagonal resize/move shape. This is usually
|
||||
* a diagonal double-headed arrow.
|
||||
*
|
||||
* @note @macos This shape is provided by a private system API and may fail
|
||||
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*/
|
||||
#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
|
||||
/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
|
||||
*
|
||||
* The top-right to bottom-left diagonal resize/move shape. This is usually
|
||||
* a diagonal double-headed arrow.
|
||||
*
|
||||
* @note @macos This shape is provided by a private system API and may fail
|
||||
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*/
|
||||
#define GLFW_RESIZE_NESW_CURSOR 0x00036008
|
||||
/*! @brief The omni-directional resize/move cursor shape.
|
||||
*
|
||||
* The omni-directional resize cursor/move shape. This is usually either
|
||||
* a combined horizontal and vertical double-headed arrow or a grabbing hand.
|
||||
*/
|
||||
#define GLFW_RESIZE_ALL_CURSOR 0x00036009
|
||||
/*! @brief The operation-not-allowed shape.
|
||||
*
|
||||
* The operation-not-allowed shape. This is usually a circle with a diagonal
|
||||
* line through it.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*/
|
||||
#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
|
||||
/*! @brief Legacy name for compatibility.
|
||||
*
|
||||
* This is an alias for compatibility with earlier versions.
|
||||
*/
|
||||
#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR
|
||||
/*! @brief Legacy name for compatibility.
|
||||
*
|
||||
* This is an alias for compatibility with earlier versions.
|
||||
*/
|
||||
#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR
|
||||
/*! @brief Legacy name for compatibility.
|
||||
*
|
||||
* This is an alias for compatibility with earlier versions.
|
||||
*/
|
||||
#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
|
||||
/*! @} */
|
||||
|
||||
#define GLFW_CONNECTED 0x00040001
|
||||
@@ -4417,19 +4494,44 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||
|
||||
/*! @brief Creates a cursor with a standard shape.
|
||||
*
|
||||
* Returns a cursor with a [standard shape](@ref shapes), that can be set for
|
||||
* a window with @ref glfwSetCursor.
|
||||
* Returns a cursor with a standard shape, that can be set for a window with
|
||||
* @ref glfwSetCursor. The images for these cursors come from the system
|
||||
* cursor theme and their exact appearance will vary between platforms.
|
||||
*
|
||||
* Most of these shapes are guaranteed to exist on every supported platform but
|
||||
* a few may not be present. See the table below for details.
|
||||
*
|
||||
* Cursor shape | Windows | macOS | X11 | Wayland
|
||||
* ------------------------------ | ------- | ----- | ------ | -------
|
||||
* @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
|
||||
* @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
|
||||
* @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
|
||||
* @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
|
||||
*
|
||||
* 1) This uses a private system API and may fail in the future.
|
||||
*
|
||||
* 2) This uses a newer standard that not all cursor themes support.
|
||||
*
|
||||
* If the requested shape is not available, this function emits a @ref
|
||||
* GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
|
||||
*
|
||||
* @param[in] shape One of the [standard shapes](@ref shapes).
|
||||
* @return A new cursor ready to use or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
|
||||
* GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref cursor_object
|
||||
* @sa @ref cursor_standard
|
||||
* @sa @ref glfwCreateCursor
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
|
||||
Reference in New Issue
Block a user