Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Kvaz1r

#1
Feature requests / Re: Modal dialog
30 September 2023, 10:50:58
Quote from: texus on 30 September 2023, 09:23:00All you should need to do in your code is keep a flag that a message box is open, and not do anything in the main loop except for passing events to TGUI when the flag is set (until you get signal from the message box that it was closed).

Yeah, it should work. Not sure though how complex this approach will be if I'd have modal dialog inside modal child window, but for my current needs it suits.
#2
Feature requests / Re: Modal dialog
28 September 2023, 21:07:33
Quote from: texus on 28 September 2023, 17:19:31You can use the technique described in https://tgui.eu/examples/1.0/blocking-events-outside-child-window/, but with a MessageBox instead of a ChildWindow

Nice technique, but it's won't work here. For example I have some Yes/No confirmation dialog that showing on button click:
button->onPress([this](const tgui::String& text) {
            if (showModal(L"Confirm nick changing?"))
            {
            // do something with gui
            }
 });
without real blocking showModal must return something before user perform any action. But if I block thread then gui loop won't be updated.
#3
Feature requests / Modal dialog
28 September 2023, 12:21:55
I don't found a way create modal (blocking) dialog in TGUI now, but it's something that might be using often (e.g. input password or confirmation).
#4
Installation help / Re: Build error
27 August 2023, 14:45:29
Was able to build with SFML 2.6, don't know what the difference, anyway for now it's good enough to me.
#5
Installation help / Re: Build error
27 August 2023, 14:27:28
Quote from: texus on 27 August 2023, 12:29:30Did you perhaps build shared SFML libraries and are trying to build static TGUI libraries? If you are trying to use a different shared/static config for SFML and TGUI then you need to define SFML_STATIC_LIBRARIES to either TRUE or FALSE to select how to link SFML.
No I always use static config (checked it several times). And in case with shared/static mismatch I'd get error on compile time, not CMake.

I'll try use SFML 2.6 maybe with this version all goes smoothly.
#6
Installation help / Build error
27 August 2023, 12:25:12
Trying to build lib, but getting CMake errors:

CMake Warning at cmake/Dependencies.cmake:54 (find_package):
  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2".

  The following configuration files were considered but not accepted:

    T:/libraries/C++/SFML/build/SFMLConfig.cmake, version: 3.0.0

Call Stack (most recent call first):
  cmake/Dependencies.cmake:86 (tgui_find_dependency_sfml)
  src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
  src/CMakeLists.txt:300 (include)


Requested SFML configuration (Static) was not found
CMake Warning at cmake/Dependencies.cmake:57 (find_package):
  Found package configuration file:

    T:/libraries/C++/SFML/build/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:86 (tgui_find_dependency_sfml)
  src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
  src/CMakeLists.txt:300 (include)


CMake Error at cmake/Dependencies.cmake:73 (message):
  CMake couldn't find SFML.

  Set SFML_DIR to the directory containing SFMLConfig.cmake (usually
  something like SFML_ROOT/lib/cmake/SFML)

Call Stack (most recent call first):
  cmake/Dependencies.cmake:86 (tgui_find_dependency_sfml)
  src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
  src/CMakeLists.txt:300 (include)
TGUI and SFML - current master branch. I didn't request "2" version anywhere.


P.S. CMake seems to me like a real disaster  :D
#7
Solution (define FreeType_LIB variable) was found in this issue - https://github.com/texus/TGUI/issues/180

thanks texus ;-)
#8
Help requests / Re: ListView removeItem error
02 September 2021, 22:12:53
Can you provide minimal reproducible sample?
#9
As usual - just write code, don't be afraid to be mistaken and don't hesitate to ask.
#10
Quote from: texus on 03 August 2021, 18:32:20
The hover only looks at the top 80px because it considers everything else to be outside the grid, while the rendering doesn't perform any clipping and thus renders the last 19px as well even though they lie outside the grid.
The most correct solution based on the current code would actually be to add clipping to the rendering and not draw the bottom part of the edit boxes.

Thanks, got it. I agree that rendering clipping would be useful for avoiding such behaviour - it'd made mistake obvious.
Or optional(?) assert with checking. In that case it won't break current behaviour, but still will be helpful.
#11
When both (padding and text size) are setting not to default value hovering on EditBox works incorrectly.

MCVE:

#include <TGUI/TGUI.hpp>

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

