Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CmdPal] Settings UI polishing #38094

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/WindowExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;

namespace Microsoft.CmdPal.UI.Helpers;

public static class WindowExtensions
{
public static void SetIcon(this Window window)
{
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd);
AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
appWindow.SetIcon(@"Assets\icon.ico");
}
}
2 changes: 2 additions & 0 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.CmdPal.Common.Messages;
using Microsoft.CmdPal.Common.Services;
using Microsoft.CmdPal.UI.Events;
using Microsoft.CmdPal.UI.Helpers;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -71,6 +72,7 @@ public MainWindow()
// notification area icon back
WM_TASKBAR_RESTART = PInvoke.RegisterWindowMessage("TaskbarCreated");

this.SetIcon();
AppWindow.Title = RS_.GetString("AppName");
AppWindow.Resize(new SizeInt32 { Width = 1000, Height = 620 });
PositionCentered();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1" Padding="0,0,8,0">
<Grid Padding="8,-8,8,8">
<ScrollViewer Grid.Row="1">
<Grid Padding="16">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1" Padding="0,0,8,0">
<Grid Padding="8,16,8,8">
<ScrollViewer Grid.Row="1">
<Grid Padding="16">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1" Padding="0,0,8,0">
<Grid Padding="8,16,8,8">
<ScrollViewer Grid.Row="1">
<Grid Padding="16">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down
53 changes: 32 additions & 21 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- TO DO: Replace this with WinUI TitleBar once that ships. -->
<StackPanel Height="48" Orientation="Horizontal">
<Button
x:Name="PaneToggleBtn"
Width="48"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Click="PaneToggleBtn_Click"
Style="{StaticResource PaneToggleButtonStyle}" />
<StackPanel
x:Name="AppTitleBar"
Grid.Row="0"
Height="48"
Orientation="Horizontal">
<Image
Width="16"
Height="16"
Margin="16,0,0,0"
Source="ms-appx:///Assets/StoreLogo.png" />
<TextBlock
Margin="12,0,0,0"
Expand All @@ -35,6 +45,7 @@
<NavigationView
x:Name="NavView"
Grid.Row="1"
DisplayModeChanged="NavView_DisplayModeChanged"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
ItemInvoked="NavView_ItemInvoked"
Expand All @@ -46,10 +57,28 @@
<Thickness x:Key="NavigationViewHeaderMargin">15,0,0,0</Thickness>
</NavigationView.Resources>

<NavigationView.Header>
<NavigationView.MenuItems>
<NavigationViewItem
x:Uid="Settings_GeneralPage_NavigationViewItem_General"
Icon="{ui:FontIcon Glyph=&#xE80F;}"
Tag="General" />
<NavigationViewItem
x:Uid="Settings_GeneralPage_NavigationViewItem_Extensions"
Icon="{ui:FontIcon Glyph=&#xEA86;}"
Tag="Extensions" />
</NavigationView.MenuItems>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<BreadcrumbBar
x:Name="NavigationBreadcrumbBar"
Grid.Row="0"
MaxWidth="1000"
Margin="16,0,0,0"
ItemClicked="NavigationBreadcrumbBar_ItemClicked"
ItemsSource="{x:Bind BreadCrumbs, Mode=OneWay}">
<BreadcrumbBar.ItemTemplate>
Expand All @@ -67,24 +96,6 @@
</BreadcrumbBar.Resources>
</BreadcrumbBar>

</NavigationView.Header>
<NavigationView.MenuItems>
<NavigationViewItem
x:Uid="Settings_GeneralPage_NavigationViewItem_General"
Icon="{ui:FontIcon Glyph=&#xE80F;}"
Tag="General" />
<NavigationViewItem
x:Uid="Settings_GeneralPage_NavigationViewItem_Extensions"
Icon="{ui:FontIcon Glyph=&#xEA86;}"
Tag="Extensions" />
</NavigationView.MenuItems>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Frame x:Name="NavFrame" Grid.Row="1" />
</Grid>
</NavigationView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.CmdPal.UI.Helpers;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Windowing;
Expand All @@ -24,7 +25,7 @@ public SettingsWindow()
{
this.InitializeComponent();
this.ExtendsContentIntoTitleBar = true;
this.AppWindow.SetIcon("ms-appx:///Assets/Icons/StoreLogo.png");
this.SetIcon();
this.AppWindow.Title = RS_.GetString("SettingsWindowTitle");
this.AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
PositionCentered();
Expand Down Expand Up @@ -110,6 +111,27 @@ private void Window_Closed(object sender, WindowEventArgs args)
WeakReferenceMessenger.Default.Send<SettingsWindowClosedMessage>();
}

private void PaneToggleBtn_Click(object sender, RoutedEventArgs e)
{
NavView.IsPaneOpen = !NavView.IsPaneOpen;
}

private void NavView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
{
if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
{
PaneToggleBtn.Visibility = Visibility.Visible;
NavView.IsPaneToggleButtonVisible = false;
AppTitleBar.Margin = new Thickness(48, 0, 0, 0);
}
else
{
PaneToggleBtn.Visibility = Visibility.Collapsed;
NavView.IsPaneToggleButtonVisible = true;
AppTitleBar.Margin = new Thickness(16, 0, 0, 0);
}
}

public void Receive(QuitMessage message)
{
// This might come in on a background thread
Expand Down
7 changes: 2 additions & 5 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/ToastWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@

using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.CmdPal.UI.Helpers;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Composition;
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Windows.Graphics;
using Windows.UI;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
using WinRT;
using RS_ = Microsoft.CmdPal.UI.Helpers.ResourceLoaderInstance;

namespace Microsoft.CmdPal.UI;
Expand All @@ -37,7 +34,7 @@ public ToastWindow()
AppWindow.IsShownInSwitchers = false;
ExtendsContentIntoTitleBar = true;
AppWindow.SetPresenter(AppWindowPresenterKind.CompactOverlay);
AppWindow.SetIcon("ms-appx:///Assets/Icons/StoreLogo.png");
this.SetIcon();
AppWindow.Title = RS_.GetString("ToastWindowTitle");
AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Collapsed;

Expand Down
Loading