TGUI builder 0.8.5 - missing vertical slider

Started by Hexile, 10 August 2019, 20:45:27

Hexile

Hi. The option is missing. did it get removed from the builder?

Also; If possible, it would be nice if we could set the angles of scrollbars, sliders, etc.

texus

QuoteThe option is missing.
You actually just have to set the Height to a larger value than the Width. I'll put on my todo list that I should add a property for it in the gui builder to make it more intuitive, because someone else recently had the same problem with a Slider and I agree that it isn't obvious at all.

QuoteAlso; If possible, it would be nice if we could set the angles of scrollbars, sliders, etc.
When rotating over an angle other than 90° there is no more obvious definition about where the top left position actually is. There are multiple ways the scrollbar could be positioned after e.g. a 45° turn. I've never seen diagonal scrollbar, is there a use case that you have in mind where you would need to rotate it over such a non-standard angle?

Hexile

#2
Quote from: texus on 10 August 2019, 22:40:14
QuoteThe option is missing.
You actually just have to set the Height to a larger value than the Width. I'll put on my todo list that I should add a property for it in the gui builder to make it more intuitive, because someone else recently had the same problem with a Slider and I agree that it isn't obvious at all.
Alright.

Quote from: texus on 10 August 2019, 22:40:14
QuoteAlso; If possible, it would be nice if we could set the angles of scrollbars, sliders, etc.
When rotating over an angle other than 90° there is no more obvious definition about where the top left position actually is. There are multiple ways the scrollbar could be positioned after e.g. a 45° turn. I've never seen diagonal scrollbar, is there a use case that you have in mind where you would need to rotate it over such a non-standard angle?

I do agree that beyond 45 degrees do not make sense, however, i'm interested in replicating the EQ sliders on an obscure hifi unit i saw a while back.
Instead of them being vertical |||||| they were slanted/angled like //////

texus

The problem isn't going beyond 45°, any angle that can't be divided by 90 is problematic. If an object has to be rotated, around what point should the rotation take place?
Imagine you have a slider of 400 pixels width and 20 pixels height. The slider is places on position (100, 100).
- If you rotate 90° clockwise around the top-left corner then the new top-left position will be at (80, 100).
- If you rotate around the center of the widget, a rotation of 90° will put the top left of the slider on position (290, -100).

What I do in TGUI is correct the offset and move it back to position (100, 100). In the first case (which is what TGUI uses), I simply add 20 pixels to the left position of the slider before the rotation even happens. After the rotation the slider will end up rotated 90° and at position (100,100), which is what the user asked for.

But what happens if you rotate by 45° (or even just 1°), what is the top left position then? I could take a bounding box around the entire widget, but that box would change size for every degree you rotate, so the result will be that the slider position is unpredictable and you have to experiment a bit to find the best position for the slider.

The only way that I see to properly support it, is if I let the user set the position of the center of the widget instead of the top left position. That way you could rotate around any angle and the center would remain on the same spot, hence the result of where the slider will end up would be is predictable.

Another problem is going to be detecting when the mouse is on top of the widget. Right now there are only a handful of widgets that can be rotated and the 90° rotation makes it easy to check the mouse position. If a widget can be freely rotated around any angle, checking when the mouse is on top of the widget (and on which part) gets more difficult.

So although the feature would be nice to have, I currently have no plans to add something like that in TGUI as it involves a lot of work.

Hexile

Supposedly, it could be made working using slider 2d and clamping the xpos to something determined by the ypos.
Or at least I think it should be...

I understand it wouldn't be easy to add full rotation support, but it's nice to hear your thoughts on that feature.

texus

Actually the Slider2d widget no longer exists. In 0.7 it seems like it was still in an extra folder (together with AnimatedPicture and SpriteSheet), but these 3 "widgets" were removed in 0.8. They didn't fully fit in a gui library and I decided that I wasn't going to keep maintaining them (since every version update required rewriting a lot of code in all widgets).

It wouldn't really solve the issue with detecting where the mouse is. The Slider2d class just acted as one big rectangle and would absorb all mouse events in that area, even if your diagonal slider would only fill a small part of that area. The changes required to Slider2d are so large that you might as well just create a new widget for it

If anyone comes up with the necessary code to make rotation work then I would of course merge it, but I have no intention of writing it myself on short term.

Hexile

hmm, okay. It might be worth adding an "obsolete section" in the docs then, in case there is more things no longer supported.