Codechange: Remove FONT_HEIGHT_... macros. (#11481)

These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
This commit is contained in:
Peter Nelson
2023-11-21 19:04:24 +00:00
committed by GitHub
parent 96ec9c1b47
commit c18a1494b7
57 changed files with 369 additions and 381 deletions

View File

@@ -80,7 +80,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
uint DropDownListIconItem::Height() const
{
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
return std::max(this->dim.height, (uint)GetCharacterHeight(FS_NORMAL));
}
uint DropDownListIconItem::Width() const
@@ -94,7 +94,7 @@ void DropDownListIconItem::Draw(const Rect &r, bool sel, Colours) const
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
Rect tr = ir.Indent(this->dim.width + WidgetDimensions::scaled.hsep_normal, rtl);
DrawSprite(this->sprite, this->pal, ir.WithWidth(this->dim.width, rtl).left, CenterBounds(r.top, r.bottom, this->sprite_y));
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), this->String(), sel ? TC_WHITE : TC_BLACK);
}
void DropDownListIconItem::SetDimension(Dimension d)

View File

@@ -27,7 +27,7 @@ public:
virtual ~DropDownListItem() = default;
virtual bool Selectable() const { return false; }
virtual uint Height() const { return FONT_HEIGHT_NORMAL; }
virtual uint Height() const { return GetCharacterHeight(FS_NORMAL); }
virtual uint Width() const { return 0; }
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
};

View File

@@ -29,7 +29,7 @@ static const int SLIDER_WIDTH = 3;
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels)
{
/* Allow space for labels. We assume they are in the small font. */
if (!labels.empty()) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
if (!labels.empty()) r.bottom -= GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.hsep_normal;
max_value -= min_value;