diff --git a/TuneLab/Views/AutomationRenderer.cs b/TuneLab/Views/AutomationRenderer.cs index 8facce0..8030a72 100644 --- a/TuneLab/Views/AutomationRenderer.cs +++ b/TuneLab/Views/AutomationRenderer.cs @@ -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); } diff --git a/TuneLab/Views/AutomationRendererItem.cs b/TuneLab/Views/AutomationRendererItem.cs index 55cd904..b679753 100644 --- a/TuneLab/Views/AutomationRendererItem.cs +++ b/TuneLab/Views/AutomationRendererItem.cs @@ -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) { diff --git a/TuneLab/Views/AutomationRendererOperation.cs b/TuneLab/Views/AutomationRendererOperation.cs index 779c162..13d023e 100644 --- a/TuneLab/Views/AutomationRendererOperation.cs +++ b/TuneLab/Views/AutomationRendererOperation.cs @@ -122,6 +122,8 @@ protected override void OnMouseRelativeMoveToView(MouseMoveEventArgs e) } break; } + + InvalidateVisual(); } protected override void OnMouseUp(MouseUpEventArgs e) @@ -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) diff --git a/TuneLab/Views/PianoGrid.cs b/TuneLab/Views/PianoGrid.cs index c635c27..105b827 100644 --- a/TuneLab/Views/PianoGrid.cs +++ b/TuneLab/Views/PianoGrid.cs @@ -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)) { diff --git a/TuneLab/Views/PianoGridItem.cs b/TuneLab/Views/PianoGridItem.cs index cd52440..789a0d8 100644 --- a/TuneLab/Views/PianoGridItem.cs +++ b/TuneLab/Views/PianoGridItem.cs @@ -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; }