mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-20 17:52:50 +03:00
Added Window::getBorderSize.
--HG-- branch : dev
This commit is contained in:
@@ -271,6 +271,9 @@ class EE_API Window {
|
||||
/** Center the window to the desktop ( if windowed ) */
|
||||
virtual void centerToDisplay();
|
||||
|
||||
/** @return The window borders size */
|
||||
virtual Rect getBorderSize();
|
||||
|
||||
/** @return If the aplication is running returns true ( If you Init correctly the window and is running ). */
|
||||
bool isRunning() const;
|
||||
|
||||
|
||||
@@ -585,6 +585,16 @@ const Sizei& WindowSDL::getDesktopResolution() {
|
||||
return Window::getDesktopResolution();
|
||||
}
|
||||
|
||||
Rect WindowSDL::getBorderSize() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,5)
|
||||
Rect bordersSize;
|
||||
SDL_GetWindowBordersSize( mSDLWindow, &bordersSize.Top, &bordersSize.Left, &bordersSize.Bottom, &bordersSize.Right );
|
||||
return bordersSize;
|
||||
#else
|
||||
return Rect();
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_Window * WindowSDL::GetSDLWindow() const {
|
||||
return mSDLWindow;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
const Sizei& getDesktopResolution();
|
||||
|
||||
virtual Rect getBorderSize();
|
||||
|
||||
SDL_Window * GetSDLWindow() const;
|
||||
|
||||
void startTextInput();
|
||||
|
||||
@@ -535,6 +535,10 @@ void Window::centerToDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
Rect Window::getBorderSize() {
|
||||
return Rect();
|
||||
}
|
||||
|
||||
Platform::PlatformImpl * Window::getPlatform() const {
|
||||
return mPlatform;
|
||||
}
|
||||
|
||||
@@ -287,10 +287,13 @@ void mainLoop() {
|
||||
|
||||
if ( NULL != uiContainer && window->getInput()->isKeyUp( KEY_F1 ) ) {
|
||||
Sizef size( uiContainer->getSize() );
|
||||
DisplayMode displayMode = Engine::instance()->getDisplayManager()->getDisplayIndex(0)->getCurrentMode();
|
||||
Rect borderSize( window->getBorderSize() );
|
||||
Sizei displayMode = Engine::instance()->getDisplayManager()->getDisplayIndex(0)->getUsableBounds().getSize();
|
||||
displayMode.x = displayMode.x - borderSize.Left - borderSize.Right;
|
||||
displayMode.y = displayMode.y - borderSize.Top - borderSize.Bottom;
|
||||
|
||||
Float scaleW = size.getWidth() > displayMode.Width ? displayMode.Width / size.getWidth() : 1.f;
|
||||
Float scaleH = size.getHeight() > displayMode.Height * 0.9f ? displayMode.Height * 0.9f / size.getHeight() : 1.f;
|
||||
Float scaleW = size.getWidth() > displayMode.getWidth() ? displayMode.getWidth() / size.getWidth() : 1.f;
|
||||
Float scaleH = size.getHeight() > displayMode.getHeight() ? displayMode.getHeight() / size.getHeight() : 1.f;
|
||||
Float scale = scaleW < scaleH ? scaleW : scaleH;
|
||||
|
||||
window->setSize( (Uint32)( uiContainer->getSize().getWidth() * scale ), (Uint32)( uiContainer->getSize().getHeight() * scale ) );
|
||||
|
||||
Reference in New Issue
Block a user