diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-03-24 14:29:22 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-03-24 14:47:36 +0900 |
commit | 161a8e0f544b44f848d4c68ac9637d3a8b3f2520 (patch) | |
tree | 9a61043f0e27ef4f9855fcc1fc70693b12f10f4f /Xamarin.Forms.Platform.iOS/VisualElementTracker.cs | |
parent | 20daaa5702a27d1a9c7cf9dfacfdfa254ac0e5e3 (diff) | |
download | xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.tar.gz xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.tar.bz2 xamarin-forms-161a8e0f544b44f848d4c68ac9637d3a8b3f2520.zip |
Clean sync with 2.3.4-2
Change-Id: I6a7423d2690a1c30f46e0c128d9504a2464f8f0b
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/VisualElementTracker.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/VisualElementTracker.cs | 61 |
1 files changed, 7 insertions, 54 deletions
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs index 29840e2d..5b41ca84 100644 --- a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs +++ b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs @@ -3,13 +3,8 @@ using System.ComponentModel; using System.Drawing; using System.Threading; using CoreAnimation; -#if __MOBILE__ namespace Xamarin.Forms.Platform.iOS -#else - -namespace Xamarin.Forms.Platform.MacOS -#endif { public class VisualElementTracker : IDisposable { @@ -23,9 +18,7 @@ namespace Xamarin.Forms.Platform.MacOS // Track these by hand because the calls down into iOS are too expensive bool _isInteractive; Rectangle _lastBounds; -#if !__MOBILE__ - Rectangle _lastParentBounds; -#endif + CALayer _layer; int _updateCount; @@ -114,17 +107,12 @@ namespace Xamarin.Forms.Platform.MacOS var shouldInteract = !view.InputTransparent && view.IsEnabled; if (_isInteractive != shouldInteract) { -#if __MOBILE__ uiview.UserInteractionEnabled = shouldInteract; -#endif _isInteractive = shouldInteract; } var boundsChanged = _lastBounds != view.Bounds; -#if !__MOBILE__ - var viewParent = view.RealParent as VisualElement; - var parentBoundsChanged = _lastParentBounds != (viewParent == null ? Rectangle.Zero : viewParent.Bounds); -#endif + var thread = !boundsChanged && !caLayer.Frame.IsEmpty; var anchorX = (float)view.AnchorX; @@ -148,17 +136,13 @@ namespace Xamarin.Forms.Platform.MacOS { if (updateTarget != _updateCount) return; -#if __MOBILE__ + var visualElement = view; -#endif var parent = view.RealParent; var shouldRelayoutSublayers = false; if (isVisible && caLayer.Hidden) { -#if !__MOBILE__ - uiview.Hidden = false; -#endif caLayer.Hidden = false; if (!caLayer.Frame.IsEmpty) shouldRelayoutSublayers = true; @@ -166,9 +150,6 @@ namespace Xamarin.Forms.Platform.MacOS if (!isVisible && !caLayer.Hidden) { -#if !__MOBILE__ - uiview.Hidden = true; -#endif caLayer.Hidden = true; shouldRelayoutSublayers = true; } @@ -176,26 +157,11 @@ namespace Xamarin.Forms.Platform.MacOS // ripe for optimization var transform = CATransform3D.Identity; -#if __MOBILE__ - bool shouldUpdate = (!(visualElement is Page) || visualElement is ContentPage) && width > 0 && height > 0 && parent != null && boundsChanged; -#else - // We don't care if it's a page or not since bounds of the window can change - // TODO: Find why it doesn't work to check if the parentsBounds changed and remove true; - parentBoundsChanged = true; - bool shouldUpdate = width > 0 && height > 0 && parent != null && (boundsChanged || parentBoundsChanged); -#endif // Dont ever attempt to actually change the layout of a Page unless it is a ContentPage // iOS is a really big fan of you not actually modifying the View's of the UIViewControllers - if (shouldUpdate) + if ((!(visualElement is Page) || visualElement is ContentPage) && width > 0 && height > 0 && parent != null && boundsChanged) { -#if __MOBILE__ var target = new RectangleF(x, y, width, height); -#else - var visualParent = parent as VisualElement; - float newY = visualParent == null ? y : Math.Max(0, (float)(visualParent.Height - y - view.Height)); - var target = new RectangleF(x, newY, width, height); -#endif - // must reset transform prior to setting frame... caLayer.Transform = transform; uiview.Frame = target; @@ -204,17 +170,11 @@ namespace Xamarin.Forms.Platform.MacOS } else if (width <= 0 || height <= 0) { - //TODO: FInd why it doesn't work -#if __MOBILE__ caLayer.Hidden = true; -#endif return; } -#if __MOBILE__ + caLayer.AnchorPoint = new PointF(anchorX, anchorY); -#else - caLayer.AnchorPoint = new PointF(anchorX - 0.5f, anchorY - 0.5f); -#endif caLayer.Opacity = opacity; const double epsilon = 0.001; @@ -249,9 +209,6 @@ namespace Xamarin.Forms.Platform.MacOS update(); _lastBounds = view.Bounds; -#if !__MOBILE__ - _lastParentBounds = viewParent?.Bounds ?? Rectangle.Zero; -#endif } void SetElement(VisualElement oldElement, VisualElement newElement) @@ -282,18 +239,14 @@ namespace Xamarin.Forms.Platform.MacOS if (_layer == null) { -#if !__MOBILE__ - Renderer.NativeView.WantsLayer = true; -#endif _layer = Renderer.NativeView.Layer; -#if __MOBILE__ _isInteractive = Renderer.NativeView.UserInteractionEnabled; -#endif } OnUpdateNativeControl(_layer); - NativeControlUpdated?.Invoke(this, EventArgs.Empty); + if (NativeControlUpdated != null) + NativeControlUpdated(this, EventArgs.Empty); } } }
\ No newline at end of file |