浏览代码

Enhance Glass Theme styling and transparency handling.

- Added support for transparent and consistent backgrounds in `GlassTheme` across multiple views.
- Centralized noisy texture handling via `Application.Current.TryGetResource`.
- Set `BorderThickness` to zero for buttons in `HoverBar` and `ZoomPreviewer` when `GlassTheme` is enabled.
- Applied `x:Name` attributes for easier element reference in menus and views.
- Unified geometry and style definitions for improved theme consistency.
Ruben 1 天之前
父节点
当前提交
b12f51247c

+ 2 - 0
src/PicView.Avalonia.Win32/Views/SettingsWindow.axaml.cs

@@ -44,6 +44,8 @@ public partial class SettingsWindow : Window
         ParentBorder.Height = ScreenHelper.GetWindowMaxHeight();
         if (Settings.Theme.GlassTheme)
         {
+            SettingsView.Background = Brushes.Transparent;
+            
             LogoBorder.Background = Brushes.Transparent;
             LogoBorder.BorderThickness = new Thickness(0);
 

+ 4 - 8
src/PicView.Avalonia/PicViewTheme/Controls/MenuItem.axaml

@@ -85,12 +85,10 @@
             </ControlTemplate>
         </Setter>
 
-        <Style
-            Selector="^:toggle /template/ Viewbox#PART_ToggleIconPresenter, ^:radio /template/ Viewbox#PART_ToggleIconPresenter">
+        <Style Selector="^:toggle /template/ Viewbox#PART_ToggleIconPresenter, ^:radio /template/ Viewbox#PART_ToggleIconPresenter">
             <Setter Property="IsVisible" Value="True" />
         </Style>
-        <Style
-            Selector="^:toggle /template/ ContentPresenter#PART_IconPresenter, ^:radio /template/ ContentPresenter#PART_IconPresenter">
+        <Style Selector="^:toggle /template/ ContentPresenter#PART_IconPresenter, ^:radio /template/ ContentPresenter#PART_IconPresenter">
             <Setter Property="IsVisible" Value="False" />
         </Style>
         <Style Selector="^:checked:toggle /template/ ContentControl#PART_ToggleIconPresenter">
@@ -293,12 +291,10 @@
             </ControlTemplate>
         </Setter>
 
-        <Style
-            Selector="^:toggle /template/ Viewbox#PART_ToggleIconPresenter, ^:radio /template/ Viewbox#PART_ToggleIconPresenter">
+        <Style Selector="^:toggle /template/ Viewbox#PART_ToggleIconPresenter, ^:radio /template/ Viewbox#PART_ToggleIconPresenter">
             <Setter Property="IsVisible" Value="True" />
         </Style>
-        <Style
-            Selector="^:toggle /template/ ContentPresenter#PART_IconPresenter, ^:radio /template/ ContentPresenter#PART_IconPresenter">
+        <Style Selector="^:toggle /template/ ContentPresenter#PART_IconPresenter, ^:radio /template/ ContentPresenter#PART_IconPresenter">
             <Setter Property="IsVisible" Value="False" />
         </Style>
         <Style Selector="^:checked:toggle /template/ ContentControl#PART_ToggleIconPresenter">

文件差异内容过多而无法显示
+ 2 - 6
src/PicView.Avalonia/PicViewTheme/Icons.axaml


文件差异内容过多而无法显示
+ 0 - 1
src/PicView.Avalonia/Views/Config/InterfaceConfigurationView.axaml


+ 4 - 0
src/PicView.Avalonia/Views/Main/PrintPreviewView.axaml

@@ -186,6 +186,7 @@
                                 Text="{CompiledBinding Translation.Top.Value,
                                                        Mode=OneWay}" />
                             <NumericUpDown
+                                Background="{DynamicResource SecondaryBackgroundColor}"
                                 FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                 Foreground="{DynamicResource MainTextColor}"
                                 HorizontalAlignment="Stretch"
@@ -204,6 +205,7 @@
                                 Text="{CompiledBinding Translation.Bottom.Value,
                                                        Mode=OneWay}" />
                             <NumericUpDown
+                                Background="{DynamicResource SecondaryBackgroundColor}"
                                 FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                 Foreground="{DynamicResource MainTextColor}"
                                 HorizontalAlignment="Stretch"
@@ -222,6 +224,7 @@
                                 Text="{CompiledBinding Translation.Left.Value,
                                                        Mode=OneWay}" />
                             <NumericUpDown
