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

Rejuvenate the color schemes page #13269

Merged
merged 76 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d447166
invoking rightmost breadcrumb does nothing
PankajBhojwani Feb 2, 2022
5430de6
partway through color scheme MVVM
PankajBhojwani Feb 4, 2022
447c1be
main page now holds vector of csvms
PankajBhojwani Feb 4, 2022
1342d92
conflict
PankajBhojwani May 4, 2022
93b8ecb
need to update event handlers
PankajBhojwani May 10, 2022
987002e
propagate changes to scheme
PankajBhojwani May 11, 2022
f5fef4e
color table colors ...
PankajBhojwani May 18, 2022
152974d
delete works
PankajBhojwani May 20, 2022
65fc789
page view model is up
PankajBhojwani May 24, 2022
a51c166
rename and delete work
PankajBhojwani May 25, 2022
d0c9881
add new works
PankajBhojwani May 25, 2022
946f10a
remove nav state
PankajBhojwani May 25, 2022
9be1b68
some fixes
PankajBhojwani May 26, 2022
322766d
select last selected scheme
PankajBhojwani May 26, 2022
ac75ed3
move to header
PankajBhojwani May 26, 2022
c91ade5
neaten
PankajBhojwani May 26, 2022
219a329
update settings
PankajBhojwani May 27, 2022
0fe0612
Format
PankajBhojwani May 27, 2022
79d92d4
nits
PankajBhojwani May 27, 2022
face837
nits
PankajBhojwani May 31, 2022
264f4dd
rename property
PankajBhojwani May 31, 2022
d76c3c3
fix settings reload issue
PankajBhojwani Jun 1, 2022
44cf7f6
don't expose model object
PankajBhojwani Jun 1, 2022
003f9fc
rename
PankajBhojwani Jun 1, 2022
eee069d
init in ctor
PankajBhojwani Jun 1, 2022
9c297b6
omg i forgot to add the labels back in
PankajBhojwani Jun 10, 2022
cb0fafa
start revamping cs page
PankajBhojwani Jun 10, 2022
c311955
get rid of rename mode stuff, first step of moving color grid into ex…
PankajBhojwani Jun 10, 2022
2b25c98
color chips
PankajBhojwani Jun 10, 2022
a615077
split grid
PankajBhojwani Jun 10, 2022
66e0ef9
preview grid
PankajBhojwani Jun 14, 2022
c23c7db
format
PankajBhojwani Jun 14, 2022
9e8516d
add border
PankajBhojwani Jun 14, 2022
5c70fdf
move disclaimer into the container
PankajBhojwani Jun 14, 2022
f1ee5a5
nits
PankajBhojwani Jun 14, 2022
941e7c0
move in box schemes to cpp
PankajBhojwani Jun 15, 2022
f71d68c
first pass of list view
PankajBhojwani Jun 27, 2022
1727a3a
need new page
PankajBhojwani Jun 28, 2022
c2aaa07
new page boilerplate
PankajBhojwani Jun 29, 2022
43f8e70
breadcrumb works
PankajBhojwani Jul 1, 2022
a5ded1d
preview grid
PankajBhojwani Jul 5, 2022
398285a
in one expander
PankajBhojwani Jul 5, 2022
69db27c
colors header
PankajBhojwani Jul 6, 2022
bbf77e2
some fixes
PankajBhojwani Jul 6, 2022
c133e37
breadcrumb changes
PankajBhojwani Jul 7, 2022
be8a3f9
StartExpanded dependency property on setting container
PankajBhojwani Jul 7, 2022
1971e83
nits
PankajBhojwani Jul 7, 2022
1e82b51
format
PankajBhojwani Jul 7, 2022
52c3a4b
tab stop false
PankajBhojwani Jul 7, 2022
5ca7a16
conflict
PankajBhojwani Jul 11, 2022
670ec6b
conflict
PankajBhojwani Jul 11, 2022
e1a0be8
use macro instead
PankajBhojwani Jul 11, 2022
fbe2ebd
delete
PankajBhojwani Jul 11, 2022
d65b448
some keyboard navigation stuff
PankajBhojwani Jul 12, 2022
63de875
focus to list view
PankajBhojwani Jul 14, 2022
ab13a8d
narrator now reads this
PankajBhojwani Jul 14, 2022
23ef052
builds but opening sui causes crash
PankajBhojwani Jul 29, 2022
bbd398c
fix random diffs
PankajBhojwani Jul 29, 2022
38e5d28
add new back
PankajBhojwani Jul 29, 2022
03a9caa
conflict
PankajBhojwani Aug 2, 2022
1088ca4
zzz this took a while to find
PankajBhojwani Aug 2, 2022
97d21b5
an experiment as mentioned by kmahoney
zadjii-msft Aug 12, 2022
4c06258
Merge remote-tracking branch 'origin/main' into dev/migrie/b/12413-On…
zadjii-msft Aug 15, 2022
144b3b3
comments
zadjii-msft Aug 15, 2022
ccbc569
Merge branch 'main' into dev/pabhoj/sui_schemes_page
carlos-zamora Aug 23, 2022
1e4cf55
address feedback from bug bashes (and Dustin)
carlos-zamora Aug 24, 2022
6e6c0fd
fix color chip misalignment
carlos-zamora Aug 24, 2022
695d4fa
Merge branch 'main' into dev/pabhoj/sui_schemes_page
carlos-zamora Aug 25, 2022
a1ff023
bugfix: don't crash when we discard changes on deleted scheme
carlos-zamora Aug 25, 2022
6e6b780
use _NotifyChanges; disable Edit btn
carlos-zamora Aug 25, 2022
24362b7
Merge remote-tracking branch 'origin/dev/migrie/b/12413-OnUnhandledEx…
carlos-zamora Aug 25, 2022
c9d28b4
address PR feedback
carlos-zamora Aug 29, 2022
ba499ad
add icons to buttons & test w/ narrator
carlos-zamora Aug 29, 2022
5a7ab36
add 'default' tag
carlos-zamora Aug 30, 2022
b042918
address Dustin's PR feedback
carlos-zamora Aug 31, 2022
acd8b71
last second polish
carlos-zamora Aug 31, 2022
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
6 changes: 5 additions & 1 deletion src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

