Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Athenian Hoplite

Pages: 1 [2]
16
Graphics / Re: PixelPicking with sf::Image
« on: May 21, 2020, 01:25:54 pm »
.. the "==" operator does not set a color in sf::Color, it compares colors ...

The "==" operator never sets anything. It is always used to do comparisons, when valid, returning a boolean.

17
Graphics / Re: Dragging whole scene
« on: May 20, 2020, 12:52:39 pm »
Never a good idea to mix real time input with event based input just as a caution you should initialize sf::Vector2i lastMousePosition with event.mouseButton.x and event.mouseButton.y when sf::Event::MouseButtonPressed as the starting position.

If I'm not mistaken for calculating a mouse delta for movement no conversion is needed just raw position in this scenario. I've never used transform.translate but I've implemented this kind of behaviour exactly as I have described by using sf::Transformable::move(offset) meaning in this case scene.move(mouseDelta). In a case where you would need this to propagate further down a hierarchy you could implement that by overloading the move method and calling it on children or simply by passing the appropriate states to child draw calls.

18
General / Re: Text Input Field - Ideas for wrapping
« on: May 19, 2020, 03:49:34 pm »
Ahah ! What a dummie I was ! Thanks man, that's exactly it !
Cheers !

19
General / [SOLVED] Text Input Field - Ideas for wrapping
« on: May 19, 2020, 03:19:11 pm »
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

Pages: 1 [2]