Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported Fluent Theme to ControlThemes. #8479

Merged
merged 69 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2b36080
WIP: Porting fluent theme to use control themes.
grokys Jul 7, 2022
afe3486
Remove trailing /template/ selectors.
grokys Jul 7, 2022
671b7ea
WIP: HamburgerMenu.
grokys Jul 7, 2022
f57c0ff
Added ItemContainerTheme property.
grokys Jul 7, 2022
209797e
Ported HamburgerMenu to ControlTheme.
grokys Jul 7, 2022
59c58e5
Don't set Foreground in PathIcon theme.
grokys Jul 8, 2022
052cf69
Ported ScrollBar to ControlTheme.
grokys Jul 8, 2022
9d0132d
Remove unneeded normal state.
grokys Jul 8, 2022
576a8b8
Fix Button/ToggleButton transitions.
grokys Jul 8, 2022
c15837b
Ported ButtonSpinner to ControlTheme.
grokys Jul 8, 2022
ddbc9fb
Tweaked CheckBox ControlTheme.
grokys Jul 8, 2022
4721581
Validated ComboBox/Item ControlTheme.
grokys Jul 8, 2022
100978a
Formatted ContentControl ControlTheme.
grokys Jul 8, 2022
e89060f
Formatted DataValidationErrors ControlTheme.
grokys Jul 8, 2022
ebe9d6b
Tidied up DropDownButton ControlTheme.
grokys Jul 8, 2022
6f797a9
Tidied up EmbeddableControlRoot ControlTheme.
grokys Jul 8, 2022
4f3fafc
Tweaked Expander ControlTheme.
grokys Jul 8, 2022
c246d76
Formated ItemsControl ControlTheme.
grokys Jul 8, 2022
4d73e2b
Formatted Label ControlTheme.
grokys Jul 8, 2022
901026a
Formatted ListBox/Item ControlTheme.
grokys Jul 8, 2022
800967c
Formatted Menu/FlyoutPresenter ControlTheme.
grokys Jul 8, 2022
f82541a
Tweaked NotificationCard ControlTheme.
grokys Jul 8, 2022
db954bf
Formatted NumericUpDown ControlTheme.
grokys Jul 8, 2022
474df23
Formatted OverlayPopupHost ControlTheme.
grokys Jul 8, 2022
0d7bb47
Formatted PathIcon ControlTheme.
grokys Jul 8, 2022
8b69e08
Formatted PopupRoot ControlTheme.
grokys Jul 8, 2022
3dc70c0
Checked ProgressBar ControlTheme.
grokys Jul 8, 2022
d284822
Tweaked RepeatButton ControlTheme.
grokys Jul 8, 2022
250b5b9
Tweaked Slider ControlTheme.
grokys Jul 8, 2022
e5f70de
Formatted TabControl ControlTheme.
grokys Jul 8, 2022
27abe82
Twaked TabItem ControlTheme.
grokys Jul 8, 2022
1af4458
Tweaked TabStrip/Item ControlTemplates.
grokys Jul 8, 2022
c27f5e7
Tweaked ToggleButton ControlTheme.
grokys Jul 8, 2022
9e0e15f
Tweaked ToggleSwitch ControlTheme.
grokys Jul 8, 2022
e8091cf
Tweaked ToolTip ControlTheme.
grokys Jul 8, 2022
433325e
Formatted TransitioningContentControl ControlTheme.
grokys Jul 8, 2022
1bbff64
Added preview to TreeView ControlTheme.
grokys Jul 8, 2022
42da6cd
Formatted Window ControlTheme.
grokys Jul 8, 2022
fa65cae
Formatted WindowNotificationManager ControlTheme.
grokys Jul 8, 2022
5229cf5
Formatted Calendar ControlTheme.
grokys Jul 8, 2022
7af2eb9
Formatted CalendarButton ControlTheme.
grokys Jul 8, 2022
f66d9ac
Formatted CalendarDayButton ControlTheme.
grokys Jul 8, 2022
1e642fb
Tweaked CalendarItem ControlTheme.
grokys Jul 8, 2022
f6e8dda
Formatted CalendarDatePicker ControlTheme.
grokys Jul 8, 2022
902955d
Formatted Carousel ControlTheme.
grokys Jul 8, 2022
0647492
Formatted ContextMenu ControlTheme.
grokys Jul 8, 2022
fbe983b
Ported TextBox to ControlTheme.
grokys Jul 8, 2022
23a6517
Refactored CaptionButtons.
grokys Jul 8, 2022
83140fe
Reset button animations correctly.
grokys Jul 8, 2022
0d5b10e
Tweaked DatePicker ControlTheme.
grokys Jul 8, 2022
c4541e2
Ported ManagedFileChooser to ControlTheme.
grokys Jul 8, 2022
da264ac
WIP: Menu/Item.
grokys Jul 9, 2022
d2e4d58
Formatted NativeMenuBar ControlTheme.
grokys Jul 9, 2022
d902c3e
Port ScrollViewer to ControlTheme.
grokys Jul 9, 2022
1d15d1b
Ported SplitView to ControlTheme.
grokys Jul 9, 2022
b1038f1
Ported TreeViewItem to ControlTheme.
grokys Jul 9, 2022
7fcd738
Tweaked TitleBar ControlTheme.
grokys Jul 10, 2022
5864452
Undo changed to TitleBar.
grokys Jul 10, 2022
07cce63
Ported TimePicker to ControlTheme.
grokys Jul 10, 2022
2dda677
Ported SplitButton to ControlTheme.
grokys Jul 10, 2022
534ccd8
Removed a few unneeded styles I missed.
grokys Jul 10, 2022
20b2bc2
Prevent ComboBox borders getting cut off.
grokys Jul 11, 2022
51469dc
Fix ButtonSpinner borders.
grokys Jul 11, 2022
84a3d9c
Use theme default CornerRadius.
grokys Jul 11, 2022
a9925f9
Make Separator look correct.
grokys Jul 11, 2022
90a562c
Fix ButtonSpinner disabled icon color.
grokys Jul 12, 2022
68ac06d
Remove duplicated ItemsPanel on hamburger menu
maxkatz6 Jul 13, 2022
1eaf6cc
Prevent crash when switching themes.
grokys Jul 13, 2022
ffe5502
Merge branch 'master' into feature/7120-fluent-control-themes
grokys Jul 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion samples/ControlCatalog/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
x:CompileBindings="True"
Name="Avalonia ControlCatalog"
x:Class="ControlCatalog.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.Styles>
<Style Selector="TextBlock.h1, TextBlock.h2, TextBlock.h3">
<Setter Property="TextWrapping" Value="Wrap" />
Expand All @@ -29,7 +36,6 @@
<Style Selector="Label.h3">
<Setter Property="FontSize" Value="12" />
</Style>
<StyleInclude Source="avares://ControlSamples/HamburgerMenu/HamburgerMenu.xaml" />
</Application.Styles>
<TrayIcon.Icons>
<TrayIcons>
Expand Down
15 changes: 10 additions & 5 deletions samples/ControlCatalog/Pages/ExpanderPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,31 @@
Margin="0,16,0,0"
HorizontalAlignment="Center"
Spacing="16">
<Expander Header="Expand Up" ExpandDirection="Up">
<Expander Header="Expand Up" ExpandDirection="Up"
CornerRadius="{Binding CornerRadius}">
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<Expander Header="Expand Down" ExpandDirection="Down">
<Expander Header="Expand Down" ExpandDirection="Down"
CornerRadius="{Binding CornerRadius}">
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<Expander Header="Expand Left" ExpandDirection="Left">
<Expander Header="Expand Left" ExpandDirection="Left"
CornerRadius="{Binding CornerRadius}">
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
<Expander Header="Expand Right" ExpandDirection="Right">
<Expander Header="Expand Right" ExpandDirection="Right"
CornerRadius="{Binding CornerRadius}">
<StackPanel>
<TextBlock>Expanded content</TextBlock>
</StackPanel>
</Expander>
</StackPanel>
<CheckBox IsChecked="{Binding Rounded}">Rounded</CheckBox>
</StackPanel>
</StackPanel>
</UserControl>
2 changes: 2 additions & 0 deletions samples/ControlCatalog/Pages/ExpanderPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using ControlCatalog.ViewModels;

