Allowing ints with open enums in combo boxes.

This commit is contained in:
Vojtech Bubnik 2021-03-10 16:16:00 +01:00
parent 73b88e6ce0
commit 2494a8f384
2 changed files with 18 additions and 6 deletions

View File

@ -2318,7 +2318,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionInt(1)); def->set_default_value(new ConfigOptionInt(1));
auto support_material_interface_layers = def = this->add("support_material_interface_layers", coInt); auto support_material_interface_layers = def = this->add("support_material_interface_layers", coInt);
def->gui_type = "f_enum_open"; def->gui_type = "i_enum_open";
def->label = L("Top interface layers"); def->label = L("Top interface layers");
def->category = L("Support material"); def->category = L("Support material");
def->tooltip = L("Number of interface layers to insert between the object(s) and support material."); def->tooltip = L("Number of interface layers to insert between the object(s) and support material.");
@ -2336,7 +2336,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionInt(3)); def->set_default_value(new ConfigOptionInt(3));
def = this->add("support_material_bottom_interface_layers", coInt); def = this->add("support_material_bottom_interface_layers", coInt);
def->gui_type = "f_enum_open"; def->gui_type = "i_enum_open";
def->label = L("Bottom interface layers"); def->label = L("Bottom interface layers");
def->category = L("Support material"); def->category = L("Support material");
def->tooltip = L("Number of interface layers to insert between the object(s) and support material. " def->tooltip = L("Number of interface layers to insert between the object(s) and support material. "

View File

@ -965,15 +965,27 @@ void Choice::BUILD() {
} }
if (is_defined_input_value<choice_ctrl>(window, m_opt.type)) { if (is_defined_input_value<choice_ctrl>(window, m_opt.type)) {
if (m_opt.type == coFloatOrPercent) { switch (m_opt.type) {
case coFloatOrPercent:
{
std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : ""; std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : "";
if (old_val == boost::any_cast<std::string>(get_value())) if (old_val == boost::any_cast<std::string>(get_value()))
return; return;
break;
} }
else { case coInt:
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999; {
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001) int old_val = !m_value.empty() ? boost::any_cast<int>(m_value) : 0;
if (old_val == boost::any_cast<int>(get_value()))
return; return;
break;
}
default:
{
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
return;
}
} }
on_change_field(); on_change_field();
} }