bool ColorSchemeViewModel::RequestRename(winrt::hstring newName)
{
return _parentPageVM.RequestRenameCurrentScheme(newName);
if (const auto parentPageVM{ _parentPageVM.get() })
{
return parentPageVM.RequestRenameCurrentScheme(newName);
}
return false;
}

void ColorSchemeViewModel::Name(winrt::hstring newName)
Expand Down
7 changes: 1 addition & 6 deletions src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
private:
winrt::hstring _Name;
Model::ColorScheme _scheme;
Editor::ColorSchemesPageViewModel _parentPageVM{ nullptr };
weak_ref<Editor::ColorSchemesPageViewModel> _parentPageVM{ nullptr };

void _ColorEntryChangedHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);
};
Expand All @@ -69,8 +69,3 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Windows::UI::Color _color;
};
};

namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
{
BASIC_FACTORY(ColorSchemeViewModel);
}
4 changes: 1 addition & 3 deletions src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ namespace Microsoft.Terminal.Settings.Editor
{
runtimeclass ColorSchemeViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged, Windows.Foundation.IStringable
{
ColorSchemeViewModel(Microsoft.Terminal.Settings.Model.ColorScheme scheme, ColorSchemesPageViewModel parentPageVM);

String Name;
Boolean IsInBoxScheme;

Boolean RequestRename(String newName);
Boolean RequestRename(String newName);

// Terminal Colors
Windows.Foundation.Collections.IVector<ColorTableEntry> NonBrightColorTable;
Expand Down
10 changes: 7 additions & 3 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
InitializeComponent();

Automation::AutomationProperties::SetName(AddNewButton(), RS_(L"ColorScheme_AddNewButton/Text"));
Automation::AutomationProperties::SetName(DeleteButton(), RS_(L"ColorScheme_DeleteButton/Text"));
}

void ColorSchemes::OnNavigatedTo(const NavigationEventArgs& e)
Expand Down Expand Up @@ -64,7 +63,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
itemContainer.as<ContentControl>().Focus(FocusState::Programmatic);
}