namespace ControlCatalog.Pages
{
Expand All @@ -8,6 +9,7 @@ public class ExpanderPage : UserControl
public ExpanderPage()
{
this.InitializeComponent();
DataContext = new ExpanderPageViewModel();
}

private void InitializeComponent()
Expand Down
27 changes: 27 additions & 0 deletions samples/ControlCatalog/ViewModels/ExpanderPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Avalonia;
using MiniMvvm;

namespace ControlCatalog.ViewModels
{
public class ExpanderPageViewModel : ViewModelBase
{
private object _cornerRadius = AvaloniaProperty.UnsetValue;
private bool _rounded;

public object CornerRadius
{
get => _cornerRadius;
private set => RaiseAndSetIfChanged(ref _cornerRadius, value);
}

public bool Rounded
{
get => _rounded;
set
{
if (RaiseAndSetIfChanged(ref _rounded, value))
CornerRadius = _rounded ? new CornerRadius(25) : AvaloniaProperty.UnsetValue;
}
}
}
}
286 changes: 154 additions & 132 deletions samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Avalonia.Base/StyledElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,12 @@ private void DetachStyles(IReadOnlyList<IStyle> styles)

if (applied.Source == styles[i])
{
applied.Dispose();
_appliedStyles.RemoveAt(j);
applied.Dispose();
}

if (j > _appliedStyles.Count)
j = _appliedStyles.Count;
}
}
}
Expand Down
27 changes: 12 additions & 15 deletions src/Avalonia.Controls/Chrome/CaptionButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace Avalonia.Controls.Chrome
/// <summary>
/// Draws window minimize / maximize / close buttons in a <see cref="TitleBar"/> when managed client decorations are enabled.
/// </summary>
[TemplatePart("PART_CloseButton", typeof(Panel))]
[TemplatePart("PART_RestoreButton", typeof(Panel))]
[TemplatePart("PART_MinimiseButton", typeof(Panel))]
[TemplatePart("PART_FullScreenButton", typeof(Panel))]
[TemplatePart("PART_CloseButton", typeof(Button))]
[TemplatePart("PART_RestoreButton", typeof(Button))]
[TemplatePart("PART_MinimiseButton", typeof(Button))]
[TemplatePart("PART_FullScreenButton", typeof(Button))]
[PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")]
public class CaptionButtons : TemplatedControl
{
Expand Down Expand Up @@ -88,18 +88,15 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);

var closeButton = e.NameScope.Get<Panel>("PART_CloseButton");
var restoreButton = e.NameScope.Get<Panel>("PART_RestoreButton");
var minimiseButton = e.NameScope.Get<Panel>("PART_MinimiseButton");
var fullScreenButton = e.NameScope.Get<Panel>("PART_FullScreenButton");
var closeButton = e.NameScope.Get<Button>("PART_CloseButton");
var restoreButton = e.NameScope.Get<Button>("PART_RestoreButton");
var minimiseButton = e.NameScope.Get<Button>("PART_MinimiseButton");
var fullScreenButton = e.NameScope.Get<Button>("PART_FullScreenButton");

closeButton.PointerReleased += (sender, e) => OnClose();

restoreButton.PointerReleased += (sender, e) => OnRestore();

minimiseButton.PointerReleased += (sender, e) => OnMinimize();

fullScreenButton.PointerReleased += (sender, e) => OnToggleFullScreen();
closeButton.Click += (sender, e) => OnClose();
restoreButton.Click += (sender, e) => OnRestore();
minimiseButton.Click += (sender, e) => OnMinimize();
fullScreenButton.Click += (sender, e) => OnToggleFullScreen();
}
}
}
8 changes: 4 additions & 4 deletions src/Avalonia.Controls/Chrome/TitleBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
base.OnApplyTemplate(e);

