[Bf-committers] uiList enhancements

Bastien Montagne montagne29 at wanadoo.fr
Thu Aug 15 00:43:01 CEST 2013


Hi Devs,

I finally manage to get valid separated patches for this project, pfew!

So, first one fixes some bugs with PROP_DYNAMIC RNA parameters (for RNA 
functions) - unless I completely misunderstood that piece of code, that 
kind of props was not handled nicely!

     http://www.pasteall.org/44830/diff

Next patch adds resizing of list by dragging (similar to scopes of Image 
editor), and improves handling of GRID layout:
* The way the dragging is handled is slightly hacky (it mostly uses num 
buttons system, but has to twist a bit to adapt to uiList 
specificities). All in all, it works pretty good!
* I decided to drop the "maxrows" option of list template, afaict it's 
not used anywhere, and it added quite some unneeded complication to 
template code (especially as we now support the same kind of features 
for GRID layout as well).
* I replaced it with a "columns" one, which allows to specify the number 
of columns you want when using a GRID layout. That layout also respect 
the "rows" option, is resizeable and scrollable.
-> This means a first API change, though it should be completely 
harmless in practice.
I also reshuffled a bit the uiList struct, moving all data that do not 
need to be stored into a substruct, uiListDyn (ignored by DNA).

     http://www.pasteall.org/44831/diff

Note that this patch has a few elements that are actually used by the 
next step (filtering and ordering patch below).

I also needed a new "drag" icon...

     http://www.pasteall.org/44832/diff

And finally, the main part of the project, filtering and ordering options.
So now, you can decide to show only some elements of the collection, and 
in a specific order. By default (C code), you can filter and/or sort 
over the name of the items (Unix wildcards supported), with reversed 
option for both.

But each custom uiList class can define its own filtering/reordering 
function, to have custom behavior based on what they list. As an example 
(example only, that code should be partly ported to C RNA to be usable 
with heavy meshes), I added the following features to vgroup list:
* Empty groups are shown grayed out in list.
* Groups can be filtered by name or emptiness.
* Groups can be sorted by name or importance (average weight over all 
vertices).

Results of filtering function are two lists (same length as number of 
items in list, or empty/NULL when no filtering or reordering was done), 
one of filtering flags, the other a mapping [org_idx] -> new_idx.

API changes:
* Added the flt_flag parameter to draw_item function (to allow things 
like graying out empty vgroups).
* Added two new functions, draw_filter and filter_items (called once per 
list draw), to draw filtering options and do the filtering job.

Note that to allow custom uiList sub-classes to have their own filtering 
options, I added an IDPropertyGroup to uiList.

     http://www.pasteall.org/44834/diff

I put all the "API maintenance" edits to scripts in a separate patch:

     http://www.pasteall.org/44835/diff

And that's it! ;) As usual, all comments, reviews etc. are highly 
appreciated!

Best regards,
Bastien

PS: No user doc for now, will do (and perhaps a small video too) asap.
PPS: patches should be applied more or less in above order, esp. 44834 
depends on 44831!


More information about the Bf-committers mailing list