summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs
blob: e6e56cdb35254fdb988443a6a17d57a774c9f5c8 (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
using ESize = ElmSharp.Size;

namespace Xamarin.Forms.Platform.Tizen
{
	public class EvasObjectWrapperRenderer : VisualElementRenderer<EvasObjectWrapper>
	{
		protected override void OnElementChanged(ElementChangedEventArgs<EvasObjectWrapper> e)
		{
			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);
		}
	}
}