-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[settings-editor] Switch to function bindings instead of Converter objects #10846
Conversation
OpenConsole.sln
Outdated
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31410.414 |
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.
If desired, I can also revert these changes.
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.
Yes, if you could revert this change specifically, that would be nice.
I'm running into the same problem all the time, as I'm also using VS2022 already. 😅
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.
Reverted them now. Good to hear though, I'm not the only running into 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.
Thanks for doing this! Big fan! haha
@@ -17,9 +17,6 @@ | |||
<ItemGroup> | |||
<ClInclude Include="pch.h" /> | |||
<ClInclude Include="Utils.h" /> | |||
<ClInclude Include="PercentageSignConverter.h"> |
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.
You can probably also...
- remove the reference to
PercentageSignConverter.cpp
on line 13 above - remove the
Converters
filter on line 50 below
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.
Good point! Fixed that now.
@@ -330,7 +272,6 @@ | |||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalConnection\TerminalConnection.vcxproj"> | |||
<Private>false</Private> | |||
</ProjectReference> | |||
|
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.
nit: mind adding in these empty lines again?
@@ -68,5 +72,6 @@ namespace Microsoft.Terminal.Settings.Editor | |||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> FontWeightList { get; }; | |||
|
|||
IInspectable CurrentFontFace { get; }; | |||
Windows.UI.Xaml.Controls.Slider BIOpacitySlider { get; }; |
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.
Wait... is this just a way to get access to the element named BIOpacitySlider
? 🤯
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.
Exactly! Since we need to reference the control from XAML and the XAML Compiler only can access controls that are exposed through the winmd/metadata, we need to define them in IDL since otherwise they won't be available to the metadata provider.
@@ -139,11 +139,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||
{ | |||
bool result{ false }; | |||
const auto currentFont{ Appearance().FontFace() }; | |||
for (const auto& font : SourceProfile().MonospaceFontList()) | |||
if (!SourceProfile()) |
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.
wait... isn't this backwards? Don't we want to make sure SourceProfile
is populated because we're using it on the line below?
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.
That code change was not supposed to get into this PR, sorry about that ^^
@@ -144,7 +134,7 @@ | |||
Minimum="0" | |||
TickFrequency="50" | |||
TickPlacement="Outside" | |||
Value="{x:Bind Appearance.FontWeight, Converter={StaticResource FontWeightConverter}, Mode=TwoWay}" /> | |||
Value="{x:Bind local:Converters.FontWeightToDouble(Appearance.FontWeight), BindBack=Appearance.SetFontWeightFromDouble, Mode=TwoWay}" /> |
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.
Value="{x:Bind local:Converters.FontWeightToDouble(Appearance.FontWeight), BindBack=Appearance.SetFontWeightFromDouble, Mode=TwoWay}" /> | |
Value="{x:Bind Appearance.FontWeight.Weight, BindBack=Appearance.SetFontWeightFromDouble, Mode=TwoWay}" /> |
Can we extract the Weight
directly and get rid of the converter entirely?
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.
Unfortunately, this doesn't seem to work since two way binding either wants to bind to a property for both directions or have a function for both directions. Having a property for one direction (as would be the case with simply using Appearance.FontWeight.Weight) and a BindBack for the other direction does not seem to be supported.
Co-authored-by: Carlos Zamora <[email protected]>
Co-authored-by: Carlos Zamora <[email protected]>
Co-authored-by: Carlos Zamora <[email protected]>
Co-authored-by: Carlos Zamora <[email protected]>
Co-authored-by: Carlos Zamora <[email protected]>
Co-authored-by: Carlos Zamora <[email protected]>
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.
Thank you!!
Always happy to help! |
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.
You know, I think I'm okay with the desktopWallpaper
thing. That's really not so bad, and the rest of this is all goodness. Thanks for doing this!
Style="{StaticResource TextBoxSettingStyle}" | ||
Text="{x:Bind Appearance.BackgroundImagePath, Mode=TwoWay, Converter={StaticResource DesktopWallpaperToEmptyStringConverter}}" /> | ||
Text="{x:Bind local:Converters.StringFallBackToEmptyString('desktopWallpaper', Appearance.BackgroundImagePath), Mode=TwoWay, BindBack=Appearance.SetBackgroundImagePath}" /> |
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 so this TextBox is enabled when the BackgroundImagePath != 'desktopWallpaper'
. When the BackgroundImagePath=='desktopWallpaper'
, StringFallBackToEmptyString
will convert that to desktopWallpaper
. When the string is anything else, it'll bind the text as the empty string? Is this right? This might need some comments adjacent to it to help explain what's going on here (though admittedly I didn't leave any behind when I wrote this the first time 😋)
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.
I think right now we're actually filling the box with the empty string, but still enabling the rest of background image settings. This PR updates it to actually fill the box with desktopWallpaper
, which is a little weird, but probably okay? Everything else still seems to work fine.
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.
So much happier with this than what we had before. Excellent work @chingucoding!
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 (
|
Thank you @DHowett !@zadjii-msft, should I create a follow up PR in the next few days to fix the behavior you noticed? |
🎉 Handy links: |
Validation Steps Performed
Clicked around, validated that settings still behave the same (as far as
I can tell with my limited terminal configuration expertise)
Closes #10387