diff --git a/ComputeSharp.sln b/ComputeSharp.sln index c5e81c77..08b74376 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -636,6 +636,9 @@ Global src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{54654960-54b5-4e19-b3ed-993591ca39e5}*SharedItemsImports = 5 src\ComputeSharp.D2D1.UI.SourceGenerators\ComputeSharp.D2D1.UI.SourceGenerators.projitems*{690c4014-a06b-44db-b717-aea4cafa9d68}*SharedItemsImports = 5 src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{690c4014-a06b-44db-b717-aea4cafa9d68}*SharedItemsImports = 5 + samples\ComputeSharp.SwapChain.Shaders.D2D1\ComputeSharp.SwapChain.Shaders.D2D1.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5 + samples\ComputeSharp.SwapChain.Shaders\ComputeSharp.SwapChain.Shaders.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5 + samples\ComputeSharp.SwapChain.UI\ComputeSharp.SwapChain.UI.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.UI\ComputeSharp.SwapChain.UI.projitems*{6bc471c6-72f9-43cf-ae1e-f6d3e5ed3129}*SharedItemsImports = 13 src\ComputeSharp.D2D1.UI\ComputeSharp.D2D1.UI.projitems*{716df19e-69ba-4a9c-9ca4-bfd196152f46}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.Shaders.D2D1\ComputeSharp.SwapChain.Shaders.D2D1.projitems*{73c32d0f-64db-4674-84e9-8fcc41228474}*SharedItemsImports = 5 diff --git a/samples/ComputeSharp.SwapChain.UI/Controls/D2D1AnimatedPixelShaderPanel.cs b/samples/ComputeSharp.SwapChain.UI/Controls/D2D1AnimatedPixelShaderPanel.cs index 654da8bc..bbde7698 100644 --- a/samples/ComputeSharp.SwapChain.UI/Controls/D2D1AnimatedPixelShaderPanel.cs +++ b/samples/ComputeSharp.SwapChain.UI/Controls/D2D1AnimatedPixelShaderPanel.cs @@ -1,10 +1,19 @@ using ComputeSharp.SwapChain.Core.Shaders; using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas.UI.Xaml; +#if WINDOWS_UWP +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +#else using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +#endif +#if WINDOWS_UWP +namespace ComputeSharp.SwapChain.Uwp.Views; +#else namespace ComputeSharp.SwapChain.WinUI.Views; +#endif /// /// A custom that can be used to render animated backgrounds via Win2D. diff --git a/samples/ComputeSharp.SwapChain.UI/Converters/RenderingPauseConverter.cs b/samples/ComputeSharp.SwapChain.UI/Converters/RenderingPauseConverter.cs index 8420af17..0888d6e1 100644 --- a/samples/ComputeSharp.SwapChain.UI/Converters/RenderingPauseConverter.cs +++ b/samples/ComputeSharp.SwapChain.UI/Converters/RenderingPauseConverter.cs @@ -1,4 +1,8 @@ +#if WINDOWS_UWP +using Windows.UI.Xaml.Controls; +#else using Microsoft.UI.Xaml.Controls; +#endif namespace ComputeSharp.SwapChain.Core.Converters; diff --git a/samples/ComputeSharp.SwapChain.UI/Shaders/PixelShaderEffect.cs b/samples/ComputeSharp.SwapChain.UI/Shaders/PixelShaderEffect.cs index 69f2a8e8..a66fc56a 100644 --- a/samples/ComputeSharp.SwapChain.UI/Shaders/PixelShaderEffect.cs +++ b/samples/ComputeSharp.SwapChain.UI/Shaders/PixelShaderEffect.cs @@ -1,7 +1,11 @@ using System; using ComputeSharp.D2D1; using ComputeSharp.D2D1.Descriptors; +#if WINDOWS_UWP +using ComputeSharp.D2D1.Uwp; +#else using ComputeSharp.D2D1.WinUI; +#endif namespace ComputeSharp.SwapChain.Core.Shaders; diff --git a/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/ContouredLayersRunner.cs b/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/ContouredLayersRunner.cs index 261f1ce4..4c6fd817 100644 --- a/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/ContouredLayersRunner.cs +++ b/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/ContouredLayersRunner.cs @@ -1,7 +1,11 @@ using System; using System.IO; using ComputeSharp.SwapChain.Shaders; +#if WINDOWS_UWP +using ComputeSharp.Uwp; +#else using ComputeSharp.WinUI; +#endif using Windows.ApplicationModel; namespace ComputeSharp.SwapChain.Core.Shaders.Runners; diff --git a/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/D2D1ContouredLayersRunner.cs b/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/D2D1ContouredLayersRunner.cs index 70c2ec39..5a1d5db9 100644 --- a/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/D2D1ContouredLayersRunner.cs +++ b/samples/ComputeSharp.SwapChain.UI/Shaders/Runners/D2D1ContouredLayersRunner.cs @@ -2,7 +2,11 @@ using System; using System.IO; using ComputeSharp.D2D1; using ComputeSharp.D2D1.Interop; +#if WINDOWS_UWP +using ComputeSharp.D2D1.Uwp; +#else using ComputeSharp.D2D1.WinUI; +#endif using ComputeSharp.SwapChain.Shaders.D2D1; using Windows.ApplicationModel; diff --git a/samples/ComputeSharp.SwapChain.UI/ViewModels/MainViewModel.cs b/samples/ComputeSharp.SwapChain.UI/ViewModels/MainViewModel.cs index e9dd941b..89d42abd 100644 --- a/samples/ComputeSharp.SwapChain.UI/ViewModels/MainViewModel.cs +++ b/samples/ComputeSharp.SwapChain.UI/ViewModels/MainViewModel.cs @@ -5,7 +5,11 @@ using ComputeSharp.SwapChain.Core.Enums; using ComputeSharp.SwapChain.Core.Shaders; using ComputeSharp.SwapChain.Core.Shaders.Runners; using ComputeSharp.SwapChain.Shaders; +#if WINDOWS_UWP +using ComputeSharp.Uwp; +#else using ComputeSharp.WinUI; +#endif #pragma warning disable IDE0300 // CsWinRT does not support marshalling collection expression (https://github.com/microsoft/CsWinRT/issues/1661) diff --git a/samples/ComputeSharp.SwapChain.UI/ViewModels/ShaderRunnerViewModel.cs b/samples/ComputeSharp.SwapChain.UI/ViewModels/ShaderRunnerViewModel.cs index 443689ec..eac80e84 100644 --- a/samples/ComputeSharp.SwapChain.UI/ViewModels/ShaderRunnerViewModel.cs +++ b/samples/ComputeSharp.SwapChain.UI/ViewModels/ShaderRunnerViewModel.cs @@ -1,6 +1,10 @@ using CommunityToolkit.Mvvm.ComponentModel; using ComputeSharp.SwapChain.Core.Shaders; +#if WINDOWS_UWP +using ComputeSharp.Uwp; +#else using ComputeSharp.WinUI; +#endif namespace ComputeSharp.SwapChain.Core.ViewModels; diff --git a/samples/ComputeSharp.SwapChain.Uwp/App.xaml b/samples/ComputeSharp.SwapChain.Uwp/App.xaml index f15ffba6..9ee3a3dc 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/App.xaml +++ b/samples/ComputeSharp.SwapChain.Uwp/App.xaml @@ -1,7 +1,13 @@ - - - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + + + + + + + + \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs index 77206708..d60363db 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs +++ b/samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs @@ -1,6 +1,9 @@ +using ComputeSharp.SwapChain.Uwp.Views; using Windows.ApplicationModel.Activation; +using Windows.ApplicationModel.Core; +using Windows.UI; +using Windows.UI.ViewManagement; using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; namespace ComputeSharp.SwapChain.Uwp; @@ -10,7 +13,7 @@ namespace ComputeSharp.SwapChain.Uwp; sealed partial class App : Application { /// - /// Initializes the singleton application object. This is the first line of authored code + /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// public App() @@ -21,26 +24,49 @@ sealed partial class App : Application /// protected override void OnLaunched(LaunchActivatedEventArgs e) { - // Initialize the frame if needed - if (Window.Current.Content is not Frame rootFrame) + if (Window.Current.Content is not MainView) { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); + StyleTitleBar(); + ExpandViewIntoTitleBar(); - // Place the frame in the current Window - Window.Current.Content = rootFrame; + Window.Current.Content = new MainView(); } if (!e.PrelaunchActivated) { - if (rootFrame.Content is null) - { - // Navigate to the root page - _ = rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - - // Ensure the current window is active Window.Current.Activate(); } } -} + + /// + /// Styles the title bar buttons according to the theme in use + /// + private static void StyleTitleBar() + { + ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; + + // Transparent colors + titleBar.ForegroundColor = Colors.Transparent; + titleBar.BackgroundColor = Colors.Transparent; + titleBar.ButtonBackgroundColor = Colors.Transparent; + titleBar.InactiveBackgroundColor = Colors.Transparent; + titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; + + // Theme aware colors + titleBar.ButtonForegroundColor = titleBar.ButtonHoverForegroundColor = titleBar.ButtonPressedForegroundColor = Colors.White; + titleBar.ButtonHoverBackgroundColor = Color.FromArgb(0x20, 0xFF, 0xFF, 0xFF); + titleBar.ButtonPressedBackgroundColor = Color.FromArgb(0x40, 0xFF, 0xFF, 0xFF); + titleBar.ButtonInactiveForegroundColor = Color.FromArgb(0xC0, 0xFF, 0xFF, 0xFF); + titleBar.InactiveForegroundColor = Color.FromArgb(0xA0, 0xA0, 0xA0, 0xA0); + } + + /// + /// Sets up the app UI to be expanded into the title bar + /// + private static void ExpandViewIntoTitleBar() + { + CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; + + coreTitleBar.ExtendViewIntoTitleBar = true; + } +} \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/LockScreenLogo.scale-200.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57ad..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/SplashScreen.scale-200.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1f..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square150x150Logo.scale-200.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.scale-200.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2e..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce9..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/StoreLogo.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/StoreLogo.png deleted file mode 100644 index 7385b56c..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/StoreLogo.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/Assets/Wide310x150Logo.scale-200.png b/samples/ComputeSharp.SwapChain.Uwp/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b3..00000000 Binary files a/samples/ComputeSharp.SwapChain.Uwp/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj index 055b7bb2..9616379f 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj +++ b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj @@ -8,16 +8,59 @@ true x86;x64;arm64 win-x86;win-x64;win-arm64 + $(DefineConstants);WINDOWS_UWP en-US true win-$(Platform).pubxml true + + + false + + + + + false + true + 2 + + + + + false + true + + + + + true + true + true + false + Speed + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.xaml b/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.xaml new file mode 100644 index 00000000..b7c172e8 --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.xaml @@ -0,0 +1,16 @@ + + + + diff --git a/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml b/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml deleted file mode 100644 index b9a4a926..00000000 --- a/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml.cs deleted file mode 100644 index 8319d033..00000000 --- a/samples/ComputeSharp.SwapChain.Uwp/MainPage.xaml.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Windows.UI.Xaml.Controls; - -namespace ComputeSharp.SwapChain.Uwp; - -/// -/// An empty page that can be used on its own or navigated to within a Frame. -/// -public sealed partial class MainPage : Page -{ - public MainPage() - { - InitializeComponent(); - } -} diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml new file mode 100644 index 00000000..55151d18 --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs new file mode 100644 index 00000000..756d5329 --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs @@ -0,0 +1,50 @@ +using System; +using ComputeSharp.Uwp; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Input; + +namespace ComputeSharp.SwapChain.Uwp.Views; + +/// +/// A view for . +/// +public sealed partial class MainView : UserControl +{ + public MainView() + { + InitializeComponent(); + } + + // Opens the shader selection panel + private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e) + { + _ = this.Root.Resources.Remove(nameof(this.ShaderSelectionPanel)); + + this.Root.Children.Add(this.ShaderSelectionPanel); + } + + // Hides the shader selection panel + private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e) + { + _ = this.Root.Children.Remove(this.ShaderSelectionPanel); + } + + // Updates the size of the shaders list panel + private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) + { + this.ShadersListContainerPanel.Height = Math.Round(e.NewSize.Height * 0.35); + } + + // Logs rendering failed in the main panel + private void MainShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, RenderingFailedEventArgs args) + { + this.RenderingErrorInfoBar.IsOpen = true; + } + + // Logs rendering failed in a secondary panel + private void SelectionShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, RenderingFailedEventArgs args) + { + this.RenderingErrorInfoBar.IsOpen = true; + } +} \ No newline at end of file