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 Launch Mode/Size, BI Opacity, Opacity, and FontWeight #8219

Merged
17 commits merged into from
Dec 3, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Nov 10, 2020

Summary of the Pull Request

Properly binds and polishes controls for a few settings in the Settings UI:

  • LaunchMode is now bound to a radio button
  • "Launch size" was added and bound as two number boxes
  • backgroundImageOpacity and acrylicOpacity are now bound to a Slider control
    • A PercentageConverter was introduced to convert from decimal range (0.0-1.0) to whole numbers (0-100)
    • Common styling was added to CommonResources
  • fontWeight is now bound to a combination of controls:
    • ComboBox is used to display the named values (FontWeights docs)
    • A special Custom option is included. When selected, a Slider appears that lets you choose a custom value.
  • AcrylicOpacity slider only appears if useAcrylic is enabled

References

#1564 - Settings UI

Detailed Description of the Pull Request / Additional comments

bf7d06d is the most complicated commit here. FontWeight is exposed as a FontWeight but is constantly treated as a uint16_t. The following changes were made to handle this:

  • FontWeightConverter: bind the slider value to the setting
  • ConversionTrait<FontWeight> stores the values as uint16_t instead of unsigned int
  • ConversionTrait<FontWeight> accepts a range of 1 to 999 in accordance to FontWeight docs
  • manually add and track the CustomFontWeight EnumEntry for the ComboBox. A sentinel value of 0 is used
  • manually implement getter/setter for CurrentFontWeight so that the Slider control is shown/hidden appropriately

Follow-up work for a later PR

The following work items are being added and tracked.

  • non-alphabetical enum ordering
    • FontWeight struggles with this the most. We should order the options from lightest to heaviest.

Demo

Slider Demo

Startup Page

src/cascadia/TerminalSettingsEditor/Profiles.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.xaml Outdated Show resolved Hide resolved
Comment on lines +45 to +56
winrt::Windows::Foundation::Collections::IMap<winrt::hstring, uint16_t> EnumMappings::FontWeight()
{
static IMap<winrt::hstring, uint16_t> enumMap = []() {
auto map = single_threaded_map<winrt::hstring, uint16_t>();
for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait<Windows::UI::Text::FontWeight>::mappings)
{
map.Insert(winrt::to_hstring(enumStr), enumVal);
}
return map;
}();
return enumMap;
}
Copy link
Member

Choose a reason for hiding this comment

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

soooooooo what's up with this

Copy link
Member

Choose a reason for hiding this comment

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

Is it because of how weird FontWeight objects are

Copy link
Member Author

Choose a reason for hiding this comment

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

Our FontWeight ConversionTrait is weird. It spits out a uint16_t. So I need to manually create this so that I target the FontWeight trait, but store it as a uint16_t.

@@ -37,6 +37,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::TerminalControl::TextAntialiasingMode> TextAntialiasingMode();
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::TerminalControl::CursorStyle> CursorStyle();
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, BellStyle> BellStyle();
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, uint16_t> FontWeight();
Copy link
Member

Choose a reason for hiding this comment

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

surprised this is legal!

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Nov 11, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Nov 18, 2020
@ghost
Copy link

ghost commented Nov 18, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@ghost ghost removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Nov 18, 2020
@carlos-zamora carlos-zamora changed the title Bind LaunchMode, BI Opacity, Opacity, and FontWeight Bind Launch Mode/Size, BI Opacity, Opacity, and FontWeight Nov 30, 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 the code of this looks fine, and the XAML generally looks okay? That's a lot harder to review but the gifs look god

src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
@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
Copy link
Member Author

the gifs look god

Monty Python gif

(I had to hahaha)

Comment on lines 146 to 151
IInspectable Profiles::CurrentFontWeight()
{
// if no value was found, we have a custom value, and we show the slider.
const auto maybeEnumEntry{ _FontWeightMap.TryLookup(_State.Profile().FontWeight().Weight) };
CustomFontWeightControl().Visibility(maybeEnumEntry ? Visibility::Collapsed : Visibility::Visible);
return maybeEnumEntry ? maybeEnumEntry : _CustomFontWeight;
Copy link
Member

Choose a reason for hiding this comment

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

really don't love the fact that the getter for the current font weight also impacts the UI's visibility. That's not what a getter is for.

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes sense though, no? Because the visibility of the slider is dependent on the value. So we change it when we get the value? Curious what other approach you suggest though

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 1, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 2, 2020
@carlos-zamora
Copy link
Member Author

At some point, Kayla pointed out that "Base Layer" should be "Base layer". It's a super small change so I added it in here.

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 3, 2020
@ghost
Copy link

ghost commented Dec 3, 2020

Hello @DHowett!

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 5770d23 into feature/settings-ui Dec 3, 2020
@ghost ghost deleted the dev/cazamor/sui/bind-launch-mode branch December 3, 2020 00:04
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