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

feat: WindowNotificationManager: support TopCenter and BottomCenter position #12804

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 3 additions & 1 deletion src/Avalonia.Controls/Notifications/NotificationPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public enum NotificationPosition
TopLeft,
TopRight,
BottomLeft,
BottomRight
BottomRight,
TopCenter,
BottomCenter,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Avalonia.Controls.Notifications
/// An <see cref="INotificationManager"/> that displays notifications in a <see cref="Window"/>.
/// </summary>
[TemplatePart("PART_Items", typeof(Panel))]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright")]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright", ":topcenter", ":bottomcenter")]
public class WindowNotificationManager : TemplatedControl, IManagedNotificationManager
{
private IList? _items;
Expand Down Expand Up @@ -215,6 +215,8 @@ private void UpdatePseudoClasses(NotificationPosition position)
PseudoClasses.Set(":topright", position == NotificationPosition.TopRight);
PseudoClasses.Set(":bottomleft", position == NotificationPosition.BottomLeft);
PseudoClasses.Set(":bottomright", position == NotificationPosition.BottomRight);
PseudoClasses.Set(":topcenter", position == NotificationPosition.TopCenter);
PseudoClasses.Set(":bottomcenter", position == NotificationPosition.BottomCenter);
}
}
}
11 changes: 11 additions & 0 deletions src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>

<Style Selector="^:topright /template/ ReversibleStackPanel#PART_Items">
rabbitism marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style Selector="^:bottomleft /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
Expand All @@ -53,5 +58,11 @@
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>

<Style Selector="^:bottomcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</ControlTheme>
</ResourceDictionary>
11 changes: 11 additions & 0 deletions src/Avalonia.Themes.Simple/Controls/WindowNotificationManager.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>

<Style Selector="^:topcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style Selector="^:bottomleft /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
Expand All @@ -49,5 +54,11 @@
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>

<Style Selector="^:bottomcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</ControlTheme>
</ResourceDictionary>