[Bf-blender-cvs] [3bf46103473] master: GHOST: refresh standard cursors available for platforms

Harley Acheson noreply at git.blender.org
Thu Sep 26 14:33:13 CEST 2019


Commit: 3bf4610347376d326ac376e62a810e20661f1479
Author: Harley Acheson
Date:   Thu Sep 26 14:31:47 2019 +0200
Branches: master
https://developer.blender.org/rB3bf4610347376d326ac376e62a810e20661f1479

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

===================================================================

M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_WindowCocoa.mm
M	intern/ghost/intern/GHOST_WindowSDL.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp
A	release/windows/icons/cursors/arrowdown.cur
A	release/windows/icons/cursors/arrowleft.cur
A	release/windows/icons/cursors/arrowright.cur
A	release/windows/icons/cursors/arrowup.cur
A	release/windows/icons/cursors/cross.cur
A	release/windows/icons/cursors/crossa.cur
A	release/windows/icons/cursors/crossb.cur
A	release/windows/icons/cursors/crossc.cur
A	release/windows/icons/cursors/eraser.cur
A	release/windows/icons/cursors/eyedropper.cur
A	release/windows/icons/cursors/forbidden.cur
A	release/windows/icons/cursors/handopen.cur
A	release/windows/icons/cursors/knife.cur
A	release/windows/icons/cursors/moveew.cur
A	release/windows/icons/cursors/movens.cur
A	release/windows/icons/cursors/pencil.cur
A	release/windows/icons/cursors/pointer.cur
A	release/windows/icons/cursors/scrollew.cur
A	release/windows/icons/cursors/scrollns.cur
A	release/windows/icons/cursors/scrollnsew.cur
A	release/windows/icons/cursors/splith.cur
A	release/windows/icons/cursors/splitv.cur
A	release/windows/icons/cursors/zoomin.cur
A	release/windows/icons/cursors/zoomout.cur
M	release/windows/icons/winblender.rc

===================================================================

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

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list