Fix Percent fields displayed as int in modifiers

supermerill/SuperSlicer#1116
This commit is contained in:
remi durand 2021-04-28 22:30:47 +02:00
parent ad44389983
commit 7c1d29acd8
2 changed files with 6 additions and 4 deletions

View File

@ -48,6 +48,8 @@ wxString double_to_string(double const value, const int max_precision /*= 8*/)
// Remove sign from orphaned zero.
if (s.compare("-0") == 0)
s = "0";
if (s.Last() == '.')
s.erase(s.length() -1);
}
}
@ -426,7 +428,7 @@ bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
}
void TextCtrl::BUILD() {
auto size = wxSize(def_width()*m_em_unit, wxDefaultCoord);
auto size = wxSize((this->m_opt.type == ConfigOptionType::coPercent ? def_width_thinner() : def_width())*m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -442,7 +444,7 @@ void TextCtrl::BUILD() {
}
case coPercent:
{
text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getFloat()));
text_value = double_to_string(m_opt.default_value->getFloat());
text_value += "%";
break;
}

View File

@ -886,8 +886,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
}
case coPercent:{
double val = config.option<ConfigOptionPercent>(opt_key)->value;
text_value = wxString::Format(_T("%i"), int(val));
ret = text_value;// += "%";
text_value = double_to_string(val);
ret = text_value;
}
break;
case coPercents: