Skip to content
wwestrop edited this page Feb 28, 2015 · 3 revisions

The tabs that are already in Blender's interface, such as the left-hand panel are not called tabs, they are called "Categories". Tabs however are not really natively supported in Blender, and are implemented with a hack (the code even calls this out itself). These are what I've re-used to support the tabbed ribbon bar.

The region you want to tabs to must have a regiontype of RGN_TYPE_TOOLS. My region, despite setting this as the region type's regionid, did not inherit this value when instantiated, thus I set it manually in the init function for the region. The 3D view's left hand tab bar need this, I haven't worked out how this value ends up being set in that case.

Once you've set up the region with these constraints, you need to construct PanelType instances which will live inside that region and add them to the region's paneltypes linked list. Each panel you add must have it's category string set to the name you want to appear on the tab that will contain it. If you add two panels to a region with the same value in their category member, both panels will be added to the same tab (stacked together and collapsible in the usual way) .

Panels normally look like this:

They stack together and their labels act as headers which expands or collapses that panel.

When all the criteria described in the previous paragraphs are met, rather than showing all the panels in a region all stacked together, they are instead grouped into sets based on whatever is in their "category" string, and only one set is shown at a time. Tabs are provided (their titles match the category strings) to switch which set of panels is shown (see example - we still have collapsing panels, but each is now within a tab).

This entire region contains all of the panels from every one of the tabs. However only those with Tools as their category are shown

My ribbon implementation uses one panel per tab. It also sets the PNL_NO_HEADER bit within all of its panelTypes' flag field - meaning the panel header isn't drawn, and isn't available to collapse the panel either - it takes up the entire region until a different tab is selected.

Clone this wiki locally