Skip to content

Commit

Permalink
颤音相关文字提示
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYunPlayer committed May 29, 2024
1 parent 8706625 commit e69f14b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
10 changes: 10 additions & 0 deletions TuneLab/Views/AutomationRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ void Draw(string automationID)
context.DrawCurve(points, Color.Parse(config.Color).Opacity(0.5), lineWidth);
}

if (IsHover && ItemAt(MousePosition) is VibratoItem vibratoItem)
{
if (!vibratoItem.Vibrato.AffectedAutomations.ContainsKey(activeAutomation))
{
var vibrato = vibratoItem.Vibrato;
double x = TickAxis.Tick2X(vibrato.GlobalStartPos() + vibrato.Dur / 2);
context.DrawString("Drag to associate the vibrato.", new Point(x, 8), Brushes.White, 12, Alignment.CenterTop);
}
}

lineWidth = 2;
Draw(activeAutomation);
}
Expand Down
2 changes: 1 addition & 1 deletion TuneLab/Views/AutomationRendererItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AutomationRenderItem(AutomationRenderer automationRenderer) : Item

class VibratoItem(AutomationRenderer automationRenderer) : AutomationRenderItem(automationRenderer)
{
public Vibrato Vibrato;
public required Vibrato Vibrato;

public override bool Raycast(Point point)
{
Expand Down
12 changes: 12 additions & 0 deletions TuneLab/Views/AutomationRendererOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ protected override void OnMouseRelativeMoveToView(MouseMoveEventArgs e)
}
break;
}

InvalidateVisual();
}

protected override void OnMouseUp(MouseUpEventArgs e)
Expand All @@ -148,6 +150,16 @@ protected override void OnMouseUp(MouseUpEventArgs e)
mMiddleDragOperation.Up();
}

protected override void OnMouseEnter(MouseEnterEventArgs e)
{
InvalidateVisual();
}

protected override void OnMouseLeave()
{
InvalidateVisual();
}

protected override void UpdateItems(IItemCollection items)
{
if (Part == null)
Expand Down
7 changes: 7 additions & 0 deletions TuneLab/Views/PianoGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ void DrawVibratos(DrawingContext context)
{
var hoverVibrato = hoverVibratoItem.Vibrato;

var centerX = hoverVibratoItem.CenterX();
var pitch = hoverVibratoItem.Pitch();
if (double.IsNaN(pitch))
{
context.DrawString("Please draw pitch first in the area.", new Point(centerX, 32), textBrush, 12, Alignment.CenterTop);
}

var frequencyPosition = hoverVibratoItem.FrequencyPosition();
if (!double.IsNaN(frequencyPosition.Y))
{
Expand Down
4 changes: 2 additions & 2 deletions TuneLab/Views/PianoGridItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public Point ReleasePosition()
return new Point(PianoGrid.TickAxis.Tick2X(Vibrato.GlobalReleaseTick()), y);
}

double CenterX()
public double CenterX()
{
return PianoGrid.TickAxis.Tick2X(Vibrato.GlobalStartPos() + Vibrato.Dur / 2);
}

double Pitch()
public double Pitch()
{
return PianoGrid.Part == null ? double.NaN : PianoGrid.Part.Pitch.GetValue(Vibrato.Pos + Vibrato.Dur / 2) + 0.5;
}
Expand Down

0 comments on commit e69f14b

Please sign in to comment.