Skip to content

Commit 3d96a36

Browse files
committed
Fix Preview CornerRadius (Get BasedOn Style)
1 parent 4ed9137 commit 3d96a36

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -771,22 +771,18 @@ private void ApplyPreviewBackground(Color? bgColor = null)
771771
{
772772
if (bgColor == null) return;
773773

774-
// Copy the existing WindowBorderStyle
774+
// Create a new Style for the preview
775775
var previewStyle = new Style(typeof(Border));
776-
if (Application.Current.Resources.Contains("WindowBorderStyle"))
776+
777+
// Get the original WindowBorderStyle
778+
if (Application.Current.Resources.Contains("WindowBorderStyle") &&
779+
Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
777780
{
778-
if (Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
779-
{
780-
foreach (var setter in originalStyle.Setters.OfType<Setter>())
781-
{
782-
previewStyle.Setters.Add(new Setter(setter.Property, setter.Value));
783-
}
784-
}
781+
// Copy the original style, including the base style if it exists
782+
CopyStyle(originalStyle, previewStyle);
785783
}
786784

787785
// Apply background color (remove transparency in color)
788-
// WPF does not allow the use of an acrylic brush within the window's internal area,
789-
// so transparency effects are not applied to the preview.
790786
Color backgroundColor = Color.FromRgb(bgColor.Value.R, bgColor.Value.G, bgColor.Value.B);
791787
previewStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(backgroundColor)));
792788

@@ -797,9 +793,26 @@ private void ApplyPreviewBackground(Color? bgColor = null)
797793
previewStyle.Setters.Add(new Setter(Border.CornerRadiusProperty, new CornerRadius(5)));
798794
previewStyle.Setters.Add(new Setter(Border.BorderThicknessProperty, new Thickness(1)));
799795
}
796+
797+
// Set the new style to the resource
800798
Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle;
801799
}
802800

801+
private void CopyStyle(Style originalStyle, Style targetStyle)
802+
{
803+
// If the style is based on another style, copy the base style first
804+
if (originalStyle.BasedOn != null)
805+
{
806+
CopyStyle(originalStyle.BasedOn, targetStyle);
807+
}
808+
809+
// Copy the setters from the original style
810+
foreach (var setter in originalStyle.Setters.OfType<Setter>())
811+
{
812+
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
813+
}
814+
}
815+
803816
private void ColorizeWindow(string theme, BackdropTypes backdropType)
804817
{
805818
var dict = GetThemeResourceDictionary(theme);

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
MouseDown="window_MouseDown"
2020
ResizeMode="CanResize"
2121
SnapsToDevicePixels="True"
22-
UseLayoutRounding="True"
2322
StateChanged="Window_StateChanged"
2423
Top="{Binding SettingWindowTop, Mode=TwoWay}"
24+
UseLayoutRounding="True"
2525
WindowStartupLocation="Manual"
2626
mc:Ignorable="d">
2727
<WindowChrome.WindowChrome>

0 commit comments

Comments
 (0)