Texture for RangeSlider

Started by MattDA, 12 October 2020, 02:43:11

MattDA

Hello. I am trying to make a display child window that has all of the TGUI widgets. The widgets are using a modified version of black.txt. The texture atlas is my own custom drawn png. The issue I am having is with RangeSlider. There does not seem to be a way to load textures for the space between the two thumbs.

RangeSlider is inherited from Slider, but the object properties (that we set in a theme file or setters) are not available.
In other words I can not set the RangeSlider to display textures (available to Sliders) and the color values in the RangeSlider renderer.


RangeSlider {


/*
TextureTrack      = "GUI.png" Part(245, 45, 26, 26) Middle(6, 6, 14, 14);
    //TextureTrackHover = "GUI.png" Part(297, 45, 26, 26) Middle(2, 2, 22, 22);
    TextureThumb      = "GUI.png" Part(350, 45, 26, 26) Middle(2, 2, 22, 22) Smooth;
TextureThumbHover = "GUI.png" Part(375, 45, 26, 26) Middle(2, 2, 22, 22) Smooth;
//SelectedTrack     = "GUI.png" Part(297, 45, 26, 26) Middle(2, 2, 22, 22);
*/

SelectedTrackColor = rgb(190, 0, 0, 100);
SelectedTrackColorHover = rgb(0,190, 0, 100);
}

texus

QuoteRangeSlider is inherited from Slider
It actually doesn't, it just contains mostly the same code.

QuoteI can not set the RangeSlider to display textures (available to Sliders)
What exactly doesn't work? Do you get an error or does is just not show the textures?

I just tried loading the black theme and using the Slider section to create the RangeSlider like below and it worked (it's not recommended to use a section of a wrong type, but it works here because they do support the same properties).
Code (cpp) Select
rangeSlider->setRenderer(theme.getRenderer("Slider"));

QuoteThere does not seem to be a way to load textures for the space between the two thumbs.
This indeed seems to be missing.
There are 2 ways this could be implemented though. You could have a texture that has the same size as the track and of which only a part is shows (similarly to how the front image in ProgressBar works), or you could have a small texture with the same height as the track which is stretched horizontally to fill the selected area. I guess the first one would be the better option because it can handle rounded corners on the track or other special cases.

MattDA

#2
I meant that RangeSliderRenderer is inherited from SliderRenderer; At least that's what it looks like in the documentation's UML diagram. I would expect then that a RangeSliderRenderer would have all the properties of a SliderRenderer.

QuoteWhat exactly doesn't work? Do you get an error or does is just not show the textures?
I can not display the RangeSlider that shows my textures and changes the color or texture between the two thumbs. I will post a screenshot.



texus

#3
I think I finally understood what you mean. When textures are loaded, nothing extra is shown inbetween the two thumbs.
I'll try to fix this soon (in TGUI 0.9-dev).

Edit: I've already fixed the SelectedTrackColor property, it should work now even when textures are loaded. I'll look into adding a new SelectedTrackTexture property later.

Edit2: TextureSelectedTrack and TextureSelectedTrackHover properties have been added to RangeSliderRenderer.