bWidgets
Core widget toolkit designed for Blender
bwRange.h
Go to the documentation of this file.
1#pragma once
2
3namespace bWidgets {
4
5template<typename T> class bwRange {
6 public:
7 bwRange(T _min, T _max) : min(_min), max(_max)
8 {
9 }
10
11 void clampValue(T& value)
12 {
13 value = (value < min) ? min : ((value > max) ? max : value);
14 }
15 static void clampValue(T& value, const T& min, const T& max)
16 {
18 }
19
20 bool isInside(const T& value, const bool including_min_max = false) const
21 {
22 if (including_min_max) {
23 return (value >= min) && (value <= max);
24 }
25 else {
26 return (value > min) && (value < max);
27 }
28 }
29 static bool isInside(const T& value,
30 const T& min,
31 const T& max,
32 const bool including_min_max = false)
33 {
34 return bwRange<T>(min, max).isInside(value, including_min_max);
35 }
36
37 T min, max;
38};
39
40} // namespace bWidgets
Definition: bwRange.h:5
T max
Definition: bwRange.h:37
void clampValue(T &value)
Definition: bwRange.h:11
static void clampValue(T &value, const T &min, const T &max)
Definition: bwRange.h:15
bool isInside(const T &value, const bool including_min_max=false) const
Definition: bwRange.h:20
static bool isInside(const T &value, const T &min, const T &max, const bool including_min_max=false)
Definition: bwRange.h:29
bwRange(T _min, T _max)
Definition: bwRange.h:7
T min
Definition: bwRange.h:37
Definition: bwContext.h:3