From ec6135aade4db14a664840a58a1b1659aa4bd827 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Tue, 17 Jun 2008 20:20:15 +0000 Subject: [PATCH] Commit scroll adjustment patch by Benhur Stein. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26678 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSClipView.m | 29 ++++++++++++++++++++++++++++- Source/NSScrollView.m | 16 ++++++++++------ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 629b45d9f..c42402097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-06-17 Fred Kiefer + + * Source/NSClipView.m (_scrollToPoint:): New method for adjusted + scrolling. + * Source/NSScrollView.m: Use this new method. + Patch by Benhur Stein . + 2008-06-14 Adam Fedor * Version 0.14.0 diff --git a/Source/NSClipView.m b/Source/NSClipView.m index 837330225..992b0fb82 100644 --- a/Source/NSClipView.m +++ b/Source/NSClipView.m @@ -42,6 +42,10 @@ DEFINE_RINT_IF_MISSING +@interface NSClipView (Private) +- (void) _scrollToPoint: (NSPoint)aPoint; +@end + /* * Return the biggest integral (in device space) rect contained in rect. * Conversion to/from device space is done using view. @@ -538,7 +542,7 @@ static inline NSRect integralRect (NSRect rect, NSView *view) */ - (void) viewFrameChanged: (NSNotification*)aNotification { - [self scrollToPoint: _bounds.origin]; + [self _scrollToPoint: _bounds.origin]; /* If document frame does not completely cover _bounds */ if (NSContainsRect([_documentView frame], _bounds) == NO) @@ -817,3 +821,26 @@ static inline NSRect integralRect (NSRect rect, NSView *view) return self; } @end + +@implementation NSClipView (Private) + +- (void) _scrollToPoint: (NSPoint)aPoint +{ + NSRect proposedBounds; + NSRect proposedVisibleRect; + NSRect newVisibleRect; + NSRect newBounds; + + // give documentView a chance to adjust its visible rectangle + proposedBounds = _bounds; + proposedBounds.origin = aPoint; + proposedVisibleRect = [self convertRect: proposedBounds + toView: _documentView]; + newVisibleRect = [_documentView adjustScroll: proposedVisibleRect]; + newBounds = [self convertRect: newVisibleRect fromView: _documentView]; + + [self scrollToPoint: newBounds.origin]; +} + +@end + diff --git a/Source/NSScrollView.m b/Source/NSScrollView.m index a66ba297d..43f8910af 100644 --- a/Source/NSScrollView.m +++ b/Source/NSScrollView.m @@ -49,6 +49,10 @@ #include "AppKit/PSOperators.h" #include "GNUstepGUI/GSTheme.h" +@interface NSClipView (Private) +- (void) _scrollToPoint: (NSPoint)aPoint; +@end + // // For nib compatibility, this is used to properly // initialize the object from a OS X nib file in initWithCoder:. @@ -406,7 +410,7 @@ static float scrollerWidth; /* scrollToPoint: will call reflectScrolledClipView:, which will * update rules, headers, and scrollers. */ - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } - (void) keyDown: (NSEvent *)theEvent @@ -462,7 +466,7 @@ static float scrollerWidth; amount = -amount; } point.y = clipViewBounds.origin.y - amount; - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } @@ -490,7 +494,7 @@ static float scrollerWidth; amount = -amount; } point.y = clipViewBounds.origin.y + amount; - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } /** @@ -534,7 +538,7 @@ static float scrollerWidth; amount = -amount; } point.y = clipViewBounds.origin.y - amount; - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } /** @@ -577,7 +581,7 @@ static float scrollerWidth; amount = -amount; } point.y = clipViewBounds.origin.y + amount; - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } - (void) _doScroll: (NSScroller*)scroller @@ -686,7 +690,7 @@ static float scrollerWidth; /* scrollToPoint will call reflectScrollerClipView, and that will * update scrollers, rulers and headers */ - [_contentView scrollToPoint: point]; + [_contentView _scrollToPoint: point]; } //