Replaced deprecated Cocoa methods
This commit is contained in:
parent
4c7edbcaf8
commit
7b20093650
@ -343,35 +343,34 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
-(NSPoint)position
|
-(NSPoint)position
|
||||||
{
|
{
|
||||||
// First, get the top left corner of the view in its own base system
|
// Note: since 10.7 the conversion API works with NSRect
|
||||||
const NSPoint origin = [m_oglView frame].origin;
|
// instead of NSPoint. Therefore we use a NSRect but ignore
|
||||||
const NSSize size = [m_oglView frame].size;
|
// its width and height.
|
||||||
const NSPoint topLeftCornerOfView = NSMakePoint(origin.x, origin.y + size.height);
|
|
||||||
const NSPoint positionInView = [m_oglView convertPointToBacking:topLeftCornerOfView];
|
|
||||||
|
|
||||||
// Then, convert it to window base system
|
// Position of the bottom-left corner in the different coordinate systems:
|
||||||
const NSPoint positionInWindow = [m_oglView convertPoint:positionInView toView:nil];
|
NSRect corner = [m_oglView frame]; // bottom left; size is ignored
|
||||||
// here nil denotes the window containing the view
|
NSRect view = [m_oglView convertRectToBacking:corner];
|
||||||
|
NSRect window = [m_oglView convertRect:view toView:nil];
|
||||||
|
NSRect screen = [[m_oglView window] convertRectToScreen:window];
|
||||||
|
|
||||||
// Next, convert it to the screen base system
|
// Get the top-left corner in screen coordinates
|
||||||
const NSPoint positionInScreen = [[m_oglView window] convertBaseToScreen:positionInWindow];
|
CGFloat x = screen.origin.x;
|
||||||
|
CGFloat y = screen.origin.y + [m_oglView frame].size.height;
|
||||||
|
|
||||||
// Finally, flip for SFML window coordinate system
|
// Flip y-axis (titlebar was already taken into account above)
|
||||||
// Don't forget to discard the title bar !
|
y = [self screenHeight] - y;
|
||||||
const NSPoint positionInSFML = NSMakePoint(positionInScreen.x,
|
|
||||||
([self screenHeight] - [self titlebarHeight]) - positionInScreen.y);
|
|
||||||
|
|
||||||
return positionInSFML;
|
return NSMakePoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////.
|
////////////////////////////////////////////////////////
|
||||||
-(void)setWindowPositionToX:(int)x Y:(int)y
|
-(void)setWindowPositionToX:(int)x Y:(int)y
|
||||||
{
|
{
|
||||||
NSPoint point = NSMakePoint(x, y);
|
NSPoint point = NSMakePoint(x, y);
|
||||||
|
|
||||||
// Flip for SFML window coordinate system.
|
// Flip for SFML window coordinate system and take titlebar into account
|
||||||
point.y = [self screenHeight] - point.y;
|
point.y = [self screenHeight] - point.y + [self titlebarHeight];
|
||||||
|
|
||||||
// Place the window.
|
// Place the window.
|
||||||
[m_window setFrameTopLeftPoint:point];
|
[m_window setFrameTopLeftPoint:point];
|
||||||
@ -593,3 +592,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user