20 T DragInteger(
double delta, T startValue, T minVal, T maxVal)
22 if (std::isnan(delta))
23 return std::max(minVal, std::min(startValue, maxVal));
24 constexpr double kExact = 9007199254740992.0;
26 if (std::fabs(
double(startValue)) <= kExact)
27 result = double(startValue) + delta;
32 const double step = std::trunc(delta);
33 const uint64_t from = uint64_t(startValue);
34 const uint64_t room = step >= 0 ? uint64_t(std::numeric_limits<T>::max()) - from
35 : from - uint64_t(std::numeric_limits<T>::lowest());
36 if (std::fabs(step) >=
double(room))
37 return step >= 0 ? std::max(minVal, maxVal) : minVal;
38 const uint64_t by = uint64_t(std::fabs(step));
39 const T moved = T(step >= 0 ? from + by : from - by);
40 return std::max(minVal, std::min(moved, maxVal));
43 if (result <=
double(minVal))
return minVal;
44 if (result >=
double(maxVal))
return std::max(minVal, maxVal);
67 double Calculate(int32_t offset,
double speedScale,
double startValue)
const
69 double result = startValue + offset * speedScale *
stepPerPixel;
70 if (std::isnan(result))
return 0.0;
86 float Calculate(int32_t offset,
double speedScale,
float startValue)
const
88 double result = double(startValue) + offset * speedScale *
stepPerPixel;
89 if (std::isnan(result))
return 0.0f;
90 return float(std::max(
double(
minVal), std::min(result,
double(
maxVal))));
103 uint64_t
Calculate(int32_t offset,
double speedScale, uint64_t startValue)
const
118 uint32_t
Calculate(int32_t offset,
double speedScale, uint32_t startValue)
const
133 uint16_t
Calculate(int32_t offset,
double speedScale, uint16_t startValue)
const
148 uint8_t
Calculate(int32_t offset,
double speedScale, uint8_t startValue)
const
163 int64_t
Calculate(int32_t offset,
double speedScale, int64_t startValue)
const
178 int32_t
Calculate(int32_t offset,
double speedScale, int32_t startValue)
const
193 int16_t
Calculate(int32_t offset,
double speedScale, int16_t startValue)
const
208 int8_t
Calculate(int32_t offset,
double speedScale, int8_t startValue)
const
Definition gui_logging.h:24
double Calculate(int32_t offset, double speedScale, double startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:67
double minVal
lowest allowed value
Definition gui_numeric_field_config.h:61
int decimals
digits shown after the point (2: "1.00"); -1: as few as the value needs
Definition gui_numeric_field_config.h:63
double maxVal
highest allowed value
Definition gui_numeric_field_config.h:62
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:60
int decimals
digits shown after the point (2: "1.00"); -1: as few as the value needs
Definition gui_numeric_field_config.h:82
float Calculate(int32_t offset, double speedScale, float startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:86
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:79
float minVal
lowest allowed value
Definition gui_numeric_field_config.h:80
float maxVal
highest allowed value
Definition gui_numeric_field_config.h:81
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:188
int16_t Calculate(int32_t offset, double speedScale, int16_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:193
int16_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:189
int16_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:190
int32_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:174
int32_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:175
int32_t Calculate(int32_t offset, double speedScale, int32_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:178
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:173
int64_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:159
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:158
int64_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:160
int64_t Calculate(int32_t offset, double speedScale, int64_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:163
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:203
int8_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:205
int8_t Calculate(int32_t offset, double speedScale, int8_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:208
int8_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:204
uint16_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:129
uint16_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:130
uint16_t Calculate(int32_t offset, double speedScale, uint16_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:133
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:128
uint32_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:115
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:113
uint32_t Calculate(int32_t offset, double speedScale, uint32_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:118
uint32_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:114
uint64_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:100
uint64_t Calculate(int32_t offset, double speedScale, uint64_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:103
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:98
uint64_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:99
uint8_t minVal
lowest allowed value
Definition gui_numeric_field_config.h:144
uint8_t Calculate(int32_t offset, double speedScale, uint8_t startValue) const
The value after dragging offset pixels from startValue; speedScale is the modifier factor (Ctrl 0....
Definition gui_numeric_field_config.h:148
double stepPerPixel
value change per pixel dragged
Definition gui_numeric_field_config.h:143
uint8_t maxVal
highest allowed value
Definition gui_numeric_field_config.h:145
Drag speed and range of a numeric Field, specialized per value type.
Definition gui_numeric_field_config.h:54