mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Updated Mac OS X code according to 15e9d999b3
commit
This commit is contained in:
parent
15e9d999b3
commit
2680d3df65
@ -51,8 +51,8 @@ struct SFMLmainWindow
|
||||
sprite.SetOrigin(size / 2.f);
|
||||
sprite.Scale(0.3, 0.3);
|
||||
|
||||
unsigned int ww = renderWindow.GetWidth();
|
||||
unsigned int wh = renderWindow.GetHeight();
|
||||
unsigned int ww = renderWindow.GetSize().x;
|
||||
unsigned int wh = renderWindow.GetSize().y;
|
||||
sprite.SetPosition(sf::Vector2f(ww, wh) / 2.f);
|
||||
|
||||
text.SetColor(sf::Color::White);
|
||||
@ -104,7 +104,7 @@ struct SFMLmainWindow
|
||||
{
|
||||
if (!self.initialized)
|
||||
{
|
||||
// Init the 1st SFML render area.
|
||||
// Init the SFML render area.
|
||||
self.mainWindow = new SFMLmainWindow(self.sfmlView);
|
||||
self.mainWindow->text.SetString([self.textField.stringValue tostdwstring]);
|
||||
self.visible = YES;
|
||||
@ -141,7 +141,7 @@ struct SFMLmainWindow
|
||||
self.sfmlView = nil;
|
||||
self.textField = nil;
|
||||
|
||||
delete self.mainWindow;
|
||||
delete (SFMLmainWindow *) self.mainWindow;
|
||||
self.mainWindow = 0;
|
||||
self.renderTimer = nil;
|
||||
|
||||
|
@ -195,6 +195,18 @@
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
-(NSPoint)position
|
||||
{
|
||||
NSPoint pos = [myView frame].origin;
|
||||
|
||||
// Flip screen coodinates
|
||||
float const screenHeight = NSHeight([[[myView window] screen] frame]);
|
||||
pos.y = screenHeight - pos.y;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////.
|
||||
-(void)setWindowPositionToX:(unsigned int)x Y:(unsigned int)y
|
||||
{
|
||||
@ -202,6 +214,12 @@
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
-(NSSize)size
|
||||
{
|
||||
return [myView frame].size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)resizeTo:(unsigned int)width by:(unsigned int)height
|
||||
{
|
||||
|
@ -289,6 +289,18 @@
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
-(NSPoint)position
|
||||
{
|
||||
NSPoint pos = [myOGLView frame].origin;
|
||||
|
||||
// Flip for SFML window coordinate system.
|
||||
pos.y = [self screenHeight] - pos.y;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////.
|
||||
-(void)setWindowPositionToX:(unsigned int)x Y:(unsigned int)y
|
||||
{
|
||||
@ -302,6 +314,13 @@
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(NSSize)size
|
||||
{
|
||||
return [myOGLView frame].size;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)resizeTo:(unsigned int)width by:(unsigned int)height
|
||||
{
|
||||
|
@ -55,20 +55,12 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
||||
|
||||
// We have a window.
|
||||
myDelegate = [[SFWindowController alloc] initWithWindow:nsHandle];
|
||||
|
||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||
myWidth = [[nsHandle contentView] frame].size.width;
|
||||
myHeight = [[nsHandle contentView] frame].size.height;
|
||||
|
||||
} else if ([nsHandle isKindOfClass:[NSView class]]) {
|
||||
|
||||
// We have a view.
|
||||
myDelegate = [[SFViewController alloc] initWithView:nsHandle];
|
||||
|
||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||
myWidth = [nsHandle frame].size.width;
|
||||
myHeight = [nsHandle frame].size.height;
|
||||
|
||||
} else {
|
||||
|
||||
sf::Err()
|
||||
@ -100,10 +92,6 @@ WindowImplCocoa::WindowImplCocoa(VideoMode mode,
|
||||
// Ask for a pool.
|
||||
RetainPool();
|
||||
|
||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||
myWidth = mode.Width;
|
||||
myHeight = mode.Height;
|
||||
|
||||
myDelegate = [[SFWindowController alloc] initWithMode:mode andStyle:style];
|
||||
[myDelegate changeTitle:stringToNSString(title)];
|
||||
[myDelegate setRequesterTo:this];
|
||||
@ -173,14 +161,10 @@ void WindowImplCocoa::WindowClosed(void)
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::WindowResized(unsigned int width, unsigned int height)
|
||||
{
|
||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
|
||||
Event event;
|
||||
event.Type = Event::Resized;
|
||||
event.Size.Width = myWidth;
|
||||
event.Size.Height = myHeight;
|
||||
event.Size.Width = width;
|
||||
event.Size.Height = height;
|
||||
|
||||
PushEvent(event);
|
||||
}
|
||||
@ -350,33 +334,32 @@ WindowHandle WindowImplCocoa::GetSystemHandle() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::ShowMouseCursor(bool show)
|
||||
Vector2i WindowImplCocoa::GetPosition() const
|
||||
{
|
||||
myShowCursor = show;
|
||||
|
||||
if (myShowCursor) {
|
||||
[myDelegate showMouseCursor];
|
||||
} else {
|
||||
[myDelegate hideMouseCursor];
|
||||
}
|
||||
NSPoint pos = [myDelegate position];
|
||||
return Vector2i(pos.x, pos.y);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetPosition(const Vector2i& position)
|
||||
{
|
||||
[myDelegate setWindowPositionToX:position.x Y:position.y];
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2u WindowImplCocoa::GetSize() const
|
||||
{
|
||||
NSSize size = [myDelegate size];
|
||||
return Vector2u(size.width, size.height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetPosition(int x, int y)
|
||||
{
|
||||
[myDelegate setWindowPositionToX:x Y:y];
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetSize(unsigned int width, unsigned int height)
|
||||
{
|
||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
|
||||
[myDelegate resizeTo:width by:height];
|
||||
void WindowImplCocoa::SetSize(const Vector2u& size)
|
||||
{
|
||||
[myDelegate resizeTo:size.x by:size.y];
|
||||
}
|
||||
|
||||
|
||||
@ -388,9 +371,16 @@ void WindowImplCocoa::SetTitle(const std::string& title)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::Show(bool show)
|
||||
void WindowImplCocoa::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
||||
{
|
||||
if (show) {
|
||||
[myDelegate setIconTo:width by:height with:pixels];
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
[myDelegate showWindow];
|
||||
} else {
|
||||
[myDelegate hideWindow];
|
||||
@ -399,7 +389,20 @@ void WindowImplCocoa::Show(bool show)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::EnableKeyRepeat(bool enabled)
|
||||
void WindowImplCocoa::SetMouseCursorVisible(bool visible)
|
||||
{
|
||||
myShowCursor = visible;
|
||||
|
||||
if (myShowCursor) {
|
||||
[myDelegate showMouseCursor];
|
||||
} else {
|
||||
[myDelegate hideMouseCursor];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetKeyRepeatEnabled(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
[myDelegate enableKeyRepeat];
|
||||
@ -409,12 +412,6 @@ void WindowImplCocoa::EnableKeyRepeat(bool enabled)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImplCocoa::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
|
||||
{
|
||||
[myDelegate setIconTo:width by:height with:pixels];
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
@ -89,12 +89,24 @@ namespace sf {
|
||||
////////////////////////////////////////////////////////////
|
||||
-(void)setCursorPositionToX:(unsigned int)x Y:(unsigned int)y;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get window's position.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
-(NSPoint)position;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Move the window (not the view if we handle not a window) (SFML Coordinates).
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
-(void)setWindowPositionToX:(unsigned int)x Y:(unsigned int)y;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get window's size.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
-(NSSize)size;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Resize the window/view.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user