• 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: displaying a calculated image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: displaying a calculated image


  • Subject: Re: displaying a calculated image
  • From: Cameron Hayne <email@hidden>
  • Date: Sun, 26 May 2002 08:55:23 -0400

I had asked a while ago about how best to display an image which is the result of an ongoing calculation in another thread. I have now accomplished what I had hoped for by using NSTimer to tell the view to redisplay at fixed intervals and by doing the drawing in a subclass of NSView. One problem that I had to overcome was that NSSlider does not seem to allow processing of timer events when the mouse is held down on the slider. To fix this (which might be considered a bug in NSSlider ?), I use a subclass of NSSlider which sends a stream of Periodic Events when the mouse is down.

You can get my sample code at:
http://www.hayne.net/MacDev/ImageCalc/
This illustrates several aspects of Cocoa programming:
* calculation in a separate thread
* synchronizing use of shared variables via NSLock
* image drawn via NSBitmapImageRep in a subclass of NSView
* regular display updates via NSTimer
* subclass of NSSlider that allows timer events while mouse is down
* auxiliary information displayed in an NSDrawer

I would be very interested in hearing any comments on the above code:
- better (simpler/faster) ways to do it ?
- opinions on my use of MVC ?
... Cameron
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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.

  • Follow-Ups:
    • Re: displaying a calculated image
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: How to detect busy files?
  • Next by Date: Re: displaying a calculated image
  • Previous by thread: Re: How to detect busy files?
  • Next by thread: Re: displaying a calculated image
  • Index(es):
    • Date
    • Thread