Skip to content

Commit

Permalink
Tabs now fully themed
Browse files Browse the repository at this point in the history
  • Loading branch information
flarive committed Aug 20, 2023
1 parent 3a95e88 commit ed336f7
Show file tree
Hide file tree
Showing 12 changed files with 395 additions and 177 deletions.
6 changes: 3 additions & 3 deletions Avalonia.Themes.Neumorphism/Accents/BaseColorsPalette.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<Color x:Key="SystemRevealListLowColor">#17000000</Color>
<Color x:Key="SystemRevealListMediumColor">#2E000000</Color>

<!--new !!!!!!!!!!-->
<Color x:Key="ValidationErrorColor">#F44336</Color>
<!--new Neumorphism theme !!!!-->
<Color x:Key="ValidationErrorColor">#F44336</Color>
<Color x:Key="MaterialDesignBackground">#FFFFFFFF</Color>
<Color x:Key="MaterialDesignForeground">#FF616163</Color>
<Color x:Key="MaterialDesignPaper">#FFE0E5EC</Color>
Expand Down Expand Up @@ -106,7 +106,7 @@
<Color x:Key="SystemRevealListLowColor">#18FFFFFF</Color>
<Color x:Key="SystemRevealListMediumColor">#30FFFFFF</Color>

<!--new !!!!-->
<!--new Neumorphism theme !!!!-->
<Color x:Key="ValidationErrorColor">#f44336</Color>
<Color x:Key="MaterialDesignBackground">#FF000000</Color>
<Color x:Key="MaterialDesignForeground">#FFFFFFFF</Color>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,14 @@
ResourceKey="SystemControlHighlightListAccentLowBrush" />

<!-- Resources for TabItem.xaml -->
<x:Double x:Key="TabItemHeaderFontSize">24</x:Double>
<!--<x:Double x:Key="TabItemHeaderFontSize">24</x:Double>
<Thickness x:Key="TabItemHeaderMargin">12,0,12,0</Thickness>
<Thickness x:Key="TabItemMargin">12,0,12,0</Thickness>
<FontWeight x:Key="TabItemHeaderThemeFontWeight">SemiLight</FontWeight>
<StaticResource x:Key="TabControlBackground" ResourceKey="SystemControlTransparentBrush" />
<StaticResource x:Key="TabControlBackground" ResourceKey="SystemControlTransparentBrush" />-->

<!-- Resources for TabItem -->
<StaticResource x:Key="TabItemHeaderBackgroundUnselected" ResourceKey="SystemControlTransparentBrush" />
<!--<StaticResource x:Key="TabItemHeaderBackgroundUnselected" ResourceKey="SystemControlTransparentBrush" />
<StaticResource x:Key="TabItemHeaderBackgroundUnselectedPointerOver"
ResourceKey="SystemControlHighlightTransparentBrush" />
<StaticResource x:Key="TabItemHeaderBackgroundUnselectedPressed"
Expand All @@ -549,7 +549,7 @@
<StaticResource x:Key="TabItemHeaderForegroundSelectedPressed"
ResourceKey="SystemControlHighlightAltBaseMediumHighBrush" />
<StaticResource x:Key="TabItemHeaderForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
<StaticResource x:Key="TabItemHeaderSelectedPipeFill" ResourceKey="SystemControlHighlightAltAccentBrush" />
<StaticResource x:Key="TabItemHeaderSelectedPipeFill" ResourceKey="SystemControlHighlightAltAccentBrush" />-->

