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

Add New Tab Menu Customization to Settings UI #18015

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0e304d8
Add New Tab Menu Customization to Settings UI
carlos-zamora Mar 14, 2024
2cef0c1
[broken] drag and drop don't work
carlos-zamora Sep 20, 2024
cda72b6
Add nested folder support (and serialization)
carlos-zamora Oct 4, 2024
577ca8b
Add ability to modify current folder properties
carlos-zamora Oct 8, 2024
4d5616c
last bit of polish
carlos-zamora Oct 8, 2024
99d2d39
Add support for action entries
carlos-zamora Oct 8, 2024
a0a84f9
Display icons for actions and folders
carlos-zamora Oct 9, 2024
4b85165
accessibility pass
carlos-zamora Oct 9, 2024
78de36b
make NewTabMenuEntry::Copy virtual
carlos-zamora Oct 28, 2024
8fd6d9f
use std::vector; remove extra resources; remove redundant var
carlos-zamora Oct 28, 2024
0944064
Merge branch 'main' into dev/cazamor/SUI/newTabMenu
carlos-zamora Oct 28, 2024
4574b3d
Merge branch 'main' into dev/cazamor/SUI/newTabMenu
carlos-zamora Oct 30, 2024
babcd9f
thanks Leonard!
carlos-zamora Nov 6, 2024
b0c2558
Enable buttons iff items selected
carlos-zamora Nov 21, 2024
2bcf07e
Normalize size for item buttons
carlos-zamora Nov 21, 2024
e5ccac1
Make ListView larger (better for drag & drop)
carlos-zamora Nov 21, 2024
cdd8d32
Scroll to newly added entry
carlos-zamora Nov 21, 2024
53cfce7
Update SettingsNav's SelectedItem when discarding changes from a nest…
carlos-zamora Nov 21, 2024
06ef29c
Use EvaluatedIcon over Icon for profiles
carlos-zamora Nov 21, 2024
b1f695f
polish moving entries to folders
carlos-zamora Nov 21, 2024
1c661f7
address most of Pankaj's feedback
carlos-zamora Nov 22, 2024
aeab125
Navigate to correct folder when discarding changes
carlos-zamora Nov 22, 2024
3ca7810
QOL = Quality Of Life
carlos-zamora Nov 22, 2024
14f6c3e
subpage is a word!
carlos-zamora Nov 22, 2024
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
23 changes: 21 additions & 2 deletions src/cascadia/TerminalSettingsEditor/CommonResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Thickness x:Key="StandardControlMargin">0,24,0,0</Thickness>
<x:Double x:Key="StandardBoxMinWidth">250</x:Double>
<x:Double x:Key="StandardControlMaxWidth">1000</x:Double>
<Thickness x:Key="SettingStackMargin">13,0,13,48</Thickness>

<!--
This is for styling the entire items control used on the
Expand All @@ -80,13 +81,13 @@
<!-- Used to stack a group of settings -->
<Style x:Key="SettingsStackStyle"
TargetType="StackPanel">
<Setter Property="Margin" Value="13,0,13,48" />
<Setter Property="Margin" Value="{StaticResource SettingStackMargin}" />
</Style>

<!-- Used to stack a group of settings inside a pivot -->
<Style x:Key="PivotStackStyle"
TargetType="StackPanel">
<Setter Property="Margin" Value="0,0,13,48" />
<Setter Property="Margin" Value="{StaticResource SettingStackMargin}" />
</Style>

<!-- Combo Box -->
Expand Down Expand Up @@ -247,6 +248,15 @@
</Setter>
</Style>

<Style x:Key="ExtraSmallButtonStyle"
BasedOn="{StaticResource BrowseButtonStyle}"
TargetType="Button">
<Setter Property="Height" Value="25" />
<Setter Property="Width" Value="25" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>

<Style x:Key="SmallButtonStyle"
BasedOn="{StaticResource BrowseButtonStyle}"
TargetType="Button">
Expand Down Expand Up @@ -280,6 +290,15 @@
<Setter Property="Padding" Value="5" />
</Style>

<Style x:Key="DeleteExtraSmallButtonStyle"
BasedOn="{StaticResource DeleteButtonStyle}"
TargetType="Button">
<Setter Property="Height" Value="25" />
<Setter Property="Width" Value="25" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>

<Style x:Key="IconButtonTextBlockStyle"
TargetType="TextBlock">
<Setter Property="Margin" Value="10,0,0,0" />
Expand Down
79 changes: 78 additions & 1 deletion src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "AddProfile.h"
#include "InteractionViewModel.h"
#include "LaunchViewModel.h"
#include "NewTabMenuViewModel.h"
#include "..\types\inc\utils.hpp"
#include <..\WinRTUtils\inc\Utils.h>

