I think it might be beneficial for the SFML library to have a quick method for setting the window in the user's screen center. I'm sure this has been thought of before by SFML devs, however, I don't see any discussion in the forums that I could find. Here's a quick and simple look at how I think it might be implemented in the Window class.
For instance, at line 220 in SFML/src/SFML/Window.cpp:
////////////////////////////////////////////////////////////
void Window::setPosition(const Vector2i& position)
{
if (m_impl)
m_impl->setPosition(position);
}
could be called using something like:
window.setPosition(sf::Vector2i(sf::Window::CenterHorizontal(), sf::Window::CenterVertical()));
Where sf::Window::CenterHorizontal/Vertical are static public methods that calculate the equivalent call:
window.setPosition(sf::Vector2i(sf::VideoMode::getDesktopMode().width * 0.5 - window.getSize().x * 0.5, sf::VideoMode::getDesktopMode().height * 0.5 - window.getSize().y * 0.5));
I'm sure there'd be better ways to implement this functionality within SFML's API but this was a quick way to illustrate what I was referring by setting the window to the user's screen center. I realize it's not very much code to replace but I think it does reduce some clutter in the call. Part of the inspiration was from SDL's library with regards to:
SDL_CreateWindow(titleString.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, SDL_WINDOW_OPENGL);