Skip to content

Commit

Permalink
ITempo使用基础数据类型防止外界信号连接
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYunPlayer committed May 19, 2024
1 parent ba1e4ed commit bddba96
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions TuneLab/Data/ITempo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace TuneLab.Data;

internal interface ITempo : IDataObject<TempoInfo>
{
IReadOnlyDataProperty<double> Pos { get; }
IReadOnlyDataProperty<double> Bpm { get; }
double Pos { get; }
double Bpm { get; }
}
6 changes: 3 additions & 3 deletions TuneLab/Data/ITempoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static double GetBpmAt(this ITempoManager manager, double tick)
for (int i = manager.Tempos.Count - 1; i >= 0; i--)
{
var tempo = manager.Tempos[i];
if (tempo.Pos.Value <= tick)
return tempo.Bpm.Value;
if (tempo.Pos <= tick)
return tempo.Bpm;
}

return manager.Tempos[0].Bpm.Value;
return manager.Tempos[0].Bpm;
}
}
6 changes: 3 additions & 3 deletions TuneLab/Data/TempoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TempoManager(IProject project, List<TempoInfo> tempos) : base(project)

public int AddTempo(double pos, double bpm)
{
pos = Math.Max(pos, Tempos[0].Pos.Value);
pos = Math.Max(pos, Tempos[0].Pos);

int i = mTempos.Count - 1;
for (; i >= 0; --i)
Expand Down Expand Up @@ -138,8 +138,8 @@ class TempoForTempoManager : DataObject, ITempo, ITempoHelper
double ITempoHelper.Pos => Pos;
double ITempoHelper.Bpm => Bpm;

IReadOnlyDataProperty<double> ITempo.Pos => Pos;
IReadOnlyDataProperty<double> ITempo.Bpm => Bpm;
double ITempo.Pos => Pos;
double ITempo.Bpm => Bpm;

public TempoForTempoManager(TempoInfo info)
{
Expand Down
6 changes: 3 additions & 3 deletions TuneLab/Views/TimelineScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ void OnBpmInputComplete()

if (!double.TryParse(mBpmInput.Text, out var newBpm))
{
newBpm = mInputBpmTempo.Bpm.Value;
newBpm = mInputBpmTempo.Bpm;
}
newBpm = newBpm.Limit(10, 960);
if (newBpm != mInputBpmTempo.Bpm.Value)
if (newBpm != mInputBpmTempo.Bpm)
{
Timeline.TempoManager.SetBpm(mInputBpmTempo, newBpm);
mInputBpmTempo.Commit();
Expand All @@ -109,7 +109,7 @@ Rect BpmInputRect()
if (mInputBpmTempo == null)
return new Rect();

return new Rect(mDependency.TickAxis.Tick2X(mInputBpmTempo.Pos.Value), 24, 54, 24);
return new Rect(mDependency.TickAxis.Tick2X(mInputBpmTempo.Pos), 24, 54, 24);
}

ITempo? mInputBpmTempo;
Expand Down
2 changes: 1 addition & 1 deletion TuneLab/Views/TimelineView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected override void OnRender(DrawingContext context)

public string BpmString(ITempo tempo)
{
return tempo.Bpm.Value.ToString("F2");
return tempo.Bpm.ToString("F2");
}

public double TempoWidth(ITempo tempo)
Expand Down
2 changes: 1 addition & 1 deletion TuneLab/Views/TimelineViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TempoItem(TimelineView timelineView) : TimelineViewItem(timelineView)
public required ITempoManager TempoManager;
public required int TempoIndex;

public double Left => TimelineView.TickAxis.Tick2X(Tempo.Pos.Value);
public double Left => TimelineView.TickAxis.Tick2X(Tempo.Pos);

public Rect Rect()
{
Expand Down
6 changes: 3 additions & 3 deletions TuneLab/Views/TimelineViewOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ protected override void UpdateItems(IItemCollection items)
{
var tempo = tempoManager.Tempos[i];

if (tempo.Pos.Value < startPos)
if (tempo.Pos < startPos)
continue;

if (tempo.Pos.Value > endPos)
if (tempo.Pos > endPos)
break;

items.Add(new TempoItem(this) { TempoManager = tempoManager, TempoIndex = i });
Expand Down Expand Up @@ -298,7 +298,7 @@ public void Move(double x, bool alt)

double pos = TimelineView.TickAxis.X2Tick(x - mOffset);
if (!alt) pos = TimelineView.GetQuantizedTick(pos);
double bpm = mTempoItem.Tempo.Bpm.Value;
double bpm = mTempoItem.Tempo.Bpm;

mTempoItem.TempoManager.Project.BeginMergeReSegment();
mTempoItem.TempoManager.RemoveTempoAt(mTempoItem.TempoIndex);
Expand Down

0 comments on commit bddba96

Please sign in to comment.