mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 19:24:55 +08:00
feat: no lyrics placeholder
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
<InheritWinAppVersionFrom>AssemblyVersion</InheritWinAppVersionFrom>
|
||||
<PackageVersionSettings>AssemblyVersion.None.None</PackageVersionSettings>
|
||||
<Version>2025.6.0</Version>
|
||||
<AssemblyVersion>2025.6.13.1826</AssemblyVersion>
|
||||
<FileVersion>2025.6.13.1826</FileVersion>
|
||||
<AssemblyVersion>2025.6.13.2027</AssemblyVersion>
|
||||
<FileVersion>2025.6.13.2027</FileVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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<string>? _filesUsed;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool? _isLyricsExisted;
|
||||
private bool _isLyricsExisted = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? _sourceAppUserModelId = null;
|
||||
|
||||
public List<LyricsLine>? LyricsLines { get; set; } = null;
|
||||
[ObservableProperty]
|
||||
private List<LyricsLine>? _lyricsLines = null;
|
||||
|
||||
public byte[]? AlbumArt { get; set; } = null;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BetterLyrics.WinUI3.Rendering
|
||||
|
||||
public TimeSpan CurrentTime { get; set; } = TimeSpan.Zero;
|
||||
|
||||
public abstract List<LyricsLine> LyricsLines { get; set; }
|
||||
public List<LyricsLine> 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<LyricsLine>? updatedLyricsLines = null
|
||||
)
|
||||
public async Task ReLayoutAsync(ICanvasAnimatedControl control)
|
||||
{
|
||||
if (control == null)
|
||||
return;
|
||||
|
||||
if (updatedLyricsLines != null)
|
||||
{
|
||||
LyricsLines = [.. updatedLyricsLines];
|
||||
}
|
||||
|
||||
_textFormat.FontSize = _viewModel.LyricsFontSize;
|
||||
|
||||
float y = 0;
|
||||
|
||||
@@ -13,7 +13,5 @@ namespace BetterLyrics.WinUI3.Rendering
|
||||
{
|
||||
public DesktopLyricsRenderer(DesktopLyricsViewModel viewModel)
|
||||
: base(viewModel) { }
|
||||
|
||||
public override List<LyricsLine> LyricsLines { get; set; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,5 @@ namespace BetterLyrics.WinUI3.Rendering
|
||||
{
|
||||
public InAppLyricsRenderer(InAppLyricsViewModel viewModel)
|
||||
: base(viewModel) { }
|
||||
|
||||
public override List<LyricsLine> LyricsLines { get; set; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<MetadataIndex>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<value>Change display type</value>
|
||||
</data>
|
||||
<data name="MainPageDesktopLyricsToggler.ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Toggle desktop lyrics mode</value>
|
||||
<value>Show/hide desktop lyrics</value>
|
||||
</data>
|
||||
<data name="BaseWindowMiniFlyoutItem.Text" xml:space="preserve">
|
||||
<value>Enter picture-in-picture mode</value>
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<value>切换显示模式</value>
|
||||
</data>
|
||||
<data name="MainPageDesktopLyricsToggler.ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>切换桌面歌词模式</value>
|
||||
<value>显示/隐藏桌面歌词</value>
|
||||
</data>
|
||||
<data name="BaseWindowMiniFlyoutItem.Text" xml:space="preserve">
|
||||
<value>进入画中画模式</value>
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<value>切換顯示模式</value>
|
||||
</data>
|
||||
<data name="MainPageDesktopLyricsToggler.ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>切換桌面歌詞模式</value>
|
||||
<value>顯示/隱藏桌面歌詞</value>
|
||||
</data>
|
||||
<data name="BaseWindowMiniFlyoutItem.Text" xml:space="preserve">
|
||||
<value>進入畫中畫模式</value>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,12 +14,6 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<converters:DoubleToVisibilityConverter
|
||||
x:Key="LyricsOnlyToVisibilityConverter"
|
||||
GreaterThan="0.9"
|
||||
LessThan="1.1" />
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<!-- Lyrics area -->
|
||||
@@ -37,8 +31,7 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Song info area -->
|
||||
<Grid x:Name="SongInfoGrid" Margin="36">
|
||||
<Grid Margin="36">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="36" />
|
||||
@@ -48,8 +41,32 @@
|
||||
<ScalarTransition />
|
||||
</Grid.OpacityTransition>
|
||||
|
||||
<Grid x:Name="LyricsPlaceholderGrid" SizeChanged="LyricsPlaceholderGrid_SizeChanged" />
|
||||
<!-- Lyrics placeholder -->
|
||||
<Grid
|
||||
x:Name="LyricsPlaceholderGrid"
|
||||
Opacity=".5"
|
||||
SizeChanged="LyricsPlaceholderGrid_SizeChanged">
|
||||
<Grid.OpacityTransition>
|
||||
<ScalarTransition />
|
||||
</Grid.OpacityTransition>
|
||||
<StackPanel
|
||||
x:Name="LyricsPlaceholderStackPanel"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Opacity="0"
|
||||
Spacing="12">
|
||||
<StackPanel.OpacityTransition>
|
||||
<ScalarTransition />
|
||||
</StackPanel.OpacityTransition>
|
||||
<FontIcon
|
||||
FontFamily="Segoe Fluent Icons"
|
||||
FontSize="{StaticResource DisplayTextBlockFontSize}"
|
||||
Glyph="" />
|
||||
<TextBlock FontSize="{StaticResource TitleTextBlockFontSize}" Text="Lyrics not found" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Song info area -->
|
||||
<Grid x:Name="SongInfoInnerGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4*" />
|
||||
@@ -61,26 +78,9 @@
|
||||
<RowDefinition Height="5*" />
|
||||
<RowDefinition Height="2*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.Resources>
|
||||
|
||||
<!-- Animation for song info -->
|
||||
<Storyboard x:Name="SongInfoStackPanelFadeInStoryboard">
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="SongInfoInnerGrid"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="1"
|
||||
Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
<Storyboard x:Name="SongInfoStackPanelFadeOutStoryboard" BeginTime="0:0:0.2">
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="SongInfoInnerGrid"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0"
|
||||
Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
|
||||
</Grid.Resources>
|
||||
<Grid.OpacityTransition>
|
||||
<ScalarTransition />
|
||||
</Grid.OpacityTransition>
|
||||
|
||||
<!-- Cover area -->
|
||||
<Grid
|
||||
@@ -285,7 +285,7 @@
|
||||
<Button
|
||||
x:Name="DisplayTypeSwitchButton"
|
||||
x:Uid="MainPageDisplayTypeSwitcher"
|
||||
Content="{ui:FontIcon Glyph=}"
|
||||
Content="{ui:FontIcon Glyph=}"
|
||||
Style="{StaticResource GhostButtonStyle}">
|
||||
<Button.OpacityTransition>
|
||||
<ScalarTransition />
|
||||
@@ -326,7 +326,10 @@
|
||||
IsChecked="{x:Bind ViewModel.IsImmersiveMode, Mode=TwoWay}"
|
||||
Style="{StaticResource GhostToggleButtonStyle}" />
|
||||
|
||||
<Button Content="{ui:FontIcon Glyph=}" Style="{StaticResource GhostButtonStyle}">
|
||||
<Button
|
||||
x:Name="MusicInfoButton"
|
||||
Content="{ui:FontIcon Glyph=}"
|
||||
Style="{StaticResource GhostButtonStyle}">
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<StackPanel Spacing="16">
|
||||
@@ -410,10 +413,13 @@
|
||||
To="0" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SongInfoGrid.Opacity" Value="1" />
|
||||
<Setter Target="LyricsGrid.Opacity" Value="1" />
|
||||
<Setter Target="LyricsPlaceholderGrid.Opacity" Value="0" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.Column)" Value="0" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.ColumnSpan)" Value="3" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.Column)" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.ColumnSpan)" Value="3" />
|
||||
<Setter Target="SongInfoInnerGrid.Opacity" Value="1" />
|
||||
<Setter Target="MainPageNoMusicPlayingTextBlock.Opacity" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
@@ -427,10 +433,13 @@
|
||||
To="1" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SongInfoGrid.Opacity" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.Opacity" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.Column)" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.ColumnSpan)" Value="3" />
|
||||
<Setter Target="LyricsGrid.Opacity" Value="1" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.Column)" Value="0" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.ColumnSpan)" Value="3" />
|
||||
<Setter Target="LyricsPlaceholderGrid.Opacity" Value="1" />
|
||||
<Setter Target="MainPageNoMusicPlayingTextBlock.Opacity" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
@@ -444,12 +453,13 @@
|
||||
To="2" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SongInfoGrid.Opacity" Value="1" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.Column)" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.(Grid.ColumnSpan)" Value="1" />
|
||||
<Setter Target="SongInfoInnerGrid.Opacity" Value="1" />
|
||||
<Setter Target="LyricsGrid.Opacity" Value="1" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.Column)" Value="2" />
|
||||
<Setter Target="LyricsPlaceholderGrid.(Grid.ColumnSpan)" Value="1" />
|
||||
<Setter Target="LyricsPlaceholderGrid.Opacity" Value="1" />
|
||||
<Setter Target="MainPageNoMusicPlayingTextBlock.Opacity" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
@@ -463,13 +473,14 @@
|
||||
To="3" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SongInfoGrid.Opacity" Value="0" />
|
||||
<Setter Target="SongInfoInnerGrid.Opacity" Value="0" />
|
||||
<Setter Target="LyricsGrid.Opacity" Value="0" />
|
||||
<Setter Target="LyricsPlaceholderGrid.Opacity" Value="0" />
|
||||
<Setter Target="MainPageNoMusicPlayingTextBlock.Opacity" Value="1" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
</VisualStateGroup>
|
||||
|
||||
<VisualStateGroup x:Name="FilesMatchStates">
|
||||
<VisualState x:Name="Matched" />
|
||||
<VisualState x:Name="NotMatched">
|
||||
@@ -482,13 +493,36 @@
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="DisplayTypeSwitcherStates">
|
||||
|
||||
<VisualStateGroup x:Name="LyricsExistenceStates">
|
||||
<VisualState x:Name="Existed">
|
||||
<VisualState.StateTriggers>
|
||||
<StateTrigger IsActive="{x:Bind ViewModel.SongInfo.IsLyricsExisted, Mode=OneWay}" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LyricsPlaceholderStackPanel.Opacity" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="NotExisted">
|
||||
<VisualState.StateTriggers>
|
||||
<StateTrigger IsActive="{x:Bind ViewModel.SongInfo.IsLyricsExisted, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="LyricsPlaceholderStackPanel.Opacity" Value=".5" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
<VisualStateGroup x:Name="MusicPlayingStates">
|
||||
<VisualState x:Name="MusicPlaying">
|
||||
<VisualState.StateTriggers>
|
||||
<ui:IsNotEqualStateTrigger Value="{x:Bind GlobalSettingsViewModel.DisplayType, Mode=OneWay}" To="3" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="DisplayTypeSwitchButton.Opacity" Value="1" />
|
||||
<Setter Target="DisplayTypeSwitchButton.Visibility" Value="Visible" />
|
||||
<Setter Target="DesktopLyricsToggleButton.Visibility" Value="Visible" />
|
||||
<Setter Target="ImmersiveModeButton.Visibility" Value="Visible" />
|
||||
<Setter Target="MusicInfoButton.Visibility" Value="Visible" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="NoMusicPlaying">
|
||||
@@ -499,7 +533,10 @@
|
||||
To="3" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="DisplayTypeSwitchButton.Opacity" Value="0" />
|
||||
<Setter Target="DisplayTypeSwitchButton.Visibility" Value="Collapsed" />
|
||||
<Setter Target="DesktopLyricsToggleButton.Visibility" Value="Collapsed" />
|
||||
<Setter Target="ImmersiveModeButton.Visibility" Value="Collapsed" />
|
||||
<Setter Target="MusicInfoButton.Visibility" Value="Collapsed" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace BetterLyrics.WinUI3.Views
|
||||
{
|
||||
private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
|
||||
private double _limitedLineWidth = 0;
|
||||
|
||||
public MainViewModel ViewModel => (MainViewModel)DataContext;
|
||||
|
||||
private GlobalViewModel GlobalSettingsViewModel { get; set; } =
|
||||
@@ -86,7 +84,8 @@ namespace BetterLyrics.WinUI3.Views
|
||||
DispatcherQueuePriority.High,
|
||||
async () =>
|
||||
{
|
||||
await _lyricsRenderer.ReLayoutAsync(LyricsCanvas, m.Value?.LyricsLines);
|
||||
_lyricsRenderer.LyricsLines = m.Value?.LyricsLines ?? [];
|
||||
await _lyricsRenderer.ReLayoutAsync(LyricsCanvas);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -121,13 +120,20 @@ namespace BetterLyrics.WinUI3.Views
|
||||
)
|
||||
{
|
||||
using var ds = args.DrawingSession;
|
||||
|
||||
_albumArtRenderer.Draw(sender, ds);
|
||||
if (
|
||||
GlobalSettingsViewModel.DisplayType == DisplayType.SplitView
|
||||
|| GlobalSettingsViewModel.DisplayType == DisplayType.LyricsOnly
|
||||
)
|
||||
|
||||
switch (GlobalSettingsViewModel.DisplayType)
|
||||
{
|
||||
_lyricsRenderer.Draw(sender, ds);
|
||||
case DisplayType.AlbumArtOnly:
|
||||
case DisplayType.PlaceholderOnly:
|
||||
break;
|
||||
case DisplayType.LyricsOnly:
|
||||
case DisplayType.SplitView:
|
||||
_lyricsRenderer.Draw(sender, ds);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace BetterLyrics.WinUI3.Views
|
||||
this.CenterOnScreen();
|
||||
var screenWidth = AppWindow.Position.X * 2 + AppWindow.Size.Width;
|
||||
AppWindow.Move(new Windows.Graphics.PointInt32(0, 0));
|
||||
AppWindow.Resize(new Windows.Graphics.SizeInt32(screenWidth, 64));
|
||||
AppWindow.Resize(new Windows.Graphics.SizeInt32(screenWidth, 72));
|
||||
|
||||
// Always on top
|
||||
((OverlappedPresenter)AppWindow.Presenter).IsAlwaysOnTop = true;
|
||||
|
||||
Reference in New Issue
Block a user