Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorWilliam Reynish <billrey@me.com>2019-09-27 21:41:22 +0300
committerWilliam Reynish <billrey@me.com>2019-09-27 21:41:22 +0300
commit387fe3607da865e8cd4392e214f9e85d99f48d36 (patch)
treecbd0f68a12467108abdd34dcecbda8c61744abb0 /intern
parente51b93473a24f3cddc9055d63d4ef6ed88eb0e9c (diff)
UI: Add high quality cursors on macOS
This adds the same high quality cursors on macOS as we have on Windows. These are stored as 32*32 pt PDFs, same as the built-in OS cursors Reviewed by: Brecht Van Lommel Differential Revision: https://developer.blender.org/D5907
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm59
1 files changed, 57 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index dff45ba85fb..1e0952c3bd6 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -925,6 +925,27 @@ GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
#pragma mark Cursor handling
+static NSCursor *getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSPoint hotspot)
+{
+ static NSCursor *cursors[(int)GHOST_kStandardCursorNumCursors] = {0};
+ static bool loaded[(int)GHOST_kStandardCursorNumCursors] = {false};
+
+ const int index = (int)shape;
+ if (!loaded[index]) {
+ /* Load image from file in application Resources folder. */
+ @autoreleasepool {
+ NSImage *image = [NSImage imageNamed:name];
+ if (image != NULL) {
+ cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
+ }
+ }
+
+ loaded[index] = true;
+ }
+
+ return cursors[index];
+}
+
NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) const
{
switch (shape) {
@@ -942,10 +963,8 @@ 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];
@@ -963,6 +982,42 @@ NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) cons
return [NSCursor pointingHandCursor];
case GHOST_kStandardCursorDefault:
return [NSCursor arrowCursor];
+ case GHOST_kStandardCursorKnife:
+ return getImageCursor(shape, @"knife.pdf", NSMakePoint(6, 24));
+ case GHOST_kStandardCursorEraser:
+ return getImageCursor(shape, @"eraser.pdf", NSMakePoint(6, 24));
+ case GHOST_kStandardCursorPencil:
+ return getImageCursor(shape, @"pen.pdf", NSMakePoint(6, 24));
+ case GHOST_kStandardCursorEyedropper:
+ return getImageCursor(shape, @"eyedropper.pdf", NSMakePoint(6, 24));
+ case GHOST_kStandardCursorZoomIn:
+ return getImageCursor(shape, @"zoomin.pdf", NSMakePoint(8, 7));
+ case GHOST_kStandardCursorZoomOut:
+ return getImageCursor(shape, @"zoomout.pdf", NSMakePoint(8, 7));
+ case GHOST_kStandardCursorNSEWScroll:
+ return getImageCursor(shape, @"scrollnsew.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorNSScroll:
+ return getImageCursor(shape, @"scrollns.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorEWScroll:
+ return getImageCursor(shape, @"scrollew.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorUpArrow:
+ return getImageCursor(shape, @"arrowup.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorDownArrow:
+ return getImageCursor(shape, @"arrowdown.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorLeftArrow:
+ return getImageCursor(shape, @"arrowleft.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorRightArrow:
+ return getImageCursor(shape, @"arrowright.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorVerticalSplit:
+ return getImageCursor(shape, @"splitv.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorHorizontalSplit:
+ return getImageCursor(shape, @"splith.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorCrosshairA:
+ return getImageCursor(shape, @"crossa.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorCrosshairB:
+ return getImageCursor(shape, @"crossb.pdf", NSMakePoint(16, 16));
+ case GHOST_kStandardCursorCrosshairC:
+ return getImageCursor(shape, @"crossc.pdf", NSMakePoint(16, 16));
default:
return NULL;
}