SFML community forums

General => Feature requests => Topic started by: chessguy on January 06, 2014, 08:40:46 pm

Title: float, float for ctors or setSize
Post by: chessguy on January 06, 2014, 08:40:46 pm
Greetings. This isn't so much a feature request as an idea for slight convenience.

Let's take RectangleShape as an example, though it isn't the only thing. The ctor takes sf::Vector2f, as does setSize. However, others - position, origin, scale, etc - also take two floats. For lazy people like myself, such methods are nice. Is there a reason the setSize* don't have it?

On another note, I recently added a fullscreen option for something. To check if it was, I had to get the fullscreen modes from VideoMode, then compare it. I feel there must be a better way. Should Window have a getStyle?
Title: Re: float, float for ctors or setSize
Post by: Nexus on January 06, 2014, 08:51:30 pm
These questions have already been discussed. I recommend to use the forum search, especially if you like to hear the opinion of Laurent himself.
Title: Re: float, float for ctors or setSize
Post by: chessguy on January 06, 2014, 09:08:02 pm
Hrm. Apparently it is easier to find things using google search than the forum search. Now I came up with something.

The reason I found stated was to not have duplicate code, essentially. This is logical. However, I don't see the problem here. setSize(float, float) can call setSize(sf::Vector2f), can it not? I myself did this for something, and have not seen any problems.

ctors can work similarly if using C++11. I don't know when SFML will reach that point, though.

Not sure on the window thing. One place I found said that the window needs to be recreated anyway for such a thing. Another (this by Laurent) said it was a planned feature. I don't think it would be hard to store the flags of the last set, though. Quite possible I am overlooking something obvious.
Title: Re: float, float for ctors or setSize
Post by: thomas9459 on January 11, 2014, 07:45:40 pm
It is possible (at least in c++11) to use this:
sprite.setSize({200,200});
instead of this:
sprite.setSize(sf::Vector2f(200.f, 200.f));
This technique can also be applied elsewhere, such as for sf::Color. It's not very clean, but if your lazy, what do you expect? :P
Title: AW: Re: float, float for ctors or setSize
Post by: eXpl0it3r on January 11, 2014, 08:14:17 pm
This technique can also be applied elsewhere, such as for sf::Color. It's not very clean, but if your lazy, what do you expect? :P
I consider it clean enough. The signature of functions are clearly defined, there's no need to reapt the type explicitly again. It might lose some verbosity, but I don't see that as an issue. The code will for sure start to look cleaner.