[Bf-committers] Interface Change for "new feature"
Douglas Bischoff
bf-committers@blender.org
Fri, 23 May 2003 13:46:42 -0400
Hello:
Okay, putting my money where my mouth is, and hoping that this works
out well.
I posted a feature request to allow entry of numbers 0-255 for color
values and have them translate automatically to Blender's decimal
system. Several packages (Maya, Max, Photoshop, etc.) operate on 0-255
values rather than decimals for color entry. Trying to do a tutorial or
color matching from one of these packages on Blender then involves a
calculator & pencil.
I've modified interface.c to include a VERY simple modification to
static int uiActAsTextBut(uiBut *but) that looks like this:
was:
----
if(value>max) value= max;
----
patch:
----
if(value>max) {
if(max>1) value= max;
else {
value=value/255;
if(value>max) value= max;
}
}
----
What this does is check to see if the value entered is greater than the
maximum allowed value for the button. If so, it checks to see if that
maximum value was already greater than one. If it is, simply set the
value to the maximum allowed value (just like the original function).
This works for things like "hardness."
Then, if the number was supposed to be <= 1, it will attempt to divide
the entered value by 255 to give a decimal. If that number is STILL
greater than the maximum allowed, insert the maximum allowed (which
will be 1 perforce).
There may be a more elegant way to code this (I'm a relative beginner),
I don't have commit rights, some folks might think this is not a good
idea overall, and Ton may have a heart attack that I'm messing around
in interface.c to start with. :-)
Another possibility is to define a new type: instead of NUMSLI perhaps
255SLI which permits this sort of thing. Then any location where this
behavior is desired it can be coded in buttons.c properly and that
behavior will only apply to those sliders where it is designated.
I can code that if desired.
Anyway, thanks for reading!
-Bischofftep the Neophyte