• 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
Re: How to make NSWindow redraw vacated rects "ifNeeded"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make NSWindow redraw vacated rects "ifNeeded"?


  • Subject: Re: How to make NSWindow redraw vacated rects "ifNeeded"?
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sun, 8 Apr 2007 20:12:06 -0700


On Apr 8, 2007, at 19:43, Jerry Krinock wrote:

On 2007 Apr, 08, at 15:46, Adam R. Maxwell wrote:

Did you try [[window contentView] setNeedsDisplay:YES]? You need to tell the box's superview to redisplay, or else the displayIfNeeded won't have any dirty rects to redraw (as far as I understand).

I just tried that now and indeed, it works. Furthermore, as Andrew suggested, the -setNeedsDisplay messages are unnecessary when your suggestion is used.


However, I don't think that your suggested idiom:

   [[window contentView] setNeedsDisplay:YES] ;
   [window displayIfNeeded] ;

is any more efficient than simply:

   [window display] ;

because the documentation for -setNeedsDisplay says "If YES, marks the receiver’s entire bounds as needing display". Think about it...if you mark a "whole bounds" as needing display (whether it needs it or not), and then display the parts that you marked, well, that's the same as just displaying the whole damned window, right!

If you use setNeedsDisplay: it can be displayed on the next pass through the runloop, so you can send multiple setNeedsDisplay: messages without actually drawing anything.


You can make it more efficient, certainly, using NSUnionRect, -[NSView opaqueAncestor] and other means; I have no idea how your view hierarchy is set up.

In my actual project, I recalculate the whole window layout and have lots of subviews to consider, so if this is the best answer, I believe I'll put coding efficiency over computing efficiency, and just send [window display] at the end, that is, "display the whole damned window whether it needs it or not". Maybe someday Apple will do some optimization under the hood to figure out what "really" needs to be displayed, or maybe they already have, since these methods date back to Mac OS 10.0.

Apple has thought about this and optimized it. Have you read <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Optimizing/chapter_7_section_4.html >? It describes this quite well, and says that using -display should generally be avoided.


-- adam_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to make NSWindow redraw vacated rects "ifNeeded"?
      • From: Jerry Krinock <email@hidden>
References: 
 >How to make NSWindow redraw vacated rects "ifNeeded"? (From: Jerry Krinock <email@hidden>)
 >Re: How to make NSWindow redraw vacated rects "ifNeeded"? (From: Andrew Farmer <email@hidden>)
 >Re: How to make NSWindow redraw vacated rects "ifNeeded"? (From: Jerry Krinock <email@hidden>)
 >Re: How to make NSWindow redraw vacated rects "ifNeeded"? (From: "Adam R. Maxwell" <email@hidden>)
 >Re: How to make NSWindow redraw vacated rects "ifNeeded"? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Multiple developers and nib files
  • Next by Date: Re: Multiple developers and nib files
  • Previous by thread: Re: How to make NSWindow redraw vacated rects "ifNeeded"?
  • Next by thread: Re: How to make NSWindow redraw vacated rects "ifNeeded"?
  • Index(es):
    • Date
    • Thread