Added Size/Position Getters/Setters

This commit is contained in:
Robert 2020-05-16 20:23:28 +02:00
parent bf6b934b9b
commit a57f81e0b3
2 changed files with 80 additions and 0 deletions

View file

@ -69,4 +69,38 @@ namespace sdlu
while (!PollEvent(event)) continue;
return true;
}
Vector2i RenderWindow::GetPosition()
{
int x = 0, y = 0;
SDL_GetWindowPosition(m_pWindow, &x, &y);
return Vector2i(x, y);
}
void RenderWindow::SetPosition(Vector2i position)
{
SDL_SetWindowPosition(m_pWindow, position.x, position.y);
}
void RenderWindow::SetPosition(int x, int y)
{
SDL_SetWindowPosition(m_pWindow, x, y);
}
Vector2u RenderWindow::GetSize()
{
unsigned int x = 0, y = 0;
SDL_GetWindowSize(m_pWindow, x, y);
return Vector2u(x, y);
}
void RenderWindow::SetSize(Vector2u size)
{
SDL_SetWindowSize(m_pWindow, size.x, size.y);
}
void RenderWindow::SetSize(unsigned int width, unsigned int height)
{
SDL_SetWindowSize(m_pWindow, width, height);
}
}

View file

@ -80,6 +80,52 @@ namespace sdlu
*/
bool WaitEvent(SDL_Event* event);
/**
* @brief Returns the current position of the window
*
* @return A vector with the current position relative to the top left corner of the display
*/
Vector2i GetPosition();
/**
* @brief Sets a new window position
*
* @param[in] position A vector with the new position
*/
void SetPosition(Vector2i position);
/**
* @brief Sets a new window position
*
* @param[in] x The new x position
* @param[in] y The new y position
*/
void SetPosition(int x, int y);
/**
* @brief Gets the current window size
*
* @return A vector with the windows size
*/
Vector2u GetSize();
/**
* @brief Sets a new window size
*
* @param[in] size A vector with the new size
*/
void SetSize(Vector2u size);
/**
* @brief Sets a new window size
*
* @param[in] width The new width of the window
* @param[in] height The new height of the window
*/
void SetSize(unsigned int width, unsigned int height);
protected:
SDL_Window* m_pWindow; ///< A pointer to the window object
SDL_Renderer* m_pRenderer; ///< A pointer to the renderer object