/// <summary> /// Performs the border and size hover animation for the panel. /// </summary> /// <param name="gameTime"></param> private void PerformHoverAnimation(GameTime gameTime) { var dt = gameTime.ElapsedGameTime.TotalMilliseconds; if (IsHovered) { Width = MathHelper.Lerp(Width, OriginalSize.X.Value * 1.08f + 2, (float)Math.Min(dt / 30, 1)); Height = MathHelper.Lerp(Height, OriginalSize.Y.Value * 1.08f + 2, (float)Math.Min(dt / 30, 1)); Border.Thickness = MathHelper.Lerp(Border.Thickness, 4, (float)Math.Min(dt / 30, 1)); Border.FadeToColor(Color.Yellow, dt, 30); // Resetting the parent allows the panel to go on top of the other ones (changes draw order) Parent = Parent; } else { Width = MathHelper.Lerp(Width, OriginalSize.X.Value, (float)Math.Min(dt / 30, 1)); Height = MathHelper.Lerp(Height, OriginalSize.Y.Value, (float)Math.Min(dt / 30, 1)); Border.Thickness = MathHelper.Lerp(Border.Thickness, 0, (float)Math.Min(dt / 30, 1)); Border.FadeToColor(Color.Transparent, dt, 30); } // Always make sure thumbnail is at the correct size Thumbnail.Width = Width; Thumbnail.Height = Height - 100; // Always make sure heading container is at the correct size. HeadingContainer.Width = Width; HeadingContainer.Height = 100; HeadingContainer.Y = Thumbnail.Height; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { Border.FadeToColor(Selected ? Colors.MainAccent : Color.White, gameTime.ElapsedGameTime.TotalMilliseconds, 60); KeyText.FadeToColor(Selected ? Colors.MainAccent : Color.White, gameTime.ElapsedGameTime.TotalMilliseconds, 60); base.Update(gameTime); }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { var dt = gameTime.ElapsedGameTime.TotalMilliseconds; Border.FadeToColor(IsHovered ? Color.White : OriginalColor, dt, 60); Text.FadeToColor(IsHovered ? Color.White : OriginalColor, dt, 60); base.Update(gameTime); }