Texture for RangeSlider

  • 3 Replies
  • 65 Views
Texture for RangeSlider
« on: 12 October 2020, 02:43:11 »
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.

Code: [Select]
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

  • *****
  • 1586
    • View Profile
    • Texus's Blog
Re: Texture for RangeSlider
« Reply #1 on: 12 October 2020, 08:22:12 »
Quote
RangeSlider is inherited from Slider
It actually doesn't, it just contains mostly the same code.

Quote
I 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).
rangeSlider->setRenderer(theme.getRenderer("Slider"));

Quote
There 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.

Re: Texture for RangeSlider
« Reply #2 on: 12 October 2020, 19:45:17 »
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.

Quote
What 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.

 
« Last Edit: 12 October 2020, 21:28:48 by MattDA »

*

texus

  • *****
  • 1586
    • View Profile
    • Texus's Blog
Re: Texture for RangeSlider
« Reply #3 on: 13 October 2020, 08:29:50 »
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.
« Last Edit: 13 October 2020, 22:51:39 by texus »