- glcd/weather: align next_wtemp to the right

This commit is contained in:
vanhofen
2022-11-29 20:25:45 +01:00
committed by Thilo Graf
parent 24299980fc
commit 41867ee170

View File

@@ -161,17 +161,14 @@ void RenderWeather(bool standby)
if ((current_wtemp != "") && ctx) if ((current_wtemp != "") && ctx)
{ {
//current_wtemp += "°"; //current_wtemp += "°";
int current_width;
WeatherUpdateFonts(); WeatherUpdateFonts();
if (!standby) if (!standby)
{ {
current_width = font_temperature.Width(current_wtemp);
cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp, cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp,
&font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); &font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent);
} }
else else
{ {
current_width = font_temperature_standby.Width(current_wtemp);
cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp, cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp,
&font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); &font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent);
} }
@@ -187,18 +184,18 @@ void RenderWeather(bool standby)
if ((next_wtemp != "") && ntx) if ((next_wtemp != "") && ntx)
{ {
//next_wtemp += "°"; //next_wtemp += "°";
int next_width; int offset;
WeatherUpdateFonts(); WeatherUpdateFonts();
if (!standby) if (!standby)
{ {
next_width = font_temperature.Width(next_wtemp); offset = std::max(0, font_temperature.Width("88") - font_temperature.Width(next_wtemp));
cglcd->bitmap->DrawText(ntx, y, cglcd->bitmap->Width() - 1, next_wtemp, cglcd->bitmap->DrawText(ntx + offset, y, cglcd->bitmap->Width() - 1, next_wtemp,
&font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); &font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent);
} }
else else
{ {
next_width = font_temperature_standby.Width(next_wtemp); offset = std::max(0, font_temperature_standby.Width("88") - font_temperature_standby.Width(next_wtemp));
cglcd->bitmap->DrawText(ntx, y, cglcd->bitmap->Width() - 1, next_wtemp, cglcd->bitmap->DrawText(ntx + offset, y, cglcd->bitmap->Width() - 1, next_wtemp,
&font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); &font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent);
} }
} }