Finish NSColorWell interaction tweaks:

- activation of the now happens on mouseUp, not mouseDown
- non-bordered NSColorWells can't be activated by clicking
- non-bordered NSColorWells start a drag operation upon mouseDown
- disabled NSColorWells don't accept colours being dropped on them
- dropping a colour on the well inside the NSColorPanel now
  also updates the active NSColorWell
Also moved the static variable for keeping track of where the mouseDown
occurred to an instance variable.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29150 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2009-12-21 00:31:24 +00:00
parent c1086efcd0
commit ab285b8ea4
5 changed files with 82 additions and 22 deletions

View file

@ -1,3 +1,19 @@
2209-12-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSColorWell.m
* Source/GSThemeDrawing.m
* Source/NSColorPanel.m
* Headers/AppKit/NSColorWell.h:
Finish NSColorWell interaction tweaks:
- activation of the now happens on mouseUp, not mouseDown
- non-bordered NSColorWells can't be activated by clicking
- non-bordered NSColorWells start a drag operation upon mouseDown
- disabled NSColorWells don't accept colours being dropped on them
- dropping a colour on the well inside the NSColorPanel now
also updates the active NSColorWell
Also moved the static variable for keeping track of where the mouseDown
occurred to an instance variable.
2009-12-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableColumn.m (-initWithCoder:, -encodeWithCoder:): Add

View file

@ -45,6 +45,8 @@
NSRect _wellRect;
id _target;
SEL _action;
// Mouse tracking
NSPoint _mouseDownPoint;
}
//

View file

@ -728,7 +728,7 @@
/*
* Fill in control color.
*/
if ([well isActive])
if ([[well cell] isHighlighted] || [well isActive])
{
[[NSColor selectedControlColor] set];
}

View file

@ -356,7 +356,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
- (void) _updatePicker: (id) sender
{
[_currentPicker setColor: [_colorWell color]];
[self setColor: [_colorWell color]];
}
- (void) _bottomWellAction: (id) sender

View file

@ -46,8 +46,6 @@
static NSString *GSColorWellDidBecomeExclusiveNotification =
@"GSColorWellDidBecomeExclusiveNotification";
static NSPoint _lastMouseDownPoint;
@implementation NSColorWell
/*
@ -147,6 +145,10 @@ static NSPoint _lastMouseDownPoint;
NSDragOperation sourceDragMask;
NSDebugLLog(@"NSColorWell", @"%@: draggingEntered", self);
if ([self isEnabled] == NO)
return NSDragOperationNone;
sourceDragMask = [sender draggingSourceOperationMask];
pb = [sender draggingPasteboard];
@ -289,12 +291,65 @@ static NSPoint _lastMouseDownPoint;
// OPENSTEP 4.2 and OSX behavior indicates that the colorwell doesn't
// work when the widget is marked as disabled.
//
if ([self isEnabled])
{
_lastMouseDownPoint =
[self convertPoint: [theEvent locationInWindow]
fromView: nil];
if ([self isEnabled] == NO)
return;
// Unbordered color wells start a drag immediately upon mouse down
if ([self isBordered] == NO)
{
[NSColorPanel dragColor: _the_color
withEvent: theEvent
fromView: self];
return;
}
_mouseDownPoint = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
[[self cell] setHighlighted: YES];
[self setNeedsDisplay: YES];
}
- (void) mouseDragged: (NSEvent *)theEvent
{
NSPoint point = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
BOOL inside = [self mouse: point inRect: [self bounds]];
BOOL startedInWell = [self mouse: _mouseDownPoint inRect: _wellRect];
if ([self isEnabled] == NO)
return;
if (startedInWell)
{
[[self cell] setHighlighted: NO];
[self setNeedsDisplay: YES];
[NSColorPanel dragColor: _the_color
withEvent: theEvent
fromView: self];
return;
}
else
{
[[self cell] setHighlighted: inside];
[self setNeedsDisplay: YES];
}
}
- (void) mouseUp: (NSEvent *)theEvent
{
NSPoint point = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
BOOL inside = [self mouse: point inRect: [self bounds]];
if ([self isEnabled] == NO)
return;
[[self cell] setHighlighted: NO];
[self setNeedsDisplay: YES];
if (inside)
{
if (_is_active == NO)
{
[self activate: YES];
@ -306,19 +361,6 @@ static NSPoint _lastMouseDownPoint;
}
}
- (void) mouseDragged: (NSEvent *)theEvent
{
if ([self isEnabled])
{
if ([self mouse: _lastMouseDownPoint inRect: _wellRect])
{
[NSColorPanel dragColor: _the_color
withEvent: theEvent
fromView: self];
}
}
}
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];