From 8feffc9eba315b51d17802b157a7213e5531ee47 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Mon, 27 Apr 2026 21:27:31 +0200 Subject: [PATCH] Codechange: make FillRectMode a scoped enum --- src/airport_gui.cpp | 2 +- src/bootstrap_gui.cpp | 4 ++-- src/dropdown_type.h | 2 +- src/gfx.cpp | 28 ++++++++++++++-------------- src/gfx_func.h | 17 ++++++++++++++--- src/gfx_type.h | 10 +++++----- src/graph_gui.cpp | 2 +- src/group_gui.cpp | 2 +- src/highscore_gui.cpp | 2 +- src/industry_gui.cpp | 4 ++-- src/misc_gui.cpp | 2 +- src/network/network_chat_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/news_gui.cpp | 4 ++-- src/picker_gui.cpp | 2 +- src/settings_gui.cpp | 14 +++++++------- src/textfile_gui.cpp | 2 +- src/toolbar_gui.cpp | 2 +- src/widget.cpp | 18 +++++++++--------- 19 files changed, 66 insertions(+), 55 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index ffbd7fb470..ea8c82f487 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -398,7 +398,7 @@ public: for (auto it = first; it != last; ++it) { const AirportSpec *as = *it; if (!as->IsAvailable()) { - GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER); + GfxFillRect(row, PC_BLACK, FillRectMode::Checker); } DrawString(text, as->name, (static_cast(as->index) == _selected_airport_index) ? TC_WHITE : TC_BLACK); row = row.Translate(0, this->line_height); diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 1628c9bf65..7202bfa6a9 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -60,8 +60,8 @@ public: void DrawWidget(const Rect &r, WidgetID) const override { - GfxFillRect(r, PixelColour{4}, FILLRECT_OPAQUE); - GfxFillRect(r, PixelColour{0}, FILLRECT_CHECKER); + GfxFillRect(r, PixelColour{4}, FillRectMode::Opaque); + GfxFillRect(r, PixelColour{0}, FillRectMode::Checker); } }; diff --git a/src/dropdown_type.h b/src/dropdown_type.h index f3fc33dff0..a80454701e 100644 --- a/src/dropdown_type.h +++ b/src/dropdown_type.h @@ -76,7 +76,7 @@ public: */ virtual void Draw(const Rect &full, [[maybe_unused]] const Rect &r, [[maybe_unused]] bool sel, [[maybe_unused]] int click_result, Colours bg_colour) const { - if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, SHADE_LIGHT), FILLRECT_CHECKER); + if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, SHADE_LIGHT), FillRectMode::Checker); } /** diff --git a/src/gfx.cpp b/src/gfx.cpp index 64dc21575b..6404380dac 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -107,11 +107,11 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) * @param top Minimum Y (inclusive) * @param right Maximum X (inclusive) * @param bottom Maximum Y (inclusive) - * @param colour A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR) + * @param colour A 8 bit palette index (FillRectMode::Opaque and FillRectMode::Checker) or a recolour spritenumber (FillRectMode::Recolour) * @param mode - * FILLRECT_OPAQUE: Fill the rectangle with the specified colour - * FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things) - * FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the rectangle currently on screen + * FillRectMode::Opaque: Fill the rectangle with the specified colour + * FillRectMode::Checker: Like FillRectMode::Opaque, but only draw every second pixel (used to grey out things) + * FillRectMode::Recolour: Apply a recolour sprite to every pixel in the rectangle currently on screen */ void GfxFillRect(int left, int top, int right, int bottom, const std::variant &colour, FillRectMode mode) { @@ -141,15 +141,15 @@ void GfxFillRect(int left, int top, int right, int bottom, const std::variantMoveTo(dpi->dst_ptr, left, top); switch (mode) { - default: // FILLRECT_OPAQUE + default: // FillRectMode::Opaque blitter->DrawRect(dst, right, bottom, std::get(colour)); break; - case FILLRECT_RECOLOUR: + case FillRectMode::Recolour: blitter->DrawColourMappingRect(dst, right, bottom, GB(std::get(colour), 0, PALETTE_WIDTH)); break; - case FILLRECT_CHECKER: { + case FillRectMode::Checker: { uint8_t bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; PixelColour pc = std::get(colour); do { @@ -204,11 +204,11 @@ static std::vector MakePolygonSegments(std::span shape * @note For rectangles the GfxFillRect function will be faster. * @pre dpi->zoom == ZoomLevel::Min * @param shape List of points on the polygon. - * @param colour An 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR). + * @param colour An 8 bit palette index (FillRectMode::Opaque and FillRectMode::Checker) or a recolour spritenumber (FillRectMode::Recolour). * @param mode - * FILLRECT_OPAQUE: Fill the polygon with the specified colour. - * FILLRECT_CHECKER: Fill every other pixel with the specified colour, in a checkerboard pattern. - * FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the polygon. + * FillRectMode::Opaque: Fill the polygon with the specified colour. + * FillRectMode::Checker: Fill every other pixel with the specified colour, in a checkerboard pattern. + * FillRectMode::Recolour: Apply a recolour sprite to every pixel in the polygon. */ void GfxFillPolygon(std::span shape, const std::variant &colour, FillRectMode mode) { @@ -278,13 +278,13 @@ void GfxFillPolygon(std::span shape, const std::variantMoveTo(dpi->dst_ptr, x1, y); switch (mode) { - default: // FILLRECT_OPAQUE + default: // FillRectMode::Opaque blitter->DrawRect(dst, x2 - x1, 1, std::get(colour)); break; - case FILLRECT_RECOLOUR: + case FillRectMode::Recolour: blitter->DrawColourMappingRect(dst, x2 - x1, 1, GB(std::get(colour), 0, PALETTE_WIDTH)); break; - case FILLRECT_CHECKER: { + case FillRectMode::Checker: { /* Fill every other pixel, offset such that the sum of filled pixels' X and Y coordinates is odd. * This creates a checkerboard effect. */ PixelColour pc = std::get(colour); diff --git a/src/gfx_func.h b/src/gfx_func.h index 182c2cd902..79d6772ecf 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -104,8 +104,8 @@ bool DrawStringMultiLineWithClipping(int left, int right, int top, int bottom, s void DrawCharCentered(char32_t c, const Rect &r, TextColour colour); -void GfxFillRect(int left, int top, int right, int bottom, const std::variant &colour, FillRectMode mode = FILLRECT_OPAQUE); -void GfxFillPolygon(std::span shape, const std::variant &colour, FillRectMode mode = FILLRECT_OPAQUE); +void GfxFillRect(int left, int top, int right, int bottom, const std::variant &colour, FillRectMode mode = FillRectMode::Opaque); +void GfxFillPolygon(std::span shape, const std::variant &colour, FillRectMode mode = FillRectMode::Opaque); void GfxDrawLine(int left, int top, int right, int bottom, PixelColour colour, int width = 1, int dash = 0); void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); void DrawRectOutline(const Rect &r, PixelColour colour, int width = 1, int dash = 0); @@ -174,7 +174,18 @@ inline bool DrawStringMultiLineWithClipping(const Rect &r, std::string_view str, return DrawStringMultiLineWithClipping(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize); } -inline void GfxFillRect(const Rect &r, const std::variant &colour, FillRectMode mode = FILLRECT_OPAQUE) +/** + * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. + * + * @pre dpi->zoom == ZoomLevel::Min, right >= left, bottom >= top + * @param r The rectangle to fill. + * @param colour A 8 bit palette index (FillRectMode::Opaque and FillRectMode::Checker) or a recolour spritenumber (FillRectMode::Recolour) + * @param mode + * FillRectMode::Opaque: Fill the rectangle with the specified colour + * FillRectMode::Checker: Like FillRectMode::Opaque, but only draw every second pixel (used to grey out things) + * FillRectMode::Recolour: Apply a recolour sprite to every pixel in the rectangle currently on screen + */ +inline void GfxFillRect(const Rect &r, const std::variant &colour, FillRectMode mode = FillRectMode::Opaque) { GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode); } diff --git a/src/gfx_type.h b/src/gfx_type.h index db74b52e25..f4ac7dcbc6 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -341,14 +341,14 @@ static constexpr uint8_t PALETTE_ANIM_SIZE = 28; ///< number of animated colours static constexpr uint8_t PALETTE_ANIM_START = 227; ///< Index in the _palettes array from which all animations are taking places (table/palettes.h) /** Define the operation GfxFillRect performs */ -enum FillRectMode : uint8_t { - FILLRECT_OPAQUE, ///< Fill rectangle with a single colour - FILLRECT_CHECKER, ///< Draw only every second pixel, used for greying-out - FILLRECT_RECOLOUR, ///< Apply a recolour sprite to the screen content +enum class FillRectMode : uint8_t { + Opaque, ///< Fill rectangle with a single colour + Checker, ///< Draw only every second pixel, used for greying-out + Recolour, ///< Apply a recolour sprite to the screen content }; /** Palettes OpenTTD supports. */ -enum PaletteType : uint8_t { +enum class PaletteType : uint8_t { DOS, ///< Use the DOS palette. Windows, ///< Use the Windows palette. }; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 632afa39bc..82c0cb3d46 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -725,7 +725,7 @@ public: DrawString(text, str, (this->highlight_state && this->highlight_range == index) ? TC_WHITE : TC_BLACK, SA_CENTER, false, FontSize::Small); if (HasBit(this->masked_range, index)) { - GfxFillRect(line.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(Colours::Brown, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(line.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(Colours::Brown, SHADE_DARKER), FillRectMode::Checker); } line = line.Translate(0, line_height); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index ddacaedae4..22ee6ff7c5 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -708,7 +708,7 @@ public: for (auto it = first; it != last; ++it) { const Vehicle *v = it->GetSingleVehicle(); if (v->group_id != this->vli.ToGroupID()) { - GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(Colours::Grey, SHADE_DARK), FILLRECT_CHECKER); + GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(Colours::Grey, SHADE_DARK), FillRectMode::Checker); } mr = mr.Translate(0, this->resize.step_height); } diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 2d37dcd400..c06c506698 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -50,7 +50,7 @@ struct EndGameHighScoreBaseWindow : Window { this->DrawWidgets(); /* Fill with the appropriate background colour instead of leaving default window colour */ - GfxFillRect(Rect{0, 0, this->width, this->height}, PixelColour{105}, FILLRECT_OPAQUE); + GfxFillRect(Rect{0, 0, this->width, this->height}, PixelColour{105}, FillRectMode::Opaque); /* Standard background slices are 50 pixels high, but it's designed * for 480 pixels total. 96% of 500 is 480. */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 0f00aca28e..1f10cf1496 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2218,7 +2218,7 @@ struct CargoesField { GfxDrawLine(colpos, top, colpos, bot, CARGO_LINE_COLOUR); colpos++; const CargoSpec *csp = CargoSpec::Get(this->u.cargo.vertical_cargoes[i]); - GfxFillRect(colpos, top, colpos + CargoesField::cargo_line.width - 2, bot, csp->legend_colour, FILLRECT_OPAQUE); + GfxFillRect(colpos, top, colpos + CargoesField::cargo_line.width - 2, bot, csp->legend_colour, FillRectMode::Opaque); colpos += CargoesField::cargo_line.width - 2; GfxDrawLine(colpos, top, colpos, bot, CARGO_LINE_COLOUR); colpos += 1 + CargoesField::cargo_space.width; @@ -2369,7 +2369,7 @@ private: static void DrawHorConnection(int left, int right, int top, const CargoSpec *csp) { GfxDrawLine(left, top, right, top, CARGO_LINE_COLOUR); - GfxFillRect(left, top + 1, right, top + CargoesField::cargo_line.height - 2, csp->legend_colour, FILLRECT_OPAQUE); + GfxFillRect(left, top + 1, right, top + CargoesField::cargo_line.height - 2, csp->legend_colour, FillRectMode::Opaque); GfxDrawLine(left, top + CargoesField::cargo_line.height - 1, right, top + CargoesField::cargo_line.height - 1, CARGO_LINE_COLOUR); } }; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index e8f5f78ccf..b75172f1e6 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -746,7 +746,7 @@ void QueryString::DrawEditBox(const Window *w, WidgetID wid) const DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FrameFlag::Lowered : FrameFlags{}); DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER); - if (this->text.GetText().empty()) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER); + if (this->text.GetText().empty()) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FillRectMode::Checker); DrawFrameRect(fr, wi->colour, {FrameFlag::Lowered, FrameFlag::Darkened}); GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 5ebc7b688f..6a9560ee9e 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -225,7 +225,7 @@ void NetworkDrawChatMessage() int bottom = _screen.height - _chatmsg_box.y - 2; /* Paint a half-transparent box behind the chat messages */ GfxFillRect(_chatmsg_box.x, top - 2, _chatmsg_box.x + _chatmsg_box.width - 1, bottom, - PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR // black, but with some alpha for background + PALETTE_TO_TRANSPARENT, FillRectMode::Recolour // black, but with some alpha for background ); /* Paint the chat messages starting with the lowest at the bottom */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index ff84328150..779c86aa22 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1496,7 +1496,7 @@ protected: DrawFrameRect(br, button->colour, {}); DrawSpriteIgnorePadding(button->sprite, PAL_NONE, br, SA_CENTER); if (button->disabled) { - GfxFillRect(br.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button->colour, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(br.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button->colour, SHADE_DARKER), FillRectMode::Checker); } r = r.Indent(button->width + WidgetDimensions::scaled.hsep_normal, !rtl); } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 4d8e065bd9..892e7d52d9 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -532,7 +532,7 @@ struct NewsWindow : Window { case WID_N_MGR_FACE: { const CompanyNewsInformation *cni = static_cast(this->ni->data.get()); DrawCompanyManagerFace(cni->face, cni->colour, r); - GfxFillRect(r, PALETTE_NEWSPAPER, FILLRECT_RECOLOUR); + GfxFillRect(r, PALETTE_NEWSPAPER, FillRectMode::Recolour); break; } case WID_N_MGR_NAME: { @@ -554,7 +554,7 @@ struct NewsWindow : Window { assert(std::holds_alternative(ni->ref1)); EngineID engine = std::get(this->ni->ref1); DrawVehicleEngine(r.left, r.right, CentreBounds(r.left, r.right, 0), CentreBounds(r.top, r.bottom, 0), engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW); - GfxFillRect(r, PALETTE_NEWSPAPER, FILLRECT_RECOLOUR); + GfxFillRect(r, PALETTE_NEWSPAPER, FillRectMode::Recolour); break; } case WID_N_VEH_INFO: { diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index c6b8cb9e8c..e79f27ba94 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -414,7 +414,7 @@ void PickerWindow::DrawWidget(const Rect &r, WidgetID widget) const } if (!this->callbacks.IsTypeAvailable(item.class_index, item.index)) { - GfxFillRect(ir, GetColourGradient(Colours::Grey, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(ir, GetColourGradient(Colours::Grey, SHADE_DARKER), FillRectMode::Checker); } break; } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index c187b937f2..8d42f27bc2 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1892,10 +1892,10 @@ void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool c /* Grey out the buttons that aren't clickable */ bool rtl = _current_text_dir == TD_RTL; if (rtl ? !clickable_right : !clickable_left) { - GfxFillRect(lr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER); + GfxFillRect(lr.Shrink(WidgetDimensions::scaled.bevel), colour, FillRectMode::Checker); } if (rtl ? !clickable_left : !clickable_right) { - GfxFillRect(rr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER); + GfxFillRect(rr.Shrink(WidgetDimensions::scaled.bevel), colour, FillRectMode::Checker); } } @@ -1922,8 +1922,8 @@ void DrawUpDownButtons(int x, int y, Colours button_colour, uint8_t state, bool DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, dr, SA_CENTER); /* Grey out the buttons that aren't clickable */ - if (!clickable_up) GfxFillRect(ur.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER); - if (!clickable_down) GfxFillRect(dr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER); + if (!clickable_up) GfxFillRect(ur.Shrink(WidgetDimensions::scaled.bevel), colour, FillRectMode::Checker); + if (!clickable_down) GfxFillRect(dr.Shrink(WidgetDimensions::scaled.bevel), colour, FillRectMode::Checker); } /** @@ -1944,7 +1944,7 @@ void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool cl DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, SA_CENTER); if (!clickable) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER); + GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), colour, FillRectMode::Checker); } } @@ -1962,13 +1962,13 @@ void DrawBoolButton(int x, int y, Colours button_colour, Colours background, boo Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1}; DrawFrameRect(r, state ? Colours::Green : background, state ? FrameFlags{FrameFlag::Lowered} : FrameFlags{FrameFlag::Lowered, FrameFlag::BorderOnly}); if (!clickable) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(state ? Colours::Green : background, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(state ? Colours::Green : background, SHADE_DARKER), FillRectMode::Checker); } Rect button_rect = r.WithWidth(SETTING_BUTTON_WIDTH / 3, state ^ (_current_text_dir == TD_RTL)); DrawFrameRect(button_rect, button_colour, {}); if (!clickable) { - GfxFillRect(button_rect.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button_colour, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(button_rect.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button_colour, SHADE_DARKER), FillRectMode::Checker); } } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index da20716e86..e62230b73e 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -553,7 +553,7 @@ void TextfileWindow::AfterLoadMarkdown() Rect fr = r.Shrink(WidgetDimensions::scaled.captiontext).WithHeight(WidgetDimensions::scaled.vsep_normal, true); size_t remaining = std::distance(this->reflow_iter, this->reflow_end); fr = fr.WithWidth(static_cast(remaining * fr.Width() / std::size(this->lines)), _current_text_dir != TD_RTL); - GfxFillRect(fr, PC_WHITE, FILLRECT_CHECKER); + GfxFillRect(fr, PC_WHITE, FillRectMode::Checker); } if (widget != WID_TF_BACKGROUND) return; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 77c8f69dc3..0938774e07 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1494,7 +1494,7 @@ public: /* Draw brown-red toolbar bg. */ const Rect r = this->GetCurrentRect(); GfxFillRect(r, PC_VERY_DARK_RED); - GfxFillRect(r, PC_DARK_RED, FILLRECT_CHECKER); + GfxFillRect(r, PC_DARK_RED, FillRectMode::Checker); this->NWidgetContainer::Draw(w); } diff --git a/src/widget.cpp b/src/widget.cpp index 8361f70a98..37ee61a685 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -309,7 +309,7 @@ WidgetID GetWidgetFromPos(const Window *w, int x, int y) void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags) { if (flags.Test(FrameFlag::Transparent)) { - GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR); + GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FillRectMode::Recolour); } else { assert(colour < Colours::End); @@ -532,7 +532,7 @@ static inline void DrawVerticalScrollbar(const Rect &r, Colours colour, bool up_ /* draw "shaded" background */ Rect bg = r.Shrink(0, height); GfxFillRect(bg, c2); - GfxFillRect(bg, c1, FILLRECT_CHECKER); + GfxFillRect(bg, c1, FillRectMode::Checker); /* track positions. These fractions are based on original 1x dimensions, but scale better. */ int left = r.left + r.Width() * 3 / 11; /* left track is positioned 3/11ths from the left */ @@ -572,7 +572,7 @@ static inline void DrawHorizontalScrollbar(const Rect &r, Colours colour, bool l /* draw "shaded" background */ Rect bg = r.Shrink(width, 0); GfxFillRect(bg, c2); - GfxFillRect(bg, c1, FILLRECT_CHECKER); + GfxFillRect(bg, c1, FillRectMode::Checker); /* track positions. These fractions are based on original 1x dimensions, but scale better. */ int top = r.top + r.Height() * 3 / 11; /* top track is positioned 3/11ths from the top */ @@ -1939,7 +1939,7 @@ void NWidgetSpacer::Draw(const Window *w) if (_draw_widget_outlines && this->current_x != 0 && this->current_y != 0) { /* Spacers indicate a potential design issue, so get extra highlighting. */ - GfxFillRect(this->GetCurrentRect(), PC_WHITE, FILLRECT_CHECKER); + GfxFillRect(this->GetCurrentRect(), PC_WHITE, FillRectMode::Checker); DrawOutline(w, this); } @@ -2361,7 +2361,7 @@ void NWidgetBackground::Draw(const Window *w) if (this->child != nullptr) this->child->Draw(w); if (this->IsDisabled()) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FillRectMode::Checker); } DrawOutline(w, this); @@ -2411,7 +2411,7 @@ void NWidgetViewport::Draw(const Window *w) /* Optionally shade the viewport. */ if (this->disp_flags.Any({NWidgetDisplayFlag::ShadeGrey, NWidgetDisplayFlag::ShadeDimmed})) { - GfxFillRect(this->GetCurrentRect(), this->disp_flags.Test(NWidgetDisplayFlag::ShadeDimmed) ? PALETTE_TO_TRANSPARENT : PALETTE_NEWSPAPER, FILLRECT_RECOLOUR); + GfxFillRect(this->GetCurrentRect(), this->disp_flags.Test(NWidgetDisplayFlag::ShadeDimmed) ? PALETTE_TO_TRANSPARENT : PALETTE_NEWSPAPER, FillRectMode::Recolour); } DrawOutline(w, this); @@ -2636,7 +2636,7 @@ void NWidgetScrollbar::Draw(const Window *w) } if (this->IsDisabled()) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FillRectMode::Checker); } DrawOutline(w, this); @@ -3016,7 +3016,7 @@ void NWidgetLeaf::Draw(const Window *w) case WWT_EMPTY: /* WWT_EMPTY used as a spacer indicates a potential design issue. */ if (this->index == -1 && _draw_widget_outlines) { - GfxFillRect(r, PC_BLACK, FILLRECT_CHECKER); + GfxFillRect(r, PC_BLACK, FillRectMode::Checker); } break; @@ -3126,7 +3126,7 @@ void NWidgetLeaf::Draw(const Window *w) if (this->IsDisabled() && this->type != WWT_BOOLBTN) { /* WWT_BOOLBTN is excluded as it draws its own disabled state. */ - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER); + GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FillRectMode::Checker); } DrawOutline(w, this);