Listbox renderer properties of Combobox aren't working after selection changes.

Started by Kvaz1r, 04 November 2020, 12:49:13

Kvaz1r

Listbox part renderer properties of Combobox are not working after selection changes.

Gif:

MCVE:

#include <TGUI/TGUI.hpp>

class MyFrame
{
public:
    MyFrame(sf::RenderWindow& w, tgui::Gui& g);
    void main();

protected:
    tgui::ComboBox::Ptr m_choice;
    tgui::ListBoxRenderer m_listBoxRenderer;
    sf::RenderWindow& window;
    tgui::Gui& gui;

};

MyFrame::MyFrame(sf::RenderWindow& w, tgui::Gui& g) : window(w), gui(g)
{
    m_listBoxRenderer.setBackgroundColor(tgui::Color(190, 190, 190));
    m_listBoxRenderer.setBackgroundColorHover(tgui::Color::Yellow);

    auto m_Panel = tgui::Panel::create();
    m_choice = tgui::ComboBox::create();
    m_choice->getRenderer()->setListBox(m_listBoxRenderer.getData());
    m_choice->addItem(L"1");
    m_choice->addItem(L"2");
    m_choice->addItem(L"3");
    m_choice->setSelectedItemByIndex(0);
    m_Panel->add(m_choice);
    m_choice->setSize({ window.getSize().x / 2, window.getSize().y / 15 });
    gui.add(m_Panel);
}

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

            if (event.type == sf::Event::Resized)
            {
                m_choice->setSize({ window.getSize().x / 2, window.getSize().y / 15 });
            }
            gui.handleEvent(event);
        }

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

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "MCVE");
    window.setFramerateLimit(60);

    tgui::Gui gui(window);
    MyFrame(window, gui).main();

    return EXIT_SUCCESS;
}

texus

Thanks for reporting and providing a clear MCVE. This has now been fixed in the latest 0.9-dev version.