Skip to content

Commit

Permalink
[Avalonia] Theme fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 22, 2024
1 parent ac5f3bc commit 6f91b6a
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 73 deletions.
1 change: 0 additions & 1 deletion src/PicView.Avalonia.Win32/App.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Application
RequestedThemeVariant="Dark"
x:Class="PicView.Avalonia.Win32.App"
x:CompileBindings="True"
xmlns="https://github.com/avaloniaui"
Expand Down
2 changes: 2 additions & 0 deletions src/PicView.Avalonia.Win32/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
using PicView.Avalonia.Interfaces;
using PicView.Avalonia.Navigation;
using PicView.Avalonia.UI;
Expand Down Expand Up @@ -61,6 +62,7 @@ public override async void OnFrameworkInitializationCompleted()

await Dispatcher.UIThread.InvokeAsync(() =>
{
Current.RequestedThemeVariant = SettingsHelper.Settings.Theme.Dark ? ThemeVariant.Dark : ThemeVariant.Light;
_mainWindow = new WinMainWindow();
desktop.MainWindow = _mainWindow;
});
Expand Down
3 changes: 2 additions & 1 deletion src/PicView.Avalonia.Win32/Views/WinMainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SizeToContent="{CompiledBinding SizeToContent}"
Title="{CompiledBinding WindowTitle,
Mode=OneWay}"
TransparencyBackgroundFallback="{StaticResource MenuBackgroundColor}"
TransparencyLevelHint="AcrylicBlur"
d:DesignHeight="450"
d:DesignWidth="800"
Expand All @@ -26,7 +27,7 @@
</Design.DataContext>

<Border
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{StaticResource WindowBorderColor}"
BorderThickness="1"
CornerRadius="8">
<DockPanel LastChildFill="True">
Expand Down
103 changes: 103 additions & 0 deletions src/PicView.Avalonia/PicViewTheme/Accents/Base.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<ResourceDictionary
x:ClassModifier="internal"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<Color x:Key="MainTextColor">#FFf6f4f4</Color>
<Color x:Key="MainTextColorFaded">#d6d4d4</Color>

<Color x:Key="MainIconColor">#eeebebeb</Color>
<Color x:Key="SecondaryIconColor">#eeebebeb</Color>

<Color x:Key="MainBackgroundColor">#CC2b2b2b</Color>
<Color x:Key="SecondaryBackgroundColor">#CC252525</Color>
<Color x:Key="TertiaryBackgroundColor">#CC3d3d3d</Color>
<Color x:Key="FadedBackgroundColor">#FF333333</Color>
<Color x:Key="BackgroundHoverColor">#FF4B4B4B</Color>
<Color x:Key="AltBackgroundHoverColor">#22FFFFFF</Color>
<Color x:Key="AltBackgroundColor">#A7222222</Color>

<Color x:Key="MainButtonBackgroundColor">#FF2e2e2e</Color>

<Color x:Key="MainBorderColor">#FF3A3A3A</Color>
<Color x:Key="SecondaryBorderColor">#777</Color>
<Color x:Key="TertiaryBorderColor">#555</Color>

<Color x:Key="ButtonForegroundPointerOver">#FFF</Color>

<Color x:Key="BackgroundAlpha">#442e2e2e</Color>

<Color x:Key="MenuBackgroundColor">#292929</Color>

<Color x:Key="ContextMenuBackgroundColor">#EE2b2b2b</Color>
<Color x:Key="ContextMenuTextColor">#EDEBEB</Color>

<Color x:Key="WindowBackgroundColor">#66000000</Color>
<Color x:Key="WindowBorderColor">#FF3A3A3A</Color>
<ImageBrush
DestinationRect="0,0,100,100"
Opacity=".6"
Source="/PicViewTheme/Resources/noisy-texture-200x200-o4-d31-c-161616-t0.png"
SourceRect="0,0,200,200"
Stretch="Fill"
TileMode="FlipXY"
x:Key="NoisyTexture" />

<DropShadowEffect
BlurRadius="5"
Color="#112e2e2e"
OffsetX="2"
OffsetY="2"
x:Key="MenuShadowButtonBorder" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<Color x:Key="MainTextColor">#424242</Color>
<Color x:Key="MainTextColorFaded">#61574a</Color>

<Color x:Key="MainIconColor">#474139</Color>
<Color x:Key="SecondaryIconColor">#eeebebeb</Color>

<Color x:Key="MainBackgroundColor">White</Color>
<Color x:Key="SecondaryBackgroundColor">White</Color>
<Color x:Key="TertiaryBackgroundColor">#CC3d3d3d</Color>
<Color x:Key="FadedBackgroundColor">#FF333333</Color>
<Color x:Key="BackgroundHoverColor">#D5FFFFFF</Color>
<Color x:Key="AltBackgroundHoverColor">#22FFFFFF</Color>
<Color x:Key="AltBackgroundColor">#A7222222</Color>

