mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Implement Button.ClipText.
This commit is contained in:
@@ -209,8 +209,16 @@ namespace SS14.Client.UserInterface.Controls
|
||||
|
||||
foreach (var chr in _text)
|
||||
{
|
||||
var advance = (int)font.DrawChar(handle, chr, baseLine, color);
|
||||
baseLine += new Vector2i(advance, 0);
|
||||
if (!font.TryGetCharMetrics(chr, out var metrics))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(ClipText && (baseLine.X < contentBox.Left || baseLine.X + metrics.Advance > contentBox.Right)))
|
||||
{
|
||||
font.DrawChar(handle, chr, baseLine, color);
|
||||
}
|
||||
baseLine += (metrics.Advance, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +235,11 @@ namespace SS14.Client.UserInterface.Controls
|
||||
|
||||
var fontHeight = font.Height;
|
||||
|
||||
if (ClipText)
|
||||
{
|
||||
return (0, fontHeight) + style.MinimumSize;
|
||||
}
|
||||
|
||||
var width = _ensureWidthCache();
|
||||
|
||||
return new Vector2(width, fontHeight) + style.MinimumSize;
|
||||
|
||||
Reference in New Issue
Block a user