Thanks!
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 MenuQuoteTabAlign can be moved inside TabContainerI 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.
QuoteThe layout code for example is newer than the Tabs widget, and it was only created to provide an alternative to fixed positions and sizesI 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 TGUIThat might be a point I could take up.
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).
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)};
}
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");
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);
}