Hi there,
First of all big praise to the dev team for this awesome library !
I am developing a game engine of sorts on top of SFML. With that comes the development of a UI system for it. I have already set up a sort of UI event system for dealing with events and distributing them to subscribers.
In implementing a text input field class I come to wonder how to deal with text wrapping on the end of the input field. Most fields (in most UIs I've used) usually simply continue to draw to the right as more characters are inserted and characters on the left are "lost" off the view.
I have already implemented this behaviour by using a RenderTexture to draw the sf::Text to and then drawing the RenderTexture to a final sprite. When input wraps I simply push the sprites' texture rect to the right (by adding on X) thus revealing the new text and stop rendering text on the left end.
This is all good but this forces me to create a rather big render texture so that I can continue to write on it. Lets say I have a 300x30 text field, the texture I use has to be at least 900x30 so that I can allow the user to input at least as much text as 3 times the text field size (for an example). This seems wasteful of memory (and texture binding/unbinding cost) ...
I tried simply erasing characters on the left of the text as the user reaches the limit on the right but as the characters have different sizes this sometimes results in a dance where 1 character removed on the left leaves space for 2 new ones on the right (which is annoying).
Any ideas ?
Thanks in advance