[SOLVED] Armory upgrade to Blender 2.9.X

Ok, so I found a hack with which a “cheated” custom Armory properties panel is possible, but it has some flaws:

armory_properties_prototype
It’s currently using a Python icon for the Armory tab, but it can be replaced later

This works because there are a bunch of happy coincidences in the API:

  • You can append/prepend to the tab bar drawing function
  • You can create another EnumProperty that holds all custom tabs, unfortunately you can’t update the internally used property that holds all default tabs (=> no real custom properties panel)
  • Set the options of the new EnumProperty to ENUM_FLAG so that its only value (the Armory tab) can be deselected (this enables multiple selections but we only have one item in it)
  • If the new tab is selected, set the properties panel “context” (active tab) to render.
  • Now, override/wrap the poll() function of all panels in the render context to additionally check if the Armory tab is active

So the Armory tab is actually the render tab, but when drawing the UI there is a selection based on whether that tab is active or not.

As you can see in the render properties, you can even draw on top of the properties panel without having a sub-panel (see the Render Engine dropdown for example), which has also a poll() method and to which you can also prepend/append drawing functions. This makes it possible to have even more freedom with the UI, you are not bound to panels. For example we could permanently stick the Play/Clean buttons to the top with that.

Flaws:

  • You can check for property updates on the new tab(s), but not on the existing ones as far as I know. This means that you have to deselect the Armory tab with Shift + Click which is bad (otherwise you could deselect it when another tab is activated). There might be ways around that with the msgbus module but that will not work if you switch back to the render panel as it is already active (-> no update triggered).
  • The new search menu doesn’t work yet with the Armory tab, but I think it can be made possible
  • When – for example – pinning the current material in the top left corner of the material properties area, the Armory tab doesn’t hide. I don’t know yet if this is possible to implement.

Two workarounds

  1. Replace the new Armory tab with a toggle button (BoolProperty under the hood) that just decides for ALL tabs whether only the Armory panels should be visible. Actually, I kind of like this solution even if it doesn’t give us as much freedom with the UI if we decide to keep the Armory UI visible even when this button is not activated (that’s something to discuss then). Problem: the toggle button would be a few pixels too far to the left compared to the tabs, I’ve spent half an hour searching for a way around that but I didn’t succeed. You could replace this with an icon and a checkbox below that, but it would probably look ugly.

  2. Introduce a 2-layered tab bar. There would be a Armory button at the bottom and if you click on it, the default tabs collapse into a Blender button and the Armory tab opens. To open a default tab, you’d first have to click on the Blender button to close the Armory tab and to go back to the default tab view. This allows us to even add more Armory tabs without having a too big tab bar and it solves the clicking problems mentioned above (like node categories but for tabs). This can confuse users but it’s actually not that counter intuitive. However, the disadvantage is that we need to fully override and copy the tab drawing function, which makes it more dependent of Blender updates. But it would work.

Obviously there is still the option to keep it as it is, I have to do more tests first.

I hope this was understandable to some extent, I’m pretty tired and I want to go to bed but I am too exited to not let you know about my findings today :joy:

4 Likes