setTexture in Buttons
« on: 13 October 2014, 04:48:22 »
I'd like it. What do you think? Probably in every Widget. For changing the Button texture dynamically.

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: setTexture in Buttons
« Reply #1 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.

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

Re: setTexture in Buttons
« Reply #2 on: 13 October 2014, 12:46:27 »
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().

Re: setTexture in Buttons
« Reply #3 on: 14 October 2014, 15:40:17 »
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)

Re: setTexture in Buttons
« Reply #4 on: 14 October 2014, 17:48:36 »
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

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: setTexture in Buttons
« Reply #5 on: 14 October 2014, 18:23:19 »
Quote
BTW: 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.

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

Quote
As 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)

Re: setTexture in Buttons
« Reply #6 on: 14 October 2014, 18:43:10 »
Quote
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.
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.

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

*

texus

  • *****
  • 1172
    • View Profile
    • Texus's Blog
Re: setTexture in Buttons
« Reply #7 on: 14 October 2014, 19:06:42 »
Sorry, I forgot to push the changes to github earlier. The changes are online now.
« Last Edit: 14 October 2014, 19:08:44 by texus »

Re: setTexture in Buttons
« Reply #8 on: 15 October 2014, 13:07:23 »
Alright, it compiles and works.
Some small bug I noticed in 0.6 already that still persists. Probably it's from sfml.