diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-09-26 15:31:47 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-26 15:31:47 +0300 |
commit | 3bf4610347376d326ac376e62a810e20661f1479 (patch) | |
tree | d1b2f67b0666b7028add304ce1b6f4713a21e9a8 /intern | |
parent | 6292cab193a6aa2a80ceba929079b47de7d8f48a (diff) |
GHOST: refresh standard cursors available for platforms
* Add more standard cursor types, that platforms can optionally support.
* Remove a few unused cursor types that were not properly supported and
would show the wrong cursor when used.
* Add native cursor files for Windows. These scale well with DPI and have
anti-aliasing. Designed by Duarte Farrajota Ramos.
Ref D5197
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/GHOST_Types.h | 21 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCocoa.mm | 18 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowSDL.cpp | 28 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 137 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowX11.cpp | 24 |
5 files changed, 121 insertions, 107 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 68516c3ecf8..891f9d982b9 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -197,11 +197,27 @@ typedef enum { GHOST_kStandardCursorInfo, GHOST_kStandardCursorDestroy, GHOST_kStandardCursorHelp, - GHOST_kStandardCursorCycle, - GHOST_kStandardCursorSpray, GHOST_kStandardCursorWait, GHOST_kStandardCursorText, GHOST_kStandardCursorCrosshair, + GHOST_kStandardCursorCrosshairA, + GHOST_kStandardCursorCrosshairB, + GHOST_kStandardCursorCrosshairC, + GHOST_kStandardCursorPencil, + GHOST_kStandardCursorUpArrow, + GHOST_kStandardCursorDownArrow, + GHOST_kStandardCursorVerticalSplit, + GHOST_kStandardCursorHorizontalSplit, + GHOST_kStandardCursorEraser, + GHOST_kStandardCursorKnife, + GHOST_kStandardCursorEyedropper, + GHOST_kStandardCursorZoomIn, + GHOST_kStandardCursorZoomOut, + GHOST_kStandardCursorMove, + GHOST_kStandardCursorNSEWScroll, + GHOST_kStandardCursorNSScroll, + GHOST_kStandardCursorEWScroll, + GHOST_kStandardCursorStop, GHOST_kStandardCursorUpDown, GHOST_kStandardCursorLeftRight, GHOST_kStandardCursorTopSide, @@ -214,7 +230,6 @@ typedef enum { GHOST_kStandardCursorBottomLeftCorner, GHOST_kStandardCursorCopy, GHOST_kStandardCursorCustom, - GHOST_kStandardCursorPencil, GHOST_kStandardCursorNumCursors } GHOST_TStandardCursor; diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index dcf6d5da487..dff45ba85fb 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -942,8 +942,10 @@ NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) cons case GHOST_kStandardCursorCrosshair: return [NSCursor crosshairCursor]; case GHOST_kStandardCursorUpDown: + case GHOST_kStandardCursorHorizontalSplit: return [NSCursor resizeUpDownCursor]; case GHOST_kStandardCursorLeftRight: + case GHOST_kStandardCursorVerticalSplit: return [NSCursor resizeLeftRightCursor]; case GHOST_kStandardCursorTopSide: return [NSCursor resizeUpCursor]; @@ -953,18 +955,12 @@ NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) cons return [NSCursor resizeLeftCursor]; case GHOST_kStandardCursorRightSide: return [NSCursor resizeRightCursor]; - case GHOST_kStandardCursorRightArrow: - case GHOST_kStandardCursorInfo: - case GHOST_kStandardCursorLeftArrow: - case GHOST_kStandardCursorHelp: - case GHOST_kStandardCursorCycle: - case GHOST_kStandardCursorSpray: - case GHOST_kStandardCursorWait: - case GHOST_kStandardCursorTopLeftCorner: - case GHOST_kStandardCursorTopRightCorner: - case GHOST_kStandardCursorBottomRightCorner: - case GHOST_kStandardCursorBottomLeftCorner: case GHOST_kStandardCursorCopy: + return [NSCursor dragCopyCursor]; + case GHOST_kStandardCursorStop: + return [NSCursor operationNotAllowedCursor]; + case GHOST_kStandardCursorMove: + return [NSCursor pointingHandCursor]; case GHOST_kStandardCursorDefault: return [NSCursor arrowCursor]; default: diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp index 38c6f51dea4..99988dd55cc 100644 --- a/intern/ghost/intern/GHOST_WindowSDL.cpp +++ b/intern/ghost/intern/GHOST_WindowSDL.cpp @@ -301,19 +301,6 @@ static unsigned char sdl_std_cursor_top_left_corner[] = { #define sdl_std_cursor_HOT_X_top_left_corner 0 #define sdl_std_cursor_HOT_Y_top_left_corner -14 -static unsigned char sdl_std_cursor_mask_spraycan[] = { - 0x00, 0x0c, 0x18, 0x0d, 0x7c, 0x0d, 0x7c, 0x0d, 0x7e, 0x0d, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, - 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, -}; -static unsigned char sdl_std_cursor_spraycan[] = { - 0x00, 0x06, 0x80, 0x00, 0x2c, 0x06, 0x9e, 0x00, 0x16, 0x06, 0x3f, 0x00, 0x21, 0x00, 0x27, 0x00, - 0x25, 0x00, 0x27, 0x00, 0x25, 0x00, 0x27, 0x00, 0x27, 0x00, 0x21, 0x00, 0x21, 0x00, 0x3f, 0x00, -}; -#define sdl_std_cursor_WIDTH_spraycan 12 -#define sdl_std_cursor_HEIGHT_spraycan 16 -#define sdl_std_cursor_HOT_X_spraycan -9 -#define sdl_std_cursor_HOT_Y_spraycan -14 - static unsigned char sdl_std_cursor_mask_sb_v_double_arrow[] = { 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00, 0xff, 0x01, 0xff, 0x01, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0xff, 0x01, 0xff, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, @@ -450,19 +437,6 @@ static unsigned char sdl_std_cursor_left_ptr[] = { #define sdl_std_cursor_HOT_X_left_ptr -8 #define sdl_std_cursor_HOT_Y_left_ptr -14 -static unsigned char sdl_std_cursor_mask_exchange[] = { - 0xe3, 0x07, 0xf7, 0x0f, 0xff, 0x1f, 0xff, 0x3f, 0x3f, 0x38, 0xff, 0x30, 0xff, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0xff, 0x0c, 0xfe, 0x1c, 0xfc, 0xfc, 0xff, 0xf8, 0xff, 0xf0, 0xef, 0xe0, 0xc7, -}; -static unsigned char sdl_std_cursor_exchange[] = { - 0xf1, 0x03, 0xfb, 0x07, 0x1f, 0x0c, 0x09, 0x08, 0x19, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3f, 0x00, 0x26, 0x04, 0x24, 0x0c, 0x3e, 0xf8, 0x37, 0xf0, 0x23, 0x00, 0x00, 0x00, 0x00, -}; -#define sdl_std_cursor_WIDTH_exchange 16 -#define sdl_std_cursor_HEIGHT_exchange 16 -#define sdl_std_cursor_HOT_X_exchange -6 -#define sdl_std_cursor_HOT_Y_exchange -8 - static unsigned char sdl_std_cursor_mask_crosshair[] = { 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, @@ -605,8 +579,6 @@ static void getStandardCursorShape(GHOST_TStandardCursor shape) DEF_CURSOR(umbrella, GHOST_kStandardCursorInfo); // TODO, replace this one. DEF_CURSOR(pirate, GHOST_kStandardCursorDestroy); DEF_CURSOR(question_arrow, GHOST_kStandardCursorHelp); - DEF_CURSOR(exchange, GHOST_kStandardCursorCycle); - DEF_CURSOR(spraycan, GHOST_kStandardCursorSpray); DEF_CURSOR(watch, GHOST_kStandardCursorWait); DEF_CURSOR(xterm, GHOST_kStandardCursorText); DEF_CURSOR(crosshair, GHOST_kStandardCursorCrosshair); diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 679431e8597..d283e9e3aff 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -769,6 +769,11 @@ void GHOST_WindowWin32::registerMouseClickEvent(int press) HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const { // Convert GHOST cursor to Windows OEM cursor + HANDLE cursor = NULL; + HMODULE module = ::GetModuleHandle(0); + GHOST_TUns32 flags = LR_SHARED | LR_DEFAULTSIZE; + int cx = 0, cy = 0; + switch (shape) { case GHOST_kStandardCursorCustom: if (m_customCursor) { @@ -777,64 +782,114 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const else { return NULL; } - case GHOST_kStandardCursorDefault: - return ::LoadCursor(0, IDC_ARROW); case GHOST_kStandardCursorRightArrow: - return ::LoadCursor(0, IDC_ARROW); + cursor = ::LoadImage(module, "arrowright_cursor", IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorLeftArrow: - return ::LoadCursor(0, IDC_ARROW); - case GHOST_kStandardCursorInfo: - // Four-pointed arrow pointing north, south, east, and west - return ::LoadCursor(0, IDC_SIZEALL); - case GHOST_kStandardCursorDestroy: - // Slashed circle - return ::LoadCursor(0, IDC_NO); + cursor = ::LoadImage(module, "arrowleft_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorUpArrow: + cursor = ::LoadImage(module, "arrowup_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorDownArrow: + cursor = ::LoadImage(module, "arrowdown_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorVerticalSplit: + cursor = ::LoadImage(module, "splitv_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorHorizontalSplit: + cursor = ::LoadImage(module, "splith_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorKnife: + cursor = ::LoadImage(module, "knife_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorEyedropper: + cursor = ::LoadImage(module, "eyedropper_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorZoomIn: + cursor = ::LoadImage(module, "zoomin_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorZoomOut: + cursor = ::LoadImage(module, "zoomout_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorMove: + cursor = ::LoadImage(module, "handopen_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorNSEWScroll: + cursor = ::LoadImage(module, "scrollnsew_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorNSScroll: + cursor = ::LoadImage(module, "scrollns_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorEWScroll: + cursor = ::LoadImage(module, "scrollew_cursor", IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorHelp: - // Arrow and question mark - return ::LoadCursor(0, IDC_HELP); - case GHOST_kStandardCursorCycle: - // Slashed circle - return ::LoadCursor(0, IDC_NO); - case GHOST_kStandardCursorSpray: - // Four-pointed arrow pointing north, south, east, and west - return ::LoadCursor(0, IDC_SIZEALL); + cursor = ::LoadImage(NULL, IDC_HELP, IMAGE_CURSOR, cx, cy, flags); + break; // Arrow and question mark case GHOST_kStandardCursorWait: - // Hourglass - return ::LoadCursor(0, IDC_WAIT); + cursor = ::LoadImage(NULL, IDC_WAIT, IMAGE_CURSOR, cx, cy, flags); + break; // Hourglass case GHOST_kStandardCursorText: - // I-beam - return ::LoadCursor(0, IDC_IBEAM); + cursor = ::LoadImage(NULL, IDC_IBEAM, IMAGE_CURSOR, cx, cy, flags); + break; // I-beam case GHOST_kStandardCursorCrosshair: - // Crosshair - return ::LoadCursor(0, IDC_CROSS); + cursor = ::LoadImage(module, "cross_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Standard Cross + case GHOST_kStandardCursorCrosshairA: + cursor = ::LoadImage(module, "crossA_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Crosshair A + case GHOST_kStandardCursorCrosshairB: + cursor = ::LoadImage(module, "crossB_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Diagonal Crosshair B + case GHOST_kStandardCursorCrosshairC: + cursor = ::LoadImage(module, "crossC_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Minimal Crosshair C + case GHOST_kStandardCursorBottomSide: case GHOST_kStandardCursorUpDown: - // Double-pointed arrow pointing north and south - return ::LoadCursor(0, IDC_SIZENS); + cursor = ::LoadImage(module, "movens_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Double-pointed arrow pointing north and south + case GHOST_kStandardCursorLeftSide: case GHOST_kStandardCursorLeftRight: - // Double-pointed arrow pointing west and east - return ::LoadCursor(0, IDC_SIZEWE); + cursor = ::LoadImage(module, "moveew_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Double-pointed arrow pointing west and east case GHOST_kStandardCursorTopSide: - // Vertical arrow - return ::LoadCursor(0, IDC_UPARROW); - case GHOST_kStandardCursorBottomSide: - return ::LoadCursor(0, IDC_SIZENS); - case GHOST_kStandardCursorLeftSide: - return ::LoadCursor(0, IDC_SIZEWE); + cursor = ::LoadImage(NULL, IDC_UPARROW, IMAGE_CURSOR, cx, cy, flags); + break; // Vertical arrow case GHOST_kStandardCursorTopLeftCorner: - return ::LoadCursor(0, IDC_SIZENWSE); + cursor = ::LoadImage(NULL, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorTopRightCorner: - return ::LoadCursor(0, IDC_SIZENESW); + cursor = ::LoadImage(NULL, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorBottomRightCorner: - return ::LoadCursor(0, IDC_SIZENWSE); + cursor = ::LoadImage(NULL, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorBottomLeftCorner: - return ::LoadCursor(0, IDC_SIZENESW); + cursor = ::LoadImage(NULL, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); + break; case GHOST_kStandardCursorPencil: - return ::LoadCursor(0, IDC_ARROW); - case GHOST_kStandardCursorCopy: - return ::LoadCursor(0, IDC_ARROW); + cursor = ::LoadImage(module, "pencil_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorEraser: + cursor = ::LoadImage(module, "eraser_cursor", IMAGE_CURSOR, cx, cy, flags); + break; + case GHOST_kStandardCursorDestroy: + case GHOST_kStandardCursorStop: + cursor = ::LoadImage(module, "forbidden_cursor", IMAGE_CURSOR, cx, cy, flags); + break; // Slashed circle + case GHOST_kStandardCursorDefault: + cursor = NULL; + break; default: return NULL; } + + if (cursor == NULL) { + cursor = ::LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, cx, cy, flags); + } + + return (HCURSOR)cursor; } void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor shape) const diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 402c48bc0fc..8aa4a4e284a 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -1289,27 +1289,9 @@ GHOST_TSuccess GHOST_WindowX11::getStandardCursor(GHOST_TStandardCursor g_cursor unsigned int xcursor_id; switch (g_cursor) { - case GHOST_kStandardCursorRightArrow: - xcursor_id = XC_arrow; - break; - case GHOST_kStandardCursorLeftArrow: - xcursor_id = XC_top_left_arrow; - break; - case GHOST_kStandardCursorInfo: - xcursor_id = XC_hand1; - break; - case GHOST_kStandardCursorDestroy: - xcursor_id = XC_pirate; - break; case GHOST_kStandardCursorHelp: xcursor_id = XC_question_arrow; break; - case GHOST_kStandardCursorCycle: - xcursor_id = XC_exchange; - break; - case GHOST_kStandardCursorSpray: - xcursor_id = XC_spraycan; - break; case GHOST_kStandardCursorWait: xcursor_id = XC_watch; break; @@ -1349,12 +1331,6 @@ GHOST_TSuccess GHOST_WindowX11::getStandardCursor(GHOST_TStandardCursor g_cursor case GHOST_kStandardCursorBottomLeftCorner: xcursor_id = XC_bottom_left_corner; break; - case GHOST_kStandardCursorPencil: - xcursor_id = XC_pencil; - break; - case GHOST_kStandardCursorCopy: - xcursor_id = XC_arrow; - break; case GHOST_kStandardCursorDefault: xcursor = None; return GHOST_kSuccess; |