Panel animation uses double time

This commit is contained in:
Garry Newman
2025-12-21 08:49:47 +00:00
parent f6ad79479f
commit 0298759d1f
4 changed files with 16 additions and 16 deletions

View File

@@ -187,7 +187,7 @@ public partial class Panel
if ( debounce.HasValue )
{
e.Time = TimeNow + debounce.Value;
e.Time = (float)(TimeNow + debounce.Value);
}
}

View File

@@ -5,8 +5,8 @@ namespace Sandbox.UI;
public partial class Panel
{
internal float TimeNow => PanelRealTime.TimeNow;
internal float TimeDelta => PanelRealTime.TimeDelta;
internal double TimeNow => PanelRealTime.TimeNow;
internal double TimeDelta => PanelRealTime.TimeDelta;
/// <summary>
/// Can be used to store random data without sub-classing the panel.
@@ -36,8 +36,8 @@ public partial class Panel
static class PanelRealTime
{
public static float TimeNow;
public static float TimeDelta;
public static double TimeNow;
public static double TimeDelta;
public static void Update()
{

View File

@@ -3,7 +3,7 @@
public partial class Styles
{
KeyFrames currentFrames;
float animationStart;
double animationStart;
Styles animStyle;
/// <summary>
@@ -109,7 +109,7 @@ public partial class Styles
}
var f = Utility.Easing.GetFunction( AnimationTimingFunction ?? "linear" );
delta = f( delta );
delta = f( (float)delta );
if ( playLength >= totalDuration )
{
@@ -120,7 +120,7 @@ public partial class Styles
return false;
}
keyframes.FillStyle( delta, animStyle );
keyframes.FillStyle( (float)delta, animStyle );
Add( animStyle );

View File

@@ -12,15 +12,15 @@ public sealed class Transitions
public struct Entry
{
public string Property { get; init; }
public float StartTime { get; init; }
public float Length { get; init; }
public double StartTime { get; init; }
public double Length { get; init; }
public int Target { get; init; }
public Utility.Easing.Function EasingFunction { get; init; }
public bool IsKilled { get; private set; }
public TransitionFunction Action { get; init; }
public Entry( string property, float startTime, float length, int target, TransitionFunction action, Easing.Function easingFunction ) : this()
public Entry( string property, double startTime, double length, int target, TransitionFunction action, Easing.Function easingFunction ) : this()
{
Property = property;
StartTime = startTime;
@@ -107,7 +107,7 @@ public sealed class Transitions
}
}
internal void Add( Styles from, Styles to, float startTime )
internal void Add( Styles from, Styles to, double startTime )
{
if ( !to.HasTransitions ) return;
@@ -124,7 +124,7 @@ public sealed class Transitions
}
}
void Transition( in TransitionDesc desc, BaseStyles from, BaseStyles to, TransitionFunction action, float startTime )
void Transition( in TransitionDesc desc, BaseStyles from, BaseStyles to, TransitionFunction action, double startTime )
{
if ( from == to ) return;
@@ -134,7 +134,7 @@ public sealed class Transitions
Add( desc, target, action, startTime );
}
void Add( in TransitionDesc desc, int target, TransitionFunction action, float startTime )
void Add( in TransitionDesc desc, int target, TransitionFunction action, double startTime )
{
var length = 1.0f;
var property = desc.Property;
@@ -157,7 +157,7 @@ public sealed class Transitions
Entries.Add( entry );
}
internal bool Run( Styles style, float now )
internal bool Run( Styles style, double now )
{
if ( !HasAny )
return false;
@@ -183,7 +183,7 @@ public sealed class Transitions
var t = entry.IsKilled ? 1f : (now - entry.StartTime) / entry.Length;
entry.Invoke( style, entry.Ease( t ) );
entry.Invoke( style, entry.Ease( (float)t ) );
}
if ( Entries.RemoveAll( x => x.IsKilled ) > 0 )