<Color x:Key="MainButtonBackgroundColor">#81FFFFFF</Color>

<Color x:Key="MainBorderColor">#78B5B5B5</Color>
<Color x:Key="SecondaryBorderColor">#95B5B5B5</Color>
<Color x:Key="TertiaryBorderColor">#555</Color>

<Color x:Key="ButtonForegroundPointerOver">#FFF</Color>

<Color x:Key="BackgroundAlpha">#442e2e2e</Color>

<Color x:Key="MenuBackgroundColor">#D1EEEEEE</Color>

<Color x:Key="ContextMenuBackgroundColor">#D1EEEEEE</Color>
<Color x:Key="ContextMenuTextColor">#474139</Color>

<Color x:Key="WindowBackgroundColor">#66FFFFFF</Color>
<ImageBrush
DestinationRect="0,0,100,100"
Opacity=".6"
Source="/PicViewTheme/Resources/noisy-texture-200x200-o4-d23-c-ffffff-t1.png"
SourceRect="0,0,200,200"
Stretch="Fill"
TileMode="FlipXY"
x:Key="NoisyTexture" />

<DropShadowEffect
BlurRadius="5"
Color="#112e2e2e"
OffsetX="2"
OffsetY="2"
x:Key="MenuShadowButtonBorder" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
19 changes: 10 additions & 9 deletions src/PicView.Avalonia/PicViewTheme/Controls/ToolTip.axaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ResourceDictionary
x:ClassModifier="internal"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type ToolTip}" TargetType="ToolTip">
<Setter Property="Background" Value="{DynamicResource SecondaryBackgroundColor}" />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme TargetType="ToolTip" x:Key="{x:Type ToolTip}">
<Setter Property="Background" Value="{StaticResource SecondaryBackgroundColor}" />
<Setter Property="BorderBrush" Value="{StaticResource MainBorderColor}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="12" />
Expand All @@ -12,14 +12,15 @@
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter
Name="PART_ContentPresenter"
Padding="8"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{StaticResource ContextMenuBackgroundColor}"
BorderBrush="{StaticResource MainBorderColor}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="5" />
CornerRadius="5"
Foreground="{StaticResource ContextMenuTextColor}"
Name="PART_ContentPresenter"
Padding="8" />
</ControlTemplate>
</Setter>
</ControlTheme>
Expand Down
18 changes: 8 additions & 10 deletions src/PicView.Avalonia/PicViewTheme/Controls/Window.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="TransparencyBackgroundFallback" Value="{StaticResource MenuBackgroundColor}" />
<Setter Property="Foreground" Value="{StaticResource MainTextColor}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="BorderBrush" Value="{StaticResource MainBorderColor}" />
<Setter Property="Template">
<ControlTemplate>
<Panel>
Expand All @@ -28,15 +28,13 @@
</ExperimentalAcrylicBorder.Material>
</ExperimentalAcrylicBorder>

<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
Name="PART_ContentPresenter"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
Name="PART_ContentPresenter"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</Panel>
</VisualLayerManager>
</Panel>
Expand Down
48 changes: 0 additions & 48 deletions src/PicView.Avalonia/PicViewTheme/LightColors.axaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/PicView.Avalonia/PicViewTheme/Main.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ResourceDictionary.MergedDictionaries>

<!-- TODO: Figure out switching themes -->
<ResourceInclude Source="/PicViewTheme/DarkColors.axaml" />
<ResourceInclude Source="/PicViewTheme/Accents/Base.axaml" />
<!-- <ResourceInclude Source="/PicViewTheme/LightColors.axaml" /> -->
<!-- TODO: Figure out switching themes -->

Expand Down
2 changes: 0 additions & 2 deletions src/PicView.Avalonia/PicViewTheme/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static void SetTheme(bool dark)
// StyleInclude breaks trimming and AOT
// Change colors with keys like https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Simple/Accents/Base.xaml

var test = Application.Current.Resources.MergedDictionaries[1];

// Add the new theme
if (dark)
{
Expand Down
1 change: 0 additions & 1 deletion src/PicView.Avalonia/Views/AppearanceView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
BorderBrush="{StaticResource MainBorderColor}"
BorderThickness="1"
FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
IsEnabled="False"
Margin="0,0,0,5"
Padding="5,7,0,7"
Width="270"
Expand Down
1 change: 1 addition & 0 deletions src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
</DrawingImage>
</Image>
<AutoCompleteBox
Background="{StaticResource BackgroundAlpha}"
BorderBrush="{StaticResource MainBorderColor}"
FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
Foreground="{StaticResource MainIconColor}"
Expand Down

0 comments on commit 6f91b6a

Please sign in to comment.