public UpdateState(
     DeferredDrawingContextImpl owner,
     VisualNode?node,
     int childIndex,
     int drawOperationIndex)
 {
     Owner              = owner;
     Node               = node;
     ChildIndex         = childIndex;
     DrawOperationIndex = drawOperationIndex;
 }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public void UpdateAll(Scene scene)
        {
            Contract.Requires <ArgumentNullException>(scene != null);
            Dispatcher.UIThread.VerifyAccess();

            UpdateSize(scene);
            scene.Layers.GetOrAdd(scene.Root.Visual);

            using (var impl = new DeferredDrawingContextImpl(this, scene.Layers))
                using (var context = new DrawingContext(impl))
                {
                    Update(context, scene, (VisualNode)scene.Root, scene.Root.Visual.Bounds, true);
                }
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public void UpdateAll(Scene scene)
        {
            _ = scene ?? throw new ArgumentNullException(nameof(scene));
            Dispatcher.UIThread.VerifyAccess();

            UpdateSize(scene);
            scene.Layers.GetOrAdd(scene.Root.Visual);

            using (var impl = new DeferredDrawingContextImpl(this, scene.Layers))
                using (var context = new DrawingContext(impl))
                {
                    var clip = new Rect(scene.Root.Visual.Bounds.Size);
                    Update(context, scene, (VisualNode)scene.Root, clip, true);
                }
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        public bool Update(Scene scene, IVisual visual)
        {
            Contract.Requires <ArgumentNullException>(scene != null);
            Contract.Requires <ArgumentNullException>(visual != null);

            Dispatcher.UIThread.VerifyAccess();

            if (!scene.Root.Visual.IsVisible)
            {
                throw new AvaloniaInternalException("Cannot update the scene for an invisible root visual.");
            }

            var node = (VisualNode)scene.FindNode(visual);

            if (visual == scene.Root.Visual)
            {
                UpdateSize(scene);
            }

            if (visual.VisualRoot != null)
            {
                if (visual.IsVisible)
                {
                    // If the node isn't yet part of the scene, find the nearest ancestor that is.
                    node = node ?? FindExistingAncestor(scene, visual);

                    // We don't need to do anything if this part of the tree has already been fully
                    // updated.
                    if (node != null && !node.SubTreeUpdated)
                    {
                        // If the control we've been asked to update isn't part of the scene then
                        // we're carrying out an add operation, so recurse and add all the
                        // descendents too.
                        var recurse = node.Visual != visual;

                        using (var impl = new DeferredDrawingContextImpl(this, scene.Layers))
                            using (var context = new DrawingContext(impl))
                            {
                                var clip = scene.Root.Visual.Bounds;

                                if (node.Parent != null)
                                {
                                    context.PushPostTransform(node.Parent.Transform);
                                    clip = node.Parent.ClipBounds;
                                }

                                using (context.PushTransformContainer())
                                {
                                    Update(context, scene, node, clip, recurse);
                                }
                            }

                        return(true);
                    }
                }
                else
                {
                    if (node != null)
                    {
                        // The control has been hidden so remove it from its parent and deindex the
                        // node and its descendents.
                        ((VisualNode)node.Parent)?.RemoveChild(node);
                        Deindex(scene, node);
                        return(true);
                    }
                }
            }
            else if (node != null)
            {
                // The control has been removed so remove it from its parent and deindex the
                // node and its descendents.
                var trim = FindFirstDeadAncestor(scene, node);
                ((VisualNode)trim.Parent).RemoveChild(trim);
                Deindex(scene, trim);
                return(true);
            }

            return(false);
        }