/// <summary> /// Dispatches a batch of updates. /// </summary> /// <param name="absoluteX"> /// The absolute X-position of the node. /// </param> /// <param name="absoluteY"> /// The /// </param> /// <param name="uiViewOperationQueue"> /// Interface for enqueueing UI operations. /// </param> /// <param name="nativeViewHierarchyOptimizer"> /// Interface for optimizing native hierarchy calls. /// </param> /// <returns> /// <code>true</code> if updates were dispatched, otherwise <code>false</code>. /// </returns> internal bool DispatchUpdates( float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { if (_nodeUpdated) { OnCollectExtraUpdates(uiViewOperationQueue); } if (HasNewLayout) { _absoluteLeft = absoluteX + LayoutX; _absoluteTop = absoluteY + LayoutY; _absoluteRight = absoluteX + LayoutX + LayoutWidth; _absoluteBottom = absoluteY + LayoutY + LayoutHeight; nativeViewHierarchyOptimizer.HandleUpdateLayout(this); return(true); } else { return(false); } }
/// <summary> /// Instantiates a <see cref="NativeViewHierarchyOptimizer"/>. /// </summary> /// <param name="uiViewOperationQueue">The UI view operation queue.</param> /// <param name="shadowNodeRegistry">The shadow node registry.</param> public NativeViewHierarchyOptimizer( UIViewOperationQueue uiViewOperationQueue, ShadowNodeRegistry shadowNodeRegistry) { _uiViewOperationQueue = uiViewOperationQueue; _shadowNodeRegistry = shadowNodeRegistry; _tagsWithLayoutVisited = new Dictionary <int, bool>(); }
/// <summary> /// Instantiates the <see cref="UIImplementation"/>. /// </summary> /// <param name="viewManagers">The view managers.</param> /// <param name="operationsQueue">The operations queue.</param> protected UIImplementation( ViewManagerRegistry viewManagers, UIViewOperationQueue operationsQueue) { _viewManagers = viewManagers; _operationsQueue = operationsQueue; _shadowNodeRegistry = new ShadowNodeRegistry(); _nativeViewHierarchyOptimizer = new NativeViewHierarchyOptimizer( _operationsQueue, _shadowNodeRegistry); }
/// <summary> /// Dispatches a batch of updates. /// </summary> /// <param name="uiViewOperationQueue"> /// Interface for enqueueing UI operations. /// </param> /// <param name="nativeViewHierarchyOptimizer"> /// Interface for optimizing native hierarchy calls. /// </param> internal void DispatchUpdates( UIViewOperationQueue uiViewOperationQueue, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { if (_nodeUpdated) { OnCollectExtraUpdates(uiViewOperationQueue); } if (HasNewLayout) { nativeViewHierarchyOptimizer.HandleUpdateLayout(this); } }
/// <summary> /// Dispatches a batch of updates. /// </summary> /// <param name="absoluteX"> /// The absolute X-position of the node. /// </param> /// <param name="absoluteY"> /// The /// </param> /// <param name="uiViewOperationQueue"> /// Interface for enqueueing UI operations. /// </param> /// <param name="nativeViewHierarchyOptimizer"> /// Interface for optimizing native hierarchy calls. /// </param> /// <returns> /// <code>true</code> if updates were dispatched, otherwise <code>false</code>. /// </returns> internal bool DispatchUpdates( float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { if (_nodeUpdated) { OnCollectExtraUpdates(uiViewOperationQueue); } if (HasNewLayout) { var layoutX = LayoutX; var layoutY = LayoutY; var newAbsoluteLeft = (int)Math.Round(absoluteX + layoutX); var newAbsoluteTop = (int)Math.Round(absoluteY + layoutY); var newAbsoluteRight = (int)Math.Round(absoluteX + layoutX + LayoutWidth); var newAbsoluteBottom = (int)Math.Round(absoluteY + layoutY + LayoutHeight); var newScreenX = (int)Math.Round(layoutX); var newScreenY = (int)Math.Round(layoutY); var newScreenWidth = newAbsoluteRight - newAbsoluteLeft; var newScreenHeight = newAbsoluteBottom - newAbsoluteTop; var layoutHasChanged = MustForceLayout || newScreenX != ScreenX || newScreenY != ScreenY || newScreenWidth != ScreenWidth || newScreenHeight != ScreenHeight; ScreenX = newScreenX; ScreenY = newScreenY; ScreenWidth = newScreenWidth; ScreenHeight = newScreenHeight; if (layoutHasChanged) { nativeViewHierarchyOptimizer.HandleUpdateLayout(this); } return(layoutHasChanged); } else { return(false); } }
/// <summary> /// Instantiates the <see cref="UIImplementation"/>. /// </summary> /// <param name="reactContext">The React context.</param> /// <param name="viewManagers">The view managers.</param> /// <param name="operationsQueue">The operations queue.</param> /// <param name="eventDispatcher">The event dispatcher.</param> protected UIImplementation( ReactContext reactContext, ViewManagerRegistry viewManagers, UIViewOperationQueue operationsQueue, EventDispatcher eventDispatcher) { _reactContext = reactContext; _viewManagers = viewManagers; _operationsQueue = operationsQueue; _shadowNodeRegistry = new ShadowNodeRegistry(); _nativeViewHierarchyOptimizer = new NativeViewHierarchyOptimizer( _operationsQueue, _shadowNodeRegistry); _eventDispatcher = eventDispatcher; }
/// <summary> /// Dispatches a batch of updates. /// </summary> /// <param name="absoluteX">The absolute x-coordinate.</param> /// <param name="absoluteY">The absolute y-coordinate.</param> /// <param name="uiViewOperationQueue"> /// Interface for enqueueing UI operations. /// </param> /// <param name="nativeViewHierarchyOptimizer"> /// Interface for optimizing native hierarchy calls. /// </param> internal void DispatchUpdates( double absoluteX, double absoluteY, UIViewOperationQueue uiViewOperationQueue, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { if (_nodeUpdated) { OnCollectExtraUpdates(uiViewOperationQueue); } if (HasNewLayout) { _absoluteLeft = (int)Math.Round(absoluteX + LayoutX); _absoluteTop = (int)Math.Round(absoluteY + LayoutY); _absoluteRight = (int)Math.Round(_absoluteLeft + LayoutWidth); _absoluteBottom = (int)Math.Round(_absoluteTop + LayoutHeight); nativeViewHierarchyOptimizer.HandleUpdateLayout(this); } }
/// <summary> /// Called after a layout step at the end of a UI batch from /// <see cref="UIManagerModule"/>. May be used to enqueue additional UI /// operations for the native view. Will only be called on nodes marked /// as updated. /// </summary> /// <param name="uiViewOperationQueue"> /// Interface for enqueueing UI operations. /// </param> public virtual void OnCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { }