fix: using DropShadowEffect in Launcher's popup container on Linux will get a wrong render result.

This commit is contained in:
leo 2024-03-08 15:52:40 +08:00
parent 2182d39e5f
commit 8c1fe66ee5
4 changed files with 99 additions and 72 deletions

View file

@ -251,21 +251,44 @@
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/> <Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
<Setter Property="Background" Value="{DynamicResource Brush.FlatButton.Background}"/> <Setter Property="Background" Value="{DynamicResource Brush.FlatButton.Background}"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Effect"> <Setter Property="Template">
<Setter.Value> <ControlTemplate>
<DropShadowEffect BlurRadius="2" OffsetX="0" OffsetY="0" Color="Black" Opacity=".65"/> <Grid>
</Setter.Value> <Border x:Name="PART_Border"
Margin="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Effect="drop-shadow(0 0 2 #80000000)"/>
<ContentPresenter x:Name="PART_ContentPresenter"
Margin="2"
Background="Transparent"
Padding="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="Button.flat:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="Button.flat:pointerover /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource Brush.FlatButton.BackgroundHovered}"/> <Setter Property="Background" Value="{DynamicResource Brush.FlatButton.BackgroundHovered}"/>
</Style> </Style>
<Style Selector="Button.flat:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Button.flat.primary"> <Style Selector="Button.flat.primary">
<Setter Property="Background" Value="{DynamicResource Brush.FlatButton.PrimaryBackground}"/> <Setter Property="Background" Value="{DynamicResource Brush.FlatButton.PrimaryBackground}"/>
</Style> </Style>
<Style Selector="Button.flat.primary:pointerover /template/ ContentPresenter#PART_ContentPresenter"> <Style Selector="Button.flat.primary:pointerover /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource Brush.FlatButton.PrimaryBackgroundHovered}"/> <Setter Property="Background" Value="{DynamicResource Brush.FlatButton.PrimaryBackgroundHovered}"/>
</Style> </Style>
<Style Selector="Button.flat.primary:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Border.launcher_pagetab"> <Style Selector="Border.launcher_pagetab">
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>

View file

@ -61,10 +61,7 @@
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,20,32,0"> <StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,20,32,0">
<StackPanel Height="48" Orientation="Horizontal"> <StackPanel Height="48" Orientation="Horizontal">
<TextBlock Classes="bold" Text="SourceGit" FontSize="32" /> <TextBlock Classes="bold" Text="SourceGit" FontSize="32" />
<Border Margin="12,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent1}"> <Border Margin="12,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent1}" Effect="drop-shadow(0 0 6 #40000000)">
<Border.Effect>
<DropShadowEffect OffsetX="0" OffsetY="0" BlurRadius="6" Color="Black" Opacity=".3"/>
</Border.Effect>
<TextBlock Classes="monospace" Margin="8,0" Text="{Binding Version}" FontSize="12" Foreground="White"/> <TextBlock Classes="monospace" Margin="8,0" Text="{Binding Version}" FontSize="12" Foreground="White"/>
</Border> </Border>
</StackPanel> </StackPanel>

View file

@ -239,66 +239,77 @@
<v:LauncherBody Grid.Row="1" Background="{DynamicResource Brush.ToolBar}" Data="{Binding ActivePage.Data}"/> <v:LauncherBody Grid.Row="1" Background="{DynamicResource Brush.ToolBar}" Data="{Binding ActivePage.Data}"/>
<!-- Popup container --> <!-- Popup container -->
<ContentControl Grid.Row="1" Margin="0,36,0,0" Content="{Binding ActivePage.Popup}" IsVisible="{Binding ActivePage.Popup, Converter={x:Static ObjectConverters.IsNotNull}}"> <Grid Grid.Row="1" Margin="0,36,0,0" IsVisible="{Binding ActivePage.Popup, Converter={x:Static ObjectConverters.IsNotNull}}">
<ContentControl.DataTemplates> <Border Background="Transparent" PointerPressed="OnPopupCancelByClickMask"/>
<DataTemplate DataType="vm:Popup">
<Grid> <Grid Width="500" HorizontalAlignment="Center" VerticalAlignment="Top">
<Border Background="Transparent" PointerPressed="OnPopupCancelByClickMask"/> <ContentControl Content="{Binding ActivePage.Popup}" ClipToBounds="True">
<ContentControl.DataTemplates>
<DataTemplate DataType="vm:Popup">
<Border Margin="8,0,8,8"
Background="{DynamicResource Brush.Popup}"
BorderThickness="1,0,1,1"
BorderBrush="{DynamicResource Brush.Border0}">
<Border.CornerRadius>
<OnPlatform Default="0,0,4,4" Linux="0"/>
</Border.CornerRadius>
<Grid Width="500" HorizontalAlignment="Center" VerticalAlignment="Top">
<Border Background="{DynamicResource Brush.Popup}" CornerRadius="0,0,4,4">
<Border.Effect> <Border.Effect>
<DropShadowEffect BlurRadius="8" Color="Black" Opacity=".6" OffsetX="0" OffsetY="0"/> <OnPlatform>
<On Options="Windows, macOS">
<DropShadowEffect BlurRadius="8" OffsetX="0" OffsetY="0" Color="Black" Opacity=".5"/>
</On>
</OnPlatform>
</Border.Effect> </Border.Effect>
</Border>
<StackPanel Margin="8" Orientation="Vertical">
<!-- Popup Widget -->
<ContentPresenter Margin="0,8"
Content="{Binding View}"
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/>
<StackPanel Margin="8" Orientation="Vertical"> <!-- Options -->
<!-- Popup Widget --> <StackPanel Margin="0,8,0,0"
<ContentControl Margin="0,8" Height="32"
Content="{Binding View}" Orientation="Horizontal"
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/> HorizontalAlignment="Right"
IsVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}">
<!-- Options --> <Button Classes="flat primary"
<StackPanel Margin="0,8,0,0" Width="80"
Height="32" Content="{DynamicResource Text.Sure}"
Orientation="Horizontal" Click="OnPopupSure"/>
HorizontalAlignment="Right" <Button Classes="flat"
IsVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"> Width="80"
<Button Classes="flat primary" Margin="8,0,0,0"
Width="80" Content="{DynamicResource Text.Cancel}"
Content="{DynamicResource Text.Sure}" Click="OnPopupCancel"/>
Click="OnPopupSure"/> </StackPanel>
<Button Classes="flat"
Width="80" <!-- Running -->
Margin="8,0,0,0" <StackPanel Orientation="Vertical" Margin="8" IsVisible="{Binding InProgress}">
Content="{DynamicResource Text.Cancel}" <Rectangle Height="1" Margin="-8,0" HorizontalAlignment="Stretch" Fill="{DynamicResource Brush.Border1}" />
Click="OnPopupCancel"/> <StackPanel Orientation="Horizontal" Margin="0,8">
</StackPanel> <Path Width="12" Height="12" Classes="waiting" Data="{StaticResource Icons.Waiting}" IsVisible="{Binding InProgress}"/>
<TextBlock Margin="6,0,0,0" FontSize="14" FontWeight="Bold" Text="{DynamicResource Text.Running}"/>
<!-- Running --> </StackPanel>
<StackPanel Orientation="Vertical" Margin="8" IsVisible="{Binding InProgress}"> <TextBlock HorizontalAlignment="Stretch"
<Rectangle Height="1" Margin="-8,0" HorizontalAlignment="Stretch" Fill="{DynamicResource Brush.Border1}" /> TextWrapping="Wrap"
<StackPanel Orientation="Horizontal" Margin="0,8"> FontSize="12"
<Path Width="12" Height="12" Classes="waiting" Data="{StaticResource Icons.Waiting}" IsVisible="{Binding InProgress}"/> FontStyle="Italic"
<TextBlock Margin="6,0,0,0" FontSize="14" FontWeight="Bold" Text="{DynamicResource Text.Running}"/> Text="{Binding ProgressDescription}"/>
<ProgressBar Margin="0,8,0,0"
HorizontalAlignment="Stretch"
IsIndeterminate="True"
Background="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.Accent1}"
Minimum="0" Maximum="100"/>
</StackPanel> </StackPanel>
<TextBlock HorizontalAlignment="Stretch"
TextWrapping="Wrap"
FontSize="12"
FontStyle="Italic"
Text="{Binding ProgressDescription}"/>
<ProgressBar Margin="0,8,0,0"
HorizontalAlignment="Stretch"
IsIndeterminate="True"
Background="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.Accent1}"
Minimum="0" Maximum="100"/>
</StackPanel> </StackPanel>
</StackPanel> </Border>
</Grid> </DataTemplate>
</Grid> </ContentControl.DataTemplates>
</DataTemplate> </ContentControl>
</ContentControl.DataTemplates> </Grid>
</ContentControl> </Grid>
<!-- Notification container --> <!-- Notification container -->
<Grid Grid.Row="1" Width="360" Margin="0,36,0,0" HorizontalAlignment="Right" VerticalAlignment="Top"> <Grid Grid.Row="1" Width="360" Margin="0,36,0,0" HorizontalAlignment="Right" VerticalAlignment="Top">
@ -307,11 +318,7 @@
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate DataType="m:Notification"> <DataTemplate DataType="m:Notification">
<Grid Width="320" Margin="8"> <Grid Width="320" Margin="8">
<Border Background="{DynamicResource Brush.Window}" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="1" CornerRadius="4"> <Border Background="{DynamicResource Brush.Window}" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="1" CornerRadius="4" Effect="drop-shadow(0 0 8 #40000000)"/>
<Border.Effect>
<DropShadowEffect OffsetX="0" OffsetY="0" BlurRadius="8" Color="Black" Opacity=".4"/>
</Border.Effect>
</Border>
<Grid Margin="8" RowDefinitions="26,Auto,Auto"> <Grid Margin="8" RowDefinitions="26,Auto,Auto">
<StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding IsError}"> <StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding IsError}">
@ -334,7 +341,7 @@
Text="{Binding Message}"/> Text="{Binding Message}"/>
<Button Grid.Row="3" <Button Grid.Row="3"
Classes="flat primary" Classes="flat primary"
Height="25" Height="30"
Margin="4,0" Margin="4,0"
Command="{Binding #me.DataContext.(vm:Launcher).ActivePage.DismissNotification}" Command="{Binding #me.DataContext.(vm:Launcher).ActivePage.DismissNotification}"
CommandParameter="{Binding}" CommandParameter="{Binding}"

View file

@ -376,7 +376,7 @@
<Button Grid.Column="4" <Button Grid.Column="4"
Classes="flat primary" Classes="flat primary"
Content="{DynamicResource Text.WorkingCopy.Commit}" Content="{DynamicResource Text.WorkingCopy.Commit}"
Height="24" Height="28"
Margin="8,0,0,0" Margin="8,0,0,0"
Padding="8,0" Padding="8,0"
Click="Commit"/> Click="Commit"/>
@ -384,7 +384,7 @@
<Button Grid.Column="5" <Button Grid.Column="5"
Classes="flat" Classes="flat"
Content="{DynamicResource Text.WorkingCopy.CommitAndPush}" Content="{DynamicResource Text.WorkingCopy.CommitAndPush}"
Height="24" Height="28"
Margin="8,0,0,0" Margin="8,0,0,0"
Padding="8,0" Padding="8,0"
Click="CommitWithPush"> Click="CommitWithPush">