private:
    sf::RenderWindow& window;
    tgui::Gui& gui;

    const std::size_t nRows = 2;
    const std::size_t nCols = 3;

    std::vector<tgui::EditBox::Ptr> m_widgets;
    tgui::Grid::Ptr m_grid;
};

MyFrame::MyFrame(sf::RenderWindow& w, tgui::Gui& g) : window(w), gui(g)
{
    auto panel = tgui::Panel::create();
    m_grid = tgui::Grid::create();

    m_grid->setPosition({ 0,25 });
    m_grid->setSize({ "100%","20%" });

    std::vector<tgui::String> labels = { L"1",L"2",L"3" };

    tgui::Padding padding = { 0,25,0,0 };

    for (std::size_t i = 0; i < nRows; i++)
    {
        if (i > 0)
        {
            for (std::size_t j = 0; j < nCols; j++)
            {
                auto widget = tgui::EditBox::create();
                widget->setText(labels[j]);
                widget->getRenderer()->setBackgroundColorHover(tgui::Color::Cyan);
                m_grid->addWidget(widget, i, j, tgui::Grid::Alignment::Center, padding);
                m_widgets.push_back(widget);
            }
        }
        else
        {
            for (std::size_t j = 0; j < nCols; j++)
            {
                auto widget = tgui::Label::create(labels[j]);
                m_grid->addWidget(widget, i, j, tgui::Grid::Alignment::Center, padding);
            }
        }
    }

    panel->add(m_grid);
    gui.add(panel);
}

void MyFrame::main()
{
    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();
    }
}

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 400), "MCVE");
    window.setFramerateLimit(60);
    tgui::Gui gui(window);
    gui.setTextSize(20);
    MyFrame(window, gui).main();

    return EXIT_SUCCESS;
}
#12
Help requests / Re: Grid and scrollbar
15 June 2021, 20:55:07
Quote from: texus on 15 June 2021, 19:30:51
The vertical scrollbar isn't going to work when you set the grid size to 100%. The size of the grid should depend on its contents or be a chosen size, you shouldn't limit it to the viewable area of the scrollable panel (which is what 100% does). You'll want the grid size to be larger than 100%, because otherwise there will never be anything to scroll to. If you don't call m_grid->setSize then you will see that the vertical scrollbar works as intended (the columns in the grid need to be given a different width in that case though as auto-sizing puts the columns too close to each other).
Aha, I got it, thanks for the detailed explanation.
For some reason I thought that "100%" it's about relative virtual size and not about real viewable, so expected that container will grows with it's content. Now everything makes sense.
#13
Help requests / Grid and scrollbar
15 June 2021, 12:54:02
I have some widgets in grid and not all of them fit inside usual panel. I want to use scrollbar to provide access to widgets so put grid into ScrollablePanel panel. But even with scrollbar policy Always it can't change grid appearance. Does it bug or am I missing something?

MCVE:

#include <TGUI/TGUI.hpp>

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

protected:
    tgui::Grid::Ptr m_grid;
    tgui::TextArea::Ptr m_log;

private:
    void updateLayout();

    sf::RenderWindow& window;
    tgui::Gui& gui;
};

MyFrame::MyFrame(sf::RenderWindow& w, tgui::Gui& g) : window(w), gui(g)
{
    auto panel = tgui::ScrollablePanel::create();
    panel->getRenderer()->setBackgroundColor(sf::Color(200, 200, 200, 255));

    m_grid = tgui::Grid::create();

    for (std::size_t i = 0; i < 20; i++)
    {
        m_grid->addWidget(tgui::Label::create(tgui::String(i)), i, 0, tgui::Grid::Alignment::Center, { 0,10,0,0 });

        auto widget = tgui::EditBox::create();
        widget->setText(tgui::String(i));
        m_grid->addWidget(widget, i, 1, tgui::Grid::Alignment::Center, { 0,10,0,0 });
    }

    panel->add(m_grid);

    m_log = tgui::TextArea::create();
    panel->add(m_log);
    gui.add(panel);
   
    updateLayout();
    panel->setVerticalScrollbarPolicy(tgui::Scrollbar::Policy::Always);
}

void MyFrame::updateLayout()
{
    m_grid->setSize({ "50%","100%" });
    m_log->setSize({ "50%","100%" });

    auto size = window.getSize();
    m_grid->setPosition(0, 0);
    m_log->setPosition(size.x - 0.5 * size.x, 0);
}

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)
            {
                updateLayout();
            }
            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;
}
#14
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;
}
#15
I've opened issue on SFML forum - CMAKE error missing dependencies of SFML