void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const winrt::Windows::UI::Xaml::RoutedEventArgs& /*e*/)
void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
{
if (const auto newSchemeVM{ _ViewModel.RequestAddNew() })
{
Expand All @@ -73,12 +72,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

void ColorSchemes::Edit_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
{
_ViewModel.RequestEditSelectedScheme();
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
}

void ColorSchemes::ListView_PreviewKeyDown(const IInspectable& /*sender*/, const winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs& e)
{
if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Enter)
{
// Treat this as if 'edit' was clicked
_ViewModel.Edit_Click(nullptr, nullptr);
_ViewModel.RequestEditSelectedScheme();
e.Handled(true);
}
else if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Delete)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void ListView_PreviewKeyDown(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs& e);
void ListView_SelectionChanged(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs& e);
void DeleteConfirmation_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void Edit_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);

WINRT_PROPERTY(Model::ColorScheme, CurrentColorScheme, nullptr);
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemesPageViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
Expand Down
13 changes: 4 additions & 9 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,23 @@
Orientation="Horizontal"
XYFocusKeyboardNavigation="Enabled">
<Button x:Name="EditButton"
Click="{x:Bind ViewModel.Edit_Click}"
Click="Edit_Click"
IsEnabled="{x:Bind ViewModel.HasCurrentScheme, Mode=OneWay}"
Style="{StaticResource BrowseButtonStyle}">
<TextBlock x:Uid="ColorScheme_EditButton"
Style="{StaticResource IconButtonTextBlockStyle}" />
<TextBlock x:Uid="ColorScheme_EditButton" />
</Button>

<Button x:Name="AddNewButton"
Click="AddNew_Click"
Style="{StaticResource BrowseButtonStyle}">
<TextBlock x:Uid="ColorScheme_AddNewButton"
Style="{StaticResource IconButtonTextBlockStyle}" />
<TextBlock x:Uid="ColorScheme_AddNewButton" />
</Button>

<Button x:Name="DeleteButton"
x:Uid="ColorScheme_DeleteButton"
Margin="10,0,0,0"
IsEnabled="{x:Bind ViewModel.CanDeleteCurrentScheme, Mode=OneWay}"
Style="{StaticResource DeleteButtonStyle}">
<Button.Content>
<TextBlock x:Uid="ColorScheme_DeleteButton"
Style="{StaticResource IconButtonTextBlockStyle}" />
</Button.Content>
<Button.Flyout>
<Flyout>
<StackPanel>
Expand Down
19 changes: 11 additions & 8 deletions src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return _CurrentScheme != nullptr;
}

void ColorSchemesPageViewModel::Edit_Click(const IInspectable& /*sender*/, const winrt::Windows::UI::Xaml::RoutedEventArgs& /*e*/)
{
CurrentPage(ColorSchemesSubPage::EditColorScheme);
}

void ColorSchemesPageViewModel::_MakeColorSchemeVMsHelper()
{
std::vector<Editor::ColorSchemeViewModel> allColorSchemes;
Expand All @@ -90,7 +85,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
for (const auto& pair : colorSchemeMap)
{
const auto scheme = pair.Value();
Editor::ColorSchemeViewModel viewModel{ scheme, *this };
auto viewModel{ winrt::make<ColorSchemeViewModel>(scheme, *this) };
viewModel.IsInBoxScheme(std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), scheme.Name()) != std::end(InBoxSchemes));
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
allColorSchemes.emplace_back(viewModel);

