Skip to content

Commit

Permalink
#925 #900 调整标签栏样式、支持自定义相关样式 (#932)
Browse files Browse the repository at this point in the history
Fixes #943 #925 #900 #864
实现左上角可点击,右上角不可点击
  • Loading branch information
ProJend authored Dec 17, 2024
1 parent 7a20b61 commit 1e9ab99
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 100 deletions.
1 change: 1 addition & 0 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
<DependentUpon>VideoListView.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\FilterRuleTypeConverter.cs" />
<Compile Include="Converters\InverseBooleanConverter.cs" />
<Compile Include="Dialogs\EditPlaySpeedMenuDialog.xaml.cs">
<DependentUpon>EditPlaySpeedMenuDialog.xaml</DependentUpon>
</Compile>
Expand Down
10 changes: 3 additions & 7 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public PlayerControl()
}
else
{
m_danmakuController = App.ServiceProvider.GetRequiredService<FrostMasterDanmakuController>();
m_danmakuController = App.ServiceProvider.GetRequiredService<FrostMasterDanmakuController>();
m_danmakuController.Init(DanmakuCanvas);
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@ private void LoadPlayerSetting()
{
//音量
Player.Volume = SettingService.GetValue<double>(SettingConstants.Player.PLAYER_VOLUME, SettingConstants.Player.DEFAULT_PLAYER_VOLUME);

var lockPlayerVolume = SettingService.GetValue(SettingConstants.Player.LOCK_PLAYER_VOLUME, SettingConstants.Player.DEFAULT_LOCK_PLAYER_VOLUME);
if (!lockPlayerVolume)
{
Expand Down Expand Up @@ -1588,7 +1588,7 @@ private async Task<PlayerOpenResult> ChangeQualityPlayVideo(BiliPlayUrlInfo qual
if (quality.PlayUrlType == BiliPlayUrlType.DASH)
{
var realPlayerType = (RealPlayerType)SettingService.GetValue(SettingConstants.Player.USE_REAL_PLAYER_TYPE, (int)SettingConstants.Player.DEFAULT_USE_REAL_PLAYER_TYPE);
if (realPlayerType==RealPlayerType.Native)
if (realPlayerType == RealPlayerType.Native)
{
result = await Player.PlayerDashUseNative(quality.DashInfo, quality.UserAgent, quality.Referer, positon: _postion);

Expand Down Expand Up @@ -1681,10 +1681,6 @@ public void FullScreen(bool fullScreen)
BottomBtnFull.Visibility = Visibility.Collapsed;
BottomBtnFullWindows.Visibility = Visibility.Collapsed;
BottomBtnExitFullWindows.Visibility = Visibility.Collapsed;
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
{
TopControlBar.Margin = new Thickness(0, 48, 0, 0);
}

//全屏
if (!view.IsFullScreenMode)
Expand Down
26 changes: 17 additions & 9 deletions src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,24 @@
</controls:SettingsExpander.HeaderIcon>

<controls:SettingsExpander.Items>
<controls:SettingsCard Header="固定标签宽度"
Description="是否固定标签页宽度(下次打开应用生效)">
<ToggleSwitch x:Name="SwitchTabItemFixedWidth" >
</ToggleSwitch>
<controls:SettingsCard Header="固定标签页宽度"
Description="下次打开应用生效">
<StackPanel Orientation="Horizontal">
<ToggleSwitch x:Name="SwitchTabItemFixedWidth" ></ToggleSwitch>
<controls1:NumberBox x:Name="NumTabItemFixedWidth" Minimum="200" MinWidth="200" IsEnabled="{Binding IsOn, ElementName=SwitchTabItemFixedWidth}" Margin="30 5 0 5"></controls1:NumberBox>
</StackPanel>
</controls:SettingsCard>

<controls:SettingsCard Header="固定标签宽度大小"
Description="固定标签宽度时宽度值(下次打开应用生效)">
<controls1:NumberBox x:Name="NumTabItemFixedWidth"
Minimum="20"></controls1:NumberBox>
<controls:SettingsCard Header="设置标签页最小宽度"
Description="下次打开应用生效">
<controls1:NumberBox x:Name="NumTabItemMinWidth" Minimum="0" MinWidth="200" IsEnabled="{Binding IsOn, ElementName=SwitchTabItemFixedWidth, Converter={StaticResource InverseBooleanConverter}}"></controls1:NumberBox>
</controls:SettingsCard>
<controls:SettingsCard Header="设置标签页最大宽度"
Description="下次打开应用生效">
<controls1:NumberBox x:Name="NumTabItemMaxWidth" Minimum="200" MinWidth="200" IsEnabled="{Binding IsOn, ElementName=SwitchTabItemFixedWidth, Converter={StaticResource InverseBooleanConverter}}"></controls1:NumberBox>
</controls:SettingsCard>
<controls:SettingsCard Header="设置标签页高度"
Description="下次打开应用生效,建议立即重启应用,否则会出现奇怪的bug">
<controls1:NumberBox x:Name="NumTabHeight" Minimum="32" MinWidth="200"></controls1:NumberBox>
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
Expand Down
30 changes: 30 additions & 0 deletions src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,36 @@ private void LoadUI()
};
};

// 标签最小宽度
NumTabItemMinWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MIN_WIDTH);
NumTabItemMinWidth.Loaded += (sender, e) =>
{
NumTabItemMinWidth.ValueChanged += (obj, args) =>
{
SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, NumTabItemMinWidth.Value);
};
};

// 标签最大宽度
NumTabItemMaxWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MAX_WIDTH);
NumTabItemMaxWidth.Loaded += (sender, e) =>
{
NumTabItemMaxWidth.ValueChanged += (obj, args) =>
{
SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, NumTabItemMaxWidth.Value);
};
};

// 标签高度
NumTabHeight.Value = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, SettingConstants.UI.DEFAULT_TAB_HEIGHT);
NumTabHeight.Loaded += (sender, e) =>
{
NumTabHeight.ValueChanged += (obj, args) =>
{
SettingService.SetValue(SettingConstants.UI.TAB_HEIGHT, NumTabHeight.Value);
};
};

//显示视频底部进度条
SwShowVideoBottomProgress.IsOn = SettingService.GetValue(SettingConstants.UI.SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR, SettingConstants.UI.DEFAULT_SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR);
SwShowVideoBottomProgress.Loaded += (sender, e) =>
Expand Down
12 changes: 12 additions & 0 deletions src/BiliLite.UWP/Converters/InverseBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Windows.UI.Xaml.Data;

namespace BiliLite.Converters
{
public class InverseBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => !(bool)value;

public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException();
}
}
2 changes: 0 additions & 2 deletions src/BiliLite.UWP/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
PreviewKeyDown="TabView_OnPreviewKeyDown"
TabCloseRequested="TabView_TabCloseRequested"
TabItemsChanged="tabView_TabItemsChanged"
LayoutUpdated="TabView_OnLayoutUpdated"
TabWidthMode="SizeToContent">
<winui:TabView.KeyboardAccelerators>
<KeyboardAccelerator
Expand Down Expand Up @@ -62,7 +61,6 @@
Visibility="Collapsed" />
<Grid
x:Name="gridViewer"
Margin="0,48,0,0"
Background="{ThemeResource SystemControlChromeHighAcrylicElementMediumBrush}"
Opacity="0"
Visibility="Collapsed">
Expand Down
25 changes: 15 additions & 10 deletions src/BiliLite.UWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ private void ClosePage(TabViewItem tabItem)
}
private void tabView_Loaded(object sender, RoutedEventArgs e)
{
// 根据Tab高度设置图片视图边距
gridViewer.Margin = new Thickness(0, m_viewModel.TabHeight, 0, 0);

var frame = new MyFrame();

frame.Navigate(typeof(HomePage));
Expand Down Expand Up @@ -325,17 +328,19 @@ private void InitTabViewStyle()

var styleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewItem"));

if (!(styleKvp.Value is Style style)) return;
style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth));
style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth));
}
if (styleKvp.Value is Style style)
{
style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth));
style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth));
style.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight));
}

private void TabView_OnLayoutUpdated(object sender, object e)
{
// TODO: LayoutUpdated调用频繁,后续更换其他事件
var tabList = tabView.FindFirstChildByType<Microsoft.UI.Xaml.Controls.Primitives.TabViewListView>();
if (tabList == null) return;
tabList.MaxWidth = tabView.ActualWidth - 175;
var tabStyleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewListView"));

if (tabStyleKvp.Value is Style tabStyle)
{
tabStyle.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight));
}
}
}
}
14 changes: 10 additions & 4 deletions src/BiliLite.UWP/Models/Common/SettingConstants.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using BiliLite.Models.Attributes;
using BiliLite.Models.Attributes;
using BiliLite.Models.Common.Player;
using BiliLite.Services;
using System.Collections.Generic;

namespace BiliLite.Models.Common
{
Expand Down Expand Up @@ -233,7 +233,13 @@ public class UI
public const string TAB_ITEM_MIN_WIDTH = "TabItemMinWidth";

[SettingDefaultValue]
public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 192;
public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 0;

[SettingKey(typeof(double))]
public const string TAB_HEIGHT = "TabHeight";

[SettingDefaultValue]
public const double DEFAULT_TAB_HEIGHT = 40;

/// <summary>
/// 是否启用动态磁贴
Expand Down Expand Up @@ -612,7 +618,7 @@ public class Player
[SettingKey(typeof(object))]
public const string FfmpegOptions = "FfmpegOptions";

/// <summary>
/// <summary>
/// 使用外站视频替换无法播放的视频 bool
/// </summary>
[SettingKey(typeof(bool))]
Expand Down
13 changes: 13 additions & 0 deletions src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,23 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
if (e.NewState.IsFullscreen && !view.IsFullScreenMode)
{
view.TryEnterFullScreenMode();

if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
{
var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
SettingConstants.UI.DEFAULT_TAB_HEIGHT);
this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
}
else
{
this.Margin = new Thickness(0, -40, 0, 0);
}
}
else if (view.IsFullScreenMode)
{
view.ExitFullScreenMode();

this.Margin = new Thickness(0);
}
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ private void PlayerControl_FullScreenEvent(object sender, bool e)
{
if (e)
{
this.Margin = new Thickness(0, SettingService.GetValue<int>(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
{
var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
SettingConstants.UI.DEFAULT_TAB_HEIGHT);
this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
}

m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel);
BottomInfo.Height = new GridLength(0, GridUnitType.Pixel);
}
Expand Down
11 changes: 9 additions & 2 deletions src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,21 @@ private void PlayerControl_FullScreenEvent(object sender, bool e)
{
if (e)
{
this.Margin = new Thickness(0, SettingService.GetValue<int>(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
{
var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
SettingConstants.UI.DEFAULT_TAB_HEIGHT);
this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
}

m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel);
BottomInfo.Height = new GridLength(0, GridUnitType.Pixel);
}
else
{
this.Margin = new Thickness(0);
m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue<double>(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel);
m_viewModel.DefaultRightInfoWidth = new GridLength(
SettingService.GetValue<double>(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel);
BottomInfo.Height = GridLength.Auto;
}
}
Expand Down
19 changes: 1 addition & 18 deletions src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Windows.UI.Xaml.Controls;
using Atelier39;
using AutoMapper;
using BiliLite.Models.Common;
using BiliLite.Models.Common.Danmaku;
using BiliLite.Services.Interfaces;
using BiliLite.ViewModels.Video;
Expand Down Expand Up @@ -115,23 +114,7 @@ public override void SetSpeed(int speed)
public override void SetTopMargin(double topMargin)
{
base.SetTopMargin(topMargin);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
{
m_danmakuCanvas.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
}
else
{
m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0);
}
}

public override void SetFullscreen(bool fullscreen)
{
base.SetFullscreen(fullscreen);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
{
m_danmakuCanvas.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
}
m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0);
}

public override void SetOpacity(double opacity)
Expand Down
19 changes: 1 addition & 18 deletions src/BiliLite.UWP/Services/NsDanmakuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using BiliLite.ViewModels.Video;
using NSDanmaku.Controls;
using NSDanmaku.Model;
using BiliLite.Models.Common;

namespace BiliLite.Services
{
Expand Down Expand Up @@ -112,23 +111,7 @@ public override void SetSpeed(int speed)
public override void SetTopMargin(double topMargin)
{
base.SetTopMargin(topMargin);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
{
m_danmakuControl.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
}
else
{
m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0);
}
}

public override void SetFullscreen(bool fullscreen)
{
base.SetFullscreen(fullscreen);
if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
{
m_danmakuControl.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
}
m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0);
}

public override void SetOpacity(double opacity)
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Styles/Converter.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<convert:ImageSourceConvert x:Key="imageConvert2" />
<convert:DisplayConvert x:Key="display" />
<convert:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<convert:InverseBooleanConverter x:Key="InverseBooleanConverter" />
</ResourceDictionary>
Loading

0 comments on commit 1e9ab99

Please sign in to comment.