summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs
blob: 4e11c27720b39327021620bb59a93a9465ac873b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using ESize = ElmSharp.Size;

namespace Xamarin.Forms.Platform.Tizen
{
	public class EvasObjectWrapperRenderer : VisualElementRenderer<EvasObjectWrapper>
	{
		protected override void OnElementChanged(ElementChangedEventArgs<EvasObjectWrapper> e)
		{
			if (NativeView == null)
			{
				SetNativeControl(Element.EvasObject);
			}

			base.OnElementChanged(e);
		}

		protected override ESize Measure(int availableWidth, int availableHeight)
		{
			if (Element?.MeasureDelegate == null)
			{
				return base.Measure(availableWidth, availableHeight);
			}

			// The user has specified a different implementation of MeasureDelegate
			ESize? result = Element.MeasureDelegate(this, availableWidth, availableHeight);

			// If the delegate returns a ElmSharp.Size, we use it; if it returns null,
			// fall back to the default implementation
			return result ?? base.Measure(availableWidth, availableHeight);
		}
	}
}