discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redraw view in setFrame?


From: Lundberg, Johannes
Subject: Redraw view in setFrame?
Date: Thu, 31 Oct 2013 11:07:27 +0900

Hi All!

I've been playing with the NSViewAnimation class and discovered that the view is not redrawn between animation steps.

First I was thinking that a call could be made to [_target setNeedsDisplay] at each animation step in NSViewAnimation.m but wouldn't it be better to do that in NSView's setFrame?

Whenever you change the frame of a view don't you want it to always redraw anyway?

This seems to be the case on Cocoa. I've attached a Xcode 5 project example app that shows that view is redrawn without calling setNeedsDisplay when changing frame. (not sure if the same applies to Cocoa Touch though...)

Another thing is that when moving or shrinking a view setNeedsDisplay needs to be called before and after the new frame is set otherwise the area of the old frame view won't be cleared.

Have this kind of code in your app is not so elegant.

[view setNeedsDisplay:YES];
view.frame = newFrame;
[view setNeedsDisplay:YES];

I propose that we move that into NSView. I made a dirty fix that may not be the optimal way to do it but it shows what I want to do with this proposal.


in NSView's - (void) setFrame: (NSRect)frameRect i added two calls to setNeedsDisplay like this:

  if (changedSize == YES || changedOrigin == YES)
    {
      [self setNeedsDisplay:YES];
      [self _setFrameAndClearAutoresizingError: frameRect];
      [self setNeedsDisplay:YES];
      ......

What do you guys think?

--
Johannes Lundberg
BRILLIANTSERVICE CO., LTD.

Attachment: RedrawTest.zip
Description: Zip archive


reply via email to

[Prev in Thread] Current Thread [Next in Thread]