[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-patches
Subject:    Re: [patch] New soft scrolling for NGLayout
From:       Jordan Mendelson <jordy () wserv ! com>
Date:       1998-10-27 16:44:33
[Download RAW message or body]

Sorry, didn't realize I was posting the wrong types of diffs.. here it is the
context sensitive version.

Jordan Mendelson wrote:

> Here is a patch to do IE4 style soft scrolling with NGLayout.
>
> This is basically the same as before except it uses UpdateView() and
> I've fixed a few timing issues. This requires a new copy of NGLayout
> where UpdateView() has been updated to work with syncronous repaints
> requests.
>
> Please note that this will only modify the keys page up/page down right
> now. Really, the line increment needs to be set to 4x whatever it is
> right now in order for this patch to make it scroll. Scrollbar clicking
> is also not implemented because it requires a patch in a completely
> different place and I'm not completely sure that that code won't be
> moved into nsScrollingView::HandleEvent().
>

Jordan

--
Jordan Mendelson     : http://jordy.wserv.com
Web Services, Inc.   : http://www.wserv.com


["nglayout.softscroll2.diff" (text/plain)]

Index: mozilla/view/src/nsScrollingView.cpp
===================================================================
RCS file: /cvsroot/mozilla/view/src/nsScrollingView.cpp,v
retrieving revision 3.61
diff -c -r3.61 nsScrollingView.cpp
*** nsScrollingView.cpp	1998/10/27 03:36:49	3.61
--- nsScrollingView.cpp	1998/10/27 16:44:06
***************
*** 1236,1243 ****
  // XXX This doesn't let the scrolling code slide the bits on the
  // screen and damage only the appropriate area
  
- // XXX doesn't smooth scroll
- 
  NS_IMETHODIMP
  nsScrollingView :: ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
  {
--- 1236,1241 ----
***************
*** 1269,1307 ****
        }
  
        // Move the scrollbar's thumb
  
!       PRUint32  oldpos = mOffsetY;
!       nscoord dy;
  
!       PRUint32 newpos =
!         NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
!       scrollv->SetPosition(newpos);
  
!       dy = oldpos - newpos;
  
-       // Update the scrolled view's position
        nsIView* scrolledView;
        GetScrolledView(scrolledView);
-       if (nsnull != scrolledView)
-       {
-         scrolledView->SetPosition(-aX, -aY);
-         mOffsetX = aX;
-         mOffsetY = aY;
-       }
  
!       AdjustChildWidgets(this, scrolledView, 0, 0, t2p);
  
!       // Damage the updated area
!       nsRect  r;
  
!       r.x = 0;
!       r.y = aY;
!       mClipView->GetDimensions(&r.width, &r.height);
!       if (nsnull != scrolledView)
!       {
!         mViewManager->UpdateView(scrolledView, r, aUpdateFlags);
!       }
  
        NS_RELEASE(scrollv);
      }
      NS_RELEASE(win);
--- 1267,1330 ----
        }
  
        // Move the scrollbar's thumb
+       nsRect   r;
+       nscoord  dy;
+       PRUint32 oldpos = mOffsetY;
+       PRInt32  countIncr, perIncr;
+       PRUint32 curpos, diffTime;
+       PRUint32 newpos = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
+       PRTime   startTime;
+ 
+       dy = newpos - oldpos;
+ 
+       countIncr = dy * 10 / clipSize.height;
  
!       if (countIncr < 0)
!         countIncr = -countIncr;
  
!       if (countIncr == 0)
!         countIncr++;
  
!       perIncr = dy / countIncr;
!       curpos = oldpos + (dy % countIncr);
  
        nsIView* scrolledView;
        GetScrolledView(scrolledView);
  
!       mClipView->GetDimensions(&r.width, &r.height);
  
!       while (countIncr--) {
!         startTime = PR_Now();
  
!         curpos += perIncr;
!         newpos = curpos;
!         scrollv->SetPosition(newpos);
! 
!         aY = curpos;
!         dy = oldpos - newpos;
! 
!         // Update the scrolled view's position
!         if (nsnull != scrolledView)
!         {
!           scrolledView->SetPosition(-aX, -aY);
!           mOffsetX = aX;
!           mOffsetY = aY;
!         }
! 
!         AdjustChildWidgets(this, scrolledView, 0, 0, t2p);
  
+         // Damage the updated area
+         r.x = 0;
+         r.y = aY;
+         if (nsnull != scrolledView)
+           mViewManager->UpdateView(scrolledView, r, NS_VMREFRESH_IMMEDIATE);
+ 
+         // 10 ms delay/iteration for slowing down animation on speed demons
+         diffTime = (PRUint32)(PR_Now() - startTime);
+         if (diffTime < 1000 && countIncr)
+           PR_Sleep(PR_MicrosecondsToInterval(1000 - diffTime));
+ 
+       }
        NS_RELEASE(scrollv);
      }
      NS_RELEASE(win);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic