From 6ab530cd1629ad44c9cc9b88c7c282329281d4b4 Mon Sep 17 00:00:00 2001 From: darkleem Date: Fri, 19 May 2017 21:31:53 +0900 Subject: [PATCH] Fix Native.Button default size issue - DatePicker & TimePicker size issue can be resolved. Change-Id: I2eb1ad1577be7cbb91c4dc2b8bd21e0dabc72298 Signed-off-by: darkleem --- Xamarin.Forms.Platform.Tizen/Native/Button.cs | 69 ++++----------------------- 1 file changed, 9 insertions(+), 60 deletions(-) diff --git a/Xamarin.Forms.Platform.Tizen/Native/Button.cs b/Xamarin.Forms.Platform.Tizen/Native/Button.cs index c663866..a3f36a4 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Button.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Button.cs @@ -1,8 +1,8 @@ -using System; using ElmSharp; +using System; using EButton = ElmSharp.Button; -using ESize = ElmSharp.Size; using EColor = ElmSharp.Color; +using ESize = ElmSharp.Size; namespace Xamarin.Forms.Platform.Tizen.Native { @@ -18,11 +18,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native readonly Span _span = new Span(); /// - /// The internal padding of the button, helps to determine the size. - /// - ESize _internalPadding; - - /// /// Optional image, if set will be drawn on the button. /// Image _image; @@ -186,51 +181,14 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// public ESize Measure(int availableWidth, int availableHeight) { - var size = Geometry; - - // resize the control using the whole available width - Resize(availableWidth, size.Height); - - // measure the button's text, use it as a hint for the size - var rawSize = Native.TextHelper.GetRawTextBlockSize(this); - var formattedSize = Native.TextHelper.GetFormattedTextBlockSize(this); - - // restore the original size - Resize(size.Width, size.Height); - - var padding = _internalPadding; - - // TODO : If the efl theme for the circle button is modified, it will be deleted. - if (Style == "circle") + switch (Style) { - var circleTextPadding = (EdjeObject["icon_text_padding"]?.Geometry.Height).GetValueOrDefault(0); - var circleHeight = padding.Height + ((rawSize.Width == 0) ? 0 : circleTextPadding + formattedSize.Height); - - return new ESize - { - Width = padding.Width, - Height = circleHeight - }; - } - - if (rawSize.Width > availableWidth) - { - // if the raw text width is larger than the available width, use - // either formatted size or internal padding, whichever is bigger - return new ESize() - { - Width = Math.Max(padding.Width, formattedSize.Width), - Height = Math.Max(padding.Height, Math.Min(formattedSize.Height, Math.Max(rawSize.Height, availableHeight))), - }; - } - else - { - // otherwise use the formatted size along with padding - return new ESize() - { - Width = padding.Width + formattedSize.Width, - Height = Math.Max(padding.Height, formattedSize.Height), - }; + case "bottom": + case "circle": + return new ESize(MinimumWidth, MinimumHeight); + default: + var rawSize = TextHelper.GetRawTextBlockSize(this); + return new ESize(rawSize.Width + MinimumWidth, Math.Max(MinimumHeight, rawSize.Height)); } } @@ -310,19 +268,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native if (Style != style) { Style = style; - - //TODO : If the efl theme for the circle button is modified, will use MinimumWidth, MinimumHeight to get the size. if (Style == "circle") - { - var circleSize = (EdjeObject["bg"]?.Geometry.Width).GetValueOrDefault(0); - _internalPadding = new ESize(circleSize, circleSize); _span.HorizontalTextAlignment = TextAlignment.Center; - } else - { - _internalPadding = new ESize(MinimumWidth, MinimumHeight); _span.HorizontalTextAlignment = TextAlignment.Auto; - } ApplyTextAndStyle(); } } -- 2.7.4