How's best to centre align TabbedButtonBar's TabBarButton elements?

Hi

I’m looking to use a TabbedComponent and centre the buttons in the bar (and ideally the text within those buttons), but its TabbedButtonBar::Orientation only contains TabsAtTop/Bottom/Left/Right. What’s the best way to achieve what something like a TabsAtTopCenter orientation option might do?

Similar to above, what would be the best way to inset the buttons by an amount? (I mean, if I am top-left aligning with TabsAtTop, if I wanted to start the buttons a little way in to the right).

Thanks
Matt

Hi Matt, I am afraid there is no declarative way to do this. You will need to code the resizing manually, but if I understand it correctly you can have a look how it is done in the Projucer:

There is a TabbedComponent with Tabs “Files”, “Config” and “Build” in the left section. If live builds are not enabled, it shows centered text and buttons. Please find the respective code on GitHub:
https://github.com/julianstorer/JUCE/blob/master/extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp#L388

Thanks Stefan.

I found another way was via look and feel so it sizes the buttons so in total they fill the available space (and the text within them is justified by default).

int custom_laf::getTabButtonBestWidth (TabBarButton& button, int tabDepth)
{
    TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>();
    if (bar && bar->getNumTabs() > 0)
        return bar->getWidth() / bar->getNumTabs();
    else
        return 50;
}

Only problem here is I’d still like to be able to reduce that width so I can have some smaller width buttons that are themselves centred via an inset on TabButtonBar’s first button placement. Any ideas where that would be? I’m sure this should be possible without subclassing, it must be in the laf layout facility somewhere.