Use RenderTemperature method in OptionsView, always re-render it on defocus, and remove degree symbol

This commit is contained in:
jacob1 2022-12-27 11:33:44 -05:00
parent fe67ec8550
commit b6cb6801df
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995
2 changed files with 4 additions and 17 deletions

View File

@ -184,13 +184,13 @@ void format::RenderTemperature(StringBuilder &sb, float temp, int scale)
switch (scale) switch (scale)
{ {
case 1: case 1:
sb << (temp - 273.15f) << " °C"; sb << (temp - 273.15f) << "C";
break; break;
case 2: case 2:
sb << (temp - 273.15f) * 1.8f + 32.0f << " °F"; sb << (temp - 273.15f) * 1.8f + 32.0f << "F";
break; break;
default: default:
sb << temp << " K"; sb << temp << "K";
break; break;
} }
} }

View File

@ -455,18 +455,7 @@ void OptionsView::AmbientAirTempToTextBox(float airTemp)
{ {
StringBuilder sb; StringBuilder sb;
sb << Format::Precision(2); sb << Format::Precision(2);
switch (temperatureScale->GetOption().second) format::RenderTemperature(sb, airTemp, temperatureScale->GetOption().second);
{
case 1:
sb << (airTemp - 273.15f) << "C";
break;
case 2:
sb << (airTemp - 273.15f) * 1.8f + 32.0f << "F";
break;
default:
sb << airTemp;
break;
}
ambientAirTemp->SetText(sb.Build()); ambientAirTemp->SetText(sb.Build());
} }
@ -499,8 +488,6 @@ void OptionsView::UpdateAirTemp(String temp, bool isDefocus)
airTemp = MIN_TEMP; airTemp = MIN_TEMP;
else if (airTemp > MAX_TEMP) else if (airTemp > MAX_TEMP)
airTemp = MAX_TEMP; airTemp = MAX_TEMP;
else
return;
AmbientAirTempToTextBox(airTemp); AmbientAirTempToTextBox(airTemp);
} }