blob: f22d27b530e186675f51ab7c2ce6e8e8bd9870c6 (
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
58
59
60
61
62
63
64
65
66
67
|
using System;
using ElmSharp;
using EBox = ElmSharp.Box;
namespace Xamarin.Forms.Platform.Tizen.Native
{
/// <summary>
/// Extends the ElmSharp.Box class with functionality useful to Xamarin.Forms renderer.
/// </summary>
/// <remarks>
/// This class overrides the layout mechanism. Instead of using the native layout,
/// <c>LayoutUpdated</c> event is sent.
/// </remarks>
public class Box : EBox
{
/// <summary>
/// The last processed geometry of the Box which was reported from the native layer.
/// </summary>
Rect _previousGeometry;
/// <summary>
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Box"/> class.
/// </summary>
/// <param name="parent">The parent EvasObject.</param>
public Box(EvasObject parent) : base(parent)
{
Resized += (sender, e) => { NotifyOnLayout(); };
SetLayoutCallback(() => { NotifyOnLayout(); });
}
/// <summary>
/// Notifies that the layout has been updated.
/// </summary>
public event EventHandler<LayoutEventArgs> LayoutUpdated;
/// <summary>
/// Triggers the <c>LayoutUpdated</c> event.
/// </summary>
/// <remarks>
/// This method is called whenever there is a possibility that the size and/or position has been changed.
/// </remarks>
void NotifyOnLayout()
{
var g = Geometry;
if (0 == g.Width || 0 == g.Height)
{
// ignore irrelevant dimensions
return;
}
if (null != LayoutUpdated)
{
LayoutUpdated(this, new LayoutEventArgs()
{
HasChanged = g != _previousGeometry,
X = g.X,
Y = g.Y,
Width = g.Width,
Height = g.Height,
}
);
}
_previousGeometry = g;
}
}
}
|