Author: dpsimons
Date: Mon Nov 23 20:52:22 2015
New Revision: 39193
URL: http://svn.gna.org/viewcvs/gnustep?rev=39193&view=rev
Log:
improve user experience with the color picker magnifying glass, particularly on
Windows which would crash
Modified:
libs/gui/branches/gnustep_testplant_branch/ChangeLog
libs/gui/branches/gnustep_testplant_branch/Source/NSColorPanel.m
Modified: libs/gui/branches/gnustep_testplant_branch/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/ChangeLog?rev=39193&r1=39192&r2=39193&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/ChangeLog (original)
+++ libs/gui/branches/gnustep_testplant_branch/ChangeLog Mon Nov 23
20:52:22 2015
@@ -1,3 +1,9 @@
+2015-11-23 Doug Simons <[email protected]>
+
+ * Source/NSColorPanel.m: Improve the user experience when using
+ the magnifying glass to select a color from the screen. Also,
+ allow typing Escape to cancel the magnify mode.
+
2015-09-10 Doug Simons <[email protected]> and Paul Landers
<[email protected]>
* Source/NSLayoutManager.m: Fix a bug that would try to adjust
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSColorPanel.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSColorPanel.m?rev=39193&r1=39192&r2=39193&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSColorPanel.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSColorPanel.m Mon Nov
23 20:52:22 2015
@@ -58,6 +58,7 @@
#import "GNUstepGUI/GSDisplayServer.h"
#import "GNUstepGUI/IMLoading.h"
+#import "unistd.h"
#import "GSGuiPrivate.h"
@@ -372,6 +373,13 @@
{
NSEvent *currentEvent;
NSCursor *cursor;
+ NSColor *color = nil;
+ BOOL cancel = NO;
+ BOOL liveFeedback = YES; // set to show color dynamically in the panel while
mouse is moving
+#if defined(__MINGW__)
+ liveFeedback = NO; // live feedback causes serious problems on Windows
+#endif
+ liveFeedback = NO; // even on Linux the experience is better without the
feedback (at least on CentOS 6.5)
[self _captureMouse: self];
@@ -387,30 +395,54 @@
NS_DURING
{
+ NSPoint mouseLoc;
+ NSImage *img;
do {
- NSPoint mouseLoc;
- NSImage *img;
CREATE_AUTORELEASE_POOL(pool);
- currentEvent = [NSApp nextEventMatchingMask: NSLeftMouseDownMask |
NSLeftMouseUpMask | NSMouseMovedMask
+ currentEvent = [NSApp nextEventMatchingMask: NSLeftMouseDownMask |
NSLeftMouseUpMask | NSMouseMovedMask | NSKeyDownMask | NSKeyUpMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
+ if ([currentEvent type] == NSKeyUp || [currentEvent type] == NSKeyDown)
+ {
+ if ([[currentEvent charactersIgnoringModifiers]
isEqualToString:@"\e"])
+ {
+ cancel = YES; // allow Escape to cancel the magnifier
+ }
+ }
+ else if (liveFeedback)
+ {
+ mouseLoc = [self convertBaseToScreen: [self
mouseLocationOutsideOfEventStream]];
- mouseLoc = [self convertBaseToScreen: [self
mouseLocationOutsideOfEventStream]];
+ img = [GSCurrentServer() contentsOfScreen: [[self screen]
screenNumber]
+ inRect: NSMakeRect(mouseLoc.x,
mouseLoc.y, 1, 1)];
- img = [GSCurrentServer() contentsOfScreen: [[self screen] screenNumber]
- inRect: NSMakeRect(mouseLoc.x,
mouseLoc.y, 1, 1)];
-
- if (img != nil)
- {
- NSBitmapImageRep *rep = (NSBitmapImageRep *)[img
bestRepresentationForDevice: nil];
- NSColor *color = [rep colorAtX: 0 y: 0];
- [self setColor: color];
+ if (img != nil)
+ {
+ NSBitmapImageRep *rep = (NSBitmapImageRep *)[img
bestRepresentationForDevice: nil];
+ color = [rep colorAtX: 0 y: 0];
+ [_colorWell setColor: color]; // show color for feedback, but
don't send action yet
+ }
}
- [pool drain];
- } while ([currentEvent type] != NSLeftMouseUp &&
+ [pool drain];
+ } while (!cancel &&
+ [currentEvent type] != NSLeftMouseUp &&
[currentEvent type] != NSLeftMouseDown);
+
+ if (!liveFeedback && !cancel)
+ {
+ mouseLoc = [self convertBaseToScreen: [self
mouseLocationOutsideOfEventStream]];
+ img = [GSCurrentServer() contentsOfScreen: [[self screen]
screenNumber]
+ inRect: NSMakeRect(mouseLoc.x,
mouseLoc.y, 1, 1)];
+ if (img != nil)
+ {
+ NSBitmapImageRep *rep = (NSBitmapImageRep *)[img
bestRepresentationForDevice: nil];
+ color = [rep colorAtX: 0 y: 0];
+ }
+ }
+ if (color && !cancel)
+ [self setColor: color];
}
NS_HANDLER
{
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs