2016-03-22 23:02:25 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using Android.Content;
|
2018-09-05 21:15:30 +03:00
|
|
|
using Android.Graphics;
|
2016-03-22 23:02:25 +03:00
|
|
|
using Android.OS;
|
|
|
|
using Android.Views;
|
|
|
|
using AView = Android.Views.View;
|
|
|
|
using Object = Java.Lang.Object;
|
2017-03-07 22:56:24 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
namespace Xamarin.Forms.Platform.Android
|
|
|
|
{
|
|
|
|
public class VisualElementTracker : IDisposable
|
|
|
|
{
|
|
|
|
readonly EventHandler<EventArg<VisualElement>> _batchCommittedHandler;
|
|
|
|
readonly IList<string> _batchedProperties = new List<string>();
|
|
|
|
readonly PropertyChangedEventHandler _propertyChangedHandler;
|
|
|
|
Context _context;
|
|
|
|
|
|
|
|
bool _disposed;
|
|
|
|
|
|
|
|
VisualElement _element;
|
|
|
|
bool _initialUpdateNeeded = true;
|
|
|
|
bool _layoutNeeded;
|
|
|
|
IVisualElementRenderer _renderer;
|
|
|
|
|
|
|
|
public VisualElementTracker(IVisualElementRenderer renderer)
|
|
|
|
{
|
|
|
|
if (renderer == null)
|
|
|
|
throw new ArgumentNullException("renderer");
|
|
|
|
|
|
|
|
_batchCommittedHandler = HandleRedrawNeeded;
|
|
|
|
_propertyChangedHandler = HandlePropertyChanged;
|
|
|
|
|
|
|
|
_renderer = renderer;
|
2017-04-06 16:19:52 +03:00
|
|
|
_context = renderer.View.Context;
|
2016-03-22 23:02:25 +03:00
|
|
|
_renderer.ElementChanged += RendererOnElementChanged;
|
|
|
|
|
|
|
|
VisualElement view = renderer.Element;
|
|
|
|
SetElement(null, view);
|
|
|
|
|
2017-04-06 16:19:52 +03:00
|
|
|
renderer.View.SetCameraDistance(3600);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2017-04-06 16:19:52 +03:00
|
|
|
renderer.View.AddOnAttachStateChangeListener(AttachTracker.Instance);
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
2016-09-22 01:04:36 +03:00
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
2016-03-22 23:02:25 +03:00
|
|
|
{
|
|
|
|
if (_disposed)
|
|
|
|
return;
|
|
|
|
|
2016-09-22 01:04:36 +03:00
|
|
|
_disposed = true;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2016-09-22 01:04:36 +03:00
|
|
|
if (disposing)
|
2016-03-22 23:02:25 +03:00
|
|
|
{
|
2016-09-22 01:04:36 +03:00
|
|
|
SetElement(_element, null);
|
|
|
|
|
|
|
|
if (_renderer != null)
|
|
|
|
{
|
|
|
|
_renderer.ElementChanged -= RendererOnElementChanged;
|
2017-04-06 16:19:52 +03:00
|
|
|
_renderer.View.RemoveOnAttachStateChangeListener(AttachTracker.Instance);
|
2016-09-22 01:04:36 +03:00
|
|
|
_renderer = null;
|
|
|
|
_context = null;
|
|
|
|
}
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateLayout()
|
|
|
|
{
|
2018-11-04 01:45:28 +03:00
|
|
|
Performance.Start(out string reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2017-09-13 12:18:59 +03:00
|
|
|
var headlessOffset = CompressedLayout.GetHeadlessOffset(view);
|
|
|
|
var x = (int)_context.ToPixels(view.X + headlessOffset.X);
|
|
|
|
var y = (int)_context.ToPixels(view.Y + headlessOffset.Y);
|
2017-03-03 14:28:44 +03:00
|
|
|
var width = Math.Max(0, (int)_context.ToPixels(view.Width));
|
|
|
|
var height = Math.Max(0, (int)_context.ToPixels(view.Height));
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
var formsViewGroup = aview as FormsViewGroup;
|
|
|
|
if (formsViewGroup == null)
|
|
|
|
{
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Start(reference, "Measure");
|
2016-03-22 23:02:25 +03:00
|
|
|
aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly));
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference, "Measure");
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Start(reference, "Layout");
|
2016-03-22 23:02:25 +03:00
|
|
|
aview.Layout(x, y, x + width, y + height);
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference, "Layout");
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Start(reference, "MeasureAndLayout");
|
2016-03-22 23:02:25 +03:00
|
|
|
formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height);
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference, "MeasureAndLayout");
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
2018-09-28 21:31:16 +03:00
|
|
|
// If we're running sufficiently new Android, we have to make sure to update the ClipBounds to
|
|
|
|
// match the new size of the ViewGroup
|
|
|
|
if ((int)Build.VERSION.SdkInt >= 18)
|
|
|
|
{
|
|
|
|
UpdateClipToBounds();
|
|
|
|
}
|
|
|
|
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
//On Width or Height changes, the anchors needs to be updated
|
|
|
|
UpdateAnchorX();
|
|
|
|
UpdateAnchorY();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
{
|
2017-04-06 16:19:52 +03:00
|
|
|
if (_renderer == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName)
|
|
|
|
{
|
|
|
|
UpdateClipToBounds();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_renderer.Element.Batched)
|
|
|
|
{
|
|
|
|
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
|
|
|
|
e.PropertyName == VisualElement.HeightProperty.PropertyName)
|
|
|
|
_layoutNeeded = true;
|
2018-05-07 15:22:56 +03:00
|
|
|
else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName ||
|
2016-03-22 23:02:25 +03:00
|
|
|
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
|
|
|
|
e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName ||
|
|
|
|
e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName)
|
|
|
|
{
|
|
|
|
if (!_batchedProperties.Contains(e.PropertyName))
|
|
|
|
_batchedProperties.Add(e.PropertyName);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
|
|
|
|
e.PropertyName == VisualElement.HeightProperty.PropertyName)
|
|
|
|
MaybeRequestLayout();
|
|
|
|
else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName)
|
|
|
|
UpdateAnchorX();
|
|
|
|
else if (e.PropertyName == VisualElement.AnchorYProperty.PropertyName)
|
|
|
|
UpdateAnchorY();
|
2018-11-04 01:45:28 +03:00
|
|
|
else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName
|
2018-05-09 14:32:26 +03:00
|
|
|
|| e.PropertyName == VisualElement.ScaleXProperty.PropertyName
|
|
|
|
|| e.PropertyName == VisualElement.ScaleYProperty.PropertyName)
|
2016-03-22 23:02:25 +03:00
|
|
|
UpdateScale();
|
|
|
|
else if (e.PropertyName == VisualElement.RotationProperty.PropertyName)
|
|
|
|
UpdateRotation();
|
|
|
|
else if (e.PropertyName == VisualElement.RotationXProperty.PropertyName)
|
|
|
|
UpdateRotationX();
|
|
|
|
else if (e.PropertyName == VisualElement.RotationYProperty.PropertyName)
|
|
|
|
UpdateRotationY();
|
|
|
|
else if (e.PropertyName == VisualElement.IsVisibleProperty.PropertyName)
|
|
|
|
UpdateIsVisible();
|
|
|
|
else if (e.PropertyName == VisualElement.OpacityProperty.PropertyName)
|
|
|
|
UpdateOpacity();
|
|
|
|
else if (e.PropertyName == VisualElement.TranslationXProperty.PropertyName)
|
|
|
|
UpdateTranslationX();
|
|
|
|
else if (e.PropertyName == VisualElement.TranslationYProperty.PropertyName)
|
|
|
|
UpdateTranslationY();
|
2017-06-09 00:30:25 +03:00
|
|
|
else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
|
|
|
|
UpdateIsEnabled();
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void HandleRedrawNeeded(object sender, EventArg<VisualElement> e)
|
|
|
|
{
|
|
|
|
foreach (string propertyName in _batchedProperties)
|
|
|
|
HandlePropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
_batchedProperties.Clear();
|
|
|
|
|
|
|
|
if (_layoutNeeded)
|
|
|
|
MaybeRequestLayout();
|
|
|
|
_layoutNeeded = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandleViewAttachedToWindow()
|
|
|
|
{
|
|
|
|
if (_initialUpdateNeeded)
|
|
|
|
{
|
|
|
|
UpdateNativeView(this, EventArgs.Empty);
|
|
|
|
_initialUpdateNeeded = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateClipToBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaybeRequestLayout()
|
|
|
|
{
|
|
|
|
var isInLayout = false;
|
|
|
|
if ((int)Build.VERSION.SdkInt >= 18)
|
2017-04-06 16:19:52 +03:00
|
|
|
isInLayout = _renderer.View.IsInLayout;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2017-04-06 16:19:52 +03:00
|
|
|
if (!isInLayout && !_renderer.View.IsLayoutRequested)
|
|
|
|
_renderer.View.RequestLayout();
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void RendererOnElementChanged(object sender, VisualElementChangedEventArgs args)
|
|
|
|
{
|
|
|
|
SetElement(args.OldElement, args.NewElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetElement(VisualElement oldElement, VisualElement newElement)
|
|
|
|
{
|
|
|
|
if (oldElement != null)
|
|
|
|
{
|
|
|
|
oldElement.BatchCommitted -= _batchCommittedHandler;
|
|
|
|
oldElement.PropertyChanged -= _propertyChangedHandler;
|
|
|
|
_context = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
_element = newElement;
|
|
|
|
if (newElement != null)
|
|
|
|
{
|
|
|
|
newElement.BatchCommitted += _batchCommittedHandler;
|
|
|
|
newElement.PropertyChanged += _propertyChangedHandler;
|
2017-04-06 16:19:52 +03:00
|
|
|
_context = _renderer.View.Context;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
if (oldElement != null)
|
|
|
|
{
|
2017-04-06 16:19:52 +03:00
|
|
|
AView view = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
// ReSharper disable CompareOfFloatsByEqualityOperator
|
|
|
|
if (oldElement.AnchorX != newElement.AnchorX)
|
|
|
|
UpdateAnchorX();
|
|
|
|
if (oldElement.AnchorY != newElement.AnchorY)
|
|
|
|
UpdateAnchorY();
|
|
|
|
if (oldElement.IsVisible != newElement.IsVisible)
|
|
|
|
UpdateIsVisible();
|
|
|
|
if (oldElement.IsEnabled != newElement.IsEnabled)
|
|
|
|
view.Enabled = newElement.IsEnabled;
|
|
|
|
if (oldElement.Opacity != newElement.Opacity)
|
|
|
|
UpdateOpacity();
|
|
|
|
if (oldElement.Rotation != newElement.Rotation)
|
|
|
|
UpdateRotation();
|
|
|
|
if (oldElement.RotationX != newElement.RotationX)
|
|
|
|
UpdateRotationX();
|
|
|
|
if (oldElement.RotationY != newElement.RotationY)
|
|
|
|
UpdateRotationY();
|
2018-05-07 15:22:56 +03:00
|
|
|
if (oldElement.Scale != newElement.Scale || oldElement.ScaleX != newElement.ScaleX || oldElement.ScaleY != newElement.ScaleY)
|
2016-03-22 23:02:25 +03:00
|
|
|
UpdateScale();
|
|
|
|
// ReSharper restore CompareOfFloatsByEqualityOperator
|
|
|
|
|
|
|
|
_initialUpdateNeeded = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAnchorX()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
float currentPivot = aview.PivotX;
|
|
|
|
var target = (float)(view.AnchorX * _context.ToPixels(view.Width));
|
|
|
|
if (currentPivot != target)
|
|
|
|
aview.PivotX = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAnchorY()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
float currentPivot = aview.PivotY;
|
|
|
|
var target = (float)(view.AnchorY * _context.ToPixels(view.Height));
|
|
|
|
if (currentPivot != target)
|
|
|
|
aview.PivotY = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateClipToBounds()
|
|
|
|
{
|
2018-09-05 21:15:30 +03:00
|
|
|
if (!(_renderer.Element is Layout layout))
|
|
|
|
{
|
2016-03-22 23:02:25 +03:00
|
|
|
return;
|
2018-09-05 21:15:30 +03:00
|
|
|
}
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
bool shouldClip = layout.IsClippedToBounds;
|
|
|
|
|
2018-09-05 21:15:30 +03:00
|
|
|
// setClipBounds is only available in API 18 +
|
|
|
|
if ((int)Build.VERSION.SdkInt >= 18)
|
|
|
|
{
|
|
|
|
if (!(_renderer.View is ViewGroup viewGroup))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2018-09-05 21:15:30 +03:00
|
|
|
// Forms layouts should not impose clipping on their children
|
|
|
|
viewGroup.SetClipChildren(false);
|
|
|
|
|
|
|
|
// But if IsClippedToBounds is true, they _should_ enforce clipping at their own edges
|
|
|
|
viewGroup.ClipBounds = shouldClip ? new Rect(0, 0, viewGroup.Width, viewGroup.Height) : null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// For everything in 17 and below, use the setClipChildren method
|
|
|
|
if (!(_renderer.View.Parent is ViewGroup parent))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((int)Build.VERSION.SdkInt >= 18 && parent.ClipChildren == shouldClip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
parent.SetClipChildren(shouldClip);
|
|
|
|
parent.Invalidate();
|
|
|
|
}
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateIsVisible()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
if (view.IsVisible && aview.Visibility != ViewStates.Visible)
|
|
|
|
aview.Visibility = ViewStates.Visible;
|
|
|
|
if (!view.IsVisible && aview.Visibility != ViewStates.Gone)
|
|
|
|
aview.Visibility = ViewStates.Gone;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateNativeView(object sender, EventArgs e)
|
|
|
|
{
|
2018-05-23 02:54:21 +03:00
|
|
|
Performance.Start(out string reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2018-05-09 14:32:26 +03:00
|
|
|
if (aview is FormsViewGroup formsViewGroup)
|
2016-03-22 23:02:25 +03:00
|
|
|
{
|
2018-05-07 15:22:56 +03:00
|
|
|
formsViewGroup.SendBatchUpdate((float)(view.AnchorX * _context.ToPixels(view.Width)),
|
|
|
|
(float)(view.AnchorY * _context.ToPixels(view.Height)),
|
|
|
|
(int)(view.IsVisible ? ViewStates.Visible : ViewStates.Invisible),
|
|
|
|
view.IsEnabled,
|
|
|
|
(float)view.Opacity,
|
|
|
|
(float)view.Rotation,
|
|
|
|
(float)view.RotationX,
|
|
|
|
(float)view.RotationY,
|
2018-05-09 14:32:26 +03:00
|
|
|
(float)view.Scale * (float)view.ScaleX,
|
|
|
|
(float)view.Scale * (float)view.ScaleY,
|
2018-05-07 15:22:56 +03:00
|
|
|
_context.ToPixels(view.TranslationX),
|
|
|
|
_context.ToPixels(view.TranslationY));
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-09 14:32:26 +03:00
|
|
|
FormsViewGroup.SendViewBatchUpdate(aview,
|
|
|
|
(float)(view.AnchorX * _context.ToPixels(view.Width)),
|
|
|
|
(float)(view.AnchorY * _context.ToPixels(view.Height)),
|
|
|
|
(int)(view.IsVisible ? ViewStates.Visible : ViewStates.Invisible),
|
|
|
|
view.IsEnabled,
|
|
|
|
(float)view.Opacity,
|
|
|
|
(float)view.Rotation,
|
|
|
|
(float)view.RotationX,
|
|
|
|
(float)view.RotationY,
|
|
|
|
(float)view.Scale * (float)view.ScaleX,
|
|
|
|
(float)view.Scale * (float)view.ScaleY,
|
|
|
|
_context.ToPixels(view.TranslationX),
|
|
|
|
_context.ToPixels(view.TranslationY));
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateOpacity()
|
|
|
|
{
|
2018-05-23 02:54:21 +03:00
|
|
|
Performance.Start(out string reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.Alpha = (float)view.Opacity;
|
|
|
|
|
2018-01-31 21:09:15 +03:00
|
|
|
Performance.Stop(reference);
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateRotation()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.Rotation = (float)view.Rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateRotationX()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.RotationX = (float)view.RotationX;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateRotationY()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.RotationY = (float)view.RotationY;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateScale()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
2018-05-07 15:22:56 +03:00
|
|
|
aview.ScaleX = (float)view.Scale * (float)view.ScaleX;
|
|
|
|
aview.ScaleY = (float)view.Scale * (float)view.ScaleY;
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateTranslationX()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.TranslationX = _context.ToPixels(view.TranslationX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateTranslationY()
|
|
|
|
{
|
|
|
|
VisualElement view = _renderer.Element;
|
2017-04-06 16:19:52 +03:00
|
|
|
AView aview = _renderer.View;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
aview.TranslationY = _context.ToPixels(view.TranslationY);
|
|
|
|
}
|
|
|
|
|
2017-06-09 00:30:25 +03:00
|
|
|
void UpdateIsEnabled()
|
|
|
|
{
|
|
|
|
_renderer.View.Enabled = _renderer.Element.IsEnabled;
|
|
|
|
}
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
class AttachTracker : Object, AView.IOnAttachStateChangeListener
|
|
|
|
{
|
|
|
|
public static readonly AttachTracker Instance = new AttachTracker();
|
|
|
|
|
|
|
|
public void OnViewAttachedToWindow(AView attachedView)
|
|
|
|
{
|
|
|
|
var renderer = attachedView as IVisualElementRenderer;
|
|
|
|
if (renderer == null || renderer.Tracker == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
renderer.Tracker.HandleViewAttachedToWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnViewDetachedFromWindow(AView detachedView)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-07 15:22:56 +03:00
|
|
|
}
|