-
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
Changes from 8 commits
3fee481
3ea94fb
9030618
dfbaa36
2e2b9b5
4bd044b
3e34e5d
92e7fa0
b2f50b8
7e9c7af
d69429c
363a310
2583135
3e5aad1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. wait... isn't this backwards? Don't we want to make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ^^ |
||
{ | ||
if (font.LocalizedName() == currentFont) | ||
for (const auto& font : SourceProfile().MonospaceFontList()) | ||
{ | ||
result = true; | ||
if (font.LocalizedName() == currentFont) | ||
{ | ||
result = true; | ||
} | ||
} | ||
} | ||
return result; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ namespace Microsoft.Terminal.Settings.Editor | |
{ | ||
Boolean IsDefault; | ||
|
||
void SetFontWeightFromDouble(Double fontWeight); | ||
void SetBackgroundImageOpacityFromPercentageValue(Double percentageValue); | ||
void SetBackgroundImagePath(String path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you just use the setter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That does not work, XAML Compiler gives us the error:
I'm afraid there really isn't a way around these bindback functions :/ |
||
|
||
Boolean UseDesktopBGImage; | ||
Boolean BackgroundImageSettingsVisible { get; }; | ||
|
||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,16 +34,6 @@ | |||||
<TextBlock FontFamily="{x:Bind Name}" | ||||||
Text="{x:Bind LocalizedName}" /> | ||||||
</DataTemplate> | ||||||
|
||||||
<local:ColorToBrushConverter x:Key="ColorToBrushConverter" /> | ||||||
<local:PercentageConverter x:Key="PercentageConverter" /> | ||||||
<local:PercentageSignConverter x:Key="PercentageSignConverter" /> | ||||||
<local:FontWeightConverter x:Key="FontWeightConverter" /> | ||||||
<local:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" /> | ||||||
<local:StringIsEmptyConverter x:Key="StringIsEmptyConverter" /> | ||||||
<local:PaddingConverter x:Key="PaddingConverter" /> | ||||||
<local:StringIsNotDesktopConverter x:Key="StringIsNotDesktopConverter" /> | ||||||
<local:DesktopWallpaperToEmptyStringConverter x:Key="DesktopWallpaperToEmptyStringConverter" /> | ||||||
</ResourceDictionary> | ||||||
</UserControl.Resources> | ||||||
|
||||||
|
@@ -87,7 +77,7 @@ | |||||
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}" | ||||||
SelectionChanged="FontFace_SelectionChanged" | ||||||
Style="{StaticResource ComboBoxSettingStyle}" | ||||||
Visibility="{x:Bind ShowAllFonts, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}" /> | ||||||
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(ShowAllFonts), Mode=OneWay}" /> | ||||||
<ComboBox ItemTemplate="{StaticResource FontFaceComboBoxItemTemplate}" | ||||||
ItemsSource="{x:Bind SourceProfile.CompleteFontList, Mode=OneWay}" | ||||||
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}" | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Can we extract the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
<TextBlock Grid.Column="1" | ||||||
Margin="10,0,0,0" | ||||||
Style="{StaticResource SliderValueLabelStyle}" | ||||||
|
@@ -215,12 +205,12 @@ | |||||
SettingOverrideSource="{x:Bind Appearance.BackgroundImagePathOverrideSource, Mode=OneWay}"> | ||||||
<StackPanel Orientation="Vertical"> | ||||||
<StackPanel Orientation="Horizontal"> | ||||||
<TextBox IsEnabled="{x:Bind Appearance.BackgroundImagePath, Mode=OneWay, Converter={StaticResource StringIsNotDesktopConverter}}" | ||||||
<TextBox IsEnabled="{x:Bind local:Converters.StringsAreNotEqual('desktopWallpaper', Appearance.BackgroundImagePath), Mode=OneWay}" | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. okay so this TextBox is enabled when the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
<Button x:Uid="Profile_BackgroundImageBrowse" | ||||||
Click="BackgroundImage_Click" | ||||||
IsEnabled="{x:Bind Appearance.BackgroundImagePath, Mode=OneWay, Converter={StaticResource StringIsNotDesktopConverter}}" | ||||||
IsEnabled="{x:Bind local:Converters.StringsAreNotEqual('desktopWallpaper', Appearance.BackgroundImagePath), Mode=OneWay}" | ||||||
Style="{StaticResource BrowseButtonStyle}" /> | ||||||
</StackPanel> | ||||||
<CheckBox x:Name="UseDesktopImageCheckBox" | ||||||
|
@@ -431,10 +421,10 @@ | |||||
</Grid.ColumnDefinitions> | ||||||
<Slider x:Name="BIOpacitySlider" | ||||||
Grid.Column="0" | ||||||
Value="{x:Bind Appearance.BackgroundImageOpacity, Converter={StaticResource PercentageConverter}, Mode=TwoWay}" /> | ||||||
Value="{x:Bind local:Converters.PercentageToPercentageValue(Appearance.BackgroundImageOpacity), BindBack=Appearance.SetBackgroundImageOpacityFromPercentageValue, Mode=TwoWay}" /> | ||||||
<TextBlock Grid.Column="1" | ||||||
Style="{StaticResource SliderValueLabelStyle}" | ||||||
Text="{Binding ElementName=BIOpacitySlider, Path=Value, Mode=OneWay, Converter={StaticResource PercentageSignConverter}}" /> | ||||||
Text="{x:Bind local:Converters.AppendPercentageSign(BIOpacitySlider.Value), Mode=OneWay}" /> | ||||||
</Grid> | ||||||
</local:SettingContainer> | ||||||
</StackPanel> | ||||||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 😄