On 27 Oct 2007, at 8:01 PM, Adam R. Maxwell wrote:
> On Oct 27, 2007, at 10:09 AM, Christiaan Hofman wrote:
>
>>> On Saturday, October 27, 2007, at 09:23AM, "Christiaan Hofman"
>>> <[EMAIL PROTECTED]> wrote:
>>>> Have you tried setting the clipView variable in -[SKPDFView
>>>> magnifyWithEvent:] to documentView? That's the only thing I can
>>>> think
>>>> of ATM.
>
> This doesn't seem to help.
>
>> Another thing to try is to set the documentView variable (and perhaps
>> the clipView variable) to [self documentView], though that clips the
>> magnifying glass to the documentView.
>
> This doesn't seem to help either.
>
> The magnifier flickers at low frequency when moving the mouse, and
> just goes away if you don't move the mouse. It almost seems like
> something else is running the event loop.
>
> --
> adam
Try to replace magnifyWithEvent: method with the following
implementation.
- (void)magnifyWithEvent:(NSEvent *)theEvent {
NSPoint mouseLoc = [theEvent locationInWindow];
NSScrollView *scrollView = [[self documentView]
enclosingScrollView];
NSView *documentView = [scrollView documentView];
NSView *clipView = [scrollView contentView];
NSRect originalBounds = [documentView bounds];
NSRect visibleRect = [clipView convertRect:[clipView
visibleRect] toView: nil];
NSRect magBounds, magRect, outlineRect;
BOOL mouseInside = NO;
int currentLevel = 0;
int originalLevel = [theEvent clickCount]; // this should be at
least 1
BOOL postNotification = [documentView
postsBoundsChangedNotifications];
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
NSSize smallSize = NSMakeSize([sud
floatForKey:SKSmallMagnificationWidthKey], [sud
floatForKey:SKSmallMagnificationHeightKey]);
NSSize largeSize = NSMakeSize([sud
floatForKey:SKLargeMagnificationWidthKey], [sud
floatForKey:SKLargeMagnificationHeightKey]);
NSRect smallMagRect = SKRectFromCenterAndSize(NSZeroPoint,
smallSize);
NSRect largeMagRect = SKRectFromCenterAndSize(NSZeroPoint,
largeSize);
NSBezierPath *path;
NSColor *color = [NSColor colorWithCalibratedWhite:0.2 alpha:1.0];
NSShadow *shadow = [[[NSShadow alloc] init] autorelease];
[shadow setShadowBlurRadius:4.0];
[shadow setShadowOffset:NSMakeSize(0.0, -2.0)];
[shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0
alpha:0.5]];
[documentView setPostsBoundsChangedNotifications: NO];
[[self window] discardCachedImage]; // make sure not to use the
cached image
while ([theEvent type] != NSLeftMouseUp) {
if ([theEvent type] == NSLeftMouseDown || [theEvent type] ==
NSFlagsChanged) {
// set up the currentLevel and magnification
unsigned modifierFlags = [theEvent modifierFlags];
currentLevel = originalLevel + ((modifierFlags &
NSAlternateKeyMask) ? 1 : 0);
if (currentLevel > 2) {
[[self window] restoreCachedImage];
[[self window] cacheImageInRect:visibleRect];
}
magnification = (modifierFlags & NSCommandKeyMask) ?
4.0 : (modifierFlags & NSControlKeyMask) ? 1.5 : 2.5;
if (modifierFlags & NSShiftKeyMask) {
magnification = 1.0 / magnification;
}
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewMagnificationChangedNotification
object:self];
[[self cursorForEvent:theEvent] set];
} else if ([theEvent type] == NSLeftMouseDragged) {
// get Mouse location and check if it is with the view's
rect
mouseLoc = [theEvent locationInWindow];
}
if ([self mouse:mouseLoc inRect:visibleRect]) {
if (mouseInside == NO) {
mouseInside = YES;
[NSCursor hide];
[[self window] disableFlushWindow];
}
// make sure we flush the complete drawing to avoid
flickering
//[[self window] disableFlushWindow];
// define rect for magnification in window coordinate
if (currentLevel > 2) {
magRect = (visibleRect);
} else {
magRect = currentLevel == 2 ? largeMagRect :
smallMagRect;
magRect.origin = SKAddPoints(magRect.origin, mouseLoc);
magRect = NSIntegralRect(magRect);
// restore the cached image in order to clear the rect
[[self window] restoreCachedImage];
[[self window] cacheImageInRect:NSIntersectionRect
(NSInsetRect(magRect, -8.0, -8.0), visibleRect)];
}
// resize bounds around mouseLoc
magBounds.origin = [documentView convertPoint:mouseLoc
fromView:nil];
magBounds = NSMakeRect(NSMinX(magBounds) + (NSMinX
(originalBounds) - NSMinX(magBounds)) / magnification,
NSMinY(magBounds) + (NSMinY
(originalBounds) - NSMinY(magBounds)) / magnification,
NSWidth(originalBounds) /
magnification, NSHeight(originalBounds) / magnification);
[clipView lockFocus];
outlineRect = [clipView convertRect:magRect fromView:nil];
[shadow set];
[color set];
path = [NSBezierPath
bezierPathWithRoundRectInRect:outlineRect radius:9.5];
[path fill];
[clipView unlockFocus];
[documentView setBounds:magBounds];
[self displayRect:[self convertRect:NSInsetRect(magRect,
3.0, 3.0) fromView:nil]]; // this flushes the buffer
[documentView setBounds:originalBounds];
[clipView lockFocus];
outlineRect = NSInsetRect(outlineRect, 1.5, 1.5);
[color set];
path = [NSBezierPath
bezierPathWithRoundRectInRect:outlineRect radius:8.0];
[path setLineWidth:3.0];
[path stroke];
[clipView unlockFocus];
[[self window] enableFlushWindow];
[[self window] flushWindowIfNeeded];
[[self window] disableFlushWindow];
} else { // mouse is not in the rect
// show cursor
if (mouseInside == YES) {
mouseInside = NO;
[NSCursor unhide];
// restore the cached image in order to clear the rect
[[self window] restoreCachedImage];
[[self window] enableFlushWindow];
[[self window] flushWindowIfNeeded];
}
if ([theEvent type] == NSLeftMouseDragged)
[documentView autoscroll:theEvent];
if (currentLevel > 2)
[[self window] cacheImageInRect:visibleRect];
else
[[self window] discardCachedImage];
}
theEvent = [[self window] nextEventMatchingMask:
NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSFlagsChangedMask];
}
magnification = 0.0;
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewMagnificationChangedNotification
object:self];
[[self window] restoreCachedImage];
if (mouseInside == YES)
[[self window] enableFlushWindow];
[[self window] flushWindowIfNeeded];
[NSCursor unhide];
[documentView setPostsBoundsChangedNotifications:postNotification];
// ??? PDFView's delayed layout seems to reset the cursor to an
arrow
[[self cursorForEvent:theEvent] performSelector:@selector(set)
withObject:nil afterDelay:0];
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
skim-app-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-develop