重构Animation动画系统,增加Addition新增动画支持

This commit is contained in:
monitor1394
2023-07-12 08:28:42 +08:00
parent eca0c6ea46
commit e515908f9b
19 changed files with 51 additions and 75 deletions

View File

@@ -62,8 +62,8 @@ namespace XCharts.Editor
++EditorGUI.indentLevel;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_UnscaledTime");
PropertyField(prop, "m_Fadein");
PropertyField(prop, "m_Fadeout");
PropertyField(prop, "m_FadeIn");
PropertyField(prop, "m_FadeOut");
PropertyField(prop, "m_Change");
PropertyField(prop, "m_Addition");
--EditorGUI.indentLevel;

View File

@@ -380,7 +380,7 @@ namespace XCharts.Runtime
/// </summary>
[Since("v3.8.0")]
[System.Serializable]
public class AnimationFadeout : AnimationInfo
public class AnimationFadeOut : AnimationInfo
{
}

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
/// <summary>
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
/// |动画表现。支持配置四种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画
/// |动画系统。支持配置四种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画
/// </summary>
[System.Serializable]
public class AnimationStyle : ChildComponent
@@ -55,8 +55,8 @@ namespace XCharts.Runtime
[SerializeField] private AnimationEasing m_Easting;
[SerializeField] private int m_Threshold = 2000;
[SerializeField][Since("v3.4.0")] private bool m_UnscaledTime;
[SerializeField][Since("v3.8.0")] private AnimationFadeIn m_Fadein = new AnimationFadeIn();
[SerializeField][Since("v3.8.0")] private AnimationFadeout m_Fadeout = new AnimationFadeout() { reverse = true };
[SerializeField][Since("v3.8.0")] private AnimationFadeIn m_FadeIn = new AnimationFadeIn();
[SerializeField][Since("v3.8.0")] private AnimationFadeOut m_FadeOut = new AnimationFadeOut() { reverse = true };
[SerializeField][Since("v3.8.0")] private AnimationChange m_Change = new AnimationChange() { duration = 500 };
[SerializeField][Since("v3.8.0")] private AnimationAddition m_Addition = new AnimationAddition() { duration = 500 };
@@ -98,12 +98,12 @@ namespace XCharts.Runtime
/// Fade in animation configuration.
/// |渐入动画配置。
/// </summary>
public AnimationFadeIn fadein { get { return m_Fadein; } }
public AnimationFadeIn fadein { get { return m_FadeIn; } }
/// <summary>
/// Fade out animation configuration.
/// |渐出动画配置。
/// </summary>
public AnimationFadeout fadeout { get { return m_Fadeout; } }
public AnimationFadeOut fadeout { get { return m_FadeOut; } }
/// <summary>
/// Update data animation configuration.
/// |数据变更动画配置。
@@ -124,8 +124,8 @@ namespace XCharts.Runtime
if (m_Animations == null)
{
m_Animations = new List<AnimationInfo>();
m_Animations.Add(m_Fadein);
m_Animations.Add(m_Fadeout);
m_Animations.Add(m_FadeIn);
m_Animations.Add(m_FadeOut);
m_Animations.Add(m_Change);
m_Animations.Add(m_Addition);
}
@@ -153,10 +153,10 @@ namespace XCharts.Runtime
/// Start fadein animation.
/// |开始渐入动画。
/// </summary>
public void Fadein()
public void FadeIn()
{
if (m_Fadeout.context.start) return;
m_Fadein.Start();
if (m_FadeOut.context.start) return;
m_FadeIn.Start();
}
/// <summary>
@@ -177,9 +177,9 @@ namespace XCharts.Runtime
/// Start fadeout animation.
/// |开始渐出动画。
/// </summary>
public void Fadeout()
public void FadeOut()
{
m_Fadeout.Start();
m_FadeOut.Start();
}
/// <summary>
@@ -189,7 +189,7 @@ namespace XCharts.Runtime
public void Addition()
{
if (!enable) return;
if (!m_Fadein.context.start && !m_Fadeout.context.start)
if (!m_FadeIn.context.start && !m_FadeOut.context.start)
{
m_Addition.Start(false);
}
@@ -312,7 +312,7 @@ namespace XCharts.Runtime
if (animation.context.start)
return animation.context.end;
}
return m_Fadein.context.end;
return m_FadeIn.context.end;
}
@@ -333,9 +333,9 @@ namespace XCharts.Runtime
}
if (IsIndexAnimation())
{
if (m_Fadeout.context.start) return m_Fadeout.context.currProgress <= m_Fadeout.context.destProgress;
if (m_FadeOut.context.start) return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress;
else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress;
else return m_Fadein.context.currProgress >= m_Fadein.context.destProgress;
else return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress;
}
else if (IsItemAnimation())
{
@@ -434,8 +434,8 @@ namespace XCharts.Runtime
public void CheckSymbol(float dest)
{
m_Fadein.CheckSymbol(dest, m_UnscaledTime);
m_Fadeout.CheckSymbol(dest, m_UnscaledTime);
m_FadeIn.CheckSymbol(dest, m_UnscaledTime);
m_FadeOut.CheckSymbol(dest, m_UnscaledTime);
}
public float GetSysmbolSize(float dest)
@@ -448,9 +448,9 @@ namespace XCharts.Runtime
return dest;
if (IsEnd())
return m_Fadeout.context.start ? 0 : dest;
return m_FadeOut.context.start ? 0 : dest;
return m_Fadeout.context.start ? m_Fadeout.context.sizeProgress : m_Fadein.context.sizeProgress;
return m_FadeOut.context.start ? m_FadeOut.context.sizeProgress : m_FadeIn.context.sizeProgress;
}
public float GetCurrDetail()
@@ -470,7 +470,7 @@ namespace XCharts.Runtime
if (animation.context.start)
return animation.context.currProgress;
}
return m_Fadein.context.currProgress;
return m_FadeIn.context.currProgress;
}
public float GetCurrRate()
@@ -481,7 +481,7 @@ namespace XCharts.Runtime
#endif
if (!enable || IsEnd())
return 1;
return m_Fadeout.context.start ? m_Fadeout.context.currProgress : m_Fadein.context.currProgress;
return m_FadeOut.context.start ? m_FadeOut.context.currProgress : m_FadeIn.context.currProgress;
}
public int GetCurrIndex()
@@ -514,9 +514,9 @@ namespace XCharts.Runtime
return 0;
}
public bool HasFadeout()
public bool HasFadeOut()
{
return enable && m_Fadeout.context.end;
return enable && m_FadeOut.context.end;
}
}
}

