How do you connect in 0.9?

  • 3 Replies
  • 56 Views
*

pbortler

  • *
  • 5
  • Where's the fucking documentation!?!?!
    • View Profile
How do you connect in 0.9?
« on: 11 September 2020, 00:06:15 »
How do you connect in 0.9? I used to be able to pass a function to listbox->connect("ItemPressed", cb) but I can no longer do this. listbox->onItemSelect.connect(cb); produces an error, as does passing (&cb).

What's the trick to getting connect to work in 0.9?

Documentation would be really helpful. Do you maybe have a younger brother or a cousin or a neighbour who could do it for you?
Where's the fucking documentation!?!?!

*

pbortler

  • *
  • 5
  • Where's the fucking documentation!?!?!
    • View Profile
Re: How do you connect in 0.9?
« Reply #1 on: 11 September 2020, 00:10:26 »
Also, How do you set a view? I used to be able to call gui.setView(sfView) but this no longer works.

I see that setView no longer exists and setRelativeView presumably should be used, but setRelativeView doesn't take a sensible obiect that can be converted into the parameter it desires. I can no longer pass in a sf::View, or even the result of sf::View::getViewport() even though it claims it is looking for a FloatRect (error converting between sf::FloatRect and tgui::FloatRect).

What's the trick to setting a view in 0.9?
Where's the fucking documentation!?!?!

*

pbortler

  • *
  • 5
  • Where's the fucking documentation!?!?!
    • View Profile
Re: How do you connect in 0.9?
« Reply #2 on: 11 September 2020, 00:25:13 »
It seems that I need to pollute my code with now-necessary type names in order to get your tgui::String to convert into either sf::String or std::string accordingly. This is very ugly.

I'm giving up on 0.9. Could you backport the fixes to the widgets to 0.8 before proceeding any further with 0.9? Thanks.
Where's the fucking documentation!?!?!

*

texus

  • *****
  • 1584
    • View Profile
    • Texus's Blog
Re: How do you connect in 0.9?
« Reply #3 on: 14 September 2020, 16:56:25 »
I'm sorry I didn't reply earlier, but somehow the forum had disabled notifications for this particular topic (while other topics that were created before and after your questions still have notify active for each message by default). I have no idea how that happened. Just for testing, could you perhaps create a new empty topic (which I will delete once I see it). If I don't get a notification for that one either then it must be some setting related to your account while otherwise it was just a temporary issue.

Quote
How do you connect in 0.9? I used to be able to pass a function to listbox->connect("ItemPressed", cb) but I can no longer do this. listbox->onItemSelect.connect(cb); produces an error, as does passing (&cb).
"listBox->onItemSelect(cb)" or "listBox->onItemSelect.connect(cb)" should work. What error did you get, maybe you were still using e.g. an sf::String as parameter instead of tgui::String?

Quote
I see that setView no longer exists and setRelativeView presumably should be used, but setRelativeView doesn't take a sensible obiect that can be converted into the parameter it desires. I can no longer pass in a sf::View, or even the result of sf::View::getViewport() even though it claims it is looking for a FloatRect (error converting between sf::FloatRect and tgui::FloatRect).
Conversion from SFML types to TGUI types sometimes requires explicit casts (because of issues you could otherwise get with ambigous function calls), you would just need to type "tgui::FloatRect(sfmlRect)". Though in most cases you won't need to use SFML types when passing things to TGUI (although it is annoying when upgrading from 0.8 as you did already use SFML types everywhere, which is why I don't recommend upgrading an existing project unless you have to). TGUI now changes the view automatically with the window size, so the most common case to call setView has been removed. Whether you need setRelativeView or setAbsoluteView to set a custom view depends on what parameters you want to give. The documentation of these functions contain a code example (e.g. https://github.com/texus/TGUI/blob/49f818919363d04bd51c87799655d52dfb78e449/include/TGUI/GuiBase.hpp#L113-L117).

Quote
It seems that I need to pollute my code with now-necessary type names in order to get your tgui::String to convert into either sf::String or std::string accordingly. This is very ugly.
I'm not sure I understand what you mean. There are implicit conversions to std::string and sf::String, plus tgui::String has all functions that std::string has, so you shouldn't need to do any manual conversions.
There are only two places where you are forced to make changes to your code: in the parameter of a callback function and when casting an sf::String to a tgui::String (by using "tgui::String(sfStr)") (but casting from tgui::String to sf::String is implicit).

Quote
Could you backport the fixes to the widgets to 0.8 before proceeding any further with 0.9?
I'm willing to backport small changes, but it would be helpful if you mentioned which changes in particular you are interested in.

Quote
Documentation would be really helpful. Do you maybe have a younger brother or a cousin or a neighbour who could do it for you?
I agree, but there is nobody that can do it for me. I've mentioned it online many times in the past that I could use help with it, but nobody else contributes any documentation.
I am currently rewriting the installation tutorials, after which I will write some other useful tutorials. I want to get some minimal information available before I launch 0.9-beta.
« Last Edit: 14 September 2020, 16:59:55 by texus »