_captionButtons?.Detach();

_captionButtons = e.NameScope.Get<CaptionButtons>("PART_CaptionButtons");

if (VisualRoot is Window window)
{
_captionButtons?.Attach(window);
_captionButtons?.Attach(window);

UpdateSize(window);
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e
base.OnDetachedFromVisualTree(e);

_disposables?.Dispose();

_captionButtons?.Detach();
_captionButtons = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ private void CreateOrDestroyItems(Controls children)
children.Add(new ListBoxItem
{
Height = ItemHeight,
Classes = new Classes("DateTimePickerItem", $"{PanelType}Item"),
Classes = new Classes($"{PanelType}Item"),
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
Focusable = false
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@

<!--Resources for NotificationCard.xaml -->
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444" />
<StaticResource x:Key="NotificationCardForegroundBrush" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" />
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#007ACC" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#1F9E45" Opacity="0.75"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@

<!--Resources for NotificationCard.xaml -->
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="White" />
<StaticResource x:Key="NotificationCardForegroundBrush" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="NotificationCardProgressBackgroundBrush" Color="#9A9A9A" />
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#0078D4" />
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#128B44" />
Expand Down
110 changes: 55 additions & 55 deletions src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<AutoCompleteBox Width="200">
Expand All @@ -16,56 +16,56 @@
</AutoCompleteBox>
</Border>
</Design.PreviewWith>

<Style Selector="AutoCompleteBox">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteListMaxHeight}" />
<Setter Property="Template">
<ControlTemplate>
<Grid Name="PART_LayoutRoot">
<TextBox Name="PART_TextBox"
Watermark="{TemplateBinding Watermark}"
Width="{TemplateBinding Width}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}"
Padding="{TemplateBinding Padding}"
Margin="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" />

<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
IsLightDismissEnabled="True"
PlacementTarget="{TemplateBinding}">
<Border Name="PART_SuggestionsContainer"
Padding="{DynamicResource AutoCompleteListMargin}"
BorderThickness="{DynamicResource AutoCompleteListBorderThemeThickness}"
BorderBrush="{DynamicResource AutoCompleteBoxSuggestionsListBorderBrush}"
Background="{DynamicResource AutoCompleteBoxSuggestionsListBackground}"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<ListBox Name="PART_SelectingItemsControl"
BorderThickness="0"
Background="Transparent"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{DynamicResource AutoCompleteListPadding}" />
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter>
</Style>
</Styles>
<ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteListMaxHeight}" />
<Setter Property="Template">
<ControlTemplate>
<Grid Name="PART_LayoutRoot">
<TextBox Name="PART_TextBox"
Watermark="{TemplateBinding Watermark}"
Width="{TemplateBinding Width}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}"
Padding="{TemplateBinding Padding}"
Margin="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" />
<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
IsLightDismissEnabled="True"
PlacementTarget="{TemplateBinding}">
<Border Name="PART_SuggestionsContainer"
Padding="{DynamicResource AutoCompleteListMargin}"
BorderThickness="{DynamicResource AutoCompleteListBorderThemeThickness}"
BorderBrush="{DynamicResource AutoCompleteBoxSuggestionsListBorderBrush}"
Background="{DynamicResource AutoCompleteBoxSuggestionsListBackground}"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<ListBox Name="PART_SelectingItemsControl"
BorderThickness="0"
Background="Transparent"
ItemTemplate="{TemplateBinding ItemTemplate}"
Margin="{DynamicResource AutoCompleteListPadding}" />
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>

</ResourceDictionary>
Loading