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 UI for adding, renaming, and deleting a color scheme #8403

Merged
121 commits merged into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
9493ca0
Add a Settings UI Prototype (#7370)
carlos-zamora Sep 17, 2020
51ba054
Convert TerminalSettingsEditor into a DLL (#7675)
leonMSFT Sep 22, 2020
a305c0d
Add a Settings UI Prototype (#7370)
carlos-zamora Sep 17, 2020
91d2148
Convert TerminalSettingsEditor into a DLL (#7675)
leonMSFT Sep 22, 2020
b87f6d6
Merge branch 'feature/settings-ui' of github.com:microsoft/terminal i…
leonMSFT Sep 24, 2020
bde5d5e
Add functionality to open the Settings UI tab through openSettings (#…
leonMSFT Oct 6, 2020
09677fd
merging from master
leonMSFT Oct 7, 2020
29578d3
Add settings UI string localization (#7833)
cinnamon-msft Oct 9, 2020
e002752
Merge branch 'master' into feature/settings-ui
carlos-zamora Oct 12, 2020
0ce05b5
Merge branch 'master' into feature/settings-ui
carlos-zamora Oct 16, 2020
c14824e
Add save button to settings UI (#7949)
cinnamon-msft Oct 16, 2020
8213cf1
Make sure TSE pulls in the wildcard resource targets (#7967)
DHowett Oct 19, 2020
788e685
Merge remote-tracking branch 'origin/master' into HEAD
DHowett Oct 19, 2020
b0b5fc1
Replace ObjectModel references in SUI (#7970)
leonMSFT Oct 21, 2020
f5e9d95
merge from master
leonMSFT Oct 21, 2020
3b04ba9
Add scrollviewers to settings UI (#7998)
cinnamon-msft Oct 22, 2020
44d16b8
Add localization to settings tab (#8012)
cinnamon-msft Oct 22, 2020
8a10d29
Update settings UI navigation icons (#8013)
cinnamon-msft Oct 22, 2020
d3d128d
Merge remote-tracking branch 'origin/master' into HEAD
DHowett Oct 22, 2020
52b0915
Merge remote-tracking branch 'origin/main' into HEAD
DHowett Oct 23, 2020
15b4565
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Oct 27, 2020
1ef9f13
Hook up the Settings UI ColorSchemes page (#8049)
leonMSFT Oct 27, 2020
9c4d77a
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Oct 27, 2020
b757e82
Fix build for broken merge in 15b4565c7
DHowett Oct 27, 2020
22805bd
Fix spacing on profile advanced page (#8065)
cinnamon-msft Oct 27, 2020
78545a0
Merge branch 'main' into feature/settings-ui
carlos-zamora Oct 28, 2020
1a36ca6
Merge branch 'main' into feature/settings-ui
carlos-zamora Oct 28, 2020
e2dcd16
Hide incomplete settings UI features (#8078)
cinnamon-msft Oct 28, 2020
9fc79d5
Hook up the Settings UI JSON button (#8059)
leonMSFT Oct 28, 2020
60b154b
Change save to apply in SUI (#8082)
cinnamon-msft Oct 28, 2020
c8fd30e
Fix the Settings UI Color Pickers (#8079)
leonMSFT Oct 28, 2020
96cbbb7
Add border to footer in SUI (#8083)
cinnamon-msft Oct 28, 2020
666e179
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Oct 29, 2020
18ac211
Fix showTabsInTitlebar SUI logic (#8088)
cinnamon-msft Oct 29, 2020
81ca24b
Make ITab an unsealed runtimeclass (#8053)
carlos-zamora Oct 29, 2020
6f56738
Make all nav items top level and remove addprofile (#8089)
cinnamon-msft Oct 30, 2020
c0bca31
Add missing settings to Settings UI (#8116)
carlos-zamora Oct 30, 2020
314baf9
Remove dead SUI files (#8119)
carlos-zamora Oct 30, 2020
aef3336
Update SUI nav for profiles (#8118)
cinnamon-msft Oct 30, 2020
a9dbe8f
Remove code to navigate to home page on SUI launch (#8134)
leonMSFT Nov 3, 2020
a8d52c1
Introduce a way to bind an Enum setting for the Settings UI (#8086)
leonMSFT Nov 3, 2020
140784f
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 3, 2020
644f732
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 4, 2020
a6eb2da
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 4, 2020
c58321a
Renormalize TSE Resources.resw to CRLF
DHowett Nov 4, 2020
7c992c2
Change reset button to discard changes (#8139)
cinnamon-msft Nov 4, 2020
36b2e29
Bind default profile global setting (#8136)
carlos-zamora Nov 4, 2020
48ad994
List all profiles in the SUI Navigation View (#8149)
leonMSFT Nov 5, 2020
f1af7ab
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 6, 2020
41d6cdd
Introduce Page parameters to SUI (#8165)
carlos-zamora Nov 6, 2020
ffa2252
Include icons in SUI DefaultProfile dropdown (#8174)
carlos-zamora Nov 6, 2020
851fb02
Merge branch 'main' into feature/settings-ui
carlos-zamora Nov 10, 2020
c731b0f
Merge branch 'main' into feature/settings-ui
carlos-zamora Nov 17, 2020
f80ee27
fix build: remove deleted function call
carlos-zamora Nov 17, 2020
5ca0db1
Polish layout for Settings UI (#8266)
carlos-zamora Nov 18, 2020
79a99bd
Merge branch 'main' into feature/settings-ui
carlos-zamora Nov 18, 2020
3cf7552
Remove dead code; Add default icon; Rename Base Layer (#8347)
carlos-zamora Nov 23, 2020
ddc4593
Merge remote-tracking branch 'origin/main' into feature/settings-ui
carlos-zamora Nov 23, 2020
1a224cc
Add new BellStyle localization
carlos-zamora Nov 24, 2020
05d1a7b
Implement UI for Rename/Delete
carlos-zamora Nov 24, 2020
36fef26
Implement ColorScheme Add/Rename/Delete
carlos-zamora Nov 25, 2020
0943ef8
address simple PR feedback
carlos-zamora Nov 26, 2020
f9fc986
Propagate IslandWindow's HWND into any component that needs it (#8391)
DHowett Nov 30, 2020
879ed1b
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 30, 2020
cbcda1a
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Nov 30, 2020
62aa0ce
Bind Profile Color Schemes (#8388)
carlos-zamora Dec 1, 2020
2f747a7
Hook up the Save and Reset buttons (#8348)
carlos-zamora Dec 1, 2020
5770d23
Bind Launch Mode/Size, BI Opacity, Opacity, and FontWeight (#8219)
carlos-zamora Dec 3, 2020
540fbb3
Merge branch 'main' into feature/settings-ui
carlos-zamora Dec 3, 2020
16ca947
Merge branch 'feature/settings-ui' into dev/cazamor/sui/rename-and-de…
carlos-zamora Dec 3, 2020
6e41aec
Color Schemes - Delete Button
carlos-zamora Dec 4, 2020
1a11ae0
Add font fallback to profile.icon
carlos-zamora Dec 4, 2020
722bf70
Bind visibility and value for Cursor Height
carlos-zamora Dec 4, 2020
4e3b6e4
Move ScrollbarVisibility to Appearance (below Padding)
carlos-zamora Dec 4, 2020
0dedf38
Merge remote-tracking branch 'origin/main' into feature/settings-ui
DHowett Dec 5, 2020
9ff3a45
Add tooltip to 'open json' button
carlos-zamora Dec 5, 2020
812c36c
Fix dangling ReapplyCompactTabSize from merge
DHowett Dec 5, 2020
af17c59
Update TSE to Microsoft.UI.Xaml 2.5 stable
DHowett Dec 5, 2020
bac748e
polish styling for Startup page
carlos-zamora Dec 7, 2020
ada4a0b
polish styling for Interaction page
carlos-zamora Dec 7, 2020
a20138c
polish styling for Appearance page
carlos-zamora Dec 7, 2020
9daf48e
polish styling for Color Schemes page
carlos-zamora Dec 7, 2020
0635849
polish styling for Rendering page
carlos-zamora Dec 7, 2020
1ce0e55
polish CommonResources (propagate changes)
carlos-zamora Dec 8, 2020
443f515
address Niksa PR comments
carlos-zamora Dec 8, 2020
b6874f6
Merge branch 'feature/settings-ui' of https://github.com/microsoft/Te…
carlos-zamora Dec 8, 2020
a030056
Merge branch 'main' into feature/settings-ui
carlos-zamora Dec 9, 2020
93158e7
Add groupings to profile page (#8516)
cinnamon-msft Dec 9, 2020
58c81ff
Bind BackgroundImageAlignment to Settings UI (#8313)
carlos-zamora Dec 9, 2020
3a38333
add 'locked' to settings.json & defaults.json
carlos-zamora Dec 9, 2020
106c1e3
address Griese PR comments
carlos-zamora Dec 9, 2020
7133d05
Merge branch 'feature/settings-ui' into dev/cazamor/sui/rename-and-de…
carlos-zamora Dec 9, 2020
91dc221
Merge branch 'main' into feature/settings-ui
carlos-zamora Dec 10, 2020
67249d9
actually fix the merge conflict...
carlos-zamora Dec 10, 2020
b38df24
Merge remote-tracking branch 'origin/main' into feature/settings-ui
carlos-zamora Dec 10, 2020
f2379e6
Merge remote-tracking branch 'origin/main' into feature/settings-ui
carlos-zamora Dec 10, 2020
69693f6
resolve second merge marker
DHowett Dec 10, 2020
d676103
Fix SwitchToTab build break (#8545)
carlos-zamora Dec 10, 2020
f829d5a
Fix crash on json change
carlos-zamora Dec 10, 2020
6bdedbe
Merge branch 'feature/settings-ui' into dev/cazamor/sui/rename-and-de…
carlos-zamora Dec 10, 2020
7315977
finalize UI for Color Schemes page
carlos-zamora Dec 10, 2020
e6a69fd
Merge branch 'feature/settings-ui' into dev/cazamor/sui/bind-launch-mode
carlos-zamora Dec 12, 2020
8165371
finalize CS renaming + style Profile delete btn
carlos-zamora Dec 14, 2020
a24e49f
hook-up 'delete profile' btn
carlos-zamora Dec 14, 2020
937a6d1
prevent deletion of CMD + Windows Pwsh
carlos-zamora Dec 14, 2020
8953246
prevent deletion of in-box schemes
carlos-zamora Dec 14, 2020
98377fa
polish content dialog theming and logic
carlos-zamora Dec 15, 2020
c240d76
add delete button disclaimer
carlos-zamora Dec 16, 2020
ac6c951
add base layer disclaimer and delete button visibility logic
carlos-zamora Dec 16, 2020
9204c88
change delete profile architecture to be event based
carlos-zamora Dec 16, 2020
2846605
bugfix: refresh the combobox on rename
carlos-zamora Dec 16, 2020
f7bb0fb
replace rename ContentDialog with TextBox
carlos-zamora Dec 17, 2020
516a047
address PR comments; add tooltips to rename buttons
carlos-zamora Dec 17, 2020
a3d6695
add confirmation dialog to delete buttons
carlos-zamora Dec 17, 2020
cc8dec1
apply changes from design review w/ cinnamon
carlos-zamora Dec 17, 2020
dd2ef1c
address Dustin's PR comments
carlos-zamora Dec 17, 2020
a2ebc74
move and wrap disclaimer
carlos-zamora Dec 17, 2020
541f46c
manually hide CS delete flyout
carlos-zamora Dec 17, 2020
fd8db96
accept enter for CS rename
carlos-zamora Dec 17, 2020
4436762
reduce standard min width to prevent cropping on resize
carlos-zamora Dec 17, 2020
556be58
fix Profile page scrolling bug
carlos-zamora Dec 17, 2020
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
129 changes: 125 additions & 4 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using namespace winrt;
using namespace winrt::Windows::UI;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Navigation;
using namespace winrt::Windows::UI::Xaml::Controls;
using namespace winrt::Windows::UI::Xaml::Media;
Expand Down Expand Up @@ -38,8 +39,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
RS_(L"ColorScheme_BrightWhite/Header")
};

static const std::array<std::wstring, 9> InBoxSchemes = {
L"Campbell",
L"Campbell Powershell",
L"Vintage",
L"One Half Dark",
L"One Half Light",
L"Solarized Dark",
L"Solarized Light",
L"Tango Dark",
L"Tango Light"
};

ColorSchemes::ColorSchemes() :
_ColorSchemeList{ single_threaded_observable_vector<hstring>() },
_ColorSchemeList{ single_threaded_observable_vector<Model::ColorScheme>() },
_CurrentColorTable{ single_threaded_observable_vector<Editor::ColorTableEntry>() }
{
InitializeComponent();
Expand Down Expand Up @@ -73,10 +86,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
SelectionChangedEventArgs const& args)
{
// Update the color scheme this page is modifying
auto str = winrt::unbox_value<hstring>(args.AddedItems().GetAt(0));
auto colorScheme = _State.Globals().ColorSchemes().Lookup(str);
const auto colorScheme{ args.AddedItems().GetAt(0).try_as<Model::ColorScheme>() };
CurrentColorScheme(colorScheme);
_UpdateColorTable(colorScheme);

// Set the text disclaimer for the text box
hstring disclaimer{};
const std::wstring schemeName{ colorScheme.Name() };
if (std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), schemeName) != std::end(InBoxSchemes))
{
// load disclaimer for in-box profiles
disclaimer = RS_(L"ColorScheme_DeleteButtonDisclaimerInBox");
}
DeleteButtonDisclaimer().Text(disclaimer);

// Update the state of the page
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"CanDeleteCurrentScheme" });
IsRenaming(false);
}

// Function Description:
Expand All @@ -92,7 +118,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const auto& colorSchemeMap{ _State.Globals().ColorSchemes() };
for (const auto& pair : colorSchemeMap)
{
_ColorSchemeList.Append(pair.Key());
_ColorSchemeList.Append(pair.Value());
}
}

Expand Down Expand Up @@ -120,6 +146,101 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

bool ColorSchemes::CanDeleteCurrentScheme() const
{
if (const auto scheme{ CurrentColorScheme() })
{
// Only allow this color scheme to be deleted if it's not provided in-box
const std::wstring myName{ scheme.Name() };
return std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), myName) == std::end(InBoxSchemes);
}
return false;
}

void ColorSchemes::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
const auto schemeName{ CurrentColorScheme().Name() };
_State.Globals().RemoveColorScheme(schemeName);

const auto removedSchemeIndex{ ColorSchemeComboBox().SelectedIndex() };
if (static_cast<uint32_t>(removedSchemeIndex) < _ColorSchemeList.Size() - 1)
{
// select same index
ColorSchemeComboBox().SelectedIndex(removedSchemeIndex + 1);
}
else
{
// select last color scheme (avoid out of bounds error)
ColorSchemeComboBox().SelectedIndex(removedSchemeIndex - 1);
}
_ColorSchemeList.RemoveAt(removedSchemeIndex);
DeleteButton().Flyout().Hide();
}

void ColorSchemes::AddNew_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
// Give the new scheme a distinct name
const hstring schemeName{ fmt::format(L"Color Scheme {}", _State.Globals().ColorSchemes().Size() + 1) };
Model::ColorScheme scheme{ schemeName };

// Add the new color scheme
_State.Globals().AddColorScheme(scheme);

// Update current page
_ColorSchemeList.Append(scheme);
ColorSchemeComboBox().SelectedItem(scheme);
}

// Function Description:
// - Pre-populates/focuses the name TextBox, updates the UI
// Arguments:
// - <unused>
// Return Value:
// - <none>
void ColorSchemes::Rename_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
NameBox().Text(CurrentColorScheme().Name());
IsRenaming(true);
NameBox().Focus(FocusState::Programmatic);
NameBox().SelectAll();
}

void ColorSchemes::RenameAccept_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
_RenameCurrentScheme(NameBox().Text());
}

void ColorSchemes::RenameCancel_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
IsRenaming(false);
}

void ColorSchemes::NameBox_PreviewKeyDown(IInspectable const& /*sender*/, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e)
{
if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Enter)
{
_RenameCurrentScheme(NameBox().Text());
e.Handled(true);
}
else if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Escape)
{
IsRenaming(false);
e.Handled(true);
}
}

void ColorSchemes::_RenameCurrentScheme(hstring newName)
{
CurrentColorScheme().Name(newName);
IsRenaming(false);

// The color scheme is renamed appropriately, but the ComboBox still shows the old name (until you open it)
// We need to manually force the ComboBox to refresh itself.
const auto selectedIndex{ ColorSchemeComboBox().SelectedIndex() };
ColorSchemeComboBox().SelectedIndex((selectedIndex + 1) % ColorSchemeList().Size());
ColorSchemeComboBox().SelectedIndex(selectedIndex);
}

// Function Description:
// - Updates the currently modifiable color table based on the given current color scheme.
// Arguments:
Expand Down
13 changes: 12 additions & 1 deletion src/cascadia/TerminalSettingsEditor/ColorSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,28 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void ColorSchemeSelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& args);
void ColorPickerChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ColorChangedEventArgs const& args);
void AddNew_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);

void Rename_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void RenameAccept_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void RenameCancel_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void NameBox_PreviewKeyDown(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);

bool CanDeleteCurrentScheme() const;
void DeleteConfirmation_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);

GETSET_PROPERTY(Editor::ColorSchemesPageNavigationState, State, nullptr);
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::Microsoft::Terminal::Settings::Editor::ColorTableEntry>, CurrentColorTable, nullptr);
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::hstring>, ColorSchemeList, nullptr);
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<Model::ColorScheme>, ColorSchemeList, nullptr);

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
OBSERVABLE_GETSET_PROPERTY(winrt::Microsoft::Terminal::Settings::Model::ColorScheme, CurrentColorScheme, _PropertyChangedHandlers, nullptr);
OBSERVABLE_GETSET_PROPERTY(bool, IsRenaming, _PropertyChangedHandlers, nullptr);

private:
void _UpdateColorTable(const winrt::Microsoft::Terminal::Settings::Model::ColorScheme& colorScheme);
void _UpdateColorSchemeList();
void _RenameCurrentScheme(hstring newName);
};

struct ColorTableEntry : ColorTableEntryT<ColorTableEntry>
Expand Down
5 changes: 4 additions & 1 deletion src/cascadia/TerminalSettingsEditor/ColorSchemes.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ namespace Microsoft.Terminal.Settings.Editor
ColorSchemes();
ColorSchemesPageNavigationState State { get; };

Boolean CanDeleteCurrentScheme { get; };
Boolean IsRenaming { get; };

Microsoft.Terminal.Settings.Model.ColorScheme CurrentColorScheme { get; };
Windows.Foundation.Collections.IObservableVector<ColorTableEntry> CurrentColorTable;
Windows.Foundation.Collections.IObservableVector<String> ColorSchemeList { get; };
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Model.ColorScheme> ColorSchemeList { get; };
}

[default_interface] runtimeclass ColorTableEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged
Expand Down
Loading