+                                Background="{DynamicResource SecondaryBackgroundColor}"
                                 FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                 Foreground="{DynamicResource MainTextColor}"
                                 HorizontalAlignment="Stretch"
@@ -240,6 +243,7 @@
                                 Text="{CompiledBinding Translation.Right.Value,
                                                        Mode=OneWay}" />
                             <NumericUpDown
+                                Background="{DynamicResource SecondaryBackgroundColor}"
                                 FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                 Foreground="{DynamicResource MainTextColor}"
                                 HorizontalAlignment="Stretch"

+ 1 - 2
src/PicView.Avalonia/Views/Main/SettingsView.axaml

@@ -140,8 +140,7 @@
                             Text="{Binding Translation.InterfaceConfiguration.Value, Mode=OneWay}" />
                     </StackPanel>
                 </TabItem.Header>
-                <customControls:AutoScrollViewer Background="Transparent"
-                                                 Height="{Binding Path=Bounds.Height, ElementName=MainTabControl}">
+                <customControls:AutoScrollViewer Background="Transparent" Height="{Binding Path=Bounds.Height, ElementName=MainTabControl}">
                     <config:InterfaceConfigurationView
                         Background="Transparent"
                         Margin="{StaticResource TabMargin}"

+ 21 - 0
src/PicView.Avalonia/Views/UC/HoverBar.axaml.cs

@@ -3,6 +3,7 @@ using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.LogicalTree;
+using Avalonia.Media;
 using Avalonia.Threading;
 using PicView.Avalonia.Functions;
 using PicView.Avalonia.Navigation;
@@ -56,6 +57,26 @@ public partial class HoverBar : UserControl
         SizeChanged += (_, args) => ApplyResponsiveResize(args.NewSize.Width);
         ApplyResponsiveResize(Bounds.Width);
 
