bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: Bouncy NSView scrolling


From: Andrew Ruder
Subject: PATCH: Bouncy NSView scrolling
Date: Sat, 28 Aug 2004 22:14:52 -0500
User-agent: Mozilla Thunderbird 0.7.1 (X11/20040626)

Hello,

When [NSView scrollToRect: (NSRect)aRect] is called with aRect being bigger than the visibleRect, the current behavior is that the first time it is called, it will scroll to the origin of the aRect, and the next time it will scroll to the top-right of aRect.

This means when you have a textview and a clip that is slightly too small, you'll get the text typed in the textview bouncing up and down every other letter. Attached is a patch to fix and a test application displaying the problem.

Thanks,
Andrew Ruder

Attachment: TestFieldEditor.tar.bz2
Description: application/bzip

Index: gui/ChangeLog
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/ChangeLog,v
retrieving revision 1.2354
diff -u -r1.2354 ChangeLog
--- gui/ChangeLog       28 Aug 2004 14:41:16 -0000      1.2354
+++ gui/ChangeLog       29 Aug 2004 02:41:53 -0000
@@ -1,3 +1,9 @@
+2004-08-28  Andrew Ruder <aeruder@ksu.edu>
+       * Source/NSView.m (-scrollToRect:): If aRect is larger than
+       the visible rectangle, make it always scroll to see the part
+       including the origin instead of bouncing back and forth between
+       the origin and the opposite corner.
+
 2004-08-28 10:34  Gregory John Casamento <greg_casamento@yahoo.com>
 
        * Source/GSNibTemplates.m: Added implementation of method
Index: gui/Source/NSView.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSView.m,v
retrieving revision 1.226
diff -u -r1.226 NSView.m
--- gui/Source/NSView.m 7 Jul 2004 21:25:42 -0000       1.226
+++ gui/Source/NSView.m 29 Aug 2004 02:41:55 -0000
@@ -2400,8 +2400,12 @@
        && (NSMaxX(vRect) >= NSMaxX(aRect))))
        {
          shouldScroll = YES;
-         if (aRect.origin.x < vRect.origin.x)
-           aPoint.x = aRect.origin.x;
+         if ((aRect.origin.y < vRect.origin.y)
+          && !((NSMinX(aRect) <= NSMinX(aRect))
+           && (NSMaxX(aRect) >= NSMaxX(aRect))))
+           {
+             aPoint.y = aRect.origin.y;
+           }
          else
            {
              float     visibleRange = vRect.origin.x + vRect.size.width;
@@ -2415,8 +2419,12 @@
        && (NSMaxY(vRect) >= NSMaxY(aRect))))
        {
          shouldScroll = YES;
-         if (aRect.origin.y < vRect.origin.y)
-           aPoint.y = aRect.origin.y;
+         if ((aRect.origin.y < vRect.origin.y)
+          && !((NSMinY(aRect) <= NSMinY(aRect))
+           && (NSMaxY(aRect) >= NSMaxY(aRect))))
+           {
+             aPoint.y = aRect.origin.y;
+           }
          else
            {
              float     visibleRange = vRect.origin.y + vRect.size.height;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]