From e028ec2f0fc6d3daea1694f8d0a6b63f397ef233 Mon Sep 17 00:00:00 2001 From: Zhe Fang Date: Fri, 13 Jun 2025 16:31:47 -0400 Subject: [PATCH] feat: no lyrics placeholder --- .../BetterLyrics.WinUI3.csproj | 4 +- .../BetterLyrics.WinUI3/Models/SongInfo.cs | 20 +-- .../Rendering/BaseLyricsRenderer.cs | 19 +-- .../Rendering/DesktopLyricsRenderer.cs | 2 - .../Rendering/InAppLyricsRenderer.cs | 2 - .../Services/Database/DatabaseService.cs | 8 +- .../Services/Playback/PlaybackService.cs | 1 + .../Strings/en-US/Resources.resw | 2 +- .../Strings/zh-CN/Resources.resw | 2 +- .../Strings/zh-TW/Resources.resw | 2 +- .../Views/DesktopLyricsPage.xaml.cs | 3 +- .../BetterLyrics.WinUI3/Views/MainPage.xaml | 115 ++++++++++++------ .../Views/MainPage.xaml.cs | 22 ++-- .../Views/OverlayWindow.xaml.cs | 2 +- 14 files changed, 107 insertions(+), 97 deletions(-) diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj index 31f724a..b1d2b32 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj @@ -85,7 +85,7 @@ AssemblyVersion AssemblyVersion.None.None 2025.6.0 - 2025.6.13.1826 - 2025.6.13.1826 + 2025.6.13.2027 + 2025.6.13.2027 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/SongInfo.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/SongInfo.cs index 349f5be..edc5e9f 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/SongInfo.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/SongInfo.cs @@ -1,20 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using ATL; -using BetterLyrics.WinUI3.Helper; -using BetterLyrics.WinUI3.Services.Database; -using BetterLyrics.WinUI3.Services.Settings; using CommunityToolkit.Mvvm.ComponentModel; -using Microsoft.UI; -using Microsoft.UI.Xaml.Media.Imaging; -using Windows.Graphics.Imaging; -using Windows.Media.Control; -using Windows.Storage.Streams; -using Windows.UI; using static ATL.LyricsInfo; namespace BetterLyrics.WinUI3.Models @@ -31,12 +18,13 @@ namespace BetterLyrics.WinUI3.Models private ObservableCollection? _filesUsed; [ObservableProperty] - private bool? _isLyricsExisted; + private bool _isLyricsExisted = false; [ObservableProperty] private string? _sourceAppUserModelId = null; - public List? LyricsLines { get; set; } = null; + [ObservableProperty] + private List? _lyricsLines = null; public byte[]? AlbumArt { get; set; } = null; diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/BaseLyricsRenderer.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/BaseLyricsRenderer.cs index 7a55dcb..1ccbdb1 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/BaseLyricsRenderer.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/BaseLyricsRenderer.cs @@ -61,7 +61,7 @@ namespace BetterLyrics.WinUI3.Rendering public TimeSpan CurrentTime { get; set; } = TimeSpan.Zero; - public abstract List LyricsLines { get; set; } + public List LyricsLines { get; set; } = []; private readonly ILyricsViewModel _viewModel; @@ -286,13 +286,6 @@ namespace BetterLyrics.WinUI3.Rendering // Reset scale ds.Transform = Matrix3x2.Identity; } - - //ds.DrawText( - // $"show range: from {_startVisibleLineIndex} to {_endVisibleLineIndex}, current: {GetCurrentPlayingLineIndex()}", - // new Vector2(10, 10), - // Colors.Red - //); - ds.DrawText($"{LimitedLineWidth}", new Vector2(10, 10), Colors.Red); } public void Draw(ICanvasAnimatedControl control, CanvasDrawingSession ds) @@ -431,19 +424,11 @@ namespace BetterLyrics.WinUI3.Rendering _forceToScroll = false; } - public async Task ReLayoutAsync( - ICanvasAnimatedControl control, - IList? updatedLyricsLines = null - ) + public async Task ReLayoutAsync(ICanvasAnimatedControl control) { if (control == null) return; - if (updatedLyricsLines != null) - { - LyricsLines = [.. updatedLyricsLines]; - } - _textFormat.FontSize = _viewModel.LyricsFontSize; float y = 0; diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/DesktopLyricsRenderer.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/DesktopLyricsRenderer.cs index 4c94566..45b73b4 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/DesktopLyricsRenderer.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/DesktopLyricsRenderer.cs @@ -13,7 +13,5 @@ namespace BetterLyrics.WinUI3.Rendering { public DesktopLyricsRenderer(DesktopLyricsViewModel viewModel) : base(viewModel) { } - - public override List LyricsLines { get; set; } = []; } } diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/InAppLyricsRenderer.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/InAppLyricsRenderer.cs index 46c3a37..05a1cc6 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/InAppLyricsRenderer.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Rendering/InAppLyricsRenderer.cs @@ -14,7 +14,5 @@ namespace BetterLyrics.WinUI3.Rendering { public InAppLyricsRenderer(InAppLyricsViewModel viewModel) : base(viewModel) { } - - public override List LyricsLines { get; set; } = []; } } diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Database/DatabaseService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Database/DatabaseService.cs index bd2a499..954d2b1 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Database/DatabaseService.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Database/DatabaseService.cs @@ -1,17 +1,13 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; using ATL; using BetterLyrics.WinUI3.Helper; using BetterLyrics.WinUI3.Models; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Media.Imaging; using SQLite; using Ude; using Windows.Media.Control; -using Windows.Storage; using Windows.Storage.Streams; namespace BetterLyrics.WinUI3.Services.Database @@ -24,7 +20,7 @@ namespace BetterLyrics.WinUI3.Services.Database public DatabaseService() { - _connection = new SQLiteConnection(Helper.AppInfo.DatabasePath); + _connection = new SQLiteConnection(AppInfo.DatabasePath); if (_connection.GetTableInfo("MetadataIndex").Count == 0) { _connection.CreateTable(); diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Playback/PlaybackService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Playback/PlaybackService.cs index e895aca..7126429 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Playback/PlaybackService.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/Playback/PlaybackService.cs @@ -1,6 +1,7 @@ using System; using BetterLyrics.WinUI3.Helper; using BetterLyrics.WinUI3.Messages; +using BetterLyrics.WinUI3.Models; using BetterLyrics.WinUI3.Services.Database; using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.WinUI; diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw index de03578..fb8b511 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw @@ -385,7 +385,7 @@ Change display type - Toggle desktop lyrics mode + Show/hide desktop lyrics Enter picture-in-picture mode diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw index 5ff4458..20cb3c1 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw @@ -385,7 +385,7 @@ 切换显示模式 - 切换桌面歌词模式 + 显示/隐藏桌面歌词 进入画中画模式 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw index 5e157a3..32fb8c6 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw @@ -385,7 +385,7 @@ 切換顯示模式 - 切換桌面歌詞模式 + 顯示/隱藏桌面歌詞 進入畫中畫模式 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/DesktopLyricsPage.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/DesktopLyricsPage.xaml.cs index 36025b0..b0dd9c9 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/DesktopLyricsPage.xaml.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/DesktopLyricsPage.xaml.cs @@ -56,7 +56,8 @@ namespace BetterLyrics.WinUI3.Views DispatcherQueuePriority.High, async () => { - await _lyricsRenderer.ReLayoutAsync(LyricsCanvas, m.Value?.LyricsLines); + _lyricsRenderer.LyricsLines = m.Value?.LyricsLines ?? []; + await _lyricsRenderer.ReLayoutAsync(LyricsCanvas); } ); } diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MainPage.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MainPage.xaml index aa2c5b6..138e3df 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MainPage.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MainPage.xaml @@ -14,12 +14,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="using:CommunityToolkit.WinUI" mc:Ignorable="d"> - - - @@ -37,8 +31,7 @@ - - + @@ -48,8 +41,32 @@ - + + + + + + + + + + + + + + @@ -61,26 +78,9 @@ - - - - - - - - - - - - + + + @@ -326,7 +326,10 @@ IsChecked="{x:Bind ViewModel.IsImmersiveMode, Mode=TwoWay}" Style="{StaticResource GhostToggleButtonStyle}" /> -