Merge pull request #30 from trunkmaster/master

Mouse cursors handling cleanup
This commit is contained in:
Fred Kiefer 2019-05-10 13:27:26 +02:00 committed by GitHub
commit f4ad8d207b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 86 deletions

View file

@ -1,3 +1,24 @@
2019-04-17 Sergii Stoian <stoyan255@gmail.com>
* Source/GSDragView.m (_setCursor): Do not hold `cursors` array -
use NSCursor's methods. Do not recolor cursor and just use
[NSCursor greenArrowCursor].
* Headers/AppKit/NSCursor.h:
* Source/NSCursor.m (greenArrowCursor):
Use getStandardCursor() to get GSGreenArrowCursor. New cursor type
GSGreeanArrowCursor was added.
* Images/GSContextualMenuCursor.tiff,
* Images/GSDisappearingItemCursor.tiff,
* Images/GSDragCopyCursor.tiff,
* Images/GSDragLinkCursor.tiff,
* Images/GSGreenArrowCursor.tiff,
* Images/GSOperationNotAllowedCursor.tiff: New cursor images.
* Images/GNUmakefile (Images_RESOURCE_FILES): Update resource
list according to cursor images addition/removal.
2019-04-10 Sergii Stoian <stoyan255@gmail.com>
* Source/NSMenuItemCell.m (drawKeyEquivalentWithFrame:inView:):

View file

@ -155,7 +155,8 @@ typedef enum {
GSResizeDownCursor,
GSResizeUpDownCursor,
GSContextualMenuCursor,
GSDisappearingItemCursor
GSDisappearingItemCursor,
GSGreenArrowCursor
} GSCursorTypes;
#endif /* _GNUstep_H_NSCursor */

View file

@ -34,6 +34,12 @@ Images_INSTALL_DIR = $(GNUSTEP_LIBRARY)/Images
Images_RESOURCE_FILES = \
GNUstep.tiff \
GNUstepMenuImage.tiff \
GSContextualMenuCursor.tiff \
GSDisappearingItemCursor.tiff \
GSDragCopyCursor.tiff \
GSDragLinkCursor.tiff \
GSGreenArrowCursor.tiff \
GSOperationNotAllowedCursor.tiff \
GSSearch.tiff \
GSStop.tiff \
LogoGNUstep.tiff \

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -36,12 +36,6 @@ NSMenuMixedState = GSMenuMixed;
common_ComboBoxEllipsis = GSComboArrow;
NSComboArrow = GSComboArrow;
common_ClosedHandCursor = GSClosedHandCursor;
common_OpenHandCursor = GSOpenHandCursor;
common_copyCursor = GSDragCopyCursor;
common_linkCursor = GSDragLinkCursor;
common_noCursor = GSOperationNotAllowedCursor;
/* Toolbar images */
common_ToolbarCustomizeToolbarItem = NSToolbarCustomizeToolbarItemImage;

View file

@ -162,7 +162,6 @@ static GSDragView *sharedDragView = nil;
- (void) dealloc
{
[super dealloc];
RELEASE(cursors);
}
/* NSDraggingInfo protocol */
@ -486,8 +485,6 @@ static GSDragView *sharedDragView = nil;
- (void) _setCursor
{
NSCursor *newCursor;
NSString *name;
NSString *iname;
NSDragOperation mask;
mask = dragMask & operationMask;
@ -497,77 +494,38 @@ static GSDragView *sharedDragView = nil;
NSDebugLLog (@"NSDragging",
@"drag, operation, target mask = (%x, %x, %x), dnd aware = %d\n",
(unsigned int)dragMask, (unsigned int)operationMask, (unsigned int)targetMask,
(targetWindowRef != 0));
(unsigned int)dragMask, (unsigned int)operationMask,
(unsigned int)targetMask, (targetWindowRef != 0));
if (cursors == nil)
cursors = RETAIN([NSMutableDictionary dictionary]);
name = nil;
newCursor = nil;
iname = nil;
switch (mask)
{
case NSDragOperationNone:
name = @"NoCursor";
iname = @"common_noCursor";
break;
case NSDragOperationCopy:
name = @"CopyCursor";
iname = @"common_copyCursor";
break;
case NSDragOperationLink:
name = @"LinkCursor";
iname = @"common_linkCursor";
newCursor = [NSCursor operationNotAllowedCursor];
break;
case NSDragOperationGeneric:
case NSDragOperationCopy:
newCursor = [NSCursor dragCopyCursor];
break;
case NSDragOperationLink:
newCursor = [NSCursor dragLinkCursor];
break;
case NSDragOperationDelete:
newCursor = [NSCursor disappearingItemCursor];
break;
default:
// FIXME: Should not happen, add warning?
// NSDragOperationEvery, NSDragOperationPrivate
if (targetWindowRef != 0)
{
newCursor = [NSCursor greenArrowCursor];
}
else
{
newCursor = [NSCursor arrowCursor];
}
break;
}
if (name != nil)
{
newCursor = [cursors objectForKey: name];
if (newCursor == nil)
{
NSImage *image = [NSImage imageNamed: iname];
newCursor = [[NSCursor alloc] initWithImage: image];
[cursors setObject: newCursor forKey: name];
RELEASE(newCursor);
}
}
if (newCursor == nil)
{
name = @"ArrowCursor";
newCursor = [cursors objectForKey: name];
if (newCursor == nil)
{
/* Make our own arrow cursor, since we want to color it */
void *c;
newCursor = [[NSCursor alloc] initWithImage: nil];
[GSCurrentServer() standardcursor: GSArrowCursor : &c];
[newCursor _setCid: c];
[cursors setObject: newCursor forKey: name];
RELEASE(newCursor);
}
}
if ((targetWindowRef != 0) && mask != NSDragOperationNone)
{
[GSCurrentServer() recolorcursor: [NSColor greenColor]
: [NSColor blackColor]
: [newCursor _cid]];
}
else
{
[GSCurrentServer() recolorcursor: [NSColor blackColor]
: [NSColor whiteColor]
: [newCursor _cid]];
}
[newCursor set];
}

View file

@ -299,22 +299,7 @@ NSCursor *getStandardCursor(NSString *name, int style)
+ (NSCursor*) greenArrowCursor
{
NSString *name = @"GSGreenArrowCursor";
NSCursor *cursor = [cursorDict objectForKey: name];
if (cursor == nil)
{
void *c;
cursor = [[NSCursor_class alloc] initWithImage: nil
hotSpot: NSZeroPoint];
[GSCurrentServer() standardcursor: GSArrowCursor : &c];
[GSCurrentServer() recolorcursor: [NSColor greenColor]
: [NSColor blackColor] : c];
[cursor _setCid: c];
[cursorDict setObject: cursor forKey: name];
RELEASE(cursor);
}
return cursor;
return getStandardCursor(@"GSGreenArrowCursor", GSGreenArrowCursor);
}
/*