Mercurial > mplayer.hg
diff gui/util/misc.c @ 37026:b6ff1451035d
Constrain an item's value to be in the range of 0 to 100.
Add function contrain() and replace checking the bounds by it.
Add it for mouse wheeling, too, where it has been missing so far.
author | ib |
---|---|
date | Thu, 03 Apr 2014 11:30:53 +0000 |
parents | 0790f864cea2 |
children | b28b632efeef |
line wrap: on
line diff
--- a/gui/util/misc.c Thu Apr 03 10:16:01 2014 +0000 +++ b/gui/util/misc.c Thu Apr 03 11:30:53 2014 +0000 @@ -47,3 +47,20 @@ return s; } + +/** + * @brief Constrain a @a value to be in the range of 0 to 100. + * + * @param value value to be checked + * + * @return a value in the range of 0 to 100 + */ +float constrain(float value) +{ + if (value < 0.0f) + return 0.0f; + if (value > 100.0f) + return 100.0f; + + return value; +}