Improve label and default element measuring

This commit is contained in:
Frank A. Krueger 2017-12-09 19:34:36 -08:00
parent d0734ae795
commit 30ca7ed0c5
2 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,7 @@ namespace Ooui.Forms.Extensions
if (self.Style.Width.Equals ("inherit")) {
s = self.Text.MeasureSize (self.Style);
measured = true;
rw = double.IsPositiveInfinity (s.Width) ? double.PositiveInfinity : s.Width;
rw = double.IsPositiveInfinity (s.Width) ? double.PositiveInfinity : Math.Ceiling (s.Width);
}
else {
rw = self.Style.GetNumberWithUnits ("width", "px", 640);
@ -27,7 +27,7 @@ namespace Ooui.Forms.Extensions
s = self.Text.MeasureSize (self.Style);
measured = true;
}
rh = double.IsPositiveInfinity (s.Height) ? double.PositiveInfinity : s.Height;
rh = double.IsPositiveInfinity (s.Height) ? double.PositiveInfinity : Math.Ceiling (s.Height * 1.4);
}
else {
rh = self.Style.GetNumberWithUnits ("height", "px", 480);

View File

@ -18,6 +18,8 @@ namespace Ooui.Forms.Renderers
{
if (!_perfectSizeValid) {
var size = Element.Text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes);
size.Width = Math.Ceiling (size.Width);
size.Height = Math.Ceiling (size.Height * 1.4);
_perfectSize = new SizeRequest (size, size);
_perfectSizeValid = true;
}