Fixed shader previews rendering when not visible
このコミットが含まれているのは:
1 親
313189ea60
コミット
5fb3f8ebab
2ファイル変更
+121
-115
検索条件に一致するファイルはありません
+118
-113
@@ -18,6 +18,116 @@
|
||||
<Grid.DataContext>
|
||||
<viewmodels:MainViewModel x:Name="ViewModel"/>
|
||||
</Grid.DataContext>
|
||||
<Grid.Resources>
|
||||
|
||||
<!--Shader selection panel. This is declared as a resource and then added and removed to the visual
|
||||
tree entirely instead of just changing its visibility, so that the loaded panels can detect the
|
||||
change and stop their render loops. This avoids wasting GPU resources when the panel isn't visible.-->
|
||||
<Border
|
||||
x:Key="ShaderSelectionPanel"
|
||||
x:Name="ShaderSelectionPanel"
|
||||
IsTapEnabled="True"
|
||||
Tapped="ShaderSelectionPanel_Tapped">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:OpacityAnimation Duration="0:0:0.5" From="0" To="1.0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:OpacityAnimation Duration="0:0:0.5" From="1.0" To="0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border.Background>
|
||||
<media:AcrylicBrush
|
||||
TintColor="#FF222222"
|
||||
TintOpacity="0.2"
|
||||
BlurAmount="12"
|
||||
TextureUri="ms-appx:///Images/Misc/noise_low.png"/>
|
||||
</Border.Background>
|
||||
|
||||
<!--Shadow panel with the shaders list-->
|
||||
<controls:DropShadowPanel
|
||||
ShadowOpacity="1"
|
||||
BlurRadius="20"
|
||||
OffsetY="-2"
|
||||
OffsetX="-12"
|
||||
IsMasked="True"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalAlignment="Bottom">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0" To="0,320,0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border
|
||||
Height="320"
|
||||
Margin="-20,0,-20,0"
|
||||
Background="#FF222222">
|
||||
|
||||
<!--Shaders list-->
|
||||
<ListView
|
||||
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden">
|
||||
<ListView.Resources>
|
||||
|
||||
<!--Lightweight styling to remove the selection background with the accent color, and
|
||||
to remove the padding and stretch the list items to occupy all the available space-->
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelected" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPointerOver" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPressed" Color="Transparent"/>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
|
||||
<!--Shader template-->
|
||||
<DataTemplate x:DataType="models:ComputeShader">
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:UIElementExtensions.ClipToBounds="True">
|
||||
|
||||
<!--Shader preview-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
Width="568"
|
||||
ShaderRunner="{x:Bind ShaderRunner}"/>
|
||||
|
||||
<!--Note: here we have a selection property to work around {x:Bind} not working correctly outside of the
|
||||
current template scope. Once that's fixed in WinUI 3, this can be rewritten as a multi-binding like this:
|
||||
Visibility="{x:Bind system:Object.ReferenceEquals((local:ComputeShader), ViewModel.SelectedComputeShader), Mode=OneWay}".
|
||||
When that is working, the ComputeShader.IsSelected property can also be removed, as it will no longer be needed.-->
|
||||
<Border
|
||||
BorderThickness="4"
|
||||
BorderBrush="White"
|
||||
Visibility="{x:Bind IsSelected, Mode=OneWay}">
|
||||
<Polygon
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Points="0,0 32,0 32,32"
|
||||
Fill="White"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Border>
|
||||
</controls:DropShadowPanel>
|
||||
</Border>
|
||||
</Grid.Resources>
|
||||
|
||||
<!--Shader-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
@@ -27,14 +137,7 @@
|
||||
ResolutionScale="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToScale(ViewModel.SelectedResolutionScale), Mode=OneWay}"
|
||||
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"/>
|
||||
|
||||
<!--Invisible title bar-->
|
||||
<Rectangle
|
||||
x:Name="TitleBarRectangle"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="32"
|
||||
Fill="Transparent"/>
|
||||
|
||||
<!--Settings panel-->
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="20"
|
||||
@@ -93,110 +196,12 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!--Shader selection panel-->
|
||||
<Border
|
||||
x:Name="ShaderSelectionPanel"
|
||||
IsTapEnabled="True"
|
||||
Tapped="ShaderSelectionPanel_Tapped"
|
||||
Visibility="Collapsed">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:OpacityAnimation Duration="0:0:0.5" From="0" To="1.0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:OpacityAnimation Duration="0:0:0.5" From="1.0" To="0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border.Background>
|
||||
<media:AcrylicBrush
|
||||
TintColor="#FF222222"
|
||||
TintOpacity="0.2"
|
||||
BlurAmount="12"
|
||||
TextureUri="ms-appx:///Images/Misc/noise_low.png"/>
|
||||
</Border.Background>
|
||||
|
||||
<!--Shadow panel with the shaders list-->
|
||||
<controls:DropShadowPanel
|
||||
ShadowOpacity="1"
|
||||
BlurRadius="20"
|
||||
OffsetY="-2"
|
||||
OffsetX="-12"
|
||||
IsMasked="True"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalAlignment="Bottom">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0" To="0,320,0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border
|
||||
Height="320"
|
||||
Margin="-20,0,-20,0"
|
||||
Background="#FF222222">
|
||||
|
||||
<!--Shaders list-->
|
||||
<ListView
|
||||
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden">
|
||||
<ListView.Resources>
|
||||
|
||||
<!--Lightweight styling to remove the selection background with the accent color, and
|
||||
to remove the padding and stretch the list items to occupy all the available space-->
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelected" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPointerOver" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPressed" Color="Transparent"/>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
|
||||
<!--Shader template-->
|
||||
<DataTemplate x:DataType="models:ComputeShader">
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:UIElementExtensions.ClipToBounds="True">
|
||||
|
||||
<!--Shader preview-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
Width="568"
|
||||
ShaderRunner="{x:Bind ShaderRunner}"/>
|
||||
|
||||
<!--Note: here we have a selection property to work around {x:Bind} not working correctly outside of the
|
||||
current template scope. Once that's fixed in WinUI 3, this can be rewritten as a multi-binding like this:
|
||||
Visibility="{x:Bind system:Object.ReferenceEquals((local:ComputeShader), ViewModel.SelectedComputeShader), Mode=OneWay}".
|
||||
When that is working, the ComputeShader.IsSelected property can also be removed, as it will no longer be needed.-->
|
||||
<Border
|
||||
BorderThickness="4"
|
||||
BorderBrush="White"
|
||||
Visibility="{x:Bind IsSelected, Mode=OneWay}">
|
||||
<Polygon
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Points="0,0 32,0 32,32"
|
||||
Fill="White"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Border>
|
||||
</controls:DropShadowPanel>
|
||||
</Border>
|
||||
<!--Invisible title bar-->
|
||||
<Rectangle
|
||||
x:Name="TitleBarRectangle"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="32"
|
||||
Fill="Transparent"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
+3
-2
@@ -19,13 +19,14 @@ namespace ComputeSharp.SwapChain.WinUI.Views
|
||||
// Opens the shader selection panel
|
||||
private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShaderSelectionPanel.Visibility = Visibility.Visible;
|
||||
Root.Resources.Remove("ShaderSelectionPanel");
|
||||
Root.Children.Add(ShaderSelectionPanel);
|
||||
}
|
||||
|
||||
// Hides the shader selection panel
|
||||
private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
ShaderSelectionPanel.Visibility = Visibility.Collapsed;
|
||||
Root.Children.Remove(ShaderSelectionPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする