Changeset - r26622:112a317caf41
[Not reviewed]
master
0 1 0
PeterN - 19 months ago 2022-11-29 18:55:02
peter1138@openttd.org
Fix: Missing extra padding when drawing tooltip text. (#10201)

* Fix: Missing extra padding when drawing tooltip text.

This padding is included when calculating the size of the tooltips, the
difference caused a mismatch in height for some tooltips.

* Codechange: Don't draw grey panel underneath tooltip.

This removes the default framerect padding so it is now added explicitly.
SetMinimalSize is also removed as this is overridden in UpdateWidgetSize
anyway.
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -656,7 +656,7 @@ void HideFillingPercent(TextEffectID *te
 
}
 

	
 
static const NWidgetPart _nested_tooltips_widgets[] = {
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(200, 32), EndContainer(),
 
	NWidget(WWT_EMPTY, INVALID_COLOUR, WID_TT_BACKGROUND), EndContainer(),
 
};
 

	
 
static WindowDesc _tool_tips_desc(
 
@@ -722,8 +722,8 @@ struct TooltipsWindow : public Window
 
		size->height = GetStringHeight(this->string_id, size->width);
 

	
 
		/* Increase slightly to have some space around the box. */
 
		size->width  += padding.width  + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height += padding.height + WidgetDimensions::scaled.fullbevel.Vertical();
 
		size->width  += WidgetDimensions::scaled.framerect.Horizontal()  + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height += WidgetDimensions::scaled.framerect.Vertical()    + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -735,7 +735,7 @@ struct TooltipsWindow : public Window
 
		for (uint arg = 0; arg < this->paramcount; arg++) {
 
			SetDParam(arg, this->params[arg]);
 
		}
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect), this->string_id, TC_FROMSTRING, SA_CENTER);
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect).Shrink(WidgetDimensions::scaled.fullbevel), this->string_id, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnMouseLoop() override
0 comments (0 inline, 0 general)