+
+        if (Settings.Theme.GlassTheme)
+        {
+            var brush = new SolidColorBrush(Color.Parse("#D1333333"));
+            NextButton.Background = brush;
+            PreviousButton.Background = brush;
+
+            var noThickness = new Thickness(0);
+            FileMenuButton.BorderThickness = noThickness;
+            ZoomOutMenuButton.BorderThickness = noThickness;
+            ZoomInMenuButton.BorderThickness = noThickness;
+            RotateLeftButton.BorderThickness = noThickness;
+            RotateRightButton.BorderThickness = noThickness;
+            FlipButton.BorderThickness = noThickness;
+            ImageMenuButton.BorderThickness = noThickness;
+            SettingsMenuButton.BorderThickness = noThickness;
+            NextButton.BorderThickness = noThickness;
+            PreviousButton.BorderThickness = noThickness;
+        }
+
         if (DataContext is not MainViewModel vm)
         {
             return;

+ 3 - 5
src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml

@@ -36,11 +36,9 @@
             BorderBrush="{DynamicResource OuterBorderColor}"
             BorderThickness="1"
             CornerRadius="8"
-            Effect="{DynamicResource MenuShadowButtonBorder}">
-            <Canvas
-                Height="208"
-                Width="315"
-                x:Name="MainCanvas">
+            Effect="{DynamicResource MenuShadowButtonBorder}"
+            x:Name="MainBorder">
+            <Canvas Height="208" Width="315">
 
                 <Border
                     Background="{DynamicResource SecondaryBackgroundColor}"

+ 16 - 2
src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml.cs

@@ -1,5 +1,7 @@
 using System.Runtime.InteropServices;
+using Avalonia;
 using Avalonia.Media;
+using Avalonia.Styling;
 using PicView.Avalonia.CustomControls;
 
 namespace PicView.Avalonia.Views.UC.Menus;
@@ -13,10 +15,22 @@ public partial class FileMenu : AnimatedMenu
         {
             if (Settings.Theme.GlassTheme)
             {
+                if (Application.Current.TryGetResource("NoisyTexture",
+                        ThemeVariant.Dark, out var texture))
+                {
+                    var brush = texture as ImageBrush;
+                    MainBorder.Background = brush;
+                    DownArrow.Fill = brush;
+                    DownArrow.StrokeThickness = 0;
+                }
             }
-            else if (!Settings.Theme.Dark)
+
+            if (!Settings.Theme.Dark || Settings.Theme.GlassTheme)
             {
-                TopBorder.Background = Brushes.White;
+                if (!Settings.Theme.GlassTheme)
+                {
+                    TopBorder.Background = Brushes.White;
+                }
 
                 NewWindowButton.Classes.Remove("altHover");
                 NewWindowButton.Classes.Add("hover");

+ 4 - 2
src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml

@@ -30,7 +30,8 @@
             BorderBrush="{DynamicResource OuterBorderColor}"
             BorderThickness="1"
             CornerRadius="8"
-            Effect="{DynamicResource MenuShadowButtonBorder}">
+            Effect="{DynamicResource MenuShadowButtonBorder}"
+            x:Name="MainBorder">
             <Canvas Height="208" Width="315">
 
                 <Border
@@ -360,6 +361,7 @@
             Margin="37,-1,0,0"
             Points="0,0 15,30, 30,0"
             Stroke="{DynamicResource MainBorderColor}"
-            StrokeThickness="1" />
+            StrokeThickness="1"
+            x:Name="DownArrow" />
     </StackPanel>
 </customControls:AnimatedMenu>

+ 17 - 2
src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml.cs

@@ -1,5 +1,6 @@
 using Avalonia;
 using Avalonia.Media;
+using Avalonia.Styling;
 using PicView.Avalonia.Crop;
 using PicView.Avalonia.CustomControls;
 using PicView.Avalonia.UI;
@@ -35,13 +36,27 @@ public partial class ImageMenu : AnimatedMenu
             Item90.Header = $"90 {TranslationManager.Translation.SecAbbreviation}";
             Item120.Header = $"120 {TranslationManager.Translation.SecAbbreviation}";
 
-            if (Settings.Theme.Dark)
+            if (Settings.Theme.Dark && !Settings.Theme.GlassTheme)
             {
                 return;
             }
 
 
-            TopBorder.Background = Brushes.White;
+            if (!Settings.Theme.GlassTheme)
+            {
+                TopBorder.Background = Brushes.White;
+            }
+            else
+            {
+                if (Application.Current.TryGetResource("NoisyTexture",
+                        ThemeVariant.Dark, out var texture))
+                {
+                    var brush = texture as ImageBrush;
+                    MainBorder.Background = brush;
+                    DownArrow.Fill = brush;
+                    DownArrow.StrokeThickness = 0;
+                }
+            }
 
             CropButton.Classes.Remove("altHover");
             CropButton.Classes.Add("hover");

+ 4 - 2
src/PicView.Avalonia/Views/UC/Menus/SettingsMenu.axaml

@@ -38,7 +38,8 @@
             BorderBrush="{DynamicResource OuterBorderColor}"
             BorderThickness="1"
             CornerRadius="8"
-            Effect="{DynamicResource MenuShadowButtonBorder}">
+            Effect="{DynamicResource MenuShadowButtonBorder}"
+            x:Name="MainBorder">
             <Canvas Height="208" Width="359">
 
                 <Border
@@ -241,6 +242,7 @@
             Margin="325,-1,0,0"
             Points="0,0 15,30, 30,0"
             Stroke="{DynamicResource MainBorderColor}"
-            StrokeThickness="1" />
+            StrokeThickness="1"
+            x:Name="DownArrow" />
     </StackPanel>
 </customControls:AnimatedMenu>

+ 25 - 7
src/PicView.Avalonia/Views/UC/Menus/SettingsMenu.axaml.cs

@@ -1,5 +1,6 @@
 using Avalonia;
 using Avalonia.Media;
+using Avalonia.Styling;
 using PicView.Avalonia.CustomControls;
 using PicView.Avalonia.UI;
 
@@ -18,16 +19,33 @@ public partial class SettingsMenu : AnimatedMenu
                 UIHelper.SwitchHoverBorderClass(AboutWindowButton);
             }
 
-            if (!Settings.Theme.Dark && !Settings.Theme.GlassTheme)
+            if (Settings.Theme.Dark && !Settings.Theme.GlassTheme)
+            {
+                return;
+            }
+
+            if (!Settings.Theme.GlassTheme)
             {
                 TopBorder.Background = Brushes.White;
-                UIHelper.SwitchHoverClass(StretchButton);
-                UIHelper.SwitchHoverClass(ScrollButton);
-                UIHelper.SwitchHoverClass(LoopingButton);
-                UIHelper.SwitchHoverClass(AutofitButton);
-                UIHelper.SwitchHoverClass(TopMostButton);
-                UIHelper.SwitchHoverClass(SubDirButton);
             }
+            else
+            {
+                if (Application.Current.TryGetResource("NoisyTexture",
+                        ThemeVariant.Dark, out var texture))
+                {
+                    var brush = texture as ImageBrush;
+                    MainBorder.Background = brush;
+                    DownArrow.Fill = brush;
+                    DownArrow.StrokeThickness = 0;
+                }
+            }
+
+            UIHelper.SwitchHoverClass(StretchButton);
+            UIHelper.SwitchHoverClass(ScrollButton);
+            UIHelper.SwitchHoverClass(LoopingButton);
+            UIHelper.SwitchHoverClass(AutofitButton);
+            UIHelper.SwitchHoverClass(TopMostButton);
+            UIHelper.SwitchHoverClass(SubDirButton);
         };
 
         if (TryGetResource("ScrollingBrush", Application.Current.RequestedThemeVariant,

+ 4 - 2
src/PicView.Avalonia/Views/UC/Menus/ToolsMenu.axaml

@@ -30,7 +30,8 @@
             BorderBrush="{DynamicResource OuterBorderColor}"
             BorderThickness="1"
             CornerRadius="8"
-            Effect="{DynamicResource MenuShadowButtonBorder}">
+            Effect="{DynamicResource MenuShadowButtonBorder}"
+            x:Name="MainBorder">
             <Canvas Height="208" Width="359">
 
                 <Border
@@ -225,6 +226,7 @@
             Margin="290,-1,0,0"
             Points="0,0 15,30, 30,0"
             Stroke="{DynamicResource MainBorderColor}"
-            StrokeThickness="1" />
+            StrokeThickness="1"
+            x:Name="DownArrow" />
     </StackPanel>
 </customControls:AnimatedMenu>

+ 17 - 10
src/PicView.Avalonia/Views/UC/Menus/ToolsMenu.axaml.cs

@@ -1,5 +1,6 @@
 using Avalonia;
 using Avalonia.Media;
+using Avalonia.Styling;
 using PicView.Avalonia.CustomControls;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
@@ -15,17 +16,23 @@ public partial class ToolsMenu : AnimatedMenu
         InitializeComponent();
         Loaded += (_, _) =>
         {
-            if (Settings.Theme.GlassTheme)
+            if (!Settings.Theme.Dark || Settings.Theme.GlassTheme)
             {
-                BatchResizeButton.Classes.Remove("noBorderHover");
-                BatchResizeButton.Classes.Add("hover");
-
-                EffectsButton.Classes.Remove("noBorderHover");
-                EffectsButton.Classes.Add("hover");
-            }
-            else if (!Settings.Theme.Dark)
-            {
-                TopBorder.Background = Brushes.White;
+                if (!Settings.Theme.GlassTheme)
+                {
+                    TopBorder.Background = Brushes.White;
+                }
+                else
+                {
+                    if (Application.Current.TryGetResource("NoisyTexture",
+                            ThemeVariant.Dark, out var texture))
+                    {
+                        var brush = texture as ImageBrush;
+                        MainBorder.Background = brush;
+                        DownArrow.Fill = brush;
+                        DownArrow.StrokeThickness = 0;
+                    }
+                }
 
                 // Batch
                 BatchResizeButton.Classes.Remove("noBorderHover");

+ 2 - 1
src/PicView.Avalonia/Views/UC/ZoomPreviewer.axaml

@@ -10,7 +10,8 @@
         Background="{DynamicResource MainBackgroundColor}"
         BorderBrush="{DynamicResource MainBorderColor}"
         BorderThickness="1"
-        CornerRadius="6,6,1,1">
+        CornerRadius="6,6,1,1"
+        x:Name="MainBorder">
         <StackPanel>
             <Border
                 Background="{DynamicResource MainBackgroundColor}"

+ 5 - 0
src/PicView.Avalonia/Views/UC/ZoomPreviewer.axaml.cs

@@ -35,6 +35,11 @@ public partial class ZoomPreviewer : UserControl
             return;
         }
 
+        if (Settings.Theme.GlassTheme)
+        {
+            MainBorder.BorderThickness = new Thickness(0);
+        }
+
         ResetZoomButton.Classes.Remove("altHover");
         CloseButton.Classes.Remove("altHover");
         ResetZoomButton.Classes.Add("hover");

部分文件因为文件数量过多而无法显示