NSView's -frame
NSView's -frame
- Subject: NSView's -frame
- From: Dario Mèndez Musicò <email@hidden>
- Date: Tue, 25 Apr 2006 15:12:31 +0200
I need to get an NSView's frame in order to set up an NSViewAnimation
to smoothly resize it even if the window is resized and therefore the
NSView's size changes as well.
In order to achieve this I've implemented a -windowsDidResize method
in my window's delegate wich sets up the NSViewAnimation by getting
the views frames and expanding/contracting them.
However, the second view sometimes does not correctly set the right
initial and last sizes.
NSLogging the process showed this only works if the view is visible
(one of the two views is sometimes hidden because in another tab).
How am I supposed to get an NSView's frame when it's not being
displayed?
Or there is a better way to perform the NSViewAnimation without
having to set NSRects every time?
The code which sets up the animations is this:
//Set up beginning and ending keyframes
NSRect modListFirstRect;
NSRect modListLastRect;
modListLastRect = [modList frame];
modListFirstRect = [modList frame];
if (currentMode == 0) {
//We are growing it by 32 pixels
modListFirstRect.size.height -= 32;
modListFirstRect.origin.y += 32; //Since coordinates start from the
bottom left we have to shift it by the same ammount of pixels
} else {
//shrinking instead
modListLastRect.size.height += 32;
modListLastRect.origin.y -= 32; //Since coordinates start from the
bottom left we have to shift it by the same ammount of pixels
}
NSDictionary *modListDic = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: modList, [NSValue valueWithRect:
modListFirstRect], [NSValue valueWithRect: modListLastRect], nil]
forKeys: [NSArray arrayWithObjects: NSViewAnimationTargetKey,
NSViewAnimationStartFrameKey, NSViewAnimationEndFrameKey, nil]];
modListExpandAnimation = [[NSViewAnimation alloc]
initWithViewAnimations: [NSArray arrayWithObject: modListDic]];
modListDic = [NSDictionary dictionaryWithObjects: [NSArray
arrayWithObjects: modList, [NSValue valueWithRect: modListLastRect],
[NSValue valueWithRect: modListFirstRect], nil] forKeys: [NSArray
arrayWithObjects: NSViewAnimationTargetKey,
NSViewAnimationStartFrameKey, NSViewAnimationEndFrameKey, nil]];
modListContractAnimation = [[NSViewAnimation alloc]
initWithViewAnimations: [NSArray arrayWithObject: modListDic]];
NSLog (@"first: %f,%f - %fx%f", modListFirstRect.origin.x,
modListFirstRect.origin.y, modListFirstRect.size.width,
modListFirstRect.size.height);
NSLog (@"last: %f,%f - %fx%f", modListLastRect.origin.x,
modListLastRect.origin.y, modListLastRect.size.width,
modListLastRect.size.height);
}
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden