1111using ReactiveUI ;
1212
1313namespace OpenUtau . App . Controls {
14- class NotesCanvas : Canvas {
14+ class NotesCanvas : Control {
1515 public static readonly DirectProperty < NotesCanvas , double > TickWidthProperty =
1616 AvaloniaProperty . RegisterDirect < NotesCanvas , double > (
1717 nameof ( TickWidth ) ,
@@ -134,11 +134,8 @@ void RefreshGhostNotes() {
134134 . ToList ( ) ;
135135 }
136136
137- protected override void OnPropertyChanged < T > ( AvaloniaPropertyChangedEventArgs < T > change ) {
137+ protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change ) {
138138 base . OnPropertyChanged ( change ) ;
139- if ( ! change . IsEffectiveValueChange ) {
140- return ;
141- }
142139 InvalidateVisual ( ) ;
143140 }
144141
@@ -210,17 +207,17 @@ private void RenderNoteBody(UNote note, NotesViewModel viewModel, DrawingContext
210207 }
211208 string displayLyric = note . lyric ;
212209 var textLayout = TextLayoutCache . Get ( displayLyric , Brushes . White , 12 ) ;
213- if ( textLayout . Size . Width + 5 > size . Width ) {
210+ if ( textLayout . Width + 5 > size . Width ) {
214211 displayLyric = displayLyric [ 0 ] + ".." ;
215212 textLayout = TextLayoutCache . Get ( displayLyric , Brushes . White , 12 ) ;
216- if ( textLayout . Size . Width + 5 > size . Width ) {
213+ if ( textLayout . Width + 5 > size . Width ) {
217214 return ;
218215 }
219216 }
220217 Point textPosition = leftTop . WithX ( leftTop . X + 5 )
221- . WithY ( Math . Round ( leftTop . Y + ( size . Height - textLayout . Size . Height ) / 2 ) ) ;
222- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( textPosition . X , textPosition . Y ) ) ) {
223- textLayout . Draw ( context ) ;
218+ . WithY ( Math . Round ( leftTop . Y + ( size . Height - textLayout . Height ) / 2 ) ) ;
219+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( textPosition . X , textPosition . Y ) ) ) {
220+ textLayout . Draw ( context , new Point ( ) ) ;
224221 }
225222 }
226223
@@ -256,7 +253,7 @@ private void RenderPitchBend(UNote note, NotesViewModel viewModel, DrawingContex
256253
257254 var brush = note . pitch . snapFirst ? ThemeManager . AccentBrush3 : null ;
258255 var pen = ThemeManager . AccentPen3 ;
259- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( p0 . X , p0 . Y ) ) ) {
256+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( p0 . X , p0 . Y ) ) ) {
260257 context . DrawGeometry ( brush , pen , pointGeometry ) ;
261258 }
262259
@@ -283,7 +280,7 @@ private void RenderPitchBend(UNote note, NotesViewModel viewModel, DrawingContex
283280 }
284281 }
285282 p0 = p1 ;
286- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( p0 . X , p0 . Y ) ) ) {
283+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( p0 . X , p0 . Y ) ) ) {
287284 context . DrawGeometry ( null , pen , pointGeometry ) ;
288285 }
289286 }
@@ -318,7 +315,7 @@ private void RenderVibratoToggle(UNote note, NotesViewModel viewModel, DrawingCo
318315 var togglePos = vibrato . GetToggle ( note ) ;
319316 Point icon = viewModel . TickToneToPoint ( togglePos . X , togglePos . Y ) ;
320317 var pen = ThemeManager . BarNumberPen ;
321- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( icon . X - 10 , icon . Y ) ) ) {
318+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( icon . X - 10 , icon . Y ) ) ) {
322319 context . DrawGeometry ( vibrato . length == 0 ? null : pen . Brush , pen , vibratoIcon ) ;
323320 }
324321 }
@@ -336,13 +333,13 @@ private void RenderVibratoControl(UNote note, NotesViewModel viewModel, DrawingC
336333 context . DrawLine ( pen , start , fadeIn ) ;
337334 context . DrawLine ( pen , fadeIn , fadeOut ) ;
338335 context . DrawLine ( pen , fadeOut , end ) ;
339- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( start ) ) ) {
336+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( start ) ) ) {
340337 context . DrawGeometry ( pen . Brush , pen , pointGeometry ) ;
341338 }
342- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( fadeIn ) ) ) {
339+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( fadeIn ) ) ) {
343340 context . DrawGeometry ( pen . Brush , pen , pointGeometry ) ;
344341 }
345- using ( var state = context . PushPreTransform ( Matrix . CreateTranslation ( fadeOut ) ) ) {
342+ using ( var state = context . PushTransform ( Matrix . CreateTranslation ( fadeOut ) ) ) {
346343 context . DrawGeometry ( pen . Brush , pen , pointGeometry ) ;
347344 }
348345 vibrato . GetPeriodStartEnd ( DocManager . Inst . Project , note , out var periodStartPos , out var periodEndPos ) ;
0 commit comments