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

Re: how to redraw a view

2010-11-26 Thread Artemiy Pavlov
Hi all, sorry for a late reply, my e-mail was in moderation queue for almost a day, but I was able to find an answer in a few hours after I sent it. This did the trick for me, all is working well now: [super setNeedsDisplay:YES] P.S. This is in Mac OS X. On 26 Nov 2010, at 17:52, Uli Kust

Re: how to redraw a view

2010-11-26 Thread Uli Kusterer
On Nov 24, 2010, at 6:50 PM, Artemiy Pavlov wrote: > I have a view whose drawRect method draws a plot according to a few > parameters which are global variables. When I change these variables > according to the user input, I want to update that plot, so I need the > drawRect method of my view to

Re: how to redraw a view

2010-11-26 Thread Chris Hanson
On Nov 24, 2010, at 9:50 AM, Artemiy Pavlov wrote: > I have a view whose drawRect method draws a plot according to a few > parameters which are global variables. When I change these variables > according to the user input, I want to update that plot, so I need the > drawRect method of my view

Re: how to redraw a view

2010-11-25 Thread Andy Lee
On Nov 24, 2010, at 12:50 PM, Artemiy Pavlov wrote: > I tried [self setNeedsDisplay] or [MyView setNeedsDisplay] but this doesn't > work. Try [self setNeedsDisplay:YES]. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not po

how to redraw a view

2010-11-25 Thread Artemiy Pavlov
Hi all! I have a view whose drawRect method draws a plot according to a few parameters which are global variables. When I change these variables according to the user input, I want to update that plot, so I need the drawRect method of my view to be called. I tried [self setNeedsDisplay] o