[iOS] Various adjustements to implementation
This commit is contained in:
parent
e20ff86330
commit
01b745185e
@ -103,14 +103,10 @@ namespace
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillResignActive:(UIApplication *)application
|
- (void)applicationWillResignActive:(UIApplication *)application
|
||||||
{
|
{
|
||||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
// Called when:
|
||||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
// - the application is sent to background
|
||||||
}
|
// - the application is interrupted by a call or message
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
|
||||||
{
|
|
||||||
// Generate a LostFocus event
|
// Generate a LostFocus event
|
||||||
if (self.sfWindow)
|
if (self.sfWindow)
|
||||||
{
|
{
|
||||||
@ -122,8 +118,19 @@ namespace
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||||
{
|
{
|
||||||
|
// Called when the application is sent to background (home button pressed)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||||
|
{
|
||||||
|
// Called when:
|
||||||
|
// - the application is sent to foreground
|
||||||
|
// - the application was interrupted by a call or message
|
||||||
|
|
||||||
// Generate a GainedFocus event
|
// Generate a GainedFocus event
|
||||||
if (self.sfWindow)
|
if (self.sfWindow)
|
||||||
{
|
{
|
||||||
@ -135,16 +142,22 @@ namespace
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||||
{
|
{
|
||||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
// Called when the application is sent to foreground (app icon pressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application
|
- (void)applicationWillTerminate:(UIApplication *)application
|
||||||
{
|
{
|
||||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
// Generate a Closed event
|
||||||
|
if (self.sfWindow)
|
||||||
|
{
|
||||||
|
sf::Event event;
|
||||||
|
event.type = sf::Event::Closed;
|
||||||
|
sfWindow->pushEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,19 +175,16 @@ namespace
|
|||||||
(orientation == UIDeviceOrientationPortrait) ||
|
(orientation == UIDeviceOrientationPortrait) ||
|
||||||
(orientation == UIDeviceOrientationPortraitUpsideDown))
|
(orientation == UIDeviceOrientationPortraitUpsideDown))
|
||||||
{
|
{
|
||||||
|
// Get the new size
|
||||||
|
CGSize size = [UIScreen mainScreen].bounds.size;
|
||||||
|
if (UIDeviceOrientationIsLandscape(orientation))
|
||||||
|
std::swap(size.width, size.height);
|
||||||
|
|
||||||
// Send a Resized event to the current window
|
// Send a Resized event to the current window
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
event.type = sf::Event::Resized;
|
event.type = sf::Event::Resized;
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
event.size.width = size.width;
|
||||||
{
|
event.size.height = size.height;
|
||||||
event.size.width = 480;
|
|
||||||
event.size.height = 320;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.size.width = 320;
|
|
||||||
event.size.height = 480;
|
|
||||||
}
|
|
||||||
sfWindow->pushEvent(event);
|
sfWindow->pushEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/VideoModeImpl.hpp>
|
#include <SFML/Window/VideoModeImpl.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
|
||||||
#include <UIKit/UIKit.h>
|
#include <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ WindowImplUIKit::WindowImplUIKit(VideoMode mode,
|
|||||||
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
|
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
CGRect frame = {{0, 0}, {mode.width, mode.height}}; // @todo keep user mode or force to device resolution?? (-> test)
|
CGRect frame = [UIScreen mainScreen].bounds; // Ignore user size, it wouldn't make sense to use something else
|
||||||
m_window = [[UIWindow alloc] initWithFrame:frame];
|
m_window = [[UIWindow alloc] initWithFrame:frame];
|
||||||
|
|
||||||
// Assign it to the application delegate
|
// Assign it to the application delegate
|
||||||
|
Loading…
Reference in New Issue
Block a user