blob: 99e422e9a1908dde16a56d85be6263ce39f27a2b (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
using System;
namespace Xamarin.Forms.Platform.Tizen
{
/// <summary>
/// Renderer of a Layout.
/// </summary>
public class LayoutRenderer : ViewRenderer<Layout, Native.Canvas>
{
/// <summary>
/// Default constructor.
/// </summary>
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<Layout> 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);
}
}
}
|