Revert "Scissor the text of a ButtonWidget if it overflows and display a tooltip"
This reverts parts of commit 76a6e7ec92.
This commit is contained in:
committed by
abcdefg30
parent
70dc053c5f
commit
ef0cb7552d
@@ -243,27 +243,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var bgDark = GetContrastColorDark();
|
||||
var bgLight = GetContrastColorLight();
|
||||
|
||||
var contentWidth = Bounds.Width - LeftMargin - RightMargin;
|
||||
var stateOffset = Depressed ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||
|
||||
var position = GetTextPosition(text, font, rb);
|
||||
|
||||
var hover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
|
||||
DrawBackground(rb, disabled, Depressed, hover, highlighted);
|
||||
|
||||
// Scissor when the text overflows
|
||||
var isTextOverflowing = font.Measure(text).X > contentWidth;
|
||||
if (isTextOverflowing && TooltipContainer != null)
|
||||
{
|
||||
Game.Renderer.EnableScissor(new Rectangle(RenderOrigin.X + LeftMargin, RenderOrigin.Y,
|
||||
contentWidth, Bounds.Bottom));
|
||||
|
||||
if (GetTooltipText() == null)
|
||||
GetTooltipText = () => GetText();
|
||||
|
||||
text = WidgetUtils.TruncateText(text, contentWidth, font);
|
||||
}
|
||||
|
||||
if (Contrast)
|
||||
font.DrawTextWithContrast(text, position + stateOffset,
|
||||
disabled ? colordisabled : color, bgDark, bgLight, 2);
|
||||
@@ -272,9 +257,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
else
|
||||
font.DrawText(text, position + stateOffset,
|
||||
disabled ? colordisabled : color);
|
||||
|
||||
if (isTextOverflowing && TooltipContainer != null)
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
|
||||
int2 GetTextPosition(string text, SpriteFont font, Rectangle rb)
|
||||
|
||||
Reference in New Issue
Block a user