setTexture in Buttons

Started by Heinrich, 13 October 2014, 04:48:22

Heinrich

I'd like it. What do you think? Probably in every Widget. For changing the Button texture dynamically.

texus

You can do this in v0.7 by accessing the renderer. It has functions for changing any property that was loaded from the theme file.

button->getRenderer()->setNormalImage("normalimage.png");

Of course you can still load a subrect of an image just like you can do in the theme file, but you should look at the documentation for the other parameters: https://tgui.eu/documentation/v0.7/classtgui_1_1ButtonRenderer.html#acb67846b97bd5b1e816e8d9e9f4ff612.

Heinrich

Quote from: texus on 13 October 2014, 06:18:24
You can do this in v0.7 by accessing the renderer. It has functions for changing any property that was loaded from the theme file.

Silly me, didn't notice the getRenderer().

Heinrich

As soon as I try to call setNormalImage() manually, I get a single unresolved external for it.

error LNK2019: unresolved external symbol "public: void __thiscall tgui::ButtonRenderer::setNormalImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class sf::Rect<int> const &,class sf::Rect<int> const &,bool)" (?setNormalImage@ButtonRenderer@tgui@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$Rect@H@sf@@1_N@Z) referenced in function "private: void __thiscall EditorGUI::rebuildWorkbenchPanel(void)" (?rebuildWorkbenchPanel@EditorGUI@@AAEXXZ)

Heinrich

BTW: I hope you do not feel annoyed at my many requests.
Small suggestion: Currently, when you tgui::Button::copy(aButton), the tgui::Button::connect(func) also gets copied. I think this is seldom what the user wants if he copies a button.

texus

QuoteBTW: I hope you do not feel annoyed at my many requests.
Not at all, I'm always glad to see that someone uses tgui.
It's probably more annoying for you to constantly hit on a bug than it is for me to fix them or answer questions.

QuoteSmall suggestion: Currently, when you tgui::Button::copy(aButton), the tgui::Button::connect(func) also gets copied. I think this is seldom what the user wants if he copies a button.
You have no idea how much work it cost me to be able to copy these signals :D.
This is indeed something that should be looked at. But I think I'm going to wait for more feedback and review this later.

QuoteAs soon as I try to call setNormalImage() manually, I get a single unresolved external for it.
Sigh. Damn windows only bugs.
I have to write TGUI_API in front of every single class. If I forget it then you can't use that class with dlls.
It's should be fixed now.

(strange that I didn't receive a mail for your posts, luckily I have a habit of just checking the site regularly)

Heinrich

QuoteNot at all, I'm always glad to see that someone uses tgui.It's probably more annoying for you to constantly hit on a bug than it is for me to fix them or answer questions.
They get fixed in a matter of hours. I still maintain the notion that tgui fits my needs almost perfectly. Maybe there will be a day when you can boast about being the creator of tgui (boastings will be totally unrelated ro my little hobby project I'm using it for :-\.

Quote
You have no idea how much work it cost me to be able to copy these signals :D.
This is indeed something that should be looked at. But I think I'm going to wait for more feedback and review this later.

Sure, my personal rationale is that when I copy an element, I copy it's appearance and set new semantics for it. The other approach would be copying a buttons semantics but give it a new look.

QuoteIt's should be fixed now.
Thank you. You're the best.

texus

#7
Sorry, I forgot to push the changes to github earlier. The changes are online now.

Heinrich

Alright, it compiles and works.
Some small bug I noticed in 0.6 already that still persists. Probably it's from sfml.