1
0
Fork 0

Codechange: Use GetVisibleRangeIterators when drawing airport specs.

pull/12864/head
Peter Nelson 2024-07-17 10:04:10 +01:00
parent 53c96df94b
commit 7910331443
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 5 additions and 4 deletions

View File

@ -384,13 +384,14 @@ public:
case WID_AP_AIRPORT_LIST: { case WID_AP_AIRPORT_LIST: {
Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel); Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix); Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
AirportClass *apclass = AirportClass::Get(_selected_airport_class); const auto specs = AirportClass::Get(_selected_airport_class)->Specs();
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) { auto [first, last] = this->vscroll->GetVisibleRangeIterators(specs);
const AirportSpec *as = apclass->GetSpec(i); for (auto it = first; it != last; ++it) {
const AirportSpec *as = *it;
if (!as->IsAvailable()) { if (!as->IsAvailable()) {
GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER); GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
} }
DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK); DrawString(text, as->name, (as->index == _selected_airport_index) ? TC_WHITE : TC_BLACK);
row = row.Translate(0, this->line_height); row = row.Translate(0, this->line_height);
text = text.Translate(0, this->line_height); text = text.Translate(0, this->line_height);
} }