Expand All @@ -40,6 +41,7 @@ static const std::wstring_view launchTag{ L"Launch_Nav" };
static const std::wstring_view interactionTag{ L"Interaction_Nav" };
static const std::wstring_view renderingTag{ L"Rendering_Nav" };
static const std::wstring_view actionsTag{ L"Actions_Nav" };
static const std::wstring_view newTabMenuTag{ L"NewTabMenu_Nav" };
static const std::wstring_view globalProfileTag{ L"GlobalProfile_Nav" };
static const std::wstring_view addProfileTag{ L"AddProfile" };
static const std::wstring_view colorSchemesTag{ L"ColorSchemes_Nav" };
Expand All @@ -59,6 +61,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
InitializeComponent();
_UpdateBackgroundForMica();

_newTabMenuPageVM = winrt::make<NewTabMenuViewModel>(_settingsClone);
_SetupNTMEventHandling();

_colorSchemesPageVM = winrt::make<ColorSchemesPageViewModel>(_settingsClone);
_colorSchemesPageViewModelChangedRevoker = _colorSchemesPageVM.PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
Expand Down Expand Up @@ -134,13 +139,24 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_InitializeProfilesList();
// Update the Nav State with the new version of the settings
_colorSchemesPageVM.UpdateSettings(_settingsClone);
_newTabMenuPageVM.UpdateSettings(_settingsClone);

// We'll update the profile in the _profilesNavState whenever we actually navigate to one

// now that the menuItems are repopulated,
// refresh the current page using the breadcrumb data we collected before the refresh
if (const auto& crumb{ lastBreadcrumb.try_as<Breadcrumb>() })
if (const auto& crumb{ lastBreadcrumb.try_as<Breadcrumb>() }; crumb && crumb->Tag())
{
// Early exit if the last breadcrumb was a FolderEntry in the NewTabMenu
if (const auto& breadcrumbFolderEntry{ crumb->Tag().try_as<Editor::FolderEntryViewModel>() })
{
// It's _a lot_ of extra work to figure out where this folder is and recreate the breadcrumbs
// (and that assumes that the folder even exists!) so for now we'll just navigate to the base page
_newTabMenuPageVM.CurrentFolder(nullptr);
_Navigate(breadcrumbFolderEntry, BreadcrumbSubPage::None);
return;
}

for (const auto& item : _menuItemSource)
{
if (const auto& menuItem{ item.try_as<MUX::Controls::NavigationViewItem>() })
Expand Down Expand Up @@ -299,6 +315,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void MainPage::_PreNavigateHelper()
{
_profileViewModelChangedRevoker.revoke();
_ntmViewModelChangedRevoker.revoke();
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
_breadcrumbs.Clear();
}

Expand Down Expand Up @@ -350,6 +367,31 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
});
}

void MainPage::_SetupNTMEventHandling()
{
_ntmViewModelChangedRevoker = _newTabMenuPageVM.PropertyChanged(winrt::auto_revoke, [this](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
if (settingName == L"CurrentFolder")
{
if (const auto& currentFolder = _newTabMenuPageVM.CurrentFolder())
{
contentFrame().Navigate(xaml_typename<Editor::NewTabMenu>(), _newTabMenuPageVM);
const auto crumb = winrt::make<Breadcrumb>(box_value(currentFolder), currentFolder.Name(), BreadcrumbSubPage::NTM_Folder);
_breadcrumbs.Append(crumb);
SettingsMainPage_ScrollViewer().ScrollToVerticalOffset(0);
}
else
{
// If we don't have a current folder, we're at the root of the NTM
contentFrame().Navigate(xaml_typename<Editor::NewTabMenu>(), _newTabMenuPageVM);
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
_breadcrumbs.Clear();
const auto crumb = winrt::make<Breadcrumb>(box_value(newTabMenuTag), RS_(L"Nav_NewTabMenu/Content"), BreadcrumbSubPage::None);
_breadcrumbs.Append(crumb);
}
}
});
}

void MainPage::_Navigate(hstring clickedItemTag, BreadcrumbSubPage subPage)
{
_PreNavigateHelper();
Expand Down Expand Up @@ -378,6 +420,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const auto crumb = winrt::make<Breadcrumb>(box_value(clickedItemTag), RS_(L"Nav_Actions/Content"), BreadcrumbSubPage::None);
_breadcrumbs.Append(crumb);
}
else if (clickedItemTag == newTabMenuTag)
{
// Reset the current folder entry and page BEFORE setting up the event handling
_newTabMenuPageVM.CurrentFolder(nullptr);

_SetupNTMEventHandling();
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved

contentFrame().Navigate(xaml_typename<Editor::NewTabMenu>(), _newTabMenuPageVM);
const auto crumb = winrt::make<Breadcrumb>(box_value(clickedItemTag), RS_(L"Nav_NewTabMenu/Content"), BreadcrumbSubPage::None);
_breadcrumbs.Append(crumb);
}
else if (clickedItemTag == globalProfileTag)
{
auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults(), _settingsClone) };
Expand Down Expand Up @@ -458,6 +511,26 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

