Skip to content

Commit

Permalink
feat: WindowNotificationManager: support TopCenter and BottomCenter p…
Browse files Browse the repository at this point in the history
…osition (#12804)

* feat: support topcenter and bottom center.

* fix: fix typo.
  • Loading branch information
rabbitism authored and maxkatz6 committed Apr 6, 2024
1 parent a814f54 commit b47d61c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
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 @@ -14,7 +14,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 @@ -159,6 +159,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="^: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 @@ -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>

0 comments on commit b47d61c

Please sign in to comment.