mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 14:45:46 +00:00
Added glfwCreateStandardCursor.
This function allows the creation of cursor objects using one of several standard cursor shapes from the current system cursor theme.
This commit is contained in:
@@ -32,6 +32,29 @@
|
||||
#include <crt_externs.h>
|
||||
|
||||
|
||||
// Returns the specified standard cursor
|
||||
//
|
||||
static NSCursor* getStandardCursor(int shape)
|
||||
{
|
||||
switch (shape)
|
||||
{
|
||||
case GLFW_ARROW_CURSOR:
|
||||
return [NSCursor arrowCursor];
|
||||
case GLFW_IBEAM_CURSOR:
|
||||
return [NSCursor IBeamCursor];
|
||||
case GLFW_CROSSHAIR_CURSOR:
|
||||
return [NSCursor crosshairCursor];
|
||||
case GLFW_HAND_CURSOR:
|
||||
return [NSCursor pointingHandCursor];
|
||||
case GLFW_HRESIZE_CURSOR:
|
||||
return [NSCursor resizeLeftRightCursor];
|
||||
case GLFW_VRESIZE_CURSOR:
|
||||
return [NSCursor resizeUpDownCursor];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Center the cursor in the view of the window
|
||||
//
|
||||
static void centerCursor(_GLFWwindow *window)
|
||||
@@ -1161,6 +1184,19 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
cursor->ns.object = getStandardCursor(shape);
|
||||
if (!cursor->ns.object)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Cocoa: Invalid standard cursor");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[cursor->ns.object retain];
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
{
|
||||
if (cursor->ns.object)
|
||||
|
||||
Reference in New Issue
Block a user