Re: How to redraw a view in slow-motion

2011-06-25 Thread Matthias Arndt
Hi guys, I'd just like to give you some final feedback, how I was able to solve my problem, drawing a view with some thousand paths in a slow-motion. You all have contributed to this approach, which is a mixture of your suggestions, and works pretty well so far. The basic idea: 1. make the d

Re: How to redraw a view in slow-motion

2011-06-20 Thread Ken Tozier
Hi Matthias I got frustrated with my own coding and thought I'd take another crack at your animation problem as a diversion... Here's the result, enjoy -Ken #define DRAW_LINES_BLOCK_SIZE 100 #define DRAW_LINES_BLOCK_DELAY 1 - (void) setFrame:(NSRect) inRect { // I'm assuming you st

Re: How to redraw a view in slow-motion

2011-06-20 Thread Matthias Arndt
Hi Graham, hi Uli, guys, you're gems! Thanks for all the input. Currently it's too early to dive into some high sophisticated optimization, and with Graham's info I'm confident the view's back buffer will work for me. Am 20. Jun 2011 um 08:59 schrieb Graham Cox : > The view is already doing th

Re: How to redraw a view in slow-motion

2011-06-20 Thread Graham Cox
On 20/06/2011, at 4:47 PM, Matthias Arndt wrote: > another idea is to cache the last output in a bitmap, redraw it in the next > iteration, and update the cache after resizing. But I'll look into this only > if a simple redraw won't be sufficient: The view is already doing this for you. Every

Re: How to redraw a view in slow-motion

2011-06-19 Thread Uli Kusterer
On 19.06.2011, at 14:46, Matthias Arndt wrote: > 1. Sleeping the drawing loop in drawRect: (or make the runLoop wait for some > time) and use [... flushGraphics]: Freezes the GUI, as the app is > single-threaded sleep() will block the thread you're in. That's never a good idea (unless the alte

Re: How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
Hi Graham, Am 20. Jun 2011 um 02:24 schrieb Graham Cox : > Your (4) is looking like the best approach - use a timer to schedule a > periodic update of the view, and during that update, draw only some portion > of the content on top of what you've drawn already. That leaves the issue of > view

Re: How to redraw a view in slow-motion

2011-06-19 Thread Graham Cox
On 19/06/2011, at 10:46 PM, Matthias Arndt wrote: > In a document-based app my custom view draws some thousand paths in drawRect: > with a good performance. Now I'd like to offer a "slow-motion" animation, so > the user can actually watch the paths being drawn (not each single one, but > e. g.

Re: How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
Am 19.06.2011 um 19:05 schrieb cocoa-dev-requ...@lists.apple.com: > If you keep the animation short (say 1.5 to 2 seconds) the freezes might not > be too irksome to the user [...] CALayer look like an attractive option. Even with only 0.01 seconds sleep after drawing each path the UI froze comp

Re: How to redraw a view in slow-motion

2011-06-19 Thread Ken Tozier
If you keep the animation short (say 1.5 to 2 seconds) the freezes might not be too irksome to the user, but eliminating them altogether would require adding NSOperationQueues and NSInvocationOperations to the mix and this is even too hokey for me :) With CALayers, you could create 10 different

Re: How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
Hi Ken, Am 19.06.2011 um 15:40 schrieb Ken Tozier: > - (void)observeValueForKeyPath:(NSString *) inKeyPath > ofObject:(id) inObject > change:(NSDictionary *) inChange > context:(void *) inContext > { > if ([inKeyPath isEqualToString: @"subsetRange"

Re: How to redraw a view in slow-motion

2011-06-19 Thread Ken Tozier
Have you tried CALayer/CAAnimation? They have a lot of power and are specifically designed for animation. If for some reason, you don't want to go that route, the following is a bit hokey, but it might work Add a "subsetRange" property to your view class Create a "setSubsetRange:(NSRange) inRan

How to redraw a view in slow-motion

2011-06-19 Thread Matthias Arndt
In a document-based app my custom view draws some thousand paths in drawRect: with a good performance. Now I'd like to offer a "slow-motion" animation, so the user can actually watch the paths being drawn (not each single one, but e. g. in steps of 100 paths per sec). I though of several approa