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

Bind Profile Color Schemes #8388

Merged
2 commits merged into from
Dec 1, 2020

Conversation

carlos-zamora
Copy link
Member

Summary of the Pull Request

Binds Profile.ColorScheme to the list of Color Schemes available in the Settings UI.

References

#1564 - Settings UI

Detailed Description of the Pull Request / Additional comments

To my knowledge, there is no way to bind an IMapView to ItemsSource. ItemsSource requires an IObservableVector, so we need to manually populate ColorSchemeList when we navigate to the page.

CurrentColorScheme operates mostly like a standard getter/setter, except it needs to account for the upcoming scenario when a color scheme is renamed or deleted. For now, we fallback to Campbell if the scheme was not found. I would like to make it update automatically, but I feel that we have two approaches here:

  1. TSM stores Profile.ColorScheme as a ColorScheme instead of only the name
  2. When a color scheme name is modified in SUI, we iterate through all of the profiles and modify Profile.ColorScheme accordingly
    Open to discuss these options or any other approaches.

Validation Steps Performed

✅ selected item initialized correctly
✅ list initialized correctly
✅ selecting a new color scheme, then creating a new terminal from that profile uses the new color scheme
✅ setting the color scheme name to a color scheme that does not exist selects "Campbell"

Comment on lines 36 to 42
const auto& colorSchemeMap{ _State.Schemes() };
for (const auto& pair : colorSchemeMap)
{
_ColorSchemeList.Append(pair.Key());
}
}

Copy link
Member

Choose a reason for hiding this comment

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

if you navigate back to the same page, isn't this gonna make the color scheme list grow without bound?

Copy link
Member Author

Choose a reason for hiding this comment

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

Surprisingly no. And I can't figure out why.

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.

This is such a trivial question, I guess I won't block over it

// winrt::com_arrays prevent data binding.
// Instead of representing Table as a property,
// we expose the getter as a function.
Windows.UI.Color[] Table();
Copy link
Member

Choose a reason for hiding this comment

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

wait but why tho? Are we using Table() anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the funny thing is, Table { get; }; and Table(); in the IDL are both called with Table() in C++. So this doesn't affect anybody calling it haha.

As for why this is happening, the compiler is asserting that winrt::com_array<winrt::Windows::UI::Color> must be a WinRT type so that it can be wrapped in an IReference. Why a winrt::com_array isn't a WinRT type, idk. So changing it to a function is just easier haha

Copy link
Member

Choose a reason for hiding this comment

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

Wait but why is the compiler asserting this now, and not before?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, because of this DataTemplate in Profiles.xaml:

<DataTemplate x:DataType="model:ColorScheme">
   <TextBlock Text="{x:Bind Name, Mode=OneWay}"/>
</DataTemplate>

Even thought we're only binding Name, XAML tries to make every property bindable. Since Table was a property, we'd hit that error :/

@zadjii-msft zadjii-msft removed their assignment Dec 1, 2020
@zadjii-msft zadjii-msft added the Area-Settings UI Anything specific to the SUI label Dec 1, 2020
@carlos-zamora carlos-zamora added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 1, 2020
@ghost
Copy link

ghost commented Dec 1, 2020

Hello @carlos-zamora!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 62aa0ce into feature/settings-ui Dec 1, 2020
@ghost ghost deleted the dev/cazamor/sui/profile-color-schemes branch December 1, 2020 19:27
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants