Added Window::getBorderSize.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2018-03-16 15:22:42 -03:00
parent dae13bda2d
commit 2f6bc4dcdc
5 changed files with 25 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -57,6 +57,8 @@ class EE_API WindowSDL : public Window {
const Sizei& getDesktopResolution();
virtual Rect getBorderSize();
SDL_Window * GetSDLWindow() const;
void startTextInput();

View File

@@ -535,6 +535,10 @@ void Window::centerToDisplay() {
}
}
Rect Window::getBorderSize() {
return Rect();
}
Platform::PlatformImpl * Window::getPlatform() const {
return mPlatform;
}

View File

@@ -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 ) );