mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-10 06:52:05 +01:00
Codechange: Call shorter variant of DrawFrameRect and GfxFillRect. (#14647)
Pass rect instead of breaking it up when possible.
This commit is contained in:
@@ -60,8 +60,8 @@ public:
|
||||
|
||||
void DrawWidget(const Rect &r, WidgetID) const override
|
||||
{
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, PixelColour{4}, FILLRECT_OPAQUE);
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, PixelColour{0}, FILLRECT_CHECKER);
|
||||
GfxFillRect(r, PixelColour{4}, FILLRECT_OPAQUE);
|
||||
GfxFillRect(r, PixelColour{0}, FILLRECT_CHECKER);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringA
|
||||
static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colour, bool clicked, SpriteID img, StringAlignment align)
|
||||
{
|
||||
assert(img != 0);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
|
||||
if ((type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; // Show different image when clicked for #WWT_IMGBTN_2.
|
||||
DrawSpriteIgnorePadding(img, PAL_NONE, r, align);
|
||||
@@ -363,7 +363,7 @@ static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colo
|
||||
*/
|
||||
static inline void DrawImageTextButtons(const Rect &r, Colours colour, bool clicked, SpriteID img, TextColour text_colour, const std::string &text, StringAlignment align, FontSize fs)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int image_width = img != 0 ? GetScaledSpriteSize(img).width : 0;
|
||||
@@ -426,7 +426,7 @@ static inline void DrawText(const Rect &r, TextColour colour, std::string_view s
|
||||
*/
|
||||
static inline void DrawInset(const Rect &r, Colours colour, TextColour text_colour, std::string_view str, StringAlignment align, FontSize fs)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, {FrameFlag::Lowered, FrameFlag::Darkened});
|
||||
DrawFrameRect(r, colour, {FrameFlag::Lowered, FrameFlag::Darkened});
|
||||
if (!str.empty()) DrawString(r.Shrink(WidgetDimensions::scaled.inset), str, text_colour, align, false, fs);
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ static inline void DrawInset(const Rect &r, Colours colour, TextColour text_colo
|
||||
*/
|
||||
static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint32_t num_columns, uint32_t num_rows, uint resize_x, uint resize_y)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
|
||||
int column_width; // Width of a single column in the matrix.
|
||||
if (num_columns == 0) {
|
||||
@@ -680,7 +680,7 @@ static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked)
|
||||
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked, bool bevel)
|
||||
{
|
||||
if (bevel) {
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
} else if (clicked) {
|
||||
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(colour, SHADE_LIGHTER));
|
||||
}
|
||||
@@ -694,7 +694,7 @@ static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bo
|
||||
*/
|
||||
static inline void DrawCloseBox(const Rect &r, Colours colour)
|
||||
{
|
||||
if (colour != COLOUR_WHITE) DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, {});
|
||||
if (colour != COLOUR_WHITE) DrawFrameRect(r, colour, {});
|
||||
Point offset;
|
||||
Dimension d = GetSpriteSize(SPR_CLOSEBOX, &offset);
|
||||
d.width -= offset.x;
|
||||
@@ -2307,7 +2307,7 @@ void NWidgetBackground::Draw(const Window *w)
|
||||
|
||||
switch (this->type) {
|
||||
case WWT_PANEL:
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, this->IsLowered() ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, this->colour, this->IsLowered() ? FrameFlag::Lowered : FrameFlags{});
|
||||
break;
|
||||
|
||||
case WWT_FRAME:
|
||||
@@ -2986,7 +2986,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
||||
break;
|
||||
|
||||
case WWT_PUSHBTN:
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, this->colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
break;
|
||||
|
||||
case WWT_BOOLBTN: {
|
||||
@@ -3006,7 +3006,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
||||
case WWT_TEXTBTN:
|
||||
case WWT_PUSHTXTBTN:
|
||||
case WWT_TEXTBTN_2:
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(r, this->colour, clicked ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawLabel(r, this->text_colour, GetStringForWidget(w, this, (type & WWT_MASK) == WWT_TEXTBTN_2 && clicked), this->align, this->text_size);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user