void MainPage::_Navigate(const Editor::NewTabMenuEntryViewModel& ntmEntryVM, BreadcrumbSubPage subPage)
{
_PreNavigateHelper();

_SetupNTMEventHandling();
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved

contentFrame().Navigate(xaml_typename<Editor::NewTabMenu>(), _newTabMenuPageVM);
const auto crumb = winrt::make<Breadcrumb>(box_value(newTabMenuTag), RS_(L"Nav_NewTabMenu/Content"), BreadcrumbSubPage::None);
_breadcrumbs.Append(crumb);

if (subPage == BreadcrumbSubPage::None)
{
_newTabMenuPageVM.CurrentFolder(nullptr);
}
else if (const auto folderEntry = ntmEntryVM.try_as<FolderEntryViewModel>(); subPage == BreadcrumbSubPage::NTM_Folder && folderEntry)
{
_newTabMenuPageVM.CurrentFolder(*folderEntry);
}
}

void MainPage::OpenJsonTapped(const IInspectable& /*sender*/, const Windows::UI::Xaml::Input::TappedRoutedEventArgs& /*args*/)
{
const auto window = CoreWindow::GetForCurrentThread();
Expand Down Expand Up @@ -500,6 +573,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
_Navigate(*profileViewModel, subPage);
}
else if (const auto ntmEntryViewModel = tag.try_as<NewTabMenuEntryViewModel>())
{
_Navigate(*ntmEntryViewModel, subPage);
}
else
{
_Navigate(tag.as<hstring>(), subPage);
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,22 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void _AddProfileHandler(const winrt::guid profileGuid);

void _SetupProfileEventHandling(const winrt::Microsoft::Terminal::Settings::Editor::ProfileViewModel profile);
void _SetupNTMEventHandling();

void _PreNavigateHelper();
void _Navigate(hstring clickedItemTag, BreadcrumbSubPage subPage);
void _Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage);
void _Navigate(const Editor::NewTabMenuEntryViewModel& ntmEntryVM, BreadcrumbSubPage subPage);

void _UpdateBackgroundForMica();
void _MoveXamlParsedNavItemsIntoItemSource();

winrt::Microsoft::Terminal::Settings::Editor::ColorSchemesPageViewModel _colorSchemesPageVM{ nullptr };
winrt::Microsoft::Terminal::Settings::Editor::NewTabMenuViewModel _newTabMenuPageVM{ nullptr };

Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _profileViewModelChangedRevoker;
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _colorSchemesPageViewModelChangedRevoker;
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _ntmViewModelChangedRevoker;
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalSettingsEditor/MainPage.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace Microsoft.Terminal.Settings.Editor
None = 0,
Profile_Appearance,
Profile_Advanced,
ColorSchemes_Edit
ColorSchemes_Edit,
NTM_Folder
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
};

runtimeclass Breadcrumb : Windows.Foundation.IStringable
Expand Down
7 changes: 7 additions & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>

<muxc:NavigationViewItem x:Uid="Nav_NewTabMenu"
Tag="NewTabMenu_Nav">
<muxc:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE71d;" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>

<muxc:NavigationViewItemHeader x:Uid="Nav_Profiles" />

<muxc:NavigationViewItem x:Name="BaseLayerMenuItem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<ClInclude Include="Launch.h">
<DependentUpon>Launch.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="NewTabMenu.h">
<DependentUpon>NewTabMenu.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="pch.h" />
<ClInclude Include="MainPage.h">
<DependentUpon>MainPage.xaml</DependentUpon>
Expand Down Expand Up @@ -106,6 +109,10 @@
<DependentUpon>LaunchViewModel.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="NewTabMenuViewModel.h">
<DependentUpon>NewTabMenuViewModel.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="Profiles_Base.h">
<DependentUpon>Profiles_Base.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -160,6 +167,9 @@
<Page Include="Launch.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="NewTabMenu.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
</Page>
Expand Down Expand Up @@ -210,6 +220,9 @@
<ClCompile Include="Launch.cpp">
<DependentUpon>Launch.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="NewTabMenu.cpp">
<DependentUpon>NewTabMenu.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -249,6 +262,10 @@
<DependentUpon>LaunchViewModel.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="NewTabMenuViewModel.cpp">
<DependentUpon>NewTabMenuViewModel.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="Profiles_Base.cpp">
<DependentUpon>Profiles_Base.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -307,6 +324,10 @@
<DependentUpon>Launch.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="NewTabMenu.idl">
<DependentUpon>NewTabMenu.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="Interaction.idl">
<DependentUpon>Interaction.xaml</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -326,6 +347,7 @@
<Midl Include="InteractionViewModel.idl" />
<Midl Include="GlobalAppearanceViewModel.idl" />
<Midl Include="LaunchViewModel.idl" />
<Midl Include="NewTabMenuViewModel.idl" />
<Midl Include="Profiles_Base.idl">
<DependentUpon>Profiles_Base.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Midl Include="LaunchViewModel.idl" />
<Midl Include="EnumEntry.idl" />
<Midl Include="SettingContainer.idl" />
<Midl Include="NewTabMenuViewModel.idl" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand All @@ -49,5 +50,6 @@
<Page Include="SettingContainerStyle.xaml" />
<Page Include="AddProfile.xaml" />
<Page Include="KeyChordListener.xaml" />
<Page Include="NewTabMenu.xaml" />
</ItemGroup>
</Project>
Loading
Loading