Use switch statement instead of if-else-chain for cursor shapes

Closes #1739.
This commit is contained in:
Luflosi
2020-07-23 18:22:23 +02:00
committed by Camilla Löwy
parent 7e8da57094
commit 08e5a17063
4 changed files with 187 additions and 123 deletions
+34 -23
View File
@@ -2123,30 +2123,41 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{
int id = 0;
if (shape == GLFW_ARROW_CURSOR)
id = OCR_NORMAL;
else if (shape == GLFW_IBEAM_CURSOR)
id = OCR_IBEAM;
else if (shape == GLFW_CROSSHAIR_CURSOR)
id = OCR_CROSS;
else if (shape == GLFW_POINTING_HAND_CURSOR)
id = OCR_HAND;
else if (shape == GLFW_RESIZE_EW_CURSOR)
id = OCR_SIZEWE;
else if (shape == GLFW_RESIZE_NS_CURSOR)
id = OCR_SIZENS;
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
id = OCR_SIZENWSE;
else if (shape == GLFW_RESIZE_NESW_CURSOR)
id = OCR_SIZENESW;
else if (shape == GLFW_RESIZE_ALL_CURSOR)
id = OCR_SIZEALL;
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
id = OCR_NO;
else
switch (shape)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
return GLFW_FALSE;
case GLFW_ARROW_CURSOR:
id = OCR_NORMAL;
break;
case GLFW_IBEAM_CURSOR:
id = OCR_IBEAM;
break;
case GLFW_CROSSHAIR_CURSOR:
id = OCR_CROSS;
break;
case GLFW_POINTING_HAND_CURSOR:
id = OCR_HAND;
break;
case GLFW_RESIZE_EW_CURSOR:
id = OCR_SIZEWE;
break;
case GLFW_RESIZE_NS_CURSOR:
id = OCR_SIZENS;
break;
case GLFW_RESIZE_NWSE_CURSOR:
id = OCR_SIZENWSE;
break;
case GLFW_RESIZE_NESW_CURSOR:
id = OCR_SIZENESW;
break;
case GLFW_RESIZE_ALL_CURSOR:
id = OCR_SIZEALL;
break;
case GLFW_NOT_ALLOWED_CURSOR:
id = OCR_NO;
break;
default:
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
return GLFW_FALSE;
}
cursor->win32.handle = LoadImageW(NULL,