• 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 can I implement labels without the overhead of an NSTextField?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I implement labels without the overhead of an NSTextField?


  • Subject: Re: How can I implement labels without the overhead of an NSTextField?
  • From: Jonathan Jackel <email@hidden>
  • Date: Sun, 12 Dec 2004 10:55:22 -0500

Presumably you are simply using [string drawAtPoint:withAttributes:] or [string drawInRect:withAttributes:] or the equivalent methods in NSAttributedString. The AppKit string drawing methods are not intended for drawing and redrawing lots of strings. They are fine for a few static labels, but not for a huge number of labels that have to be redrawn a lot.

You should get much better performance out of the "glyph" methods in NSBezierPath. If you want to understand how they work, I strongly recommend getting a copy of "Cocoa Programming" by Anguish, Buck & Yacktman and go straight to chapter 14.

Jonathan


On Dec 12, 2004, at 4:23 AM, email@hidden wrote:

Summary:

I put an NSImageView inside an NSScrollView. It scrolls smoothly. I put a large number (300) of labels inside an NSScrollView. It scrolls slowly. Why is this happening, and what can I do to change it?

Details:

I have an application that needs to display a large number of labels on screen at once. These labels must be scrolled, so I decided to use an NSScrollView. I first tested the NSScrollView out with an image, out of curiousity. It worked fine; the scrolling was smooth and responsive. Then I tested it out with a large number of labels. The scrolling slowed down considerably. This suprised me, as I thought a large number of labels would scroll as fast as an image. After all, I could display an image with the text of the 300 labels, and it would look exactly the same to the user. Then I discovered that labels in Cocoa are actually non-editable NSTextViews. Could this be the cause of the problem? Either way, how would I go about speeding up the scrolling?
Making each label into an NSImageView wouldn't work. I tried putting 300 NSImageViews onto the window in place of 300 labels, and it was even slower. I suspect that generating a new transparent image (containing the text of each label) to cover the entire window, upon each movement of the scrollbar, would be just as slow. Perhaps I would be able to override the NSTextField (or NSImageView) class to create a "lite" version that incurred less overhead? Any pointers on how to do this would be appreciated, as I am new to both Cocoa and Object Oriented Programming.
One last thing - the 300 labels are scattered about the screen, and are not in orderly rows and columns.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >How can I implement labels without the overhead of an NSTextField? (From: email@hidden)

  • Prev by Date: Seeking advice on NSLock usage
  • Next by Date: Re: Cocoa FTP Server
  • Previous by thread: How can I implement labels without the overhead of an NSTextField?
  • Next by thread: separate undo manager for textview in document app
  • Index(es):
    • Date
    • Thread