From 52eaecb6054549071456c71704c815d45c63275d Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 15 Dec 2022 16:51:05 -0800 Subject: [PATCH 1/9] seems to work --- .../TerminalSettingsEditor/Appearances.cpp | 29 +++++++++---------- .../TerminalSettingsEditor/Appearances.h | 12 ++++---- .../TerminalSettingsEditor/Appearances.idl | 8 +++-- .../TerminalSettingsEditor/Appearances.xaml | 2 +- .../TerminalSettingsEditor/MainPage.cpp | 4 +-- .../ProfileViewModel.cpp | 10 +++---- .../TerminalSettingsEditor/ProfileViewModel.h | 6 ++-- .../TerminalSettingsEditor/Profiles.h | 8 ++--- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.cpp b/src/cascadia/TerminalSettingsEditor/Appearances.cpp index ef77b5f6f73..ba239cc44b4 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.cpp +++ b/src/cascadia/TerminalSettingsEditor/Appearances.cpp @@ -87,7 +87,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Appearances::Appearances() : _ShowAllFonts{ false }, - _ColorSchemeList{ single_threaded_observable_vector() } + _ColorSchemeList{ single_threaded_observable_vector() } { InitializeComponent(); @@ -224,11 +224,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { if (Appearance()) { - const auto& colorSchemeMap{ Appearance().Schemes() }; - for (const auto& pair : colorSchemeMap) - { - _ColorSchemeList.Append(pair.Value()); - } + _ColorSchemeList = Appearance().SchemesPageVM().AllColorSchemes(); const auto& biAlignmentVal{ static_cast(Appearance().BackgroundImageAlignment()) }; for (const auto& biButton : _BIAlignmentButtons) @@ -353,22 +349,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - ColorScheme Appearances::CurrentColorScheme() + Editor::ColorSchemeViewModel Appearances::CurrentColorScheme() { const auto schemeName{ Appearance().DarkColorSchemeName() }; - if (const auto scheme{ Appearance().Schemes().TryLookup(schemeName) }) + const auto allSchemes{ Appearance().SchemesPageVM().AllColorSchemes() }; + for (const auto& scheme : allSchemes) { - return scheme; - } - else - { - // This Appearance points to a color scheme that was renamed or deleted. - // Fallback to Campbell. - return Appearance().Schemes().TryLookup(L"Campbell"); + if (scheme.Name() == schemeName) + { + return scheme; + } } + // This Appearance points to a color scheme that was renamed or deleted. + // Fallback to the first one in the list. + return allSchemes.GetAt(0); } - void Appearances::CurrentColorScheme(const ColorScheme& val) + void Appearances::CurrentColorScheme(const ColorSchemeViewModel& val) { Appearance().DarkColorSchemeName(val.Name()); Appearance().LightColorSchemeName(val.Name()); diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.h b/src/cascadia/TerminalSettingsEditor/Appearances.h index 2f67b03a9b2..5aaac9dd610 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.h +++ b/src/cascadia/TerminalSettingsEditor/Appearances.h @@ -69,8 +69,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void UseDesktopBGImage(const bool useDesktop); bool BackgroundImageSettingsVisible(); - Windows::Foundation::Collections::IMapView Schemes() { return _Schemes; } - void Schemes(const Windows::Foundation::Collections::IMapView& val) { _Schemes = val; } + Editor::ColorSchemesPageViewModel SchemesPageVM() { return _SchemesPageVM; } + void SchemesPageVM(const Editor::ColorSchemesPageViewModel& val) { _SchemesPageVM = val; } WINRT_PROPERTY(bool, IsDefault, false); WINRT_PROPERTY(IHostedInWindow, WindowRoot, nullptr); @@ -99,7 +99,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation private: Model::AppearanceConfig _appearance; winrt::hstring _lastBgImagePath; - Windows::Foundation::Collections::IMapView _Schemes; + Editor::ColorSchemesPageViewModel _SchemesPageVM{ nullptr }; }; struct Appearances : AppearancesT @@ -113,8 +113,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // CursorShape visibility logic bool IsVintageCursor() const; - Model::ColorScheme CurrentColorScheme(); - void CurrentColorScheme(const Model::ColorScheme& val); + Editor::ColorSchemeViewModel CurrentColorScheme(); + void CurrentColorScheme(const Editor::ColorSchemeViewModel& val); bool UsingMonospaceFont() const noexcept; bool ShowAllFonts() const noexcept; @@ -132,7 +132,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation GETSET_BINDABLE_ENUM_SETTING(CursorShape, Microsoft::Terminal::Core::CursorStyle, Appearance().CursorShape); GETSET_BINDABLE_ENUM_SETTING(AdjustIndistinguishableColors, Microsoft::Terminal::Core::AdjustTextMode, Appearance().AdjustIndistinguishableColors); - WINRT_PROPERTY(Windows::Foundation::Collections::IObservableVector, ColorSchemeList, nullptr); + WINRT_PROPERTY(Windows::Foundation::Collections::IObservableVector, ColorSchemeList, nullptr); WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); DEPENDENCY_PROPERTY(Editor::AppearanceViewModel, Appearance); diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index e31f7e41703..3717faa8214 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -4,6 +4,8 @@ import "EnumEntry.idl"; import "MainPage.idl"; import "Profiles.idl"; +import "ColorSchemeViewModel.idl"; +import "ColorSchemesPageViewModel.idl"; #include "ViewModelHelpers.idl.h" @@ -30,7 +32,7 @@ namespace Microsoft.Terminal.Settings.Editor Boolean UseDesktopBGImage; Boolean BackgroundImageSettingsVisible { get; }; - Windows.Foundation.Collections.IMapView Schemes; + ColorSchemesPageViewModel SchemesPageVM; IHostedInWindow WindowRoot; // necessary to send the right HWND into the file picker dialogs. OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, FontFace); @@ -67,8 +69,8 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentAdjustIndistinguishableColors; Windows.Foundation.Collections.IObservableVector AdjustIndistinguishableColorsList { get; }; - Microsoft.Terminal.Settings.Model.ColorScheme CurrentColorScheme; - Windows.Foundation.Collections.IObservableVector ColorSchemeList { get; }; + ColorSchemeViewModel CurrentColorScheme; + Windows.Foundation.Collections.IObservableVector ColorSchemeList { get; }; IInspectable CurrentBackgroundImageStretchMode; Windows.Foundation.Collections.IObservableVector BackgroundImageStretchModeList { get; }; diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 9bed48c7ef5..e66dc52c186 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -48,7 +48,7 @@ SelectedItem="{x:Bind CurrentColorScheme, Mode=TwoWay}" Style="{StaticResource ComboBoxSettingStyle}"> - + diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index 6f7256597f4..a859ce895b3 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -393,7 +393,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults(), _settingsClone) }; profileVM.IsBaseLayer(true); auto state{ winrt::make(profileVM, - _settingsClone.GlobalSettings().ColorSchemes(), + _colorSchemesPageVM, *this) }; _SetupProfileEventHandling(state); @@ -447,7 +447,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage, const bool focusDeleteButton) { auto state{ winrt::make(profile, - _settingsClone.GlobalSettings().ColorSchemes(), + _colorSchemesPageVM, *this) }; state.FocusDeleteButton(focusDeleteButton); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index 1cae80224e1..bc95b189449 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -212,14 +212,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return nullptr; } - Windows::Foundation::Collections::IMapView ProfileViewModel::Schemes() const noexcept + Editor::ColorSchemesPageViewModel ProfileViewModel::SchemesPageVM() const noexcept { - return _Schemes; + return _SchemesPageVM; } - void ProfileViewModel::Schemes(const Windows::Foundation::Collections::IMapView& val) noexcept + void ProfileViewModel::SchemesPageVM(const Editor::ColorSchemesPageViewModel& val) noexcept { - _Schemes = val; + _SchemesPageVM = val; } winrt::guid ProfileViewModel::OriginalProfileGuid() const noexcept @@ -257,7 +257,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _profile.CreateUnfocusedAppearance(); _unfocusedAppearanceViewModel = winrt::make(_profile.UnfocusedAppearance().try_as()); - _unfocusedAppearanceViewModel.Schemes(_Schemes); + _unfocusedAppearanceViewModel.SchemesPageVM(_SchemesPageVM); _unfocusedAppearanceViewModel.WindowRoot(_WindowRoot); _NotifyChanges(L"UnfocusedAppearance", L"HasUnfocusedAppearance", L"ShowUnfocusedAppearance"); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 81c8cf4d00e..7fb5213916e 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -23,8 +23,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::TerminalSettings TermSettings() const; void DeleteProfile(); - Windows::Foundation::Collections::IMapView Schemes() const noexcept; - void Schemes(const Windows::Foundation::Collections::IMapView& val) noexcept; + Editor::ColorSchemesPageViewModel SchemesPageVM() const noexcept; + void SchemesPageVM(const Editor::ColorSchemesPageViewModel& val) noexcept; // bell style bits bool IsBellStyleFlagSet(const uint32_t flag); @@ -104,7 +104,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation winrt::hstring _lastBgImagePath; winrt::hstring _lastStartingDirectoryPath; Editor::AppearanceViewModel _defaultAppearanceViewModel; - Windows::Foundation::Collections::IMapView _Schemes; + Editor::ColorSchemesPageViewModel _SchemesPageVM{ nullptr }; static Windows::Foundation::Collections::IObservableVector _MonospaceFontList; static Windows::Foundation::Collections::IObservableVector _FontList; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 45721540f96..93b7267c4ba 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -15,20 +15,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { public: ProfilePageNavigationState(const Editor::ProfileViewModel& viewModel, - const Windows::Foundation::Collections::IMapView& schemes, + const Editor::ColorSchemesPageViewModel& schemesPageVM, const IHostedInWindow& windowRoot) : _Profile{ viewModel } { auto profile{ winrt::get_self(viewModel) }; - profile->Schemes(schemes); + profile->SchemesPageVM(schemesPageVM); profile->WindowRoot(windowRoot); - viewModel.DefaultAppearance().Schemes(schemes); + viewModel.DefaultAppearance().SchemesPageVM(schemesPageVM); viewModel.DefaultAppearance().WindowRoot(windowRoot); if (viewModel.UnfocusedAppearance()) { - viewModel.UnfocusedAppearance().Schemes(schemes); + viewModel.UnfocusedAppearance().SchemesPageVM(schemesPageVM); viewModel.UnfocusedAppearance().WindowRoot(windowRoot); } } From 4c546c88e3d78653a1e8c656a3c9def7a20242a8 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 16 Dec 2022 13:15:06 -0800 Subject: [PATCH 2/9] progress towards removing nav state --- .../TerminalSettingsEditor/MainPage.cpp | 26 ++++++++++++++++--- .../ProfileViewModel.cpp | 12 +-------- .../TerminalSettingsEditor/ProfileViewModel.h | 4 --- .../TerminalSettingsEditor/Profiles.h | 4 --- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index a859ce895b3..71cd4bd1543 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -10,6 +10,7 @@ #include "RenderingViewModel.h" #include "Actions.h" #include "Profiles.h" +#include "ProfileViewModel.h" #include "GlobalAppearance.h" #include "GlobalAppearanceViewModel.h" #include "ColorSchemes.h" @@ -391,9 +392,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation else if (clickedItemTag == globalProfileTag) { auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults(), _settingsClone) }; + profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + if (profileVM.UnfocusedAppearance()) + { + profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + } profileVM.IsBaseLayer(true); auto state{ winrt::make(profileVM, - _colorSchemesPageVM, *this) }; _SetupProfileEventHandling(state); @@ -446,8 +451,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // - profile - the profile object we are getting a view of void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage, const bool focusDeleteButton) { + profile.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + if (profile.UnfocusedAppearance()) + { + profile.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + } auto state{ winrt::make(profile, - _colorSchemesPageVM, *this) }; state.FocusDeleteButton(focusDeleteButton); @@ -535,7 +544,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { if (!profile.Deleted()) { - auto navItem = _CreateProfileNavViewItem(_viewModelForProfile(profile, _settingsClone)); + auto profileVM = _viewModelForProfile(profile, _settingsClone); + profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + if (profileVM.UnfocusedAppearance()) + { + profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + } + auto navItem = _CreateProfileNavViewItem(profileVM); menuItems.Append(navItem); } } @@ -557,6 +572,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { const auto newProfile{ profile ? profile : _settingsClone.CreateNewProfile() }; const auto profileViewModel{ _viewModelForProfile(newProfile, _settingsClone) }; + profileViewModel.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + if (profileViewModel.UnfocusedAppearance()) + { + profileViewModel.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + } const auto navItem{ _CreateProfileNavViewItem(profileViewModel) }; SettingsNav().MenuItems().InsertAt(index, navItem); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index bc95b189449..70c79212216 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -212,16 +212,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return nullptr; } - Editor::ColorSchemesPageViewModel ProfileViewModel::SchemesPageVM() const noexcept - { - return _SchemesPageVM; - } - - void ProfileViewModel::SchemesPageVM(const Editor::ColorSchemesPageViewModel& val) noexcept - { - _SchemesPageVM = val; - } - winrt::guid ProfileViewModel::OriginalProfileGuid() const noexcept { return _originalProfileGuid; @@ -257,7 +247,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _profile.CreateUnfocusedAppearance(); _unfocusedAppearanceViewModel = winrt::make(_profile.UnfocusedAppearance().try_as()); - _unfocusedAppearanceViewModel.SchemesPageVM(_SchemesPageVM); + _unfocusedAppearanceViewModel.SchemesPageVM(DefaultAppearance().SchemesPageVM()); _unfocusedAppearanceViewModel.WindowRoot(_WindowRoot); _NotifyChanges(L"UnfocusedAppearance", L"HasUnfocusedAppearance", L"ShowUnfocusedAppearance"); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 7fb5213916e..e8381cc3f24 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -23,9 +23,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::TerminalSettings TermSettings() const; void DeleteProfile(); - Editor::ColorSchemesPageViewModel SchemesPageVM() const noexcept; - void SchemesPageVM(const Editor::ColorSchemesPageViewModel& val) noexcept; - // bell style bits bool IsBellStyleFlagSet(const uint32_t flag); void SetBellStyleAudible(winrt::Windows::Foundation::IReference on); @@ -104,7 +101,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation winrt::hstring _lastBgImagePath; winrt::hstring _lastStartingDirectoryPath; Editor::AppearanceViewModel _defaultAppearanceViewModel; - Editor::ColorSchemesPageViewModel _SchemesPageVM{ nullptr }; static Windows::Foundation::Collections::IObservableVector _MonospaceFontList; static Windows::Foundation::Collections::IObservableVector _FontList; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 93b7267c4ba..5384d90d891 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -15,20 +15,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { public: ProfilePageNavigationState(const Editor::ProfileViewModel& viewModel, - const Editor::ColorSchemesPageViewModel& schemesPageVM, const IHostedInWindow& windowRoot) : _Profile{ viewModel } { auto profile{ winrt::get_self(viewModel) }; - profile->SchemesPageVM(schemesPageVM); profile->WindowRoot(windowRoot); - viewModel.DefaultAppearance().SchemesPageVM(schemesPageVM); viewModel.DefaultAppearance().WindowRoot(windowRoot); if (viewModel.UnfocusedAppearance()) { - viewModel.UnfocusedAppearance().SchemesPageVM(schemesPageVM); viewModel.UnfocusedAppearance().WindowRoot(windowRoot); } } From f4f09c008c4a3970658faba7e94c209925cb532b Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 19 Dec 2022 14:08:01 -0800 Subject: [PATCH 3/9] remove navigation state --- .../TerminalSettingsEditor/Appearances.idl | 2 +- .../TerminalSettingsEditor/MainPage.cpp | 33 +++++++++--------- .../TerminalSettingsEditor/MainPage.h | 4 +-- ...Microsoft.Terminal.Settings.Editor.vcxproj | 7 ---- .../ProfileViewModel.cpp | 2 +- .../TerminalSettingsEditor/Profiles.h | 34 ------------------- .../TerminalSettingsEditor/Profiles.idl | 14 -------- .../Profiles_Advanced.cpp | 4 +-- .../Profiles_Advanced.idl | 2 +- .../Profiles_Appearance.cpp | 5 ++- .../Profiles_Appearance.idl | 2 +- .../TerminalSettingsEditor/Profiles_Base.cpp | 22 ++---------- .../TerminalSettingsEditor/Profiles_Base.h | 1 - .../TerminalSettingsEditor/Profiles_Base.idl | 2 +- 14 files changed, 30 insertions(+), 104 deletions(-) delete mode 100644 src/cascadia/TerminalSettingsEditor/Profiles.h delete mode 100644 src/cascadia/TerminalSettingsEditor/Profiles.idl diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index 3717faa8214..92988cd7358 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -3,7 +3,7 @@ import "EnumEntry.idl"; import "MainPage.idl"; -import "Profiles.idl"; +import "ProfileViewModel.idl"; import "ColorSchemeViewModel.idl"; import "ColorSchemesPageViewModel.idl"; diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index 71cd4bd1543..3720d8d6d06 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -9,7 +9,6 @@ #include "Rendering.h" #include "RenderingViewModel.h" #include "Actions.h" -#include "Profiles.h" #include "ProfileViewModel.h" #include "GlobalAppearance.h" #include "GlobalAppearanceViewModel.h" @@ -314,7 +313,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _breadcrumbs.Clear(); } - void MainPage::_SetupProfileEventHandling(const Editor::ProfilePageNavigationState state) + void MainPage::_SetupProfileEventHandling(const Editor::ProfileViewModel profile) { // Add an event handler to navigate to Profiles_Appearance or Profiles_Advanced // Some notes on this: @@ -326,7 +325,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // We decided that it's better for the owner of the BreadcrumbBar to also be responsible // for navigation, so the navigation to Profiles_Advanced/Profiles_Appearance from // Profiles_Base got moved here. - const auto profile = state.Profile(); // If this is the base layer, the breadcrumb tag should be the globalProfileTag instead of the // ProfileViewModel, because the navigation menu item for this profile is the globalProfileTag. @@ -340,20 +338,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation const auto currentPage = profile.CurrentPage(); if (currentPage == ProfileSubPage::Base) { - contentFrame().Navigate(xaml_typename(), state); + contentFrame().Navigate(xaml_typename(), profile); _breadcrumbs.Clear(); const auto crumb = winrt::make(breadcrumbTag, breadcrumbText, BreadcrumbSubPage::None); _breadcrumbs.Append(crumb); } else if (currentPage == ProfileSubPage::Appearance) { - contentFrame().Navigate(xaml_typename(), state); + contentFrame().Navigate(xaml_typename(), profile); const auto crumb = winrt::make(breadcrumbTag, RS_(L"Profile_Appearance/Header"), BreadcrumbSubPage::Profile_Appearance); _breadcrumbs.Append(crumb); } else if (currentPage == ProfileSubPage::Advanced) { - contentFrame().Navigate(xaml_typename(), state); + contentFrame().Navigate(xaml_typename(), profile); const auto crumb = winrt::make(breadcrumbTag, RS_(L"Profile_Advanced/Header"), BreadcrumbSubPage::Profile_Advanced); _breadcrumbs.Append(crumb); } @@ -393,17 +391,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults(), _settingsClone) }; profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + profileVM.DefaultAppearance().WindowRoot(*this); if (profileVM.UnfocusedAppearance()) { profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + profileVM.UnfocusedAppearance().WindowRoot(*this); } profileVM.IsBaseLayer(true); - auto state{ winrt::make(profileVM, - *this) }; - _SetupProfileEventHandling(state); + _SetupProfileEventHandling(profileVM); - contentFrame().Navigate(xaml_typename(), state); + contentFrame().Navigate(xaml_typename(), profileVM); const auto crumb = winrt::make(box_value(clickedItemTag), RS_(L"Nav_ProfileDefaults/Content"), BreadcrumbSubPage::None); _breadcrumbs.Append(crumb); @@ -449,22 +447,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // - NOTE: this does not update the selected item. // Arguments: // - profile - the profile object we are getting a view of - void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage, const bool focusDeleteButton) + void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage) { profile.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + profile.DefaultAppearance().WindowRoot(*this); if (profile.UnfocusedAppearance()) { profile.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + profile.UnfocusedAppearance().WindowRoot(*this); } - auto state{ winrt::make(profile, - *this) }; - state.FocusDeleteButton(focusDeleteButton); _PreNavigateHelper(); - _SetupProfileEventHandling(state); + _SetupProfileEventHandling(profile); - contentFrame().Navigate(xaml_typename(), state); + contentFrame().Navigate(xaml_typename(), profile); const auto crumb = winrt::make(box_value(profile), profile.Name(), BreadcrumbSubPage::None); _breadcrumbs.Append(crumb); @@ -546,9 +543,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { auto profileVM = _viewModelForProfile(profile, _settingsClone); profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + profileVM.DefaultAppearance().WindowRoot(*this); if (profileVM.UnfocusedAppearance()) { profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + profileVM.UnfocusedAppearance().WindowRoot(*this); } auto navItem = _CreateProfileNavViewItem(profileVM); menuItems.Append(navItem); @@ -573,9 +572,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation const auto newProfile{ profile ? profile : _settingsClone.CreateNewProfile() }; const auto profileViewModel{ _viewModelForProfile(newProfile, _settingsClone) }; profileViewModel.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); + profileViewModel.DefaultAppearance().WindowRoot(*this); if (profileViewModel.UnfocusedAppearance()) { profileViewModel.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); + profileViewModel.UnfocusedAppearance().WindowRoot(*this); } const auto navItem{ _CreateProfileNavViewItem(profileViewModel) }; SettingsNav().MenuItems().InsertAt(index, navItem); diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.h b/src/cascadia/TerminalSettingsEditor/MainPage.h index ba86c6d50fd..d0e792700f6 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.h +++ b/src/cascadia/TerminalSettingsEditor/MainPage.h @@ -61,11 +61,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void _DeleteProfile(const Windows::Foundation::IInspectable sender, const Editor::DeleteProfileEventArgs& args); void _AddProfileHandler(const winrt::guid profileGuid); - void _SetupProfileEventHandling(const winrt::Microsoft::Terminal::Settings::Editor::ProfilePageNavigationState state); + void _SetupProfileEventHandling(const winrt::Microsoft::Terminal::Settings::Editor::ProfileViewModel profile); void _PreNavigateHelper(); void _Navigate(hstring clickedItemTag, BreadcrumbSubPage subPage); - void _Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage, const bool focusDeleteButton = false); + void _Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage); winrt::Microsoft::Terminal::Settings::Editor::ColorSchemesPageViewModel _colorSchemesPageVM{ nullptr }; diff --git a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj index 935ce529e39..754c492bc6e 100644 --- a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj +++ b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj @@ -78,10 +78,6 @@ MainPage.xaml - - Profiles.idl - Code - ProfileViewModel.idl Code @@ -323,9 +319,6 @@ MainPage.xaml - - Code - diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index 70c79212216..2e6c5e17235 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -248,7 +248,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _unfocusedAppearanceViewModel = winrt::make(_profile.UnfocusedAppearance().try_as()); _unfocusedAppearanceViewModel.SchemesPageVM(DefaultAppearance().SchemesPageVM()); - _unfocusedAppearanceViewModel.WindowRoot(_WindowRoot); + _unfocusedAppearanceViewModel.WindowRoot(DefaultAppearance().WindowRoot()); _NotifyChanges(L"UnfocusedAppearance", L"HasUnfocusedAppearance", L"ShowUnfocusedAppearance"); } diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h deleted file mode 100644 index 5384d90d891..00000000000 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#pragma once - -#include "ProfilePageNavigationState.g.h" -#include "ProfileViewModel.h" -#include "Utils.h" -#include "ViewModelHelpers.h" -#include "Appearances.h" - -namespace winrt::Microsoft::Terminal::Settings::Editor::implementation -{ - struct ProfilePageNavigationState : ProfilePageNavigationStateT - { - public: - ProfilePageNavigationState(const Editor::ProfileViewModel& viewModel, - const IHostedInWindow& windowRoot) : - _Profile{ viewModel } - { - auto profile{ winrt::get_self(viewModel) }; - profile->WindowRoot(windowRoot); - - viewModel.DefaultAppearance().WindowRoot(windowRoot); - - if (viewModel.UnfocusedAppearance()) - { - viewModel.UnfocusedAppearance().WindowRoot(windowRoot); - } - } - WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr); - WINRT_PROPERTY(bool, FocusDeleteButton, false); - }; -}; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl deleted file mode 100644 index 9bedfd36523..00000000000 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import "MainPage.idl"; -import "ProfileViewModel.idl"; - -namespace Microsoft.Terminal.Settings.Editor -{ - runtimeclass ProfilePageNavigationState - { - ProfileViewModel Profile { get; }; - Boolean FocusDeleteButton; - }; -} diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp index 79c0edffd76..00bdff6d0b6 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp @@ -4,6 +4,7 @@ #include "pch.h" #include "Profiles_Advanced.h" #include "Profiles_Advanced.g.cpp" +#include "ProfileViewModel.h" #include "EnumEntry.h" #include @@ -20,8 +21,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void Profiles_Advanced::OnNavigatedTo(const NavigationEventArgs& e) { - auto state{ e.Parameter().as() }; - _Profile = state.Profile(); + _Profile = e.Parameter().as(); } void Profiles_Advanced::OnNavigatedFrom(const NavigationEventArgs& /*e*/) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.idl b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.idl index 44a1cbca91a..befaf556aab 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.idl @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import "Profiles.idl"; +import "ProfileViewModel.idl"; namespace Microsoft.Terminal.Settings.Editor { diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.cpp b/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.cpp index 6a5963800f0..9a621603748 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.cpp @@ -4,7 +4,7 @@ #include "pch.h" #include "Profiles_Appearance.h" #include "Profiles_Appearance.g.cpp" -#include "Profiles.h" +#include "ProfileViewModel.h" #include "PreviewConnection.h" #include "EnumEntry.h" @@ -28,8 +28,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void Profiles_Appearance::OnNavigatedTo(const NavigationEventArgs& e) { - auto state{ e.Parameter().as() }; - _Profile = state.Profile(); + _Profile = e.Parameter().as(); // generate the font list, if we don't have one if (_Profile.CompleteFontList() || !_Profile.MonospaceFontList()) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.idl b/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.idl index dff812912a7..b80311ca408 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Appearance.idl @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import "Profiles.idl"; +import "ProfileViewModel.idl"; namespace Microsoft.Terminal.Settings.Editor { diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Base.cpp b/src/cascadia/TerminalSettingsEditor/Profiles_Base.cpp index a0a0ab61e46..705a09a1de8 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Base.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Base.cpp @@ -4,7 +4,7 @@ #include "pch.h" #include "Profiles_Base.h" #include "Profiles_Base.g.cpp" -#include "Profiles.h" +#include "ProfileViewModel.h" #include #include "..\WinRTUtils\inc\Utils.h" @@ -29,31 +29,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void Profiles_Base::OnNavigatedTo(const NavigationEventArgs& e) { - auto state{ e.Parameter().as() }; - _Profile = state.Profile(); + _Profile = e.Parameter().as(); // Check the use parent directory box if the starting directory is empty if (_Profile.StartingDirectory().empty()) { StartingDirectoryUseParentCheckbox().IsChecked(true); } - - _layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [state, this](auto /*s*/, auto /*e*/) { - // This event fires every time the layout changes, but it is always the last one to fire - // in any layout change chain. That gives us great flexibility in finding the right point - // at which to initialize our renderer (and our terminal). - // Any earlier than the last layout update and we may not know the terminal's starting size. - - // Only let this succeed once. - _layoutUpdatedRevoker.revoke(); - - if (state.FocusDeleteButton()) - { - DeleteButton().Focus(FocusState::Programmatic); - state.FocusDeleteButton(false); - ProfilesBase_ScrollView().ChangeView(nullptr, ProfilesBase_ScrollView().ScrollableHeight(), nullptr); - } - }); } void Profiles_Base::OnNavigatedFrom(const NavigationEventArgs& /*e*/) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Base.h b/src/cascadia/TerminalSettingsEditor/Profiles_Base.h index 42067438ee1..c2bdd33d31d 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Base.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Base.h @@ -29,7 +29,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation private: Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _ViewModelChangedRevoker; - winrt::Windows::UI::Xaml::Controls::SwapChainPanel::LayoutUpdated_revoker _layoutUpdatedRevoker; }; }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Base.idl b/src/cascadia/TerminalSettingsEditor/Profiles_Base.idl index a0cd1b88aba..b076fe75a3c 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Base.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Base.idl @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import "Profiles.idl"; +import "ProfileViewModel.idl"; namespace Microsoft.Terminal.Settings.Editor { From e5ef83920f76ebb61f7216840421ac8f2f7b86cf Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 19 Dec 2022 14:20:26 -0800 Subject: [PATCH 4/9] helper --- .../TerminalSettingsEditor/MainPage.cpp | 32 +++---------------- .../ProfileViewModel.cpp | 11 +++++++ .../TerminalSettingsEditor/ProfileViewModel.h | 2 ++ .../ProfileViewModel.idl | 3 ++ 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index 3720d8d6d06..c70e3cbf69b 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -390,13 +390,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation else if (clickedItemTag == globalProfileTag) { auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults(), _settingsClone) }; - profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); - profileVM.DefaultAppearance().WindowRoot(*this); - if (profileVM.UnfocusedAppearance()) - { - profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); - profileVM.UnfocusedAppearance().WindowRoot(*this); - } + profileVM.SetupAppearances(_colorSchemesPageVM, *this); profileVM.IsBaseLayer(true); _SetupProfileEventHandling(profileVM); @@ -449,13 +443,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // - profile - the profile object we are getting a view of void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage) { - profile.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); - profile.DefaultAppearance().WindowRoot(*this); - if (profile.UnfocusedAppearance()) - { - profile.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); - profile.UnfocusedAppearance().WindowRoot(*this); - } + profile.SetupAppearances(_colorSchemesPageVM, *this); _PreNavigateHelper(); @@ -542,13 +530,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation if (!profile.Deleted()) { auto profileVM = _viewModelForProfile(profile, _settingsClone); - profileVM.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); - profileVM.DefaultAppearance().WindowRoot(*this); - if (profileVM.UnfocusedAppearance()) - { - profileVM.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); - profileVM.UnfocusedAppearance().WindowRoot(*this); - } + profileVM.SetupAppearances(_colorSchemesPageVM, *this); auto navItem = _CreateProfileNavViewItem(profileVM); menuItems.Append(navItem); } @@ -571,13 +553,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { const auto newProfile{ profile ? profile : _settingsClone.CreateNewProfile() }; const auto profileViewModel{ _viewModelForProfile(newProfile, _settingsClone) }; - profileViewModel.DefaultAppearance().SchemesPageVM(_colorSchemesPageVM); - profileViewModel.DefaultAppearance().WindowRoot(*this); - if (profileViewModel.UnfocusedAppearance()) - { - profileViewModel.UnfocusedAppearance().SchemesPageVM(_colorSchemesPageVM); - profileViewModel.UnfocusedAppearance().WindowRoot(*this); - } + profileViewModel.SetupAppearances(_colorSchemesPageVM, *this); const auto navItem{ _CreateProfileNavViewItem(profileViewModel) }; SettingsNav().MenuItems().InsertAt(index, navItem); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index 2e6c5e17235..3d64318fc03 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -349,4 +349,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation auto deleteProfileArgs{ winrt::make_self(Guid()) }; _DeleteProfileHandlers(*this, *deleteProfileArgs); } + + void ProfileViewModel::SetupAppearances(Editor::ColorSchemesPageViewModel colorSchemesPageVM, Editor::IHostedInWindow windowRoot) + { + DefaultAppearance().SchemesPageVM(colorSchemesPageVM); + DefaultAppearance().WindowRoot(windowRoot); + if (UnfocusedAppearance()) + { + UnfocusedAppearance().SchemesPageVM(colorSchemesPageVM); + UnfocusedAppearance().WindowRoot(windowRoot); + } + } } diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index e8381cc3f24..8bc78617600 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -23,6 +23,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::TerminalSettings TermSettings() const; void DeleteProfile(); + void SetupAppearances(Editor::ColorSchemesPageViewModel colorSchemesPageVM, Editor::IHostedInWindow windowRoot); + // bell style bits bool IsBellStyleFlagSet(const uint32_t flag); void SetBellStyleAudible(winrt::Windows::Foundation::IReference on); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl index 143fa3ca477..7497068f4b2 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl @@ -4,6 +4,7 @@ import "EnumEntry.idl"; import "MainPage.idl"; import "Appearances.idl"; +import "ColorSchemesPageViewModel.idl"; #include "ViewModelHelpers.idl.h" @@ -34,6 +35,8 @@ namespace Microsoft.Terminal.Settings.Editor event Windows.Foundation.TypedEventHandler DeleteProfile; + void SetupAppearances(ColorSchemesPageViewModel colorSchemesPageVM, IHostedInWindow windowRoot); + void SetAcrylicOpacityPercentageValue(Double value); void SetPadding(Double value); From 6593895b34a25dec9f411eea3ba5b1d000c0887a Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 19 Dec 2022 14:35:58 -0800 Subject: [PATCH 5/9] initialize profileVMs after schemesPageVM --- src/cascadia/TerminalSettingsEditor/MainPage.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index c70e3cbf69b..dc7206da0bb 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -56,8 +56,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { InitializeComponent(); - _InitializeProfilesList(); - _colorSchemesPageVM = winrt::make(_settingsClone); _colorSchemesPageViewModelChangedRevoker = _colorSchemesPageVM.PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) { const auto settingName{ args.PropertyName() }; @@ -84,6 +82,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } }); + // Make sure to initialize the profiles _after_ we have initialized the color schemes page VM, because we pass + // that VM into the appearance VMs within the profiles + _InitializeProfilesList(); + Automation::AutomationProperties::SetHelpText(SaveButton(), RS_(L"Settings_SaveSettingsButton/[using:Windows.UI.Xaml.Controls]ToolTipService/ToolTip")); Automation::AutomationProperties::SetHelpText(ResetButton(), RS_(L"Settings_ResetSettingsButton/[using:Windows.UI.Xaml.Controls]ToolTipService/ToolTip")); Automation::AutomationProperties::SetHelpText(OpenJsonNavItem(), RS_(L"Nav_OpenJSON/[using:Windows.UI.Xaml.Controls]ToolTipService/ToolTip")); @@ -443,8 +445,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // - profile - the profile object we are getting a view of void MainPage::_Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage) { - profile.SetupAppearances(_colorSchemesPageVM, *this); - _PreNavigateHelper(); _SetupProfileEventHandling(profile); From 451dae76dca86f9807438c90e8a493fac72dd3e0 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 20 Dec 2022 11:11:20 -0800 Subject: [PATCH 6/9] chips in the dropdown --- .../TerminalSettingsEditor/Appearances.xaml | 123 +++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index e66dc52c186..37c2934fb50 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -29,6 +29,14 @@ + + + + @@ -49,7 +57,120 @@ Style="{StaticResource ComboBoxSettingStyle}"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 878d1d72a5fc8e50bda1869df1211e37371cbf30 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 20 Dec 2022 11:16:12 -0800 Subject: [PATCH 7/9] format --- .../TerminalSettingsEditor/Appearances.xaml | 220 +++++++++--------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 37c2934fb50..f9e4ff7ebd5 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -60,117 +60,117 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + RowSpacing="1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 555018840e27b05e1d8ed97ace087fb69a7ea293 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 19 Jan 2023 09:12:00 -0800 Subject: [PATCH 8/9] padding, wordellipsis --- src/cascadia/TerminalSettingsEditor/Appearances.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 48bc2f30985..29165d64697 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -54,6 +54,7 @@ SettingOverrideSource="{x:Bind Appearance.DarkColorSchemeNameOverrideSource, Mode=OneWay}"> @@ -166,6 +167,7 @@ Margin="4,0,4,0" HorizontalAlignment="Center" VerticalAlignment="Center" + TextTrimming="WordEllipsis" AutomationProperties.AccessibilityView="Raw" FontFamily="Cascadia Code" Foreground="{x:Bind local:Converters.ColorToBrush(ForegroundColor.Color), Mode=OneWay}" From 388a7d697673f1acf23151809752650ebacaaea8 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 19 Jan 2023 13:12:38 -0800 Subject: [PATCH 9/9] format --- src/cascadia/TerminalSettingsEditor/Appearances.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 29165d64697..076522ff877 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -52,9 +52,9 @@ ClearSettingValue="{x:Bind Appearance.ClearColorScheme}" HasSettingValue="{x:Bind Appearance.HasDarkColorSchemeName, Mode=OneWay}" SettingOverrideSource="{x:Bind Appearance.DarkColorSchemeNameOverrideSource, Mode=OneWay}"> - @@ -167,11 +167,11 @@ Margin="4,0,4,0" HorizontalAlignment="Center" VerticalAlignment="Center" - TextTrimming="WordEllipsis" AutomationProperties.AccessibilityView="Raw" FontFamily="Cascadia Code" Foreground="{x:Bind local:Converters.ColorToBrush(ForegroundColor.Color), Mode=OneWay}" - Text="{x:Bind Name, Mode=OneWay}" /> + Text="{x:Bind Name, Mode=OneWay}" + TextTrimming="WordEllipsis" />