aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Util.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-09 13:31:54 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-09 13:31:54 (GMT)
commit77f39235cf3ad79c5ff7d2b0f4717660476f3cf4 (patch)
tree45cc07526285fc74af54f340782eb11a9d7bc55c /src/FbTk/Util.hh
parent1657374940998176c7b63eb3296265fe6fbb5458 (diff)
downloadfluxbox_pavel-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.zip
fluxbox_pavel-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.tar.bz2
added FbTk::Util::clamp() and simplified related code
Diffstat (limited to 'src/FbTk/Util.hh')
-rw-r--r--src/FbTk/Util.hh43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/FbTk/Util.hh b/src/FbTk/Util.hh
new file mode 100644
index 0000000..5e5a986
--- /dev/null
+++ b/src/FbTk/Util.hh
@@ -0,0 +1,43 @@
1// Util.hh for fluxbox
2// Copyright (c) 2010 Mathias Gumz (akira at fluxbox org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef FBTK_UTIL_HH
23#define FBTK_UTIL_HH
24
25namespace FbTk {
26
27namespace Util {
28
29template<typename T>
30inline T clamp(const T& value, const T& lower, const T& upper) {
31 if (value < lower)
32 return lower;
33 else if (value > upper)
34 return upper;
35 return value;
36}
37
38} // end namespace Util
39
40} // end namespace FbTk
41
42
43#endif // FBTK_UTIL_HH