-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Conversation
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
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; | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised this is legal!
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. |
src/cascadia/TerminalSettingsEditor/BooleanToVisibilityConverter.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
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. |
Hello @DHowett! Because this pull request has the 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 (
|
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 buttonbackgroundImageOpacity
andacrylicOpacity
are now bound to a Slider controlPercentageConverter
was introduced to convert from decimal range (0.0-1.0) to whole numbers (0-100)fontWeight
is now bound to a combination of controls:Custom
option is included. When selected, a Slider appears that lets you choose a custom value.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 auint16_t
. The following changes were made to handle this:FontWeightConverter
: bind the slider value to the settingConversionTrait<FontWeight>
stores the values asuint16_t
instead ofunsigned int
ConversionTrait<FontWeight>
accepts a range of 1 to 999 in accordance to FontWeight docsCustomFontWeight
EnumEntry
for the ComboBox. A sentinel value of 0 is usedCurrentFontWeight
so that the Slider control is shown/hidden appropriatelyFollow-up work for a later PR
The following work items are being added and tracked.
Demo