From 30ca7ed0c56a81335fe4d93964c37a575d9b7af4 Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Sat, 9 Dec 2017 19:34:36 -0800 Subject: [PATCH] Improve label and default element measuring --- Ooui.Forms/Extensions/ElementExtensions.cs | 4 ++-- Ooui.Forms/Renderers/LabelRenderer.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Ooui.Forms/Extensions/ElementExtensions.cs b/Ooui.Forms/Extensions/ElementExtensions.cs index 50b7cb6..53c1366 100644 --- a/Ooui.Forms/Extensions/ElementExtensions.cs +++ b/Ooui.Forms/Extensions/ElementExtensions.cs @@ -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); diff --git a/Ooui.Forms/Renderers/LabelRenderer.cs b/Ooui.Forms/Renderers/LabelRenderer.cs index 6a6104d..4d1884b 100644 --- a/Ooui.Forms/Renderers/LabelRenderer.cs +++ b/Ooui.Forms/Renderers/LabelRenderer.cs @@ -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; }