ConfigOptionDef: min/max values type are changed from INT to FLOAT.

This commit is contained in:
YuSanka 2022-08-30 10:33:52 +02:00
parent 656a1d262a
commit f277bc80c2
2 changed files with 8 additions and 8 deletions

View file

@ -1766,8 +1766,8 @@ public:
// <min, max> limit of a numeric input.
// If not set, the <min, max> is set to <INT_MIN, INT_MAX>
// By setting min=0, only nonnegative input is allowed.
int min = INT_MIN;
int max = INT_MAX;
float min = -FLT_MAX;
float max = FLT_MAX;
// To check if it's not a typo and a % is missing
double max_literal = 1;
ConfigOptionMode mode = comSimple;

View file

@ -777,7 +777,7 @@ void SpinCtrl::BUILD() {
break;
}
const int min_val = m_opt.min == INT_MIN
const int min_val = m_opt.min == -FLT_MAX
#ifdef __WXOSX__
// We will forcibly set the input value for SpinControl, since the value
// inserted from the keyboard is not updated under OSX.
@ -786,8 +786,8 @@ void SpinCtrl::BUILD() {
// less then min_val.
|| m_opt.min > 0
#endif
? 0 : m_opt.min;
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
? (int)0 : (int)m_opt.min;
const int max_val = m_opt.max < FLT_MAX ? (int)m_opt.max : INT_MAX;
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
@ -848,7 +848,7 @@ void SpinCtrl::BUILD() {
if (!parsed || value < INT_MIN || value > INT_MAX)
tmp_value = UNDEF_VALUE;
else {
tmp_value = std::min(std::max((int)value, m_opt.min), m_opt.max);
tmp_value = std::min(std::max((int)value, temp->GetMin()), temp->GetMax());
#ifdef __WXOSX__
// Forcibly set the input value for SpinControl, since the value
// inserted from the keyboard or clipboard is not updated under OSX
@ -1616,8 +1616,8 @@ void SliderCtrl::BUILD()
auto temp = new wxBoxSizer(wxHORIZONTAL);
auto def_val = m_opt.get_default_value<ConfigOptionInt>()->value;
auto min = m_opt.min == INT_MIN ? 0 : m_opt.min;
auto max = m_opt.max == INT_MAX ? 100 : m_opt.max;
auto min = m_opt.min == -FLT_MAX ? 0 : (int)m_opt.min;
auto max = m_opt.max == FLT_MAX ? 100 : INT_MAX;
m_slider = new wxSlider(m_parent, wxID_ANY, def_val * m_scale,
min * m_scale, max * m_scale,