View File

@@ -396,29 +396,19 @@ namespace XCharts.Runtime
/// |开始所有Serie的渐入动画。
/// </summary>
/// <param name="reset">reset animation</param>
public void AnimationFadein(bool reset = true)
{
if (reset) AnimationReset();
foreach (var serie in m_Series) serie.AnimationFadein();
}
[Obsolete("Use AnimationFadein() instead.", true)]
public void AnimationFadeIn(bool reset = true)
{
if (reset) AnimationReset();
foreach (var serie in m_Series) serie.AnimationFadeIn();
}
/// <summary>
/// Start all serie fadeout animations.
/// |开始所有Serie的渐出动画。
/// </summary>
public void AnimationFadeout()
{
foreach (var serie in m_Series) serie.AnimationFadeout();
}
[Obsolete("Use AnimationFadeout() instead.", true)]
public void AnimationFadeOut()
{
foreach (var serie in m_Series) serie.AnimationFadeOut();
}
/// <summary>

View File

@@ -649,7 +649,7 @@ namespace XCharts.Runtime
serie.show = active;
serie.RefreshLabel();
serie.AnimationReset();
if (active) serie.AnimationFadein();
if (active) serie.AnimationFadeIn();
UpdateLegendColor(serie.serieName, active);
}

View File

@@ -136,7 +136,7 @@ namespace XCharts.Runtime
InitComponentHandlers();
InitSerieHandlers();
AnimationReset();
AnimationFadein();
AnimationFadeIn();
XChartsMgr.AddChart(this);
}
@@ -416,7 +416,7 @@ namespace XCharts.Runtime
if (!m_CheckAnimation)
{
m_CheckAnimation = true;
AnimationFadein();
AnimationFadeIn();
}
}
@@ -590,7 +590,7 @@ namespace XCharts.Runtime
serie.context.dataIndexs.Clear();
serie.context.dataIgnores.Clear();
serie.animation.context.isAllItemAnimationEnd = true;
if (serie.show && !serie.animation.HasFadeout())
if (serie.show && !serie.animation.HasFadeOut())
{
if (!serie.context.pointerEnter)
serie.ResetInteract();

View File

@@ -142,7 +142,7 @@ namespace XCharts.Runtime
private void DrawBarSerie(VertexHelper vh, Bar serie)
{
if (!serie.show || serie.animation.HasFadeout())
if (!serie.show || serie.animation.HasFadeOut())
return;
Axis axis;

View File

@@ -97,7 +97,7 @@ namespace XCharts.Runtime
private void DrawBarSerie(VertexHelper vh, SimplifiedBar serie, int colorIndex)
{
if (!serie.show || serie.animation.HasFadeout())
if (!serie.show || serie.animation.HasFadeOut())
return;
Axis axis;

View File

@@ -81,7 +81,7 @@ namespace XCharts.Runtime
private void DrawCandlestickSerie(VertexHelper vh, Candlestick serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeout()) return;
if (serie.animation.HasFadeOut()) return;
XAxis xAxis;
YAxis yAxis;
GridCoord grid;

View File

@@ -81,7 +81,7 @@ namespace XCharts.Runtime
private void DrawCandlestickSerie(VertexHelper vh, SimplifiedCandlestick serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeout()) return;
if (serie.animation.HasFadeOut()) return;
XAxis xAxis;
YAxis yAxis;
GridCoord grid;

View File

@@ -185,7 +185,7 @@ namespace XCharts.Runtime
private void DrawDataHeatmapSerie(VertexHelper vh, Heatmap serie)
{
if (!serie.show || serie.animation.HasFadeout()) return;
if (!serie.show || serie.animation.HasFadeOut()) return;
XAxis xAxis;
YAxis yAxis;
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
@@ -332,7 +332,7 @@ namespace XCharts.Runtime
private void DrawCountHeatmapSerie(VertexHelper vh, Heatmap serie)
{
if (!serie.show || serie.animation.HasFadeout()) return;
if (!serie.show || serie.animation.HasFadeOut()) return;
XAxis xAxis;
YAxis yAxis;
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;

View File

@@ -248,7 +248,7 @@ namespace XCharts.Runtime
private void DrawLineSerie(VertexHelper vh, Line serie)
{
if (serie.animation.HasFadeout())
if (serie.animation.HasFadeOut())
return;
Axis axis;

View File

@@ -139,7 +139,7 @@ namespace XCharts.Runtime
{
if (!serie.show)
return;
if (serie.animation.HasFadeout())
if (serie.animation.HasFadeOut())
return;
Axis axis;

View File

@@ -21,7 +21,7 @@ namespace XCharts.Runtime
private void DrawParallelSerie(VertexHelper vh, Parallel serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeout()) return;
if (serie.animation.HasFadeOut()) return;
var parallel = chart.GetChartComponent<ParallelCoord>(serie.parallelIndex);
if (parallel == null)

View File

@@ -300,7 +300,7 @@ namespace XCharts.Runtime
private void DrawPie(VertexHelper vh, Serie serie)
{
if (!serie.show || serie.animation.HasFadeout())
if (!serie.show || serie.animation.HasFadeOut())
{
return;
}

View File

@@ -230,7 +230,7 @@ namespace XCharts.Runtime
var angle = 2 * Mathf.PI / indicatorNum;
var centerPos = m_RadarCoord.context.center;
serie.animation.InitProgress(0, 1);
if (!serie.show || serie.animation.HasFadeout())
if (!serie.show || serie.animation.HasFadeOut())
{
return;
}
@@ -365,7 +365,7 @@ namespace XCharts.Runtime
var angle = 2 * Mathf.PI / indicatorNum;
var centerPos = m_RadarCoord.context.center;
serie.animation.InitProgress(0, 1);
if (!serie.show || serie.animation.HasFadeout())
if (!serie.show || serie.animation.HasFadeOut())
{
return;
}

View File

@@ -176,7 +176,7 @@ namespace XCharts.Runtime
public override void DrawSerie(VertexHelper vh)
{
if (!serie.show || serie.animation.HasFadeout()) return;
if (!serie.show || serie.animation.HasFadeOut()) return;
var data = serie.data;
serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);

View File

@@ -106,7 +106,7 @@ namespace XCharts.Runtime
protected virtual void DrawScatterSerie(VertexHelper vh, BaseScatter serie)
{
if (serie.animation.HasFadeout())
if (serie.animation.HasFadeOut())
return;
if (!serie.show)
@@ -216,7 +216,7 @@ namespace XCharts.Runtime
protected virtual void DrawSingAxisScatterSerie(VertexHelper vh, BaseScatter serie)
{
if (serie.animation.HasFadeout())
if (serie.animation.HasFadeOut())
return;
if (!serie.show)

View File

@@ -1907,32 +1907,18 @@ namespace XCharts.Runtime
/// <summary>
/// 渐入动画
/// </summary>
public void AnimationFadein()
{
if (animation.enable) animation.Fadein();
SetVerticesDirty();
}
[Obsolete("Use Serie.AnimationFadein() instead.", true)]
public void AnimationFadeIn()
{
if (animation.enable) animation.Fadein();
if (animation.enable) animation.FadeIn();
SetVerticesDirty();
}
/// <summary>
/// 渐出动画
/// </summary>
public void AnimationFadeout()
{
if (animation.enable) animation.Fadeout();
SetVerticesDirty();
}
[Obsolete("Use Serie.AnimationFadeout() instead.", true)]
public void AnimationFadeOut()
{
if (animation.enable) animation.Fadeout();
if (animation.enable) animation.FadeOut();
SetVerticesDirty();
}