Expand All @@ -113,7 +108,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_settings.GlobalSettings().AddColorScheme(scheme);

// Construct the new color scheme VM
const Editor::ColorSchemeViewModel schemeVM{ scheme, *this };
const auto schemeVM{ winrt::make<ColorSchemeViewModel>(scheme, *this) };
_AllColorSchemes.Append(schemeVM);
_viewModelToSchemeMap.Insert(schemeVM, scheme);
return schemeVM;
Expand Down Expand Up @@ -173,12 +168,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_settings.UpdateColorSchemeReferences(name, L"Campbell");
}

void ColorSchemesPageViewModel::RequestEditSelectedScheme()
{
if (_CurrentScheme)
{
CurrentPage(ColorSchemesSubPage::EditColorScheme);
}
}

bool ColorSchemesPageViewModel::CanDeleteCurrentScheme() const
{
if (_CurrentScheme)
{
// Only allow this color scheme to be deleted if it's not provided in-box
return std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), _CurrentScheme.Name()) == std::end(InBoxSchemes);
return !_CurrentScheme.IsInBoxScheme();
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Editor::ColorSchemeViewModel RequestAddNew();
bool RequestRenameCurrentScheme(winrt::hstring newName);
void RequestDeleteCurrentScheme();

void Edit_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void RequestEditSelectedScheme();

bool CanDeleteCurrentScheme() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ namespace Microsoft.Terminal.Settings.Editor
ColorSchemeViewModel RequestAddNew();
Boolean RequestRenameCurrentScheme(String newName);
void RequestDeleteCurrentScheme();
void RequestEditSelectedScheme();

ColorSchemeViewModel CurrentScheme;
Boolean HasCurrentScheme { get; };
Boolean CanDeleteCurrentScheme { get; };
ColorSchemesSubPage CurrentPage;
Windows.Foundation.Collections.IObservableVector<ColorSchemeViewModel> AllColorSchemes { get; };

void Edit_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs e);
}
}
12 changes: 10 additions & 2 deletions src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@
<value>Edit</value>
<comment>Button label that edits the currently selected color scheme.</comment>
</data>
<data name="ColorScheme_DeleteButton.Text" xml:space="preserve">
<data name="ColorScheme_DeleteButton.Content" xml:space="preserve">
<value>Delete</value>
<comment>Button label that deletes the selected color scheme.</comment>
</data>
Expand Down Expand Up @@ -1233,7 +1233,7 @@
<value>Rename</value>
<comment>Text label for a button that can be used to begin the renaming process.</comment>
</data>
<data name="ColorScheme_DeleteButtonDisclaimerInBox" xml:space="preserve">
<data name="ColorScheme_DeleteButtonDisclaimerInBox.Text" xml:space="preserve">
<value>This color scheme cannot be deleted or renamed because it is included by default.</value>
<comment>Disclaimer presented next to the delete button when it is disabled.</comment>
</data>
Expand Down Expand Up @@ -1345,6 +1345,14 @@
<value>Reset to inherited value.</value>
<comment>This button will remove a user's customization from a given setting, restoring it to the value that the profile inherited. This is a text label on a button.</comment>
</data>
<data name="ColorScheme_TerminalColorsHeader.Text" xml:space="preserve">
<value>Terminal colors</value>
<comment>A header for a grouping of colors in the color scheme. These colors are used for basic parts of the terminal.</comment>
</data>
<data name="ColorScheme_SystemColorsHeader.Text" xml:space="preserve">
<value>System colors</value>
<comment>A header for a grouping of colors in the color scheme. These colors are used for functional parts of the terminal.</comment>
</data>
<data name="ColorScheme_ColorsHeader.Header" xml:space="preserve">
<value>Colors</value>
<comment>A header for the grouping of colors in the color scheme.</comment>
Expand Down