Exemplo n.º 1
0
        public void sendUpdate(Clock clock)
        {
            float blendPercent = currentTime / animationDuration;

            if (showing)
            {
                if (blendPercent > 1.0f)
                {
                    childLayout.setAlpha(1.0f);
                    unsubscribeFromUpdates();
                }
                else
                {
                    childLayout.setAlpha(blendPercent);
                }
            }
            else
            {
                if (blendPercent > 1.0f)
                {
                    childLayout.setAlpha(0.0f);
                    unsubscribeFromUpdates();
                    if (animationComplete != null)
                    {
                        animationComplete.Invoke(null);
                    }
                }
                childLayout.setAlpha(1.0f - blendPercent);
            }
        }
        public void sendUpdate(Clock clock)
        {
            if (animating)
            {
                currentTime += clock.DeltaSeconds;
                if (currentTime < animationLength)
                {
                    alpha       = EasingFunctions.Ease(currentEasing, 0, 1.0f, currentTime, animationLength);
                    currentSize = new IntSize2((int)(oldSize.Width + sizeDelta.Width * alpha), WorkingSize.Height);
                }
                else
                {
                    currentTime = animationLength;
                    alpha       = 1.0f;
                    currentSize = new IntSize2(oldSize.Width + sizeDelta.Width, WorkingSize.Height);

                    finishAnimation();
                    oldChildContainer = null;
                }
                if (childContainer != null && oldChildContainer != null)
                {
                    childContainer.setAlpha(alpha);
                }
                invalidate();
            }
        }
        public override void setAlpha(float alpha)
        {
            //Top
            if (top != null)
            {
                top.setAlpha(alpha);
            }

            //Bottom
            if (bottom != null)
            {
                bottom.setAlpha(alpha);
            }

            //Left
            if (left != null)
            {
                left.setAlpha(alpha);
            }

            //Center
            if (center != null)
            {
                center.setAlpha(alpha);
            }

            //Right
            if (right != null)
            {
                right.setAlpha(alpha);
            }
        }
 public override void setAlpha(float alpha)
 {
     this.alpha = alpha;
     if (child != null)
     {
         child.setAlpha(alpha);
     }
 }
 public void insertChild(LayoutContainer child, int index)
 {
     child.SuppressLayout = true;
     children.Insert(index, child);
     child._setParent(this);
     child.Visible = visible;
     child.setAlpha(alpha);
     child.SuppressLayout = false;
     invalidate();
 }
 public void addChild(LayoutContainer child)
 {
     child.SuppressLayout = true;
     children.Add(child);
     child._setParent(this);
     child.Visible = visible;
     child.setAlpha(alpha);
     child.SuppressLayout = false;
     invalidate();
 }
 private void finishAnimation()
 {
     //reset the old child
     if (oldChildContainer != null)
     {
         oldChildContainer._setParent(null);
         oldChildContainer.setAlpha(1.0f);
         oldChildContainer.WorkingSize = oldSize;
         oldChildContainer.animatedResizeCompleted(oldSize);
         oldChildContainer.layout();
     }
     fireAnimationComplete(oldChildContainer);
     if (childContainer != null)
     {
         childContainer.animatedResizeCompleted(currentSize);
     }
     unsubscribeFromUpdates();
 }
        public override void changePanel(LayoutContainer childContainer, float animDuration)
        {
            //If we were animating when a new request comes in clear the old animation first.
            if (animating)
            {
                if (this.childContainer != null)
                {
                    this.childContainer.setAlpha(1.0f);
                    this.childContainer.WorkingSize = newSize;
                    this.childContainer.layout();
                    finishAnimation();
                }
                else
                {
                    //If we were transitioning to null, but now there is another container use the child that was being transitioned
                    this.childContainer = oldChildContainer;
                    unsubscribeFromUpdates();
                }
            }

            currentTime     = 0.0f;
            animationLength = animDuration;

            oldChildContainer = this.childContainer;
            if (oldChildContainer != null)
            {
                oldSize = oldChildContainer.DesiredSize;
                oldChildContainer.animatedResizeStarted(new IntSize2(oldSize.Width, WorkingSize.Height));
            }
            else
            {
                oldSize = new IntSize2(0, 0);
            }

            this.childContainer = childContainer;
            if (childContainer != null)
            {
                childContainer._setParent(this);
                newSize = childContainer.DesiredSize;
                childContainer.animatedResizeStarted(new IntSize2(newSize.Width, WorkingSize.Height));
                //Force the child container to fit in the current alloted space
                childContainer.Location    = Location;
                childContainer.WorkingSize = new IntSize2(oldSize.Width, WorkingSize.Height);
                childContainer.layout();
            }
            else
            {
                newSize = new IntSize2(0, 0);
            }

            sizeDelta = newSize - oldSize;

            if (oldSize.Width == 0)
            {
                currentEasing = EasingFunction.EaseOutQuadratic;
            }
            else if (newSize.Width == 0)
            {
                currentEasing = EasingFunction.EaseInQuadratic;
            }
            else
            {
                currentEasing = EasingFunction.EaseInOutQuadratic;
            }

            //Make sure we start with no alpha if blending
            if (childContainer != null && oldChildContainer != null)
            {
                childContainer.setAlpha(0.0f);
            }

            subscribeToUpdates();
        }