Scissor the text of a ButtonWidget if it overflows and display a tooltip
Also: * add a variable to a comomn pattern used for truncating text in HotkeyEntryWidget and TextFieldWidget
This commit is contained in:
committed by
abcdefg30
parent
f325a4d190
commit
76a6e7ec92
@@ -579,7 +579,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var textPos = pos + new int2(LeftMargin, verticalMargin);
|
||||
|
||||
// Right align when editing and scissor when the text overflows
|
||||
if (textSize.X > Bounds.Width - LeftMargin - RightMargin)
|
||||
var isTextOverflowing = textSize.X > Bounds.Width - LeftMargin - RightMargin;
|
||||
if (isTextOverflowing)
|
||||
{
|
||||
if (HasKeyboardFocus)
|
||||
textPos += new int2(Bounds.Width - LeftMargin - RightMargin - textSize.X, 0);
|
||||
@@ -609,7 +610,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (showCursor && HasKeyboardFocus)
|
||||
font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), TextColor);
|
||||
|
||||
if (textSize.X > Bounds.Width - LeftMargin - RightMargin)
|
||||
if (isTextOverflowing)
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user