Add code to handle screen padding in new iPhone
This commit is contained in:
parent
84f91d58db
commit
be77b5f294
@ -314,6 +314,10 @@ namespace irr
|
||||
virtual bool deactivateDeviceMotion() { return false; }
|
||||
virtual bool isDeviceMotionActive() { return false; }
|
||||
virtual bool isDeviceMotionAvailable() { return false; }
|
||||
virtual s32 getTopPadding() { return 0; }
|
||||
virtual s32 getBottomPadding() { return 0; }
|
||||
virtual s32 getLeftPadding() { return 0; }
|
||||
virtual s32 getRightPadding() { return 0; }
|
||||
//! Check if a driver type is supported by the engine.
|
||||
/** Even if true is returned the driver may not be available
|
||||
for a configuration requested when creating the device. */
|
||||
|
@ -113,7 +113,30 @@ namespace irr
|
||||
m_touch_id_map.clear();
|
||||
}
|
||||
void setUpsideDown(bool val) { m_upside_down = val; }
|
||||
void setPaddings(float top, float bottom, float left, float right)
|
||||
{
|
||||
m_top_padding = top;
|
||||
m_bottom_padding = bottom;
|
||||
m_left_padding = left;
|
||||
m_right_padding = right;
|
||||
}
|
||||
static std::string getSystemLanguageCode();
|
||||
virtual s32 getTopPadding()
|
||||
{
|
||||
return m_top_padding * m_native_scale;
|
||||
}
|
||||
virtual s32 getBottomPadding()
|
||||
{
|
||||
return m_bottom_padding * m_native_scale;
|
||||
}
|
||||
virtual s32 getLeftPadding()
|
||||
{
|
||||
return m_left_padding * m_native_scale;
|
||||
}
|
||||
virtual s32 getRightPadding()
|
||||
{
|
||||
return m_right_padding * m_native_scale;
|
||||
}
|
||||
private:
|
||||
void createWindow();
|
||||
void createViewAndDriver();
|
||||
@ -124,6 +147,11 @@ namespace irr
|
||||
|
||||
std::map<void*, size_t> m_touch_id_map;
|
||||
bool m_upside_down;
|
||||
float m_top_padding;
|
||||
float m_bottom_padding;
|
||||
float m_left_padding;
|
||||
float m_right_padding;
|
||||
float m_native_scale;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -36,9 +36,20 @@ namespace irr
|
||||
@interface HideStatusBarView : UIViewController
|
||||
-(BOOL)prefersStatusBarHidden;
|
||||
-(BOOL)prefersHomeIndicatorAutoHidden;
|
||||
-(void)viewDidAppear:(BOOL)animated;
|
||||
@end
|
||||
|
||||
@implementation HideStatusBarView {}
|
||||
@implementation HideStatusBarView
|
||||
{
|
||||
irr::CIrrDeviceiOS* Device;
|
||||
}
|
||||
|
||||
- (id)init: (irr::CIrrDeviceiOS*)device
|
||||
{
|
||||
self = [super init];
|
||||
Device = device;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(BOOL)prefersStatusBarHidden
|
||||
{
|
||||
@ -50,6 +61,18 @@ namespace irr
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear : animated];
|
||||
if (@available(iOS 11.0, *))
|
||||
{
|
||||
Device->setPaddings(self.view.safeAreaInsets.top,
|
||||
self.view.safeAreaInsets.bottom,
|
||||
self.view.safeAreaInsets.left,
|
||||
self.view.safeAreaInsets.right);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/* CIrrDelegateiOS */
|
||||
@ -427,6 +450,11 @@ namespace irr
|
||||
CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params)
|
||||
: CIrrDeviceStub(params), DataStorage(0), Close(false), m_upside_down(false)
|
||||
{
|
||||
m_top_padding = 0.0f;
|
||||
m_bottom_padding = 0.0f;
|
||||
m_left_padding = 0.0f;
|
||||
m_right_padding = 0.0f;
|
||||
m_native_scale = 1.0f;
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceiOS");
|
||||
#endif
|
||||
@ -819,7 +847,7 @@ namespace irr
|
||||
{
|
||||
SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage);
|
||||
dataStorage->Window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
dataStorage->ViewController = [[HideStatusBarView alloc] init];
|
||||
dataStorage->ViewController = [[HideStatusBarView alloc] init: this];
|
||||
dataStorage->Window.rootViewController = dataStorage->ViewController;
|
||||
[dataStorage->Window makeKeyAndVisible];
|
||||
}
|
||||
@ -846,7 +874,8 @@ namespace irr
|
||||
CIrrViewiOS* view = [[CIrrViewiOS alloc] initWithFrame:[[UIScreen mainScreen] bounds]
|
||||
forDevice:this forContext:dataStorage->m_eagl_context];
|
||||
dataStorage->View = view;
|
||||
view.contentScaleFactor = dataStorage->Window.screen.nativeScale;
|
||||
m_native_scale = dataStorage->Window.screen.nativeScale;
|
||||
view.contentScaleFactor = m_native_scale;
|
||||
// This will initialize the default framebuffer, which bind its valus to GL_FRAMEBUFFER_BINDING
|
||||
beginScene();
|
||||
GLint default_fb = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user