Flipping over coordinate conversion
Flipping over coordinate conversion
- Subject: Flipping over coordinate conversion
- From: James Bucanek <email@hidden>
- Date: Wed, 26 Apr 2006 09:56:06 -0700
With the generous help of Ricky Sharp and others, I now have a spiffy semi-transparent floating child window that hovers over my NSTableView. The implementation went pretty smoothly, save for one mystery that I'm hoping someone here can explain to me -- or explain what I'm doing wrong.
I need my child window (which exists in screen coordinates) to be placed exactly over the frame of the table view. To accomplish this transformation, I wrote the following:
+ (NSRect)screenRectEquivelentOfView:(NSView*)view
{
NSWindow* viewWindow = [view window];
NSView* contentView = [viewWindow contentView];
NSRect frame = [view frame];
frame.origin.y += frame.size.height; // why is this needed?
frame.origin = [[view superview] convertPoint:frame.origin toView:contentView];
frame.origin = [viewWindow convertBaseToScreen:frame.origin];
return (frame);
}
The problem is that the frame returned by [view frame] has an origin of {0.0,0.0}. I assume this is because the NSScrollView its imbedded in uses flipped coordinates.
While I have a feeble grasp of flipped coordinate systems, what I can't figure out is this: Shouldn't convertPoint:toView: take flipped coordinate systems into account and convert the flipped coordinates of [view superview] and correctly translate it into the non-flipped coordinates of [viewWindow contentView]?
Ignoring the "flippedness" of coordinate systems seems like a gross bug in convertPoint:toView:. Which, naturally, leads me to believe that I've written this wrong but I can't for the life of me figure out what I've missed.
--
James Bucanek
_______________________________________________
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