mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Merge branch 'master' of github.com:LaurentGomila/SFML
This commit is contained in:
commit
1dad4219a6
@ -51,8 +51,8 @@ struct SFMLmainWindow
|
|||||||
sprite.SetOrigin(size / 2.f);
|
sprite.SetOrigin(size / 2.f);
|
||||||
sprite.Scale(0.3, 0.3);
|
sprite.Scale(0.3, 0.3);
|
||||||
|
|
||||||
unsigned int ww = renderWindow.GetWidth();
|
unsigned int ww = renderWindow.GetSize().x;
|
||||||
unsigned int wh = renderWindow.GetHeight();
|
unsigned int wh = renderWindow.GetSize().y;
|
||||||
sprite.SetPosition(sf::Vector2f(ww, wh) / 2.f);
|
sprite.SetPosition(sf::Vector2f(ww, wh) / 2.f);
|
||||||
|
|
||||||
text.SetColor(sf::Color::White);
|
text.SetColor(sf::Color::White);
|
||||||
@ -104,7 +104,7 @@ struct SFMLmainWindow
|
|||||||
{
|
{
|
||||||
if (!self.initialized)
|
if (!self.initialized)
|
||||||
{
|
{
|
||||||
// Init the 1st SFML render area.
|
// Init the SFML render area.
|
||||||
self.mainWindow = new SFMLmainWindow(self.sfmlView);
|
self.mainWindow = new SFMLmainWindow(self.sfmlView);
|
||||||
self.mainWindow->text.SetString([self.textField.stringValue tostdwstring]);
|
self.mainWindow->text.SetString([self.textField.stringValue tostdwstring]);
|
||||||
self.visible = YES;
|
self.visible = YES;
|
||||||
@ -141,7 +141,7 @@ struct SFMLmainWindow
|
|||||||
self.sfmlView = nil;
|
self.sfmlView = nil;
|
||||||
self.textField = nil;
|
self.textField = nil;
|
||||||
|
|
||||||
delete self.mainWindow;
|
delete (SFMLmainWindow *) self.mainWindow;
|
||||||
self.mainWindow = 0;
|
self.mainWindow = 0;
|
||||||
self.renderTimer = nil;
|
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
|
-(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
|
-(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
|
-(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
|
-(void)resizeTo:(unsigned int)width by:(unsigned int)height
|
||||||
{
|
{
|
||||||
|
@ -56,19 +56,11 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
|||||||
// We have a window.
|
// We have a window.
|
||||||
myDelegate = [[SFWindowController alloc] initWithWindow:nsHandle];
|
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]]) {
|
} else if ([nsHandle isKindOfClass:[NSView class]]) {
|
||||||
|
|
||||||
// We have a view.
|
// We have a view.
|
||||||
myDelegate = [[SFViewController alloc] initWithView:nsHandle];
|
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 {
|
} else {
|
||||||
|
|
||||||
sf::Err()
|
sf::Err()
|
||||||
@ -100,10 +92,6 @@ WindowImplCocoa::WindowImplCocoa(VideoMode mode,
|
|||||||
// Ask for a pool.
|
// Ask for a pool.
|
||||||
RetainPool();
|
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 = [[SFWindowController alloc] initWithMode:mode andStyle:style];
|
||||||
[myDelegate changeTitle:stringToNSString(title)];
|
[myDelegate changeTitle:stringToNSString(title)];
|
||||||
[myDelegate setRequesterTo:this];
|
[myDelegate setRequesterTo:this];
|
||||||
@ -173,14 +161,10 @@ void WindowImplCocoa::WindowClosed(void)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::WindowResized(unsigned int width, unsigned int height)
|
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 event;
|
||||||
event.Type = Event::Resized;
|
event.Type = Event::Resized;
|
||||||
event.Size.Width = myWidth;
|
event.Size.Width = width;
|
||||||
event.Size.Height = myHeight;
|
event.Size.Height = height;
|
||||||
|
|
||||||
PushEvent(event);
|
PushEvent(event);
|
||||||
}
|
}
|
||||||
@ -350,33 +334,32 @@ WindowHandle WindowImplCocoa::GetSystemHandle() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::ShowMouseCursor(bool show)
|
Vector2i WindowImplCocoa::GetPosition() const
|
||||||
{
|
{
|
||||||
myShowCursor = show;
|
NSPoint pos = [myDelegate position];
|
||||||
|
return Vector2i(pos.x, pos.y);
|
||||||
if (myShowCursor) {
|
|
||||||
[myDelegate showMouseCursor];
|
|
||||||
} else {
|
|
||||||
[myDelegate hideMouseCursor];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::SetPosition(int x, int y)
|
void WindowImplCocoa::SetPosition(const Vector2i& position)
|
||||||
{
|
{
|
||||||
[myDelegate setWindowPositionToX:x Y:y];
|
[myDelegate setWindowPositionToX:position.x Y:position.y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplCocoa::SetSize(unsigned int width, unsigned int height)
|
Vector2u WindowImplCocoa::GetSize() const
|
||||||
{
|
{
|
||||||
// Don't forget to update our parent (that is, WindowImpl) size :
|
NSSize size = [myDelegate size];
|
||||||
myWidth = width;
|
return Vector2u(size.width, size.height);
|
||||||
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];
|
[myDelegate showWindow];
|
||||||
} else {
|
} else {
|
||||||
[myDelegate hideWindow];
|
[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) {
|
if (enabled) {
|
||||||
[myDelegate enableKeyRepeat];
|
[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 priv
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -89,12 +89,24 @@ namespace sf {
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
-(void)setCursorPositionToX:(unsigned int)x Y:(unsigned int)y;
|
-(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).
|
/// Move the window (not the view if we handle not a window) (SFML Coordinates).
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
-(void)setWindowPositionToX:(unsigned int)x Y:(unsigned int)y;
|
-(void)setWindowPositionToX:(unsigned int)x Y:(unsigned int)y;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Get window's size.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
-(NSSize)size;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Resize the window/view.
|
/// Resize the window/view.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user