• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Force instant re-display after scrollRectToVisible
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Force instant re-display after scrollRectToVisible


  • Subject: Force instant re-display after scrollRectToVisible
  • From: Allan Odgaard <email@hidden>
  • Date: Thu, 11 Mar 2004 06:22:55 +0100

I am drawing onto an NSView by first using cacheImageInRect: (to make a backup of the the region I will draw on top), and then lockFocus, draw, unlockFocus and flushWindow.

The view is embedded in a scroll view, and at times I need to scroll before drawing, so what I wanted to do was something like this:
[win restoreCachedImage]; // remove old drawing
[view scrollRectToVisible:aRect]; // scroll view
[win disableFlushWindow]; // disable flushing
[view displayIfNeeded]; // redraw newly exposed regions caused by scroll
[win enableFlushWindow]; // re-enaable flushing
[win cacheImageInRect:otherRect]; // backup the region we'll draw onto
[view lockFocus];
...
[view unlockFocus];
[win flushWindow]; // flush window

Unfortunately it does not work as expected -- the problem is that after scrollRectToVisible: there is no dirty region to redraw, since scrolling has not taken place yet. So I end up drawing the new stuff in the view before it scrolls, and then it will scroll afterwards.

Is there anyway to make the clipview/scrollview scroll instantly?


As a workaround I implemented my own scrollRectToVisible: by using NSCopyBits(), translateOriginToPoint: and setNeedsDisplayInRect:. This made the above work, but a new problem arose, namely that the clipview/scrollview do not observe the changes made to my views bounds, when using translateOriginToPoint:, so the scrollers do not update.

I have enabled that the view should post bounds-changed notifications when using translateOriginToPoint: and I have also tried to send reflectScrolledClipView: to the enclosing scroll view (after translating the origin), but w/o luck.

I do not see any methods in NSClipView to inform it that I have translated the origin of my view, is it at all possible to use this method when under the control of a clipview/scrollview?

I guess my next workaround could be to replace the clipview used by the scrollview (to make it react on the change in bounds, resulting from the translating), but I wonder if I am not going down the wrong road here? since it doesn't look trivial to make an IB created scrollview use a different clipview, also, the documentation for some methods of the scrollview class imply that the scrollview will check if it is actually working with a real clipview, so it would seem that conforming to the interface of a clipview is not enough, I would probably need to subclass NSClipView (which I would like to avoid, so that the superclass doesn't e.g. do work when receiving bound and/or frame change notification (although I *might* be able to overwrite all methods to avoid such things).


For the records, I am aware of the possibility to modify the view's drawRect: implementation. Unfortunately this is not an option.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Cocoa Programming for Mac OS X book source code?
  • Next by Date: Re: mmalc's Controller examples: Bindings with graphics
  • Previous by thread: Display an app-less floating window without taking focus
  • Next by thread: Re: Thread safety of NSPipe
  • Index(es):
    • Date
    • Thread