Re: Resizing windows *and childs* with animate: YES
Re: Resizing windows *and childs* with animate: YES
- Subject: Re: Resizing windows *and childs* with animate: YES
- From: Yann Bizeul <email@hidden>
- Date: Tue, 11 May 2004 23:34:42 +0200
Regarding the question below, I tried to implment my own animation
method, via a NSWindow category.
This method calculate intermediate frames according to the total
duration and where we are in the timeline.
This works, but the result is visualy ugly, it is not smooth like the
real animate: made by Apple.
Here is the category, any light would be appreciated !
@implementation NSWindow (setFrameWithChildWindows)
- (void)setFrameWithChildWindows:(NSRect)aFrame display:(BOOL)display
animate:(BOOL)animate;
{
if (animate)
{
NSTimeInterval start;
NSTimeInterval stop;
float totalTime = [self animationResizeTime:aFrame];
NSRect originFrame = [self frame];
float factor = 0.0;
start = [ NSDate timeIntervalSinceReferenceDate ];
while (factor < 1)
{
stop = [ NSDate timeIntervalSinceReferenceDate ];
factor = (stop - start) / totalTime;
factor = factor < 1 ? factor : 1;
NSRect currentRect =
NSMakeRect(originFrame.origin.x+(aFrame.origin.x-
originFrame.origin.x)*factor,
originFrame.origin.y+(aFrame.origin.y-originFrame.origin.y)*factor,
originFrame.size.width+(aFrame.size.width-
originFrame.size.width)*factor,
originFrame.size.height+(aFrame.size.height-
originFrame.size.height)*factor
);
NSLog(@"%f : %f
%f",factor,currentRect.origin.x,(currentRect.origin.y+currentRect.size.h
eight));
[ self setFrame: currentRect display:display animate: NO];
[ self setChildsRect:currentRect display:display animate:NO];
}
}
[ self setFrame: aFrame display:display animate: animate];
[ self setChildsRect:aFrame display:display animate:animate];
}
- (void)setChildsRect:(NSRect)aRect display:(BOOL)display
animate:(BOOL)animate;
{
NSArray *childWindows = [self childWindows];
NSEnumerator *e = [childWindows objectEnumerator];
NSWindow *w;
while (w = [e nextObject])
[w setFrameWithChildWindows:aRect display:display animate:animate];
}
@end
Le 11 mai 04, ` 17:38, Yann Bizeul a icrit :
>
Hi list,
>
>
I used to use AJRScrollView to make NS(Text/Table)View look clean when
>
in a semi-transparent window.
>
It worked fine, but users using Thousands of colors did have problems
>
with this.
>
>
So I decided to find a better solution and people told me about
>
childWindows to be an issue.
>
>
So What I did is have my NSTextView with a transparent background and
>
all stuffs around on a window, and I created a childWindow with just my
>
Background.
>
>
It works not so bad, the only problem I have now, is resizing both in
>
the same time : I use
>
[ myWindow setFrame: frameRect display: displayFlag animate:
>
animationFlag ];
>
>
but this call is synchronous, and my windows does resize one after the
>
other.
>
>
Question are :
>
How to get the animated resize synchronous with multiple windows ?
>
If this is not possible, what would be the overhead of making visual
>
effect by myself with multiple calls to setFrame ... animate: NO
>
>
One more thing :
>
How would you people, handle auto-resizing of items when they get out
>
of bounds. When my window gets its smallest side, items inside are
>
forced to go out of bounds, and when I set it to big size again, those
>
items are not in the same place. Sorry if I'm not clear !
>
>
--
>
Yann Bizeul - yann at tynsoe.org
>
http://projects.tynsoe.org/
>
_______________________________________________
>
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.
>
>
>
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
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.