Skip to content

Commit

Permalink
Control theme (#176)
Browse files Browse the repository at this point in the history
Switch To ControlTheme
  • Loading branch information
jinek authored Dec 5, 2024
1 parent 72c5619 commit a74b10d
Show file tree
Hide file tree
Showing 59 changed files with 1,283 additions and 1,140 deletions.
17 changes: 6 additions & 11 deletions src/Consolonia.Gallery/App.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Globalization;
using System.Threading;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Styling;
using Consolonia.Core.Infrastructure;
using Consolonia.Gallery.View;
using Consolonia.Themes.TurboVision.Themes.Material;
using Consolonia.Themes.TurboVision.Themes.Fluent;

namespace Consolonia.Gallery
{
Expand All @@ -19,14 +17,11 @@ static App()

public App()
{
// Styles.Add(new TurboVisionTheme(new Uri("avares://Consolonia.Themes.TurboVision/Themes/TurboVisionDark/TurboVisionDark.axaml")));
Styles.Add(new MaterialTheme(new Uri("avares://Consolonia.Themes.TurboVision/Themes/Material/Material.axaml")));
// Styles.Add(new FluentTheme(new Uri("avares://Consolonia.Themes.TurboVision/Themes/Fluent/Fluent.axaml")));
}

public override void RegisterServices()
{
base.RegisterServices();
/*Styles.Add(new TurboVisionTheme());*/
/*Styles.Add(new TurboVisionBlackTheme());*/
/*Styles.Add(new TurboVisionDarkTheme());*/
Styles.Add(new FluentTheme());
/*Styles.Add(new MaterialTheme());*/
}

public override void OnFrameworkInitializationCompleted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Core.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Consolonia.Core\Consolonia.Core.csproj" />
<ProjectReference Include="..\Consolonia.Core\Consolonia.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Templates\Controls\DialogWrap.axaml.cs">
<DependentUpon>DialogWrap.axaml</DependentUpon>
</Compile>
<Compile Update="Templates\TurboVisionTheme.cs">
<DependentUpon>TurboVisionTheme.axaml</DependentUpon>
</Compile>
<Compile Update="Themes\TurboVisionBlack\TurboVisionBlackTheme.cs">
<DependentUpon>TurboVisionBlackTheme.axaml</DependentUpon>
</Compile>
<Compile Update="Themes\TurboVisionDark\TurboVisionDarkTheme.cs">
<DependentUpon>TurboVisionDarkTheme.axaml</DependentUpon>
</Compile>
<Compile Update="Themes\Fluent\FluentTheme.cs">
<DependentUpon>FluentTheme.axaml</DependentUpon>
</Compile>
<Compile Update="Themes\Material\MaterialTheme.cs">
<DependentUpon>MaterialTheme.axaml</DependentUpon>
</Compile>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StyleInclude Source="/Templates/Controls/TextBlock.axaml" />
<StyleInclude Source="/Templates/Controls/Window.axaml" />
<StyleInclude Source="/Templates/Controls/Button.axaml" />
<StyleInclude Source="/Templates/Controls/TextBox.axaml" />
<StyleInclude Source="/Templates/Controls/CheckBox.axaml" />
<StyleInclude Source="/Templates/Controls/ScrollViewer.axaml" />
<StyleInclude Source="/Templates/Controls/ScrollBar.axaml" />
<StyleInclude Source="/Templates/Controls/ComboBoxItem.axaml" />
<StyleInclude Source="/Templates/Controls/ComboBox.axaml" />
<StyleInclude Source="/Templates/Controls/ToggleButton.axaml" />
<StyleInclude Source="/Templates/Controls/Popup.axaml" />
<StyleInclude Source="/Templates/Controls/OverlayPopupHost.axaml" />
<StyleInclude Source="/Templates/Controls/ContentControl.axaml" />
<StyleInclude Source="/Templates/Controls/DataGrid.axaml" />
<StyleInclude Source="/Templates/Controls/CaretControl.axaml" />
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="/Templates/Controls/TextBlock.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Window.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Button.axaml" />
<MergeResourceInclude Source="/Templates/Controls/TextBox.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CheckBox.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ScrollViewer.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ScrollBar.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ComboBoxItem.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ComboBox.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ToggleButton.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Popup.axaml" />
<MergeResourceInclude Source="/Templates/Controls/OverlayPopupHost.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ContentControl.axaml" />
<MergeResourceInclude Source="/Templates/Controls/DataGrid.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CaretControl.axaml" />
<MergeResourceInclude Source="/Templates/Controls/DialogWindow.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ItemsControl.axaml" />
<MergeResourceInclude Source="/Templates/Controls/LightDismissOverlaylayer.axaml" />
<MergeResourceInclude Source="/Templates/Controls/DataValidationErrors.axaml" />
<MergeResourceInclude Source="/Templates/Controls/TabControl.axaml" />
<MergeResourceInclude Source="/Templates/Controls/TabItem.axaml" />
<MergeResourceInclude Source="/Templates/Controls/RadioButton.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ListBox.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ListBoxItem.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Menu.axaml" />
<MergeResourceInclude Source="/Templates/Controls/MenuItem.axaml" />
<MergeResourceInclude Source="/Templates/Controls/SymbolsControl.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Separator.axaml" />
<MergeResourceInclude Source="/Templates/Controls/ProgressBar.axaml" />
<MergeResourceInclude Source="/Templates/Controls/FlyoutPresenter.axaml" />
<MergeResourceInclude Source="/Templates/Controls/MenuFlyoutPresenter.axaml" />
<MergeResourceInclude Source="/Templates/Controls/Calendar.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CalendarItem.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CalendarButton.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CalendarDatePicker.axaml" />
<MergeResourceInclude Source="/Templates/Controls/CalendarDayButton.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>

<StyleInclude Source="/Templates/Controls/UserControl.axaml" />
<StyleInclude Source="/Templates/Controls/DialogWindow.axaml" />
<StyleInclude Source="/Templates/Controls/ItemsControl.axaml" />
<StyleInclude Source="/Templates/Controls/LightDismissOverlaylayer.axaml" />
<StyleInclude Source="/Templates/Controls/DataValidationErrors.axaml" />
<StyleInclude Source="/Templates/Controls/TabControl.axaml" />
<StyleInclude Source="/Templates/Controls/TabItem.axaml" />
<StyleInclude Source="/Templates/Controls/RadioButton.axaml" />
<StyleInclude Source="/Templates/Controls/ListBox.axaml" />
<StyleInclude Source="/Templates/Controls/ListBoxItem.axaml" />
<StyleInclude Source="/Templates/Controls/Menu.axaml" />
<StyleInclude Source="/Templates/Controls/MenuItem.axaml" />
<StyleInclude Source="/Templates/Controls/SymbolsControl.axaml" />
<StyleInclude Source="/Templates/Controls/Separator.axaml" />
<StyleInclude Source="/Templates/Controls/ProgressBar.axaml" />
<StyleInclude Source="/Templates/Controls/FlyoutPresenter.axaml" />
<StyleInclude Source="/Templates/Controls/MenuFlyoutPresenter.axaml" />
<StyleInclude Source="/Templates/Controls/Calendar.axaml" />
<StyleInclude Source="/Templates/Controls/CalendarItem.axaml" />
<StyleInclude Source="/Templates/Controls/CalendarButton.axaml" />
<StyleInclude Source="/Templates/Controls/CalendarDatePicker.axaml" />
<StyleInclude Source="/Templates/Controls/CalendarDayButton.axaml" />
</Styles>
67 changes: 34 additions & 33 deletions src/Consolonia.Themes.TurboVision/Templates/Controls/Button.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers;assembly=Consolonia.Themes.TurboVision">
<Style Selector="Button">
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers;assembly=Consolonia.Themes.TurboVision">
<ControlTheme x:Key="{x:Type Button}"
TargetType="Button">
<Setter Property="Background"
Value="{DynamicResource ThemeActionBackgroundBrush}" />
<!--<Setter Property="Foreground"
Expand Down Expand Up @@ -98,41 +99,41 @@

</ControlTemplate>
</Setter>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Foreground"
Value="{DynamicResource ThemeNoDisturbBrush}" />
</Style>
<Style Selector="Button:focus">
<Setter Property="BorderBrush"
Value="{DynamicResource ThemeForegroundBrush}" />
</Style>
<Style Selector="Button:clickdelayed">
<!--<Setter Property="Foreground"
<Style Selector="^:disabled">
<Setter Property="Foreground"
Value="{DynamicResource ThemeNoDisturbBrush}" />
</Style>
<Style Selector="^:focus">
<Setter Property="BorderBrush"
Value="{DynamicResource ThemeForegroundBrush}" />
</Style>
<Style Selector="^:clickdelayed">
<!--<Setter Property="Foreground"
Value="{DynamicResource ThemeAccentBackgroundBrush}" />-->
<!--<Setter Property="Background"
<!--<Setter Property="Background"
Value="{DynamicResource ThemeSelectionBackgroundBrush}" />-->
<Setter Property="Padding"
Value="1,0,0,0" />
</Style>
<!--<Style Selector="Button:clickdelayed /template/ Border#InternalBorder">
<Setter Property="Padding"
Value="1,0,0,0" />
</Style>
<!--<Style Selector="^:clickdelayed /template/ Border#InternalBorder">
<Setter Property="Padding"
Value="1,0" />
</Style>-->
<Style Selector="Button:clickdelayed /template/ helpers|SymbolsControl.shaded">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="^:clickdelayed /template/ helpers|SymbolsControl.shaded">
<Setter Property="IsVisible"
Value="False" />
</Style>

<Style Selector="Button /template/ Border#InternalBorder">
<Setter Property="Margin"
Value="0,0,1,1" />
</Style>
<Style Selector="^ /template/ Border#InternalBorder">
<Setter Property="Margin"
Value="0,0,1,1" />
</Style>

<Style Selector="Button:clickdelayed /template/ Border#InternalBorder">
<Setter Property="Margin"
Value="1,0,1,1" />
</Style>
<Style Selector="^:clickdelayed /template/ Border#InternalBorder">
<Setter Property="Margin"
Value="1,0,1,1" />
</Style>

</ControlTheme>

</Styles>
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers">
<Style Selector="Calendar">
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers;assembly=Consolonia.Themes.TurboVision">
<ControlTheme x:Key="{x:Type Calendar}"
TargetType="Calendar">
<Setter Property="(helpers:CalendarExtensions.ZoomOutOnKey)"
Value="True" />
<Setter Property="Focusable"
Expand Down Expand Up @@ -29,5 +31,5 @@
</StackPanel>
</ControlTemplate>
</Setter>
</Style>
</Styles>
</ControlTheme>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
// All other rights reserved.
-->

<Styles xmlns="https://github.com/avaloniaui">
<Style Selector="CalendarButton">
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="{x:Type CalendarButton}"
TargetType="CalendarButton">
<Setter Property="Background"
Value="{DynamicResource ThemeBackgroundBrush}" />
<Setter Property="HorizontalContentAlignment"
Expand Down Expand Up @@ -42,46 +44,46 @@
</Grid>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="CalendarButton /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="CalendarButton:pointerover /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="CalendarButton:pressed /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^ /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="^:pointerover /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^:pressed /template/ Rectangle#Background">
<Setter Property="IsVisible"
Value="True" />
</Style>

<Style Selector="CalendarButton /template/ Rectangle#SelectedBackground">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="CalendarButton:selected /template/ Rectangle#SelectedBackground">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^ /template/ Rectangle#SelectedBackground">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="^:selected /template/ Rectangle#SelectedBackground">
<Setter Property="IsVisible"
Value="True" />
</Style>

<Style Selector="CalendarButton /template/ ContentControl#Content">
<Setter Property="Foreground"
Value="{DynamicResource ThemeForegroundBrush}" />
</Style>
<Style Selector="CalendarButton:inactive /template/ ContentControl#Content">
<Setter Property="Foreground"
Value="{DynamicResource ThemeBorderBrush}" />
</Style>
<Style Selector="^ /template/ ContentControl#Content">
<Setter Property="Foreground"
Value="{DynamicResource ThemeForegroundBrush}" />
</Style>
<Style Selector="^:inactive /template/ ContentControl#Content">
<Setter Property="Foreground"
Value="{DynamicResource ThemeBorderBrush}" />
</Style>


<Style Selector="CalendarButton /template/ Rectangle#FocusVisual">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="CalendarButton:btnfocused /template/ Rectangle#FocusVisual">
<Setter Property="IsVisible"
Value="True" />
</Style>
</Styles>
<Style Selector="^ /template/ Rectangle#FocusVisual">
<Setter Property="IsVisible"
Value="False" />
</Style>
<Style Selector="^:btnfocused /template/ Rectangle#FocusVisual">
<Setter Property="IsVisible"
Value="True" />
</Style>
</ControlTheme>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
// All other rights reserved.
-->

<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers">
<Style Selector="CalendarDatePicker">
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:Consolonia.Themes.TurboVision.Templates.Controls.Helpers;assembly=Consolonia.Themes.TurboVision">
<ControlTheme x:Key="{x:Type CalendarDatePicker}"
TargetType="CalendarDatePicker">

<Setter Property="(helpers:CalendarDatePickerExtensions.OpenOnEnter)"
Value="True" />
Expand Down Expand Up @@ -81,11 +82,11 @@
</Grid>
</ControlTemplate>
</Setter>
</Style>
</ControlTheme>

<!--<Style Selector="CalendarDatePicker:focus /template/ TextBox#PART_TextBox">
<Setter Property="BorderBrush"
Value="{DynamicResource ThemeSelectionForegroundBrush}" />
</Style>-->

</Styles>
</ResourceDictionary>
Loading

0 comments on commit a74b10d

Please sign in to comment.