[Bf-committers] UI layout engine

Matt Ebb matt at mke3.net
Wed Nov 28 01:10:38 CET 2007


On Nov 27, 2007 4:41 PM, Alexander Ewering <blender at instinctive.de> wrote:
So, I'd say, this brings it to the point - now someone to implement it is
> needed :)
> As Matt seems to have some UI plans anyway (like always :), he seems like a
> good candidate :)

Ah well that's settled then! *cough* I mean, uhh... what? :P

But I agree with the premise, and in fact I already made something
like that a while ago. It was originally designed to both help adding
options for Python importers to the file selector itself (rather than
having to popup a separate pupblock after selecting the file), and
also as a replacement for the antiquated clever_numbuts().

I can't remember why I stopped with it, I'll have to hunt down the
code when I get home. But basically it was called 'SimpleBlock', an
abstraction over the current UI stuff (so it didn't have to replace
any current uiDefBut stuff).

It worked something like this (from memory):
sblock = uiSimpleBlockCreate()
uiSimpleBlockSettings(sblock, COLUMNS, 2); // or whatever per-block settings
uiSimpleBlockAdd(sblock, BUT, poin, tooltip, etc...)
uiSimpleBlockAdd(sblock, SEPARATOR, poin, tooltip, etc...)
uiSimpleBlockAdd(sblock, NUM, poin, tooltip, etc...)
uiSimpleBlockAdd(sblock, NEWCOLUMN, NULL, NULL, etc...)

uiSimpleBlockRowBegin(sblock);
uiSimpleBlockAdd(sblock, SLIDER, poin, tooltip, etc...)
uiSimpleBlockAdd(sblock, SLIDER, poin, tooltip, etc...)
uiSimpleBlockRowEnd(sblock);

then

uiSimpleBlockCreate(sblock, BUTTONS);
or
uiSimpleBlockCreate(sblock, PUPBLOCK);
or
uiSimpleBlockCreate(sblock, MENU);
etc

Those last commands would take the contents of the SimpleBlock, and
then generate UI code from that abstraction. So you could use it to
generate buttons in a panel, or a popup block similar to
clever_numbuts() does. One of the annoying things though was having to
free the sblock pointer at the end, though I guess doing it similarly
to uiBlocks are (keeping a list of them in each window space's
->blocks, and freeing those) might work...

I'll have a look for the code, but until Ton says anything I'll keep
on going with my grid system constants - it's already considerably
easier doing it that way.

Anyway, in any of this, simplicity is the key. Talk about including
GTK, or creating custom interpreted layout definition languages is way
overcomplicating the issue and missing the point a bit. The priorities
are:
* making it a bit quicker to put together button layouts in code and
* keeping things consistent and nicely laid out

The other thing is that the onus should be on getting things nicely
aligned, in consistent columned layouts, with consistent margins,
sizes, etc. rather than just stretching everything to fit haphazardly.
The aim should be to make it easier to make something like the camera
edit panel, not the 'Mesh Tools' panel.

cheers,

Matt


More information about the Bf-committers mailing list