Skip to content

Commit

Permalink
Improve Growl
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Jan 14, 2025
1 parent 9e74000 commit 43be266
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
18 changes: 2 additions & 16 deletions dev/DevWinUI.Controls/Controls/Growl/Growl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,10 @@ private static void InitGrowlGlobal(GrowlInfo growlInfo, bool isForceSeverity =
if (GrowlWindow == null || GrowlWindow.WindowClosed)
{
GrowlWindow = new GrowlWindow();
GrowlWindow.Init();
GrowlWindow.MoveAndResizeWindow();
}

switch (growlInfo.Severity)
{
case InfoBarSeverity.Informational:
ctl.Background = Application.Current.Resources["InfoBarInformationalSeverityBackgroundBrush"] as Brush;
break;
case InfoBarSeverity.Success:
ctl.Background = Application.Current.Resources["InfoBarSuccessSeverityBackgroundBrush"] as Brush;
break;
case InfoBarSeverity.Warning:
ctl.Background = Application.Current.Resources["InfoBarWarningSeverityBackgroundBrush"] as Brush;
break;
case InfoBarSeverity.Error:
ctl.Background = Application.Current.Resources["InfoBarErrorSeverityBackgroundBrush"] as Brush;
break;
}
VisualStateManager.GoToState(ctl, growlInfo.Severity.ToString(), true);

SetPanelTransition(GrowlTransition.AddDeleteThemeTransition, GrowlWindow.GrowlPanel);

Expand Down
14 changes: 4 additions & 10 deletions dev/DevWinUI.Controls/Controls/Growl/GrowlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ public partial class GrowlWindow : Window
public GrowlWindow()
{
SystemBackdrop = new TransparentBackdrop();

((OverlappedPresenter)AppWindow.Presenter).SetBorderAndTitleBar(false, false);
((OverlappedPresenter)AppWindow.Presenter).IsMinimizable = false;
((OverlappedPresenter)AppWindow.Presenter).IsMaximizable = false;
((OverlappedPresenter)AppWindow.Presenter).IsResizable = false;
ExtendsContentIntoTitleBar = true;
AppWindow.TitleBar.PreferredHeightOption = Microsoft.UI.Windowing.TitleBarHeightOption.Collapsed;
AppWindow.IsShownInSwitchers = false;

WindowHelper.RemoveWindowBorderAndTitleBar(this);

GrowlPanel = new StackPanel
{
VerticalAlignment = VerticalAlignment.Top,
Expand Down Expand Up @@ -89,9 +88,4 @@ internal void MoveAndResizeWindow(bool isRightSide = true)
AppWindow?.MoveAndResize(position);
}
}
internal void Init()
{
WindowHelper.SetWindowCornerRadius(this, NativeValues.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND);
MoveAndResizeWindow();
}
}
9 changes: 6 additions & 3 deletions dev/DevWinUI.Controls/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4405,7 +4405,10 @@ Themes\Styles\Win2D\Watermark.xaml
<Style BasedOn="{StaticResource DefaultGravatarStyle}" TargetType="local:Gravatar" />
<Style x:Key="DefaultGrowlStyle" TargetType="local:Growl">
<Setter Property="IsOpen" Value="True" />
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
<Setter Property="BorderBrush" Value="{ThemeResource ControlElevationBorderBrush}" />
<Setter Property="Background" Value="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Shadow">
<Setter.Value>
<ThemeShadow />
Expand All @@ -4415,7 +4418,7 @@ Themes\Styles\Win2D\Watermark.xaml
<Setter Property="Template">
<Setter.Value>
<ControlTemplate x:Name="Root" TargetType="local:Growl">
<Border x:Name="ContentRoot" VerticalAlignment="Top" Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}">
<Border x:Name="ContentRoot" VerticalAlignment="Top" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SeverityLevels">
<VisualState x:Name="Informational" />
Expand Down Expand Up @@ -4533,7 +4536,7 @@ Themes\Styles\Win2D\Watermark.xaml
<Button x:Name="PART_ConfirmButton" Grid.Row="2" Margin="5,0" HorizontalAlignment="Stretch" Content="{TemplateBinding ConfirmButtonText}" Foreground="{ThemeResource SystemAccentColor}" Style="{StaticResource SubtleButtonStyle}" Visibility="{TemplateBinding ShowConfirmButton}" />
<Button x:Name="PART_CloseButton" Grid.Row="2" Grid.Column="1" Margin="5,0" HorizontalAlignment="Stretch" Content="{TemplateBinding CloseButtonText}" Foreground="{ThemeResource InfoBarErrorSeverityIconBackground}" Style="{StaticResource SubtleButtonStyle}" Visibility="{TemplateBinding ShowCloseButton}" />
</Grid>
<Button Name="CloseButton" Grid.Column="2" Command="{TemplateBinding CloseButtonCommand}" CommandParameter="{TemplateBinding CloseButtonCommandParameter}" Style="{TemplateBinding CloseButtonStyle}">
<Button Name="CloseButton" Grid.Column="2" Margin="5,0,5,0" Command="{TemplateBinding CloseButtonCommand}" CommandParameter="{TemplateBinding CloseButtonCommandParameter}" CornerRadius="{ThemeResource ControlCornerRadius}" Style="{TemplateBinding CloseButtonStyle}">
<Button.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
Expand Down
11 changes: 8 additions & 3 deletions dev/DevWinUI.Controls/Themes/Styles/Controls/Growl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
<Style x:Key="DefaultGrowlStyle"
TargetType="local:Growl">
<Setter Property="IsOpen" Value="True" />
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
<Setter Property="BorderBrush" Value="{ThemeResource ControlElevationBorderBrush}" />
<Setter Property="Background" Value="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Shadow">
<Setter.Value>
<ThemeShadow />
</Setter.Value>
</Setter>
<Setter Property="Width" Value="{ThemeResource GrowlWidth}" />

<Setter Property="Template">
<Setter.Value>
<ControlTemplate x:Name="Root"
TargetType="local:Growl">
<Border x:Name="ContentRoot"
VerticalAlignment="Top"
Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
Expand Down Expand Up @@ -222,8 +224,10 @@

<Button Name="CloseButton"
Grid.Column="2"
Margin="5,0,5,0"
Command="{TemplateBinding CloseButtonCommand}"
CommandParameter="{TemplateBinding CloseButtonCommandParameter}"
CornerRadius="{ThemeResource ControlCornerRadius}"
Style="{TemplateBinding CloseButtonStyle}">
<Button.Resources>
<ResourceDictionary>
Expand Down Expand Up @@ -327,4 +331,5 @@
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>

0 comments on commit 43be266

Please sign in to comment.