TabbedComponent tabs to fill component width

I am playing around with a TabbedComponent with the orientation set to TabsAtTop. Now the TabbedComponent is rather wide, and the tab strings rather small (‘Bass’, ‘Mid’, ‘Tweet’), and so currently the tabs do not fill the horizontal width of the TabbedComponent, which stylistically is what I would like to achieve. I have had an attempt at doing this via the TabbedButtonBar property of the TabbedComponent and its minimum scale factor method, i.e.

tabs->setMinimumTabScaleFactor();

but this only seems to have an effect when the GUI is resized to be small enough that the tabs start shrinking below whatever scale factor I have set. So basically my question is: how do I get the tabs of a TabbedComponent to fill the horizontal width of the TabbedCompoenent at all times?

Thanks,

Pete

I don’t think there is an easy way to do this with JUCE at the moment. You probably will have to roll your own TabbedComponent drawing logic by creating your own look and feel which overrides the methods in TabbedButtonBar::LookAndFeelMethods. Let me know how you get on.

1 Like

Did you get anywhere with this? Would it probably be easier to create some buttons and manage the visible component manually rather than having a custom TabbedComponent?

If you (or anyone else) are still wondering, with a custom look and feel you can override the “getTabButtonBestWidth” function :

int PersonnalLookAndFeel::getTabButtonBestWidth(TabBarButton & button, int tabDepth)
{
    return button.getTabbedButtonBar().getWidth() / button.getTabbedButtonBar().getNumTabs();
} 

It does the trick.

5 Likes