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 - SteffenPloetz

#1
Thanks!
#2
I would like to be able to handle global keyboard events without having to re-implement BackendGuiSFML::mainLoop(). Otherwise, with each new version of TGUI, I would have to compare my mainLoop() implementation with the actual TGUI implementation.

But I haven't found anything how to intervene in handleEvent() or Container::processKeyPressEvent() if they return FALSE. Is a custom implementation of mainLoop() really the only way?
#3
QuoteTabAlign can be moved inside TabContainer
I got the feeling that TGUI prefers to follow the principle "one class = one file". And additionally you already figured out ...
QuoteKeeping the TabAlign enum has the advantage that it could be extended in the future
... which was my intention.

What I could do to reduce the complexity is setFixedTabWidth() to <= 0.0f and this is equal to "use the complete available space". ;)

QuoteThe layout code for example is newer than the Tabs widget, and it was only created to provide an alternative to fixed positions and sizes
I really think the layout system is outstanding (which doesn't mean it can made even better) and unique compared to other GUIs!

QuoteDocumentation is definitely lacking in TGUI
That might be a point I could take up.
#4
Thanks for the helpful step-by-step instructions (this does run a bit differently than the corporate Visual Studio steps I'm used to). Would it be a good idea to include this guide in CONTRIBUTING.md?

QuoteUnfortunately I think your changes are a bit too invasive to the code to be merged as-is: I don't like seeing changed to the Layout or global scope (tgui::TabAlign) for something specific to one widget. While bindNumberOfChildren might have other use cases, I feel like such addition needs to be discussed first and not merged together with a small addition elsewhere.
Totally understandable, it's a matter of the philosophy TGUI follows: I will try to reduce it. The difficulty here is that container and tab widgets both have child elements, but they are counted in different ways - here the TGUI API could be a bit more consistent.

QuoteThe setTabAlign function combines 2 unrelated properties: location of the tabs and whether they use the full width or not. While you probably needed to change both for your use case, I think it would be more useful to others if they are separate.
I can well understand the objection. On the other hand, you would then have to consistently tear apart enum TabAlign - and that makes the API more complicated again. Any idea to solve that?
    enum TabAlign
    {
        Top              = 0,      //!< Tabs use the complete width and are above panes
        TopFixedWidth    = 1 << 0, //!< Tabs use fixed width multiplied with tab count and are above panes
        Bottom           = 1 << 1, //!< Tabs use the complete width and are below panes
        BottomFixedWidth = 1 << 2, //!< Tabs use fixed width multiplied with tab count and are below panes
    };

QuoteIf it helps reduce the code then I'm fine with combining multiple properties like in TabAlign, but you need a setTabFixedSize function anyway, so I think you might as well use that function to determine whether the tabs have a fixed size (e.g. the default value is 0 in which case tabs have the old behavior, while calling setTabFixedSize will choose a fixed tab width).

Of course. I have only posted excerpts of my changes.
I look forward to the review comments.

I now have a sense of how TGUI should evolve - I exaggerate wildly to make it clear: Keep things simple and separated in order to minimize maintenance effort (in contrast to other tools that try to maximize programmer's convenience).
If I'm right about that - shouldn't that be pointed out somewhere?

Maybe you've already noticed: I'm a big fan of good documentation - especially for a beginner in TGUI like me it would be very helpful.

Regards
#5
Thank you for the quick response. I use GitKraken and get "Access denied". Do I have to create a fork? And if - how do you get informed about the fork?

The implementation is based on one single fixed value ( m_tabContainer->setTabFixedSize(150.0f); ) that is multiplied with the number of tabs ( m_tabs->setWidth(bindNumberOfTabs(m_tabs, m_tabFixedSize)); ). To achieve this, I added one binding and two helper to the Layout class:
        Layout bindNumberOfChildren(Container::Ptr container, const Layout& factor)
        {
            return Layout{Layout::Operation::Multiplies,
                          std::make_unique<Layout>(Layout::Operation::BindingNumberOfChildren, container.get()),
                          std::make_unique<Layout>(factor)};
        }

        Layout bindNumberOfTabs(Tabs::Ptr tabs, const Layout& factor)
        {
            return Layout{Layout::Operation::Multiplies,
                          std::make_unique<Layout>(Layout::Operation::BindingNumberOfChildren, tabs.get()),
                          std::make_unique<Layout>(factor)};
        }

My TabContainer creation code for UI test is:
        m_tabContainer = tgui::TabContainer::create();
        m_tabContainer->setPosition("0", "60%");
        m_tabContainer->setSize("100%", "80");
        m_tabContainer->setTabFixedSize(150.0f);
        auto tabPanel1 = m_tabContainer->addTab(L"Tab-Pane-01 (R)", true);
        tabPanel1->getRenderer()->setProperty("BackgroundColor", tgui::Color(255, 192, 192, 255));
        auto tabPanel2 = m_tabContainer->addTab(L"Tab-Pane-02 (G)", false);
        tabPanel2->getRenderer()->setProperty("BackgroundColor", tgui::Color(192, 255, 192, 255));
        this->getGui().add(m_tabContainer, "MyTabContainer");

To test the new functionality I use two call backs (that iterate the possible alignments and add/remove a tab to be able to test all possible combinations):
    void buttonTabAlignCallBack()
    {
        if(m_tabContainer->getTabAlign() == tgui::TabAlign::Top)
            m_tabContainer->setTabAlign(tgui::TabAlign::TopFixedWidth);
        else if(m_tabContainer->getTabAlign() == tgui::TabAlign::TopFixedWidth)
            m_tabContainer->setTabAlign(tgui::TabAlign::Bottom);
        else if(m_tabContainer->getTabAlign() == tgui::TabAlign::Bottom)
            m_tabContainer->setTabAlign(tgui::TabAlign::BottomFixedWidth);
        else
            m_tabContainer->setTabAlign(tgui::TabAlign::Top);
    }

    void buttonTabSizeCallBack()
    {
        if (m_tabContainer->getPanelCount() == 2)
        {
            auto tabPanel3 = m_tabContainer->addTab(L"Tab-Pane-02 (B)", false);
            tabPanel3->getRenderer()->setProperty("BackgroundColor", tgui::Color(192, 192, 255, 255));
        }
        else
            m_tabContainer->removeTab(m_tabContainer->getPanelCount() - 1);
    }

Beside that I also fixed a bug in removeTab(), that crashed if the tab to remove is the selected one.
#6
I like what I have seen so far. But even good things can be improved.

I could well imagine being involved in that. I wanted to start with something simple and so I extended the TabContainer.

The tabs of a TabContainer can now be aligned at the top (above the panels - the previous and default behavior) or at the bottom (below the panels) and additionally spread over the whole widget width (the previous and default behavior) or left-aligned with fixed width.

Bildschirmfoto_2022-08-20_11-50-18.png

But what do I do now exactly to make my solution available to the community? How can I support TGUI with code contribution? Didn't find any hint regarding that in https://github.com/texus/TGUI/blob/0.10/CONTRIBUTING.md.

I'm an advanced Visual Studio developer (my native language is German - if this could be of interest for translations). But I want to support OSS and so I'd like to contribute using Debian Linux and Code::Blocks 20.03. I already have a github account.

Thanks in advance.