using System;
namespace Xamarin.Forms.Platform.Tizen
{
///
/// Renderer of a Layout.
///
public class LayoutRenderer : ViewRenderer
{
///
/// Default constructor.
///
public LayoutRenderer()
{
}
protected override void UpdateLayout()
{
// in case of layouts we need to make sure that the minimum size of the native control is updated
// this is important in case of ScrollView, when it's content is likely to be wider/higher than the window
// EFL does not allow control to be larger than the window if it's minimum size is smaller than window dimensions
ScrollView scrollView = Element.Parent as ScrollView;
if (scrollView != null)
{
Size size = scrollView.ContentSize;
Control.MinimumWidth = Forms.ConvertToScaledPixel(Math.Max(size.Width, scrollView.Content.Width));
Control.MinimumHeight = Forms.ConvertToScaledPixel(Math.Max(size.Height, scrollView.Content.Height));
}
base.UpdateLayout();
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
if (null == Control)
{
var canvas = new Native.Canvas(Forms.Context.MainWindow);
canvas.LayoutUpdated += OnLayoutUpdated;
SetNativeControl(canvas);
}
base.OnElementChanged(e);
}
protected override void Dispose(bool disposing)
{
Control.LayoutUpdated -= OnLayoutUpdated;
base.Dispose(disposing);
}
void OnLayoutUpdated(object sender, Native.LayoutEventArgs e)
{
DoLayout(e);
}
}
}