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

Implement the Settings UI #8048

Merged
merged 2 commits into from
Dec 11, 2020
Merged

Implement the Settings UI #8048

merged 2 commits into from
Dec 11, 2020

Conversation

leonMSFT
Copy link
Contributor

@leonMSFT leonMSFT commented Oct 26, 2020

Summary of the Pull Request

This introduces the Settings UI to Windows Terminal. This allows users to customize their global settings, color schemes, and profiles without having to open the settings.json. Actions are not currently included in the Settings UI.

To open the Settings UI, add the following keybinding to your settings.json:

{ "name": "OPEN SETTINGS UI", "command": {"action": "openSettings", "target": "settingsUI"}, "keys": "ctrl+shift+," }

Closes #1564 - Settings UI
Spec: #6720, #8269

Demo

Settings UI Demo

@carlos-zamora carlos-zamora changed the title Merge the SUI feature branch into main Implement the Settings UI Dec 3, 2020
@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Scenario Product-Terminal The new Windows Terminal. labels Dec 3, 2020
@zadjii-msft zadjii-msft self-assigned this Dec 7, 2020
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor comments. Let's do this!

src/cascadia/TerminalSettingsEditor/Interaction.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/KeyBindingsPage.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Keybindings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/MainPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.cpp Outdated Show resolved Hide resolved
@carlos-zamora carlos-zamora self-assigned this Dec 8, 2020
@zadjii-msft
Copy link
Member

zadjii-msft commented Dec 9, 2020

Random thought while reading: we might want to actually make an updated version of AddASetting.md for the Terminal now with all this. For ex, if you add any sort of enum setting, you need to add it to a bunch of different places so it can be exposed in the SUI. Maybe a checklist would be helpful to have?
(47/90)

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I'm at 69/90 but I think he's finally asleep so I'm going to bed

TabViewItem().IconSource(IconPathConverter::IconSourceMUX(glyph));

// Update SwitchToTab command's icon
SwitchToTabCommand().Icon(glyph);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this will likely conflict with #8427, but git might not be the thing that complains about it. @Don-Vito as an FYI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zadjii-msft - not sure about the git but the compiler will complain for sure :) In any case the solution will be straightforwad - removing this line since the palette items are "bound" to TabBase::Icon.

