diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSettingsControl.xaml index 9cae603..7ea7a4d 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSettingsControl.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSettingsControl.xaml @@ -234,14 +234,46 @@ - - + + + + + + + + + + + - + + + + + + 0) + { + for (int j = 0; j < regions.Length; j++) + { + var region = regions[j]; + var rect = new Rect( + region.LayoutBounds.X, + region.LayoutBounds.Y + lyricsLine.Position.Y, + region.LayoutBounds.Width, + region.LayoutBounds.Height + ); + ds.FillRectangle(rect, Colors.White); + } + } + + return mask; + } + /// /// 创建高亮效果层 /// /// /// - public static AlphaMaskEffect CreateForegroundHighlightEffect(CanvasCommandList foregroundFontEffect, IGraphicsEffectSource mask) + public static OpacityEffect CreateForegroundHighlightEffect(CanvasCommandList foregroundFontEffect, IGraphicsEffectSource mask, double opacity) { - return new AlphaMaskEffect + return new OpacityEffect { - Source = foregroundFontEffect, - AlphaMask = mask, + Source = new AlphaMaskEffect + { + Source = foregroundFontEffect, + AlphaMask = mask, + }, + Opacity = (float)opacity, }; } @@ -291,6 +324,19 @@ namespace BetterLyrics.WinUI3.Helper }; } + public static OpacityEffect CreateForegroundTranslationEffect(CanvasCommandList foregroundFontEffect, IGraphicsEffectSource mask, double opacity) + { + return new OpacityEffect + { + Source = new AlphaMaskEffect + { + Source = foregroundFontEffect, + AlphaMask = mask, + }, + Opacity = (float)opacity, + }; + } + public static IGraphicsEffectSource GetAlphaMask(ICanvasAnimatedControl control, IGraphicsEffectSource charMask, IGraphicsEffectSource lineStartToCharMask, IGraphicsEffectSource lineMask, LineRenderingType lineRenderingType) { var result = lineRenderingType switch diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/Settings/LyricsEffectSettings.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/Settings/LyricsEffectSettings.cs index 4cc2595..79d2ec4 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/Settings/LyricsEffectSettings.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/Settings/LyricsEffectSettings.cs @@ -23,7 +23,10 @@ namespace BetterLyrics.WinUI3.Models.Settings [ObservableProperty][NotifyPropertyChangedRecipients] public partial int LyricsShadowAmount { get; set; } = 8; [ObservableProperty][NotifyPropertyChangedRecipients] public partial LineRenderingType LyricsHighlightScope { get; set; } = LineRenderingType.LineStartToCurrentChar; + [ObservableProperty][NotifyPropertyChangedRecipients] public partial int LyricsHighlightAmount { get; set; } = 100; // 100% 是上界 + [ObservableProperty][NotifyPropertyChangedRecipients] public partial int LyricsTranslationHighlightAmount { get; set; } = 60; // 100% 是上界 + [ObservableProperty][NotifyPropertyChangedRecipients] public partial bool IsLyricsFloatAnimationEnabled { get; set; } = true; [ObservableProperty][NotifyPropertyChangedRecipients] public partial int LyricsFloatAmount { get; set; } = 1; diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw index c708149..6be162a 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw @@ -779,7 +779,7 @@ If you encounter any problems, please go to the Settings page, About tab, and vi Glow effect - Highlight scope + Original highlight range Left @@ -844,6 +844,9 @@ If you encounter any problems, please go to the Settings page, About tab, and vi Lyrics timeline sync threshold + + Translation Highlight + Source and translation separator diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw index c7f6775..5c854a2 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw @@ -779,7 +779,7 @@ グロー効果 - ハイライトスコープ + オリジナルのハイライト範囲 @@ -844,6 +844,9 @@ 歌詞タイムライン同期しきい値 + + 翻訳ハイライト + ソースおよび翻訳セパレーター diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw index e4c7f66..9a8c59e 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw @@ -779,7 +779,7 @@ 글로우 효과 - 하이라이트 범위 + 원래 하이라이트 범위 왼쪽 @@ -844,6 +844,9 @@ 가사 타임 라인 동기화 임계 값 + + 번역 하이라이트 + 소스 및 번역 분리기 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw index 1705381..cdc24a7 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw @@ -779,7 +779,7 @@ 辉光效果 - 高亮显示范围 + 原文高亮显示范围 靠左 @@ -844,6 +844,9 @@ 歌词时间轴同步阈值 + + 翻译高亮 + 原文译文分隔符 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw index 7cf6e59..c23988b 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw @@ -779,7 +779,7 @@ 輝光效果 - 高亮顯示範圍 + 原文高亮顯示範圍 靠左 @@ -844,6 +844,9 @@ 歌詞時間軌同步閾值 + + 翻譯高亮 + 原文譯文分隔符 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Draw.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Draw.cs index 79ee768..52ee628 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Draw.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Draw.cs @@ -234,9 +234,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel using var combined = new CanvasCommandList(control); using var combinedDs = combined.CreateDrawingSession(); - // Mock gradient blurred lyrics layer // 先铺一层带默认透明度的已经加了模糊效果的歌词作为最底层(背景歌词层次) - // Current line will not be blurred using var backgroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor, _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor); using var backgroundEffect = CanvasHelper.CreateBackgroundEffect(line, backgroundFontEffect, _lyricsOpacityTransition.Value); @@ -253,10 +251,17 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel using var lineMask = CanvasHelper.CreateLineMask(control, line); using var foregroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor, - _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor); + _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontStrokeWidth, _fgFontColor); using var effectLayer = new CanvasCommandList(control); using var effectLayerDs = effectLayer.CreateDrawingSession(); + if (line.OriginalText != line.DisplayedText && _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsTranslationHighlightAmount != 0) + { + using var translationHighlightMask = CanvasHelper.CreateTranslationHighlightMask(control, line); + using var foregroundTranslationHighlightEffect = CanvasHelper.CreateForegroundHighlightEffect(foregroundFontEffect, translationHighlightMask, + _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsTranslationHighlightAmount / 100.0); + effectLayerDs.DrawImage(foregroundTranslationHighlightEffect); + } if (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsLyricsShadowEnabled) { var shadowEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, @@ -273,10 +278,14 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsGlowEffectAmount); effectLayerDs.DrawImage(foregroundBlurEffect); } - var highlightEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, - _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsHighlightScope); - using var foregroundHighlightEffect = CanvasHelper.CreateForegroundHighlightEffect(foregroundFontEffect, highlightEffectMask); - effectLayerDs.DrawImage(foregroundHighlightEffect); + if (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsHighlightAmount != 0) + { + var highlightEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, + _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsHighlightScope); + using var foregroundHighlightEffect = CanvasHelper.CreateForegroundHighlightEffect(foregroundFontEffect, highlightEffectMask, + _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsHighlightAmount / 100.0); + effectLayerDs.DrawImage(foregroundHighlightEffect); + } combinedDs.DrawImage(new OpacityEffect {