How do I change the texture of the scrollbar components in a ChatBox?

Started by pbortler, 10 September 2020, 18:33:24

pbortler

I can't seem to get any kind of ScrollbarRenderer from the ChatBox or the ChatBoxRenderer. I can get a RenderData object, but I can't make any use of it. Creating a ScrollbarRenderer, passing ChatBox->getRenderer()->getScrollbar() into its setData(), modifying the background texture, and using the modified ScrollbarRenderer's getData() for ChatBox->getRenderer()->setScrollbar() has no effect.

That was just a guess though, since guessing is the best I can do with no useful documentation or examples.

So what's the trick to getting access to a ChatBox ScrollbarRenderer?

texus

This is indeed undocumented.

Quotepassing ChatBox->getRenderer()->getScrollbar() into its setData(), modifying the background texture, and using the modified ScrollbarRenderer's getData() for ChatBox->getRenderer()->setScrollbar() has no effect.
That should have worked actually. Was the scrollbar already using textures? Because a known "issue" with the scrollbar is that it has to be given textures for track, thumb and arrows or it would use colors for everything. So if you only changed one texture while the others are still colors then it won't use the texture. That issue has recently been resolved in 0.9-dev though.

The WidgetRenderer constructor can be given the RenderData as parameter, then you can skip the setData call:
Code (cpp) Select
tgui::ScrollbarRenderer renderer(ChatBox->getRenderer()->getScrollbar());
renderer.setTrackColor(tgui::Color::Red);
ChatBox->getRenderer()->setScrollbar(renderer.getData());

pbortler

Quote from: texus on 10 September 2020, 18:59:36
That should have worked actually. Was the scrollbar already using textures? Because a known "issue" with the scrollbar is that it has to be given textures for track, thumb and arrows or it would use colors for everything.

This was the issue. Changing all the necessary textures worked. Thanks.