summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Button.cs69
1 files changed, 9 insertions, 60 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Button.cs b/Xamarin.Forms.Platform.Tizen/Native/Button.cs
index c6638662..a3f36a4b 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();
/// <summary>
- /// The internal padding of the button, helps to determine the size.
- /// </summary>
- ESize _internalPadding;
-
- /// <summary>
/// Optional image, if set will be drawn on the button.
/// </summary>
Image _image;
@@ -186,51 +181,14 @@ namespace Xamarin.Forms.Platform.Tizen.Native
/// </summary>
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();
}
}