Skip to content

Commit

Permalink
Hide wind information when speed is zero
Browse files Browse the repository at this point in the history
Refs: #82
  • Loading branch information
Matthias Meulien committed Dec 28, 2023
1 parent 77e53c1 commit 79181cc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 25 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- Hide wind information when speed is zero
[#82](https://github.com/orontee/taranis/issues/82)

- Resize application icon
[#72](https://github.com/orontee/taranis/issues/72)

Expand Down
26 changes: 18 additions & 8 deletions src/dailyforecastbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,25 @@ void DailyForecastBox::generate_table_content() {
units.format_temperature(forecast.temperature_max),
units.format_temperature(forecast.temperature_min)};
} else if (column_index == DailyForecastBox::WindColumn) {
const auto wind_speed_text = units.format_speed(forecast.wind_speed);
const auto wind_gust_text = units.format_speed(forecast.wind_gust);
if (forecast.wind_gust > forecast.wind_speed and
wind_gust_text != wind_speed_text) {
column_content[row_index] = std::pair<std::string, std::string>{
wind_speed_text, wind_gust_text};
} else {
if (static_cast<int>(forecast.wind_speed) == 0 and
static_cast<int>(forecast.wind_gust) == 0) {
column_content[row_index] =
std::pair<std::string, std::string>{wind_speed_text, ""};
std::pair<std::string, std::string>{"", ""};
} else {
const auto wind_speed_text =
units.format_speed(forecast.wind_speed);
const auto wind_gust_text = units.format_speed(forecast.wind_gust);
if (static_cast<int>(forecast.wind_speed) == 0) {
column_content[row_index] =
std::pair<std::string, std::string>{"", wind_gust_text};
} else if (forecast.wind_gust > forecast.wind_speed and
wind_gust_text != wind_speed_text) {
column_content[row_index] = std::pair<std::string, std::string>{
wind_speed_text, wind_gust_text};
} else {
column_content[row_index] =
std::pair<std::string, std::string>{wind_speed_text, ""};
}
}
} else if (column_index == DailyForecastBox::PrecipitationColumn) {
column_content[row_index] =
Expand Down
38 changes: 21 additions & 17 deletions src/hourlyforecastbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,29 @@ void HourlyForecastBox::draw_frame_and_values() {
DrawString(bar_center_x - StringWidth(temperature_text.c_str()) / 2.0,
this->temperature_y, temperature_text.c_str());

SetFont(tiny_font.get(), DGRAY);

const auto rotated_icon =
this->rotate_direction_icon(forecast.wind_degree);
if (rotated_icon) {
DrawBitmap(bar_center_x - this->wind_direction_icon_size / 2.0,
this->wind_direction_icon_y, rotated_icon);
if (static_cast<int>(forecast.wind_speed) != 0 or
static_cast<int>(forecast.wind_gust) != 0) {
const auto rotated_icon =
this->rotate_direction_icon(forecast.wind_degree);
if (rotated_icon) {
DrawBitmap(bar_center_x - this->wind_direction_icon_size / 2.0,
this->wind_direction_icon_y, rotated_icon);
}
}

const auto wind_speed_text = units.format_speed(forecast.wind_speed);
DrawString(bar_center_x - StringWidth(wind_speed_text.c_str()) / 2.0,
this->wind_speed_y, wind_speed_text.c_str());

const auto wind_gust_text = units.format_speed(forecast.wind_gust);
if (forecast.wind_gust > forecast.wind_speed and
wind_gust_text != wind_speed_text) {
SetFont(tiny_italic_font.get(), DGRAY);
DrawString(bar_center_x - StringWidth(wind_gust_text.c_str()) / 2.0,
this->wind_gust_y, wind_gust_text.c_str());
if (static_cast<int>(forecast.wind_speed) != 0) {
SetFont(tiny_font.get(), DGRAY);
DrawString(bar_center_x - StringWidth(wind_speed_text.c_str()) / 2.0,
this->wind_speed_y, wind_speed_text.c_str());
}
if (static_cast<int>(forecast.wind_gust) != 0) {
const auto wind_gust_text = units.format_speed(forecast.wind_gust);
if (forecast.wind_gust > forecast.wind_speed and
wind_gust_text != wind_speed_text) {
SetFont(tiny_italic_font.get(), DGRAY);
DrawString(bar_center_x - StringWidth(wind_gust_text.c_str()) / 2.0,
this->wind_gust_y, wind_gust_text.c_str());
}
}
}

Expand Down

0 comments on commit 79181cc

Please sign in to comment.