[Bf-committers] uiDefBut(...BIT...) proposal

Daniel Dunbar bf-committers@blender.org
Wed, 7 Jan 2004 21:10:38 -0800 (PST)


One thing that has always annoyed me is that uiDefBut with
a type of BIT takes the bit index, not the bit value. This means
that you can't use the normal #define and so normally just a raw 
integer gets stuck there. This is a maintainance nightmare; for 
example, just searching for the ME_SUBSURF flag will not show you 
that it is toggled by a button.

Simple proposal to fix this problem:
For typed button definer functions (uiDefBut? uiDefIconBut? uiDefIconTextBut?)
add Bit variants, for example:
uiBut *uiDefButS(uiBlock *block, int type, ...);
uiBut *uiDefButBitS(uiBlock *block, int type, int bit, ...);
where bit is the actual flag value.

Then code can look like:
uiDefButBitS(block, TOG, ME_SUBSURF, B_MAKEDISP, "SubSurf", ...);
instead of:
uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf", ...);

Its a minor change, and I will probably not make all button definers use the
new functions (old still will work of course), but will make code more readable,
and easier to work with. Any detractors?



=====
daniel dunbar
daniel@zuster.org