<!-- Resources for ScrollBar.xaml -->
<x:Double x:Key="ScrollBarTrackBorderThemeThickness">0</x:Double>
Expand Down
10 changes: 5 additions & 5 deletions Avalonia.Themes.Neumorphism/Avalonia.Themes.Neumorphism.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.5.1</Version>
<Version>0.6.0</Version>
<Title>Neumorphism.Avalonia</Title>
<Authors>Eviral</Authors>
<Company>Eviral</Company>
Expand All @@ -21,10 +21,10 @@
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.3" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.3" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.3" />
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.4" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<AvaloniaResource Include="**/*.xaml" />
</ItemGroup>
Expand Down
151 changes: 74 additions & 77 deletions Avalonia.Themes.Neumorphism/Controls/ColorZone.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Media;

Expand Down Expand Up @@ -50,8 +49,6 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
// ???????????????????????????
//OnModeChanged(null);

//OnModeChanged();

DisposeSubscription();

// ????????????????????????????
Expand Down Expand Up @@ -79,80 +76,80 @@ private void DisposeSubscription()
// Dispatcher.UIThread.InvokeAsync(delegate { OnModeChanged(theme); });
//}

private void OnModeChanged()
{
var colorZone = this;
//theme ??= Application.Current!.LocateMaterialTheme<MaterialTheme>();

//var resources = theme;

//var foregroundProperty = TemplatedControl.ForegroundProperty;

switch (colorZone.Mode)
{
case ColorZoneMode.Standard:
{
SetValueInternal(BackgroundProperty, Application.Current!.Resources["MaterialDesignPaper"]);
SetValueInternal(ForegroundProperty, Application.Current!.Resources["MaterialDesignBody"]);
}
break;

//case ColorZoneMode.Inverted:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignBody"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignPaper"));
// }
// break;

//case ColorZoneMode.Light:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignLightBackground"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignLightForeground"));
// }
// break;

//case ColorZoneMode.Dark:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignDarkBackground"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignDarkForeground"));
// }
// break;

//case ColorZoneMode.PrimaryLight:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueLightBrush"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueLightForegroundBrush"));
// }
// break;

//case ColorZoneMode.PrimaryMid:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueMidBrush"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueMidForegroundBrush"));
// }
// break;

//case ColorZoneMode.PrimaryDark:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueDarkBrush"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueDarkForegroundBrush"));
// }
// break;

//case ColorZoneMode.Accent:
// {
// SetValueInternal(BackgroundProperty, GetBrushResource(resources, "SecondaryHueMidBrush"));
// SetValueInternal(foregroundProperty, GetBrushResource(resources, "SecondaryHueMidForegroundBrush"));
// }
// break;

//case ColorZoneMode.Custom:
// break;

//default:
// throw new ArgumentOutOfRangeException();
}
}
//private void OnModeChanged()
//{
// var colorZone = this;
// //theme ??= Application.Current!.LocateMaterialTheme<MaterialTheme>();

// //var resources = theme;

// //var foregroundProperty = TemplatedControl.ForegroundProperty;

// switch (colorZone.Mode)
// {
// case ColorZoneMode.Standard:
// {
// SetValueInternal(BackgroundProperty, Application.Current!.Resources["MaterialDesignPaper"]);
// SetValueInternal(ForegroundProperty, Application.Current!.Resources["MaterialDesignBody"]);
// }
// break;

// //case ColorZoneMode.Inverted:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignBody"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignPaper"));
// // }
// // break;

// //case ColorZoneMode.Light:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignLightBackground"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignLightForeground"));
// // }
// // break;

// //case ColorZoneMode.Dark:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "MaterialDesignDarkBackground"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "MaterialDesignDarkForeground"));
// // }
// // break;

// //case ColorZoneMode.PrimaryLight:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueLightBrush"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueLightForegroundBrush"));
// // }
// // break;

// //case ColorZoneMode.PrimaryMid:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueMidBrush"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueMidForegroundBrush"));
// // }
// // break;

// //case ColorZoneMode.PrimaryDark:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "PrimaryHueDarkBrush"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "PrimaryHueDarkForegroundBrush"));
// // }
// // break;

// //case ColorZoneMode.Accent:
// // {
// // SetValueInternal(BackgroundProperty, GetBrushResource(resources, "SecondaryHueMidBrush"));
// // SetValueInternal(foregroundProperty, GetBrushResource(resources, "SecondaryHueMidForegroundBrush"));
// // }
// // break;

// //case ColorZoneMode.Custom:
// // break;

// //default:
// // throw new ArgumentOutOfRangeException();
// }
//}

private void SetValueInternal(AvaloniaProperty property, object value) {
SetValue(property, value, BindingPriority.Style);
Expand Down
14 changes: 7 additions & 7 deletions Avalonia.Themes.Neumorphism/Themes/TabControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Setter Property="Height" Value="200" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Background" Value="{DynamicResource TabControlBackground}" />
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
<Setter Property="assist:ShadowAssist.ShadowDepth" Value="Depth1" />
<Setter Property="Template">
<ControlTemplate>
Expand All @@ -44,7 +44,7 @@
Margin="0"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<DockPanel Name="PART_TabControlDockPanel" VerticalAlignment="Bottom">
<DockPanel Name="PART_TabControlDockPanel" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<ItemsPresenter Name="PART_ItemsPresenter"
ItemsPanel="{TemplateBinding ItemsPanel}"
DockPanel.Dock="{TemplateBinding TabStripPlacement}" />
Expand Down Expand Up @@ -116,7 +116,7 @@
<Setter Property="BorderThickness" Value="0,1,0,0" />
<Setter Property="BorderBrush" Value="#ffd1d6dc" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="Margin" Value="0,-1,0,0" />
<Setter Property="Margin" Value="0,-2,0,0" />
<Setter Property="assist:ShadowAssist.ShadowDepth" Value="Depth0" />
</Style>

Expand All @@ -132,15 +132,15 @@
<Setter Property="BorderThickness" Value="1,0,0,0" />
<Setter Property="BorderBrush" Value="#ffd1d6dc" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="Margin" Value="-8,0,0,0" />
<Setter Property="Margin" Value="-10,0,0,0" />
<Setter Property="assist:ShadowAssist.ShadowDepth" Value="Depth0" />
</Style>

<Style Selector="^[TabStripPlacement=Right]:not(.Bordered) /template/ Border#PART_SelectedContentBorder">
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="BorderBrush" Value="Green" />
<Setter Property="BorderThickness" Value="0,0,1,0" />
<Setter Property="BorderBrush" Value="#ffd1d6dc" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="Margin" Value="0,0,0,-1" />
<Setter Property="Margin" Value="0,0,-10,0" />
<Setter Property="assist:ShadowAssist.ShadowDepth" Value="Depth0" />
</Style>

Expand Down
40 changes: 30 additions & 10 deletions Avalonia.Themes.Neumorphism/Themes/TabItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@
</Design.PreviewWith>



<SolidColorBrush x:Key="TabItemHeaderBackgroundSelected" Color="Transparent" />
<SolidColorBrush x:Key="TabItemHeaderForegroundSelected" Color="Black" />
<SolidColorBrush x:Key="TabItemHeaderBackgroundUnselectedPointerOver" Color="Transparent"/>
<SolidColorBrush x:Key="TabItemHeaderForegroundUnselectedPointerOver" Color="Black"/>
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelectedPointerOver" Color="Transparent"/>
<SolidColorBrush x:Key="TabItemHeaderForegroundSelectedPointerOver" Color="Black"/>
<SolidColorBrush x:Key="TabItemHeaderBackgroundUnselectedPressed" Color="Transparent"/>
<SolidColorBrush x:Key="TabItemHeaderForegroundUnselectedPressed" Color="Black"/>
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelectedPressed" Color="Transparent"/>
<SolidColorBrush x:Key="TabItemHeaderForegroundSelectedPressed" Color="Black"/>
<SolidColorBrush x:Key="TabItemHeaderBackgroundDisabled" Color="Transparent"/>
<SolidColorBrush x:Key="TabItemHeaderForegroundDisabled" Color="#FFCCCCCC"/>


<ControlTheme x:Key="{x:Type TabItem}" TargetType="TabItem">
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
Expand Down Expand Up @@ -206,9 +219,9 @@
<!-- TabStripPlacement Left -->
<Style Selector="^[TabStripPlacement=Left] /template/ Border#PART_SelectedPipe">
<Setter Property="Width" Value="{TemplateBinding assist:TabControlAssist.HighlightStrokeSize}" />
<Setter Property="Margin" Value="0,0,2,0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Stretch" />
</Style>

<Style Selector="^[TabStripPlacement=Left] /template/ ContentPresenter#PART_ContentPresenter">
Expand All @@ -217,7 +230,7 @@

<Style Selector="^[TabStripPlacement=Left]:not(.Button) /template/ Border#PART_LayoutRoot">
<Setter Property="Margin" Value="8"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource CustomCornerRadiusConverter}, ConverterParameter=100%|0%|0%|100%}" />
</Style>

Expand All @@ -236,17 +249,24 @@
<!-- TabStripPlacement Right -->
<Style Selector="^[TabStripPlacement=Right] /template/ Border#PART_SelectedPipe">
<Setter Property="Width" Value="{TemplateBinding assist:TabControlAssist.HighlightStrokeSize}" />
<Setter Property="Margin" Value="2,0,0,0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Stretch" />
</Style>

<Style Selector="^[TabStripPlacement=Right] /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Margin" Value="0,0,8,0" />
<Setter Property="Margin" Value="20,0,20,0" />
</Style>

<Style Selector="^[TabStripPlacement=Right]">
<Setter Property="HorizontalContentAlignment" Value="Right" />

<Style Selector="^[TabStripPlacement=Right]:not(.Button) /template/ Border#PART_LayoutRoot">
<Setter Property="Margin" Value="8"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource CustomCornerRadiusConverter}, ConverterParameter=0%|100%|100%|0%}" />
</Style>

<Style Selector="^[TabStripPlacement=Right].Button /template/ Border#PART_LayoutRoot">
<Setter Property="Margin" Value="10"/>
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource CustomCornerRadiusConverter}, ConverterParameter=100%|100%|100%|100%}" />
</Style>
</ControlTheme>
</ResourceDictionary>
Expand Down
10 changes: 5 additions & 5 deletions Neumorphism.Avalonia.Demo/Neumorphism.Avalonia.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.3" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.3" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.3" />
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.4" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.3" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.4" />
<PackageReference Include="DialogHost.Avalonia" Version="0.7.6" />
<!--Condition below is needed to generate macOS App only.-->
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" Condition="$(RuntimeIdentifier.StartsWith('osx'))" />
Expand Down
2 changes: 1 addition & 1 deletion Neumorphism.Avalonia.Demo/Pages/Home.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Style>
</StackPanel.Styles>

<Image Width="1004" Height="301" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,50,0,40" Source="avares://Neumorphism.Avalonia.Demo/Assets/Neumorphism.png" Opacity="1"/>
<Image Width="1004" Height="301" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,50,0,40" Source="avares://Neumorphism.Avalonia.Demo/Assets/Neumorphism.png"/>


<StackPanel Margin="16">
Expand Down
Loading

0 comments on commit ed336f7

Please sign in to comment.