SFML community forums

General => Feature requests => Topic started by: LucasM on July 04, 2020, 05:42:36 am

Title: Set Window Position on Creation
Post by: LucasM on July 04, 2020, 05:42:36 am
There is no option to set the sf::Window position on creation.  Have to create the window, then set its position which causes the window to 'jump'.  Seems to be coded to position in the middle of the screen according to source.  Shouldn't be too difficult to overload the constructor to optionally take in parameters for window location.

Thanks.
Title: Re: Set Window Position on Creation
Post by: Hapax on July 04, 2020, 08:10:56 pm
You could create the window at size (1, 1), quickly move it offscreen (e.g. -2000, -2000), resize it to the size you want and then reposition it. This is much less noticeable than moving it onscreen but works even better if the window doesn't need decorations.

One thing I haven't tried is to create the window after setting its position but I would guess that the setting position method affects the actual created window, not the sf::Window object, which would've allowed you to set the position first and that position taken into account when the actual window is created.

With all that said, users tend to accept "imperfect" motion when a window is first set-up and when applications are first started.
Title: Re: Set Window Position on Creation
Post by: eXpl0it3r on July 06, 2020, 11:53:31 pm
The issue here is much more that the window is shown/visible right when the class is instantiated.

This flaw was also picked up in the Window States and Styles discussion here (https://en.sfml-dev.org/forums/index.php?topic=23578.0), here (https://github.com/SFML/SFML/issues/744), and here (https://github.com/SFML/SFML/wiki/SD%3A-States-and-Styles).
We don't really want to further uglify the constructor overloads and instead rather provide an option to create windows hidden and let the user decide when it's time to show it.