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
#16
I removed Strawberry but still got the same error.
I tried to build another project that has SFML as dependency and also got the same result. So it's not TGUI issue, but SFML one. I am going to create MCVE and raise issue on SFML forum.
#17
Quote from: texus on 19 September 2020, 20:05:12
Could it be that C:/Strawberry/c/include/freetype2 is giving a conflict with the freetype that comes with SFML?
Maybe, in any case I am going to remove Strawberry and test it again to be sure.
#18
Quote from: texus on 19 September 2020, 20:01:39
I don't see anything wrong with those files, it says that it has freetype at T:/libraries/C++/SFML-2.5.1/extlibs/libs-msvc-universal/x86/freetype.lib

Did you download the SFML version from github?
You are setting TGUI_SHARED_LIBS to FALSE, right?
Could you send the CMakeCache.txt file from your TGUI build?
Could you send your entire SFML folder?
Yes, I download sourse for 2.5.1 release from Github.
Right.
CMakeCache.txt attached

Entire SFML folder is huge (.pdb files for samples are heavy) if it's really useful I'll build SFML without them and send folder.
#19
Yes, attached
#20
No, same issue even when build SFML from source into separate folder.
#21
Maybe it exactly the mess in folder, because I built SFML from source into the same folder. I'll try rebuilt it to different location.
#22
Quote from: texus on 19 September 2020, 13:41:57
Did you manually copy the SFMLConfig.cmake to a different location, because it seems like SFMLConfig.cmake can't find FreeType? The SFMLConfig.cmake hardcodes relative paths, so you are supposed to keep the SFML folder structure.

No, I didn't change(or move, or copied somewhere else) any file inside SFML folder.
#23
Installation help / Error CMake couldn't find SFML
19 September 2020, 13:34:49
While building TGUI got such error:

QuoteSFML found but some of its dependencies are missing ( FreeType)
CMake Warning at src/Backends/SFML/CMakeLists.txt:13 (find_package):
  Found package configuration file:

    */libraries/C++/SFML-2.5.1/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
Call Stack (most recent call first):
  src/Backends/CMakeLists.txt:44 (include)
  src/CMakeLists.txt:162 (include)


CMake Error at src/Backends/SFML/CMakeLists.txt:25 (message):
  CMake couldn't find SFML.

  Set SFML_DIR to the directory containing SFMLConfig.cmake (usually
  something like SFML_ROOT/lib/cmake/SFML), or change TGUI_BACKEND to not use
  SFML.
Call Stack (most recent call first):
  src/Backends/CMakeLists.txt:44 (include)
  src/CMakeLists.txt:162 (include)

I suppose that's because this part was removed from CMakeLists.txt:

Quoteif(NOT TGUI_SHARED_LIBS)   
    if(SFML_ROOT)   
        if(TGUI_OS_WINDOWS)   
            set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${SFML_ROOT}/extlibs/headers")   
            if(ARCH_32BITS)   
                if(TGUI_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc/x86")   
                elseif(TGUI_COMPILER_MSVC) # VC++14 or newer   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc-universal/x86")   
                else() # gcc   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-mingw/x86")   
                endif()   
            elseif(ARCH_64BITS)   
                if(TGUI_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc/x64")   
                elseif(TGUI_COMPILER_MSVC) # VC++14 or newer   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc-universal/x64")   
                else() # gcc   
                    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-mingw/x64")   
                endif()   
            endif()   
        elseif(TGUI_OS_MACOSX)   
            set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${SFML_ROOT}/extlibs/headers")   
            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-osx/lib/")   
        elseif(TGUI_OS_ANDROID)   
            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/extlibs/lib/${CMAKE_ANDROID_ARCH_ABI}/")   
        elseif(TGUI_OS_IOS)   
            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-ios/")   
        endif()   
    endif()   
endif()   

together with SFML_ROOT. When I return it back and define SFML_ROOT all build as expected.
#24
Updated.
Single remaining part is saving/loading the widget to/from file.
Default implementation won't work, because not all panels are holding in inner container so their renderers are not inserted at this point into the renderer map.
#25
Quote from: texus on 24 July 2020, 19:57:18
The code mostly looks fine. A few remarks:
- Why double the height of the tab in the constructor?
For me default height in Tabs is a bit narrow, in PR I changed to default one, but I think it would be good to provide method for changing height of Tabs in some form.
In code above I just use getTabs function, but I removed it in PR because I don't see any sense to provide full access to private member in library. Or am I wrong and such function is OK?

Quote from: texus on 24 July 2020, 19:57:18
- Is "m_tabs->select(m_index);" in "m_tabs->onTabSelect" in tgPanelHolder constructor needed? Wouldn't it already be selected before this callback function is even called (and changed a second time in the Select function)?
Yes, it's needed for case if user forbid selection changing in onSelectionChanging handler, i.e:

            tabContainer->onSelectionChanging([&tabContainerelectedCount](int idx, bool* Vetoed)
            {
                if (someCondition)
                {
                    *Vetoed = true;
                }
            });


Quote from: texus on 24 July 2020, 19:57:18
- Perhaps you should only call "m_tabs->select(index);" in the Select function when the index in the tab is different (i.e. when the user called select himself). Right now you have something that looks like a recursion: Select calls m_tabs->select which triggers onTabSelect in which you call Select again.
It's indeed was reason of one extra call Select function. Index should be changed first, fixed.