src/cascadia/TerminalSettingsModel/Profile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
Foundation::IInspectable const& /* parameter */,
hstring const& /* language */)
{
return winrt::box_value(Windows::UI::Xaml::Media::SolidColorBrush(winrt::unbox_value<Windows::UI::Color>(value)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to worry about this unbox_value throwing an exception if value isn't a Color

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, yes. But considering that this is a Color-to-Brush converter, I feel like this is fine? (also, idk how to check the type of something without unboxing it, would try_as work?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, try_as returns null if it couldn't do the conversion.

src/cascadia/TerminalSettingsModel/EnumMappings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Utils.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/GlobalSettings.idl Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 9, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm through 90/90. I've got a pile of nits and questions so I'll hold for answers, but there's nothing dramatic here

_State.WindowRoot().TryPropagateHostingWindow(picker); // if we don't do this, there's no HWND for it to attach to
picker.ViewMode(PickerViewMode::Thumbnail);
picker.SuggestedStartLocation(PickerLocationId::ComputerFolder);
picker.FileTypeFilter().ReplaceAll({ L".bat", L".exe", L".cmd" });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, we definitely can't put .bat or .cmd's in here directly -

holy shit what, you can CreateProcess(foo.bat) and it works? That's insane.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, if you do select a .bat file, then apply, it seems to roundtrip it as cmd.exe. Not sure if that counts as a follow-up though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait that might just be it's not persisting at all. That's probably something else, nevermind me.


fire_and_forget Profiles::StartingDirectory_Click(IInspectable const&, RoutedEventArgs const&)
{
auto lifetime = get_strong();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be weak refs that we check on the other side of the co_await?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest, I straight up took this from the FilePicker Sample. We don't even use lifetime. I'll have to play around a bit here to see if that works. I'll get back to you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, it really doesn't matter. lifetime anchors the page so that it stays alive while the button click handler is being run.

That's a good thing.

We've gone crazy with the weak references in Terminal. We make them weak, check if they're alive, all the dang time

src/cascadia/TerminalSettingsEditor/Profiles.cpp Outdated Show resolved Hide resolved
Comment on lines 2785 to 2830
_tabs.Append(*newTabImpl);
_mruTabActions.Append(newTabImpl->SwitchToTabCommand());

newTabImpl->SetDispatch(*_actionDispatch);

// Give the tab its index in the _tabs vector so it can manage its own SwitchToTab command.
_UpdateTabIndices();

// Don't capture a strong ref to the tab. If the tab is removed as this
// is called, we don't really care anymore about handling the event.
auto weakTab = make_weak(newTabImpl);

auto tabViewItem = newTabImpl->TabViewItem();
_tabView.TabItems().Append(tabViewItem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this seems similar to the setup we do when we create a terminal tab, should we make a card to unify it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was some of the code that Leon wrote up. I'm a bit worried that I may break some tab switching functionality in the process of moving stuff around. For now, I've lumped it into #8452 since that seems to be touching some similar code. I'll do it as a follow-up to this PR since this is already a pretty big one.

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. lets do this. We can polish in post

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Uid="Settings_UnsavedSettingsWarning"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently isnt used, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. We need a way to detect unsaved changes to properly show/hide it. #8552 starts getting us there, so I'll keep it in there for now. But I'll definitely add a comment explaining that (and filing a follow-up)

@zadjii-msft zadjii-msft removed their assignment Dec 11, 2020
@carlos-zamora carlos-zamora mentioned this pull request Dec 11, 2020
25 tasks
@@ -168,7 +167,7 @@ struct ::Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait<::winr
}

::winrt::Windows::UI::Text::FontWeight weight{
static_cast<uint16_t>(std::clamp(value, 100u, 990u))
static_cast<uint16_t>(std::clamp(value, 1u, 999u))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, what? 1 is not a valid font weight

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, what? 1 is not a valid font weight

Typically goes from 100 to 990 I think - but I believe the font sets its minimum and maximum values?

https://docs.microsoft.com/en-us/typography/opentype/spec/fvar

Example This example is for a hypothetical font with family name “SelawikV” that has two axes of variation, for weight and width. This table summarizes the description of the axes for the font:

Axis tag Minimum value Default value Maximum value Axis name ID
'wght' 300 400 700 256
'wdth' 62.5 100 150 257

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the documentation for FontWeight says that this is the supported range though. Do we clamp it somewhere else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I backed this out and clamped it to 100 on deserialization. On a round trip it will be "fixed".

DHowett pushed a commit that referenced this pull request Dec 11, 2020
This commit is an amalgamation of some of the TSM changes in PR #8048.
It:
* Introduces CascadiaSettings.CreateNewProfile to add a new profile
* Introduces CascadiaSettings.ProfileDefaults, which returns the
  "defaults" object as a profile
* Fixes the font weight deserializer to work on uint16_ts
* Fixes a property getter in ColorScheme to not be a property getter
* Fixes a reserialization error with default profiles
* Sets a default icon for all profiles (to the C:\ Segoe MDL2 icon)
DHowett and others added 2 commits December 11, 2020 13:35
This commit introduces the terminal settings editor (to wit: the
Settings UI) as a standalone project. This project, and this commit, is
the result of two and a half months of work.

TSE started as a hackathon project in the Microsoft 2020 Hackathon, and
from there it's grown to be a bona-fide graphical settings editor.

There is a lot of xaml data binding in here, a number of views and a
number of view models, and a bunch of paradigms that we've been
reviewing and testing out and designing and refining.

Specified in #6720, #8269
Follow-up work in #6800
Closes #1564
Closes #8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Alberto Medina Gutierrez <almedina@microsoft.com>
Co-authored-by: John Grandle <jograndl@microsoft.com>
Co-authored-by: xerootg <xerootg@users.noreply.github.com>
Co-authored-by: Scott <sarmiger1@gmail.com>
Co-authored-by: Vineeth Thomas Alex <vineeththomasalex@gmail.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
Signed-off-by: Dustin L. Howett <duhowett@microsoft.com>
This commit iontroduces another `target` to the `openSettings` binding:
`settingsUI`. It opens the settings UI introduced in the previous
commit.

Closes #1564
Closes #8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
@DHowett DHowett merged commit d02812d into main Dec 11, 2020
DHowett added a commit that referenced this pull request Dec 11, 2020
This commit introduces the terminal settings editor (to wit: the
Settings UI) as a standalone project. This project, and this commit, is
the result of two and a half months of work.

TSE started as a hackathon project in the Microsoft 2020 Hackathon, and
from there it's grown to be a bona-fide graphical settings editor.

There is a lot of xaml data binding in here, a number of views and a
number of view models, and a bunch of paradigms that we've been
reviewing and testing out and designing and refining.

Specified in #6720, #8269
Follow-up work in #6800
Closes #1564
Closes #8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Alberto Medina Gutierrez <almedina@microsoft.com>
Co-authored-by: John Grandle <jograndl@microsoft.com>
Co-authored-by: xerootg <xerootg@users.noreply.github.com>
Co-authored-by: Scott <sarmiger1@gmail.com>
Co-authored-by: Vineeth Thomas Alex <vineeththomasalex@gmail.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
Signed-off-by: Dustin L. Howett <duhowett@microsoft.com>
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
This commit is an amalgamation of some of the TSM changes in PR microsoft#8048.
It:
* Introduces CascadiaSettings.CreateNewProfile to add a new profile
* Introduces CascadiaSettings.ProfileDefaults, which returns the
  "defaults" object as a profile
* Fixes the font weight deserializer to work on uint16_ts
* Fixes a property getter in ColorScheme to not be a property getter
* Fixes a reserialization error with default profiles
* Sets a default icon for all profiles (to the C:\ Segoe MDL2 icon)
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
This commit introduces the terminal settings editor (to wit: the
Settings UI) as a standalone project. This project, and this commit, is
the result of two and a half months of work.

TSE started as a hackathon project in the Microsoft 2020 Hackathon, and
from there it's grown to be a bona-fide graphical settings editor.

There is a lot of xaml data binding in here, a number of views and a
number of view models, and a bunch of paradigms that we've been
reviewing and testing out and designing and refining.

Specified in microsoft#6720, microsoft#8269
Follow-up work in microsoft#6800
Closes microsoft#1564
Closes microsoft#8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Alberto Medina Gutierrez <almedina@microsoft.com>
Co-authored-by: John Grandle <jograndl@microsoft.com>
Co-authored-by: xerootg <xerootg@users.noreply.github.com>
Co-authored-by: Scott <sarmiger1@gmail.com>
Co-authored-by: Vineeth Thomas Alex <vineeththomasalex@gmail.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
Signed-off-by: Dustin L. Howett <duhowett@microsoft.com>
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
…t#8048)

This commit iontroduces another `target` to the `openSettings` binding:
`settingsUI`. It opens the settings UI introduced in the previous
commit.

Closes microsoft#1564
Closes microsoft#8048 (PR)

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Co-authored-by: Leon Liang <lelian@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Scenario Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - Implement Settings UI
7 participants