Fix #8770: Centre vehicle status bar icon.

The icon is now centred within its scaled bounding box, which intentionally
leaves a little space around the icon when not at 1/2/4x scale.
pull/461/head
Peter Nelson 2 years ago committed by PeterN
parent 9bf24ec56f
commit 60404c3aea

@ -2878,7 +2878,7 @@ public:
const Vehicle *v = Vehicle::Get(this->window_number);
switch (widget) {
case WID_VV_START_STOP:
size->height = std::max<uint>({size->height, (uint)FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_WARNING_SIGN).height, GetSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
size->height = std::max<uint>({size->height, (uint)FONT_HEIGHT_NORMAL, GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
break;
case WID_VV_FORCE_PROCEED:
@ -3025,11 +3025,11 @@ public:
/* Draw the flag plus orders. */
bool rtl = (_current_text_dir == TD_RTL);
uint icon_width = std::max({GetSpriteSize(SPR_WARNING_SIGN).width, GetSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetSpriteSize(SPR_FLAG_VEH_RUNNING).width});
uint icon_width = std::max({GetScaledSpriteSize(SPR_WARNING_SIGN).width, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).width});
int lowered = this->IsWidgetLowered(widget) ? WidgetDimensions::scaled.pressed : 0;
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect).Translate(lowered, lowered);
SpriteID image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING;
DrawSprite(image, PAL_NONE, tr.WithWidth(icon_width, rtl).left, CenterBounds(tr.top, tr.bottom, GetSpriteSize(image).height));
DrawSpriteIgnorePadding(image, PAL_NONE, tr.WithWidth(icon_width, rtl), false, SA_CENTER);
tr = tr.Indent(icon_width + WidgetDimensions::scaled.imgbtn.Horizontal(), rtl);
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), str, text_colour, SA_HOR_CENTER);
}

Loading…
Cancel
Save