Broken Layouts?
« on: 01 September 2017, 09:30:27 »
Hi,

I cant figure out why the following code is not working. I'm using the latest dev version 0.8.
My problem occurs when I try to reference another widget (parent or sibling) in a layout-string.
It seems like the parsing it these cases is broken, or is something wrong with the code below?

#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "gui test");
    window.setFramerateLimit(60);

    tgui::Gui gui(window);

    try
    {
        tgui::Theme theme{"data/Black.txt"};

        auto button1 = tgui::Button::create();
        auto button2 = tgui::Button::create();
        auto group = tgui::Group::create();

        group->add(button1, "button");
        group->add(button2);

        button1->setRenderer(theme.getRenderer("Button"));
        button2->setRenderer(theme.getRenderer("Button"));

        button2->setPosition({"button.right + 100", "button.top"});  //error here

        gui.add(group);

    }
    catch (const tgui::Exception& e)
    {
        std::cerr << "TGUI Exception: " << e.what() << std::endl;
        return -1;
    }

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            gui.handleEvent(event);
        }

        window.clear();
        gui.draw();
        window.display();
    }

    return 0;
}
 

edit: The version 0.8 from the website works fine, but the latest github version is buggy. Anyway, the problem might be worth noticing.
« Last Edit: 01 September 2017, 09:56:35 by ungod »

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Broken Layouts?
« Reply #1 on: 01 September 2017, 10:46:31 »
Quote
The version 0.8 from the website works fine, but the latest github version is buggy
These versions are identical, the source code button is just a link to the github download. The VS2015 libs on the download page are however delayed 30 minutes (because they have to be build after the commit is made).

I did fix an issue yesterday where the layout did not work properly when the widget is added to a group, your code looks exactly like that issue. Maybe you downloaded the github version a bit before the fix? I would expect it to work if you try the github version again.

Re: Broken Layouts?
« Reply #2 on: 02 September 2017, 13:38:45 »
It worked and yes, my github version was a few days (too) old. :)