[settings-editor] Switch to function bindings instead of Converter objects (#10846)
## 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
This commit is contained in:
parent
cccaab8545
commit
8ab3422b57
|
@ -158,7 +158,6 @@
|
||||||
|
|
||||||
<!-- Converters & Misc. -->
|
<!-- Converters & Misc. -->
|
||||||
<model:IconPathConverter x:Key="IconSourceConverter" />
|
<model:IconPathConverter x:Key="IconSourceConverter" />
|
||||||
<local:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" />
|
|
||||||
<SolidColorBrush x:Key="ActionContainerBackgroundEditing"
|
<SolidColorBrush x:Key="ActionContainerBackgroundEditing"
|
||||||
Color="{ThemeResource SystemListMediumColor}" />
|
Color="{ThemeResource SystemListMediumColor}" />
|
||||||
<SolidColorBrush x:Key="ActionContainerBackground"
|
<SolidColorBrush x:Key="ActionContainerBackground"
|
||||||
|
@ -195,7 +194,7 @@
|
||||||
<TextBlock Grid.Column="0"
|
<TextBlock Grid.Column="0"
|
||||||
Style="{StaticResource KeyBindingNameTextBlockStyle}"
|
Style="{StaticResource KeyBindingNameTextBlockStyle}"
|
||||||
Text="{x:Bind Name, Mode=OneWay}"
|
Text="{x:Bind Name, Mode=OneWay}"
|
||||||
Visibility="{x:Bind IsInEditMode, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}" />
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(IsInEditMode), Mode=OneWay}" />
|
||||||
|
|
||||||
<!-- Edit Mode: Action Combo-box -->
|
<!-- Edit Mode: Action Combo-box -->
|
||||||
<ComboBox x:Uid="Actions_ActionComboBox"
|
<ComboBox x:Uid="Actions_ActionComboBox"
|
||||||
|
@ -211,7 +210,7 @@
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{ThemeResource KeyChordBorderStyle}"
|
Style="{ThemeResource KeyChordBorderStyle}"
|
||||||
Visibility="{x:Bind IsInEditMode, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(IsInEditMode), Mode=OneWay}">
|
||||||
|
|
||||||
<TextBlock FontSize="14"
|
<TextBlock FontSize="14"
|
||||||
Style="{ThemeResource KeyChordTextBlockStyle}"
|
Style="{ThemeResource KeyChordTextBlockStyle}"
|
||||||
|
@ -303,7 +302,7 @@
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
AutomationProperties.Name="{x:Bind DeleteButtonName}"
|
AutomationProperties.Name="{x:Bind DeleteButtonName}"
|
||||||
Style="{StaticResource EditButtonStyle}"
|
Style="{StaticResource EditButtonStyle}"
|
||||||
Visibility="{x:Bind IsNewlyAdded, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(IsNewlyAdded), Mode=OneWay}">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
|
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
|
||||||
Glyph="" />
|
Glyph="" />
|
||||||
|
|
|
@ -51,6 +51,19 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
public:
|
public:
|
||||||
AppearanceViewModel(const Model::AppearanceConfig& appearance);
|
AppearanceViewModel(const Model::AppearanceConfig& appearance);
|
||||||
|
|
||||||
|
void SetFontWeightFromDouble(double fontWeight)
|
||||||
|
{
|
||||||
|
FontWeight(winrt::Microsoft::Terminal::Settings::Editor::Converters::DoubleToFontWeight(fontWeight));
|
||||||
|
}
|
||||||
|
void SetBackgroundImageOpacityFromPercentageValue(double percentageValue)
|
||||||
|
{
|
||||||
|
BackgroundImageOpacity(winrt::Microsoft::Terminal::Settings::Editor::Converters::PercentageValueToPercentage(percentageValue));
|
||||||
|
}
|
||||||
|
void SetBackgroundImagePath(winrt::hstring path)
|
||||||
|
{
|
||||||
|
BackgroundImagePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
// background image
|
// background image
|
||||||
bool UseDesktopBGImage();
|
bool UseDesktopBGImage();
|
||||||
void UseDesktopBGImage(const bool useDesktop);
|
void UseDesktopBGImage(const bool useDesktop);
|
||||||
|
|
|
@ -23,6 +23,10 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||||
{
|
{
|
||||||
Boolean IsDefault;
|
Boolean IsDefault;
|
||||||
|
|
||||||
|
void SetFontWeightFromDouble(Double fontWeight);
|
||||||
|
void SetBackgroundImageOpacityFromPercentageValue(Double percentageValue);
|
||||||
|
void SetBackgroundImagePath(String path);
|
||||||
|
|
||||||
Boolean UseDesktopBGImage;
|
Boolean UseDesktopBGImage;
|
||||||
Boolean BackgroundImageSettingsVisible { get; };
|
Boolean BackgroundImageSettingsVisible { get; };
|
||||||
|
|
||||||
|
@ -68,5 +72,6 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> FontWeightList { get; };
|
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> FontWeightList { get; };
|
||||||
|
|
||||||
IInspectable CurrentFontFace { get; };
|
IInspectable CurrentFontFace { get; };
|
||||||
|
Windows.UI.Xaml.Controls.Slider BIOpacitySlider { get; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,6 @@
|
||||||
<TextBlock FontFamily="{x:Bind Name}"
|
<TextBlock FontFamily="{x:Bind Name}"
|
||||||
Text="{x:Bind LocalizedName}" />
|
Text="{x:Bind LocalizedName}" />
|
||||||
</DataTemplate>
|
</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>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
@ -87,7 +77,7 @@
|
||||||
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}"
|
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}"
|
||||||
SelectionChanged="FontFace_SelectionChanged"
|
SelectionChanged="FontFace_SelectionChanged"
|
||||||
Style="{StaticResource ComboBoxSettingStyle}"
|
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}"
|
<ComboBox ItemTemplate="{StaticResource FontFaceComboBoxItemTemplate}"
|
||||||
ItemsSource="{x:Bind SourceProfile.CompleteFontList, Mode=OneWay}"
|
ItemsSource="{x:Bind SourceProfile.CompleteFontList, Mode=OneWay}"
|
||||||
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}"
|
SelectedItem="{x:Bind CurrentFontFace, Mode=OneWay}"
|
||||||
|
@ -144,7 +134,7 @@
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
TickFrequency="50"
|
TickFrequency="50"
|
||||||
TickPlacement="Outside"
|
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}" />
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
Style="{StaticResource SliderValueLabelStyle}"
|
Style="{StaticResource SliderValueLabelStyle}"
|
||||||
|
@ -215,12 +205,12 @@
|
||||||
SettingOverrideSource="{x:Bind Appearance.BackgroundImagePathOverrideSource, Mode=OneWay}">
|
SettingOverrideSource="{x:Bind Appearance.BackgroundImagePathOverrideSource, Mode=OneWay}">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<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}"
|
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}" />
|
||||||
<Button x:Uid="Profile_BackgroundImageBrowse"
|
<Button x:Uid="Profile_BackgroundImageBrowse"
|
||||||
Click="BackgroundImage_Click"
|
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}" />
|
Style="{StaticResource BrowseButtonStyle}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<CheckBox x:Name="UseDesktopImageCheckBox"
|
<CheckBox x:Name="UseDesktopImageCheckBox"
|
||||||
|
@ -431,10 +421,10 @@
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Slider x:Name="BIOpacitySlider"
|
<Slider x:Name="BIOpacitySlider"
|
||||||
Grid.Column="0"
|
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"
|
<TextBlock Grid.Column="1"
|
||||||
Style="{StaticResource SliderValueLabelStyle}"
|
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>
|
</Grid>
|
||||||
</local:SettingContainer>
|
</local:SettingContainer>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ColorLightenConverter.h"
|
|
||||||
#include "ColorLightenConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
using namespace winrt::Windows::UI::Text;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable ColorLightenConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
auto original = winrt::unbox_value_or<Color>(value, Color{ 255, 0, 0, 0 });
|
|
||||||
auto result = original;
|
|
||||||
result.A = 128; // halfway transparent
|
|
||||||
return winrt::box_value(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable ColorLightenConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ColorLightenConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, ColorLightenConverter);
|
|
|
@ -60,7 +60,7 @@
|
||||||
<DataTemplate x:Key="ColorTableEntryTemplate"
|
<DataTemplate x:Key="ColorTableEntryTemplate"
|
||||||
x:DataType="local:ColorTableEntry">
|
x:DataType="local:ColorTableEntry">
|
||||||
<Button AutomationProperties.Name="{x:Bind Name}"
|
<Button AutomationProperties.Name="{x:Bind Name}"
|
||||||
Background="{x:Bind Color, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}"
|
Background="{x:Bind local:Converters.ColorToBrush(Color), Mode=OneWay}"
|
||||||
Style="{StaticResource ColorButtonStyle}"
|
Style="{StaticResource ColorButtonStyle}"
|
||||||
ToolTipService.ToolTip="{x:Bind Name}">
|
ToolTipService.ToolTip="{x:Bind Name}">
|
||||||
<Button.Resources>
|
<Button.Resources>
|
||||||
|
@ -69,11 +69,11 @@
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary x:Key="Light">
|
<ResourceDictionary x:Key="Light">
|
||||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
|
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
|
||||||
Color="{x:Bind Color, Converter={StaticResource ColorLightenConverter}, Mode=OneWay}" />
|
Color="{x:Bind local:Converters.LightenColor(Color), Mode=OneWay}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
<ResourceDictionary x:Key="Dark">
|
<ResourceDictionary x:Key="Dark">
|
||||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
|
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
|
||||||
Color="{x:Bind Color, Converter={StaticResource ColorLightenConverter}, Mode=OneWay}" />
|
Color="{x:Bind local:Converters.LightenColor(Color), Mode=OneWay}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
<!-- No High contrast dictionary, let's just leave that unchanged. -->
|
<!-- No High contrast dictionary, let's just leave that unchanged. -->
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
@ -90,11 +90,6 @@
|
||||||
</Button>
|
</Button>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<local:ColorToBrushConverter x:Key="ColorToBrushConverter" />
|
|
||||||
<local:ColorToHexConverter x:Key="ColorToHexConverter" />
|
|
||||||
<local:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" />
|
|
||||||
<local:ColorLightenConverter x:Key="ColorLightenConverter" />
|
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
|
@ -106,7 +101,7 @@
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Visibility="{x:Bind IsRenaming, Converter={StaticResource InvertedBooleanToVisibilityConverter}, Mode=OneWay}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(IsRenaming), Mode=OneWay}">
|
||||||
<!-- Select a color scheme -->
|
<!-- Select a color scheme -->
|
||||||
<ComboBox x:Name="ColorSchemeComboBox"
|
<ComboBox x:Name="ColorSchemeComboBox"
|
||||||
ItemsSource="{x:Bind ColorSchemeList, Mode=OneWay}"
|
ItemsSource="{x:Bind ColorSchemeList, Mode=OneWay}"
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ColorToBrushConverter.h"
|
|
||||||
#include "ColorToBrushConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable ColorToBrushConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
return winrt::box_value(Windows::UI::Xaml::Media::SolidColorBrush(winrt::unbox_value<Windows::UI::Color>(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable ColorToBrushConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ColorToBrushConverter.g.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
struct ColorToBrushConverter : ColorToBrushConverterT<ColorToBrushConverter>
|
|
||||||
{
|
|
||||||
ColorToBrushConverter() = default;
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
||||||
{
|
|
||||||
BASIC_FACTORY(ColorToBrushConverter);
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ColorToHexConverter.h"
|
|
||||||
#include "ColorToHexConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable ColorToHexConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
til::color color{ winrt::unbox_value<winrt::Windows::UI::Color>(value) };
|
|
||||||
auto hex = winrt::to_hstring(color.ToHexString().data());
|
|
||||||
return winrt::box_value(hex);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable ColorToHexConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ColorToHexConverter.g.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
struct ColorToHexConverter : ColorToHexConverterT<ColorToHexConverter>
|
|
||||||
{
|
|
||||||
ColorToHexConverter() = default;
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
||||||
{
|
|
||||||
BASIC_FACTORY(ColorToHexConverter);
|
|
||||||
}
|
|
106
src/cascadia/TerminalSettingsEditor/Converters.cpp
Normal file
106
src/cascadia/TerminalSettingsEditor/Converters.cpp
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
#include "pch.h"
|
||||||
|
#include "Converters.h"
|
||||||
|
#if __has_include("Converters.g.cpp")
|
||||||
|
#include "Converters.g.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
|
{
|
||||||
|
winrt::hstring Converters::AppendPercentageSign(double value)
|
||||||
|
{
|
||||||
|
const auto number{ value };
|
||||||
|
return to_hstring((int)number) + L"%";
|
||||||
|
}
|
||||||
|
|
||||||
|
winrt::Windows::UI::Xaml::Media::SolidColorBrush Converters::ColorToBrush(winrt::Windows::UI::Color color)
|
||||||
|
{
|
||||||
|
return Windows::UI::Xaml::Media::SolidColorBrush(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
winrt::Windows::UI::Text::FontWeight Converters::DoubleToFontWeight(double value)
|
||||||
|
{
|
||||||
|
return winrt::Windows::UI::Text::FontWeight{ base::ClampedNumeric<uint16_t>(value) };
|
||||||
|
}
|
||||||
|
|
||||||
|
double Converters::FontWeightToDouble(winrt::Windows::UI::Text::FontWeight fontWeight)
|
||||||
|
{
|
||||||
|
return fontWeight.Weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Converters::InvertBoolean(bool value)
|
||||||
|
{
|
||||||
|
return !value;
|
||||||
|
}
|
||||||
|
|
||||||
|
winrt::Windows::UI::Xaml::Visibility Converters::InvertedBooleanToVisibility(bool value)
|
||||||
|
{
|
||||||
|
return value ? winrt::Windows::UI::Xaml::Visibility::Collapsed : winrt::Windows::UI::Xaml::Visibility::Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
winrt::Windows::UI::Color Converters::LightenColor(winrt::Windows::UI::Color color)
|
||||||
|
{
|
||||||
|
color.A = 128; // halfway transparent
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Converters::MaxValueFromPaddingString(winrt::hstring paddingString)
|
||||||
|
{
|
||||||
|
const wchar_t singleCharDelim = L',';
|
||||||
|
std::wstringstream tokenStream(paddingString.c_str());
|
||||||
|
std::wstring token;
|
||||||
|
double maxVal = 0;
|
||||||
|
size_t* idx = nullptr;
|
||||||
|
|
||||||
|
// Get padding values till we run out of delimiter separated values in the stream
|
||||||
|
// Non-numeral values detected will default to 0
|
||||||
|
// std::getline will not throw exception unless flags are set on the wstringstream
|
||||||
|
// std::stod will throw invalid_argument exception if the input is an invalid double value
|
||||||
|
// std::stod will throw out_of_range exception if the input value is more than DBL_MAX
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (std::getline(tokenStream, token, singleCharDelim))
|
||||||
|
{
|
||||||
|
// std::stod internally calls wcstod which handles whitespace prefix (which is ignored)
|
||||||
|
// & stops the scan when first char outside the range of radix is encountered
|
||||||
|
// We'll be permissive till the extent that stod function allows us to be by default
|
||||||
|
// Ex. a value like 100.3#535w2 will be read as 100.3, but ;df25 will fail
|
||||||
|
const auto curVal = std::stod(token, idx);
|
||||||
|
if (curVal > maxVal)
|
||||||
|
{
|
||||||
|
maxVal = curVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// If something goes wrong, even if due to a single bad padding value, we'll return default 0 padding
|
||||||
|
maxVal = 0;
|
||||||
|
LOG_CAUGHT_EXCEPTION();
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Converters::PercentageToPercentageValue(double value)
|
||||||
|
{
|
||||||
|
return base::ClampMul(value, 100u);
|
||||||
|
}
|
||||||
|
|
||||||
|
double Converters::PercentageValueToPercentage(double value)
|
||||||
|
{
|
||||||
|
return base::ClampDiv<double, double>(value, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Converters::StringsAreNotEqual(winrt::hstring expected, winrt::hstring actual)
|
||||||
|
{
|
||||||
|
return expected != actual;
|
||||||
|
}
|
||||||
|
winrt::Windows::UI::Xaml::Visibility Converters::StringNotEmptyToVisibility(winrt::hstring value)
|
||||||
|
{
|
||||||
|
return value.empty() ? winrt::Windows::UI::Xaml::Visibility::Collapsed : winrt::Windows::UI::Xaml::Visibility::Visible;
|
||||||
|
}
|
||||||
|
winrt::hstring Converters::StringFallBackToEmptyString(winrt::hstring expected, winrt::hstring actual)
|
||||||
|
{
|
||||||
|
return expected == actual ? expected : L"";
|
||||||
|
}
|
||||||
|
}
|
33
src/cascadia/TerminalSettingsEditor/Converters.h
Normal file
33
src/cascadia/TerminalSettingsEditor/Converters.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (c) Microsoft Corporation.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Converters.g.h"
|
||||||
|
|
||||||
|
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
|
{
|
||||||
|
struct Converters : ConvertersT<Converters>
|
||||||
|
{
|
||||||
|
static winrt::hstring AppendPercentageSign(double value);
|
||||||
|
static winrt::Windows::UI::Text::FontWeight DoubleToFontWeight(double value);
|
||||||
|
static winrt::Windows::UI::Xaml::Media::SolidColorBrush ColorToBrush(winrt::Windows::UI::Color color);
|
||||||
|
static double FontWeightToDouble(winrt::Windows::UI::Text::FontWeight fontWeight);
|
||||||
|
static bool InvertBoolean(bool value);
|
||||||
|
static winrt::Windows::UI::Xaml::Visibility InvertedBooleanToVisibility(bool value);
|
||||||
|
static winrt::Windows::UI::Color LightenColor(winrt::Windows::UI::Color color);
|
||||||
|
static double MaxValueFromPaddingString(winrt::hstring paddingString);
|
||||||
|
static int PercentageToPercentageValue(double value);
|
||||||
|
static double PercentageValueToPercentage(double value);
|
||||||
|
static bool StringsAreNotEqual(winrt::hstring expected, winrt::hstring actual);
|
||||||
|
static winrt::Windows::UI::Xaml::Visibility StringNotEmptyToVisibility(winrt::hstring value);
|
||||||
|
static winrt::hstring StringFallBackToEmptyString(winrt::hstring expected, winrt::hstring actual);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
||||||
|
{
|
||||||
|
struct Converters : ConvertersT<Converters, implementation::Converters>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,63 +4,22 @@
|
||||||
namespace Microsoft.Terminal.Settings.Editor
|
namespace Microsoft.Terminal.Settings.Editor
|
||||||
{
|
{
|
||||||
|
|
||||||
runtimeclass ColorLightenConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
[bindable]
|
||||||
|
[default_interface] static runtimeclass Converters
|
||||||
{
|
{
|
||||||
ColorLightenConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass FontWeightConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
static String AppendPercentageSign(Double value);
|
||||||
{
|
static Windows.UI.Text.FontWeight DoubleToFontWeight(Double value);
|
||||||
FontWeightConverter();
|
static Windows.UI.Xaml.Media.SolidColorBrush ColorToBrush(Windows.UI.Color color);
|
||||||
};
|
static Double FontWeightToDouble(Windows.UI.Text.FontWeight fontWeight);
|
||||||
|
static Boolean InvertBoolean(Boolean value);
|
||||||
runtimeclass InvertedBooleanConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
static Windows.UI.Xaml.Visibility InvertedBooleanToVisibility(Boolean value);
|
||||||
{
|
static Windows.UI.Color LightenColor(Windows.UI.Color color);
|
||||||
InvertedBooleanConverter();
|
static Double MaxValueFromPaddingString(String paddingString);
|
||||||
};
|
static Int32 PercentageToPercentageValue(Double value);
|
||||||
|
static Double PercentageValueToPercentage(Double value);
|
||||||
runtimeclass InvertedBooleanToVisibilityConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
static Boolean StringsAreNotEqual(String expected, String actual);
|
||||||
{
|
static Windows.UI.Xaml.Visibility StringNotEmptyToVisibility(String value);
|
||||||
InvertedBooleanToVisibilityConverter();
|
static String StringFallBackToEmptyString(String expected, String actual);
|
||||||
};
|
}
|
||||||
|
|
||||||
runtimeclass ColorToBrushConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
ColorToBrushConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass ColorToHexConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
ColorToHexConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass PercentageConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
PercentageConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass PercentageSignConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
PercentageSignConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass StringIsEmptyConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
StringIsEmptyConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass PaddingConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
PaddingConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass StringIsNotDesktopConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
StringIsNotDesktopConverter();
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeclass DesktopWallpaperToEmptyStringConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
|
||||||
{
|
|
||||||
DesktopWallpaperToEmptyStringConverter();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "FontWeightConverter.h"
|
|
||||||
#include "FontWeightConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
using namespace winrt::Windows::UI::Text;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable FontWeightConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto weight{ winrt::unbox_value<FontWeight>(value) };
|
|
||||||
return winrt::box_value<double>(weight.Weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable FontWeightConverter::ConvertBack(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto sliderVal{ winrt::unbox_value<double>(value) };
|
|
||||||
FontWeight weight{ base::ClampedNumeric<uint16_t>(sliderVal) };
|
|
||||||
return winrt::box_value<FontWeight>(weight);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "FontWeightConverter.g.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
struct FontWeightConverter : FontWeightConverterT<FontWeightConverter>
|
|
||||||
{
|
|
||||||
FontWeightConverter() = default;
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
||||||
{
|
|
||||||
BASIC_FACTORY(FontWeightConverter);
|
|
||||||
}
|
|
|
@ -21,8 +21,6 @@
|
||||||
x:DataType="local:EnumEntry">
|
x:DataType="local:EnumEntry">
|
||||||
<RadioButton Content="{x:Bind EnumName, Mode=OneWay}" />
|
<RadioButton Content="{x:Bind EnumName, Mode=OneWay}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<local:InvertedBooleanConverter x:Key="InvertedBooleanConverter" />
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
|
@ -79,7 +77,7 @@
|
||||||
<!-- Disable Animations -->
|
<!-- Disable Animations -->
|
||||||
<!-- NOTE: the UID is "DisablePaneAnimationsReversed" not "DisablePaneAnimations". See GH#9124 for more details. -->
|
<!-- NOTE: the UID is "DisablePaneAnimationsReversed" not "DisablePaneAnimations". See GH#9124 for more details. -->
|
||||||
<local:SettingContainer x:Uid="Globals_DisableAnimationsReversed">
|
<local:SettingContainer x:Uid="Globals_DisableAnimationsReversed">
|
||||||
<ToggleSwitch IsOn="{x:Bind State.Globals.DisableAnimations, Mode=TwoWay, Converter={StaticResource InvertedBooleanConverter}}" />
|
<ToggleSwitch IsOn="{x:Bind local:Converters.InvertBoolean(State.Globals.DisableAnimations), BindBack=State.Globals.SetInvertedDisableAnimationsValue, Mode=TwoWay}" />
|
||||||
</local:SettingContainer>
|
</local:SettingContainer>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "InvertedBooleanConverter.h"
|
|
||||||
#include "InvertedBooleanConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable InvertedBooleanConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
return winrt::box_value(!winrt::unbox_value<bool>(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable InvertedBooleanConverter::ConvertBack(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
return winrt::box_value(!winrt::unbox_value<bool>(value));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "InvertedBooleanConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, InvertedBooleanConverter);
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "InvertedBooleanToVisibilityConverter.h"
|
|
||||||
#include "InvertedBooleanToVisibilityConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable InvertedBooleanToVisibilityConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
return winrt::box_value(winrt::unbox_value<bool>(value) ? Visibility::Collapsed : Visibility::Visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable InvertedBooleanToVisibilityConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "InvertedBooleanToVisibilityConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, InvertedBooleanToVisibilityConverter);
|
|
|
@ -42,41 +42,9 @@
|
||||||
<ClInclude Include="AddProfile.h">
|
<ClInclude Include="AddProfile.h">
|
||||||
<DependentUpon>AddProfile.xaml</DependentUpon>
|
<DependentUpon>AddProfile.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="ColorToBrushConverter.h">
|
<ClInclude Include="Converters.h">
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ColorLightenConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ColorToHexConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="FontWeightConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="InvertedBooleanConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="InvertedBooleanToVisibilityConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="KeyChordListener.h">
|
|
||||||
<DependentUpon>KeyChordListener.xaml</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="PercentageSignConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="StringIsEmptyConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="PaddingConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="StringIsNotDesktopConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="PercentageConverter.h">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
<DependentUpon>Converters.idl</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="EnumEntry.h">
|
<ClInclude Include="EnumEntry.h">
|
||||||
<DependentUpon>EnumEntry.idl</DependentUpon>
|
<DependentUpon>EnumEntry.idl</DependentUpon>
|
||||||
|
@ -91,6 +59,9 @@
|
||||||
<ClInclude Include="Interaction.h">
|
<ClInclude Include="Interaction.h">
|
||||||
<DependentUpon>Interaction.xaml</DependentUpon>
|
<DependentUpon>Interaction.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="KeyChordListener.h">
|
||||||
|
<DependentUpon>KeyChordListener.xaml</DependentUpon>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="Launch.h">
|
<ClInclude Include="Launch.h">
|
||||||
<DependentUpon>Launch.xaml</DependentUpon>
|
<DependentUpon>Launch.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -171,41 +142,9 @@
|
||||||
<ClCompile Include="AddProfile.cpp">
|
<ClCompile Include="AddProfile.cpp">
|
||||||
<DependentUpon>AddProfile.xaml</DependentUpon>
|
<DependentUpon>AddProfile.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="ColorToBrushConverter.cpp">
|
<ClCompile Include="Converters.cpp">
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ColorLightenConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ColorToHexConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="FontWeightConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="InvertedBooleanConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="InvertedBooleanToVisibilityConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="KeyChordListener.cpp">
|
|
||||||
<DependentUpon>KeyChordListener.xaml</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="PercentageSignConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="StringIsEmptyConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="PaddingConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="StringIsNotDesktopConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="PercentageConverter.cpp">
|
|
||||||
<DependentUpon>Converters.idl</DependentUpon>
|
<DependentUpon>Converters.idl</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="GlobalAppearance.cpp">
|
<ClCompile Include="GlobalAppearance.cpp">
|
||||||
<DependentUpon>GlobalAppearance.xaml</DependentUpon>
|
<DependentUpon>GlobalAppearance.xaml</DependentUpon>
|
||||||
|
@ -217,6 +156,9 @@
|
||||||
<ClCompile Include="Interaction.cpp">
|
<ClCompile Include="Interaction.cpp">
|
||||||
<DependentUpon>Interaction.xaml</DependentUpon>
|
<DependentUpon>Interaction.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="KeyChordListener.cpp">
|
||||||
|
<DependentUpon>KeyChordListener.xaml</DependentUpon>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="Launch.cpp">
|
<ClCompile Include="Launch.cpp">
|
||||||
<DependentUpon>Launch.xaml</DependentUpon>
|
<DependentUpon>Launch.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -339,7 +281,6 @@
|
||||||
<Private>true</Private>
|
<Private>true</Private>
|
||||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
|
||||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalSettingsModel\dll\Microsoft.Terminal.Settings.Model.vcxproj">
|
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalSettingsModel\dll\Microsoft.Terminal.Settings.Model.vcxproj">
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
@ -379,4 +320,4 @@
|
||||||
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets'))" />
|
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.5.0-prerelease.201202003\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
|
<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -10,16 +10,10 @@
|
||||||
<ClCompile Include="pch.cpp" />
|
<ClCompile Include="pch.cpp" />
|
||||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||||
<ClCompile Include="Utils.cpp" />
|
<ClCompile Include="Utils.cpp" />
|
||||||
<ClCompile Include="PercentageSignConverter.cpp">
|
|
||||||
<Filter>Converters</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="Utils.h" />
|
<ClInclude Include="Utils.h" />
|
||||||
<ClInclude Include="PercentageSignConverter.h">
|
|
||||||
<Filter>Converters</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="PreviewConnection.h" />
|
<ClInclude Include="PreviewConnection.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -49,9 +43,4 @@
|
||||||
<Page Include="ReadOnlyActions.xaml" />
|
<Page Include="ReadOnlyActions.xaml" />
|
||||||
<Page Include="KeyChordListener.xaml" />
|
<Page Include="KeyChordListener.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
</Project>
|
||||||
<Filter Include="Converters">
|
|
||||||
<UniqueIdentifier>{00f725c8-41b4-40a8-995e-8ee2e49a4a4c}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
|
@ -1,65 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "PaddingConverter.h"
|
|
||||||
#include "PaddingConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
using namespace winrt::Windows::UI::Text;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable PaddingConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto& padding = winrt::unbox_value<hstring>(value);
|
|
||||||
|
|
||||||
const wchar_t singleCharDelim = L',';
|
|
||||||
std::wstringstream tokenStream(padding.c_str());
|
|
||||||
std::wstring token;
|
|
||||||
double maxVal = 0;
|
|
||||||
size_t* idx = nullptr;
|
|
||||||
|
|
||||||
// Get padding values till we run out of delimiter separated values in the stream
|
|
||||||
// Non-numeral values detected will default to 0
|
|
||||||
// std::getline will not throw exception unless flags are set on the wstringstream
|
|
||||||
// std::stod will throw invalid_argument exception if the input is an invalid double value
|
|
||||||
// std::stod will throw out_of_range exception if the input value is more than DBL_MAX
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (std::getline(tokenStream, token, singleCharDelim))
|
|
||||||
{
|
|
||||||
// std::stod internally calls wcstod which handles whitespace prefix (which is ignored)
|
|
||||||
// & stops the scan when first char outside the range of radix is encountered
|
|
||||||
// We'll be permissive till the extent that stod function allows us to be by default
|
|
||||||
// Ex. a value like 100.3#535w2 will be read as 100.3, but ;df25 will fail
|
|
||||||
const auto curVal = std::stod(token, idx);
|
|
||||||
if (curVal > maxVal)
|
|
||||||
{
|
|
||||||
maxVal = curVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// If something goes wrong, even if due to a single bad padding value, we'll return default 0 padding
|
|
||||||
maxVal = 0;
|
|
||||||
LOG_CAUGHT_EXCEPTION();
|
|
||||||
}
|
|
||||||
|
|
||||||
return winrt::box_value<double>(maxVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable PaddingConverter::ConvertBack(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto padding{ winrt::unbox_value<double>(value) };
|
|
||||||
return winrt::box_value(winrt::to_hstring(padding));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "PaddingConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, PaddingConverter);
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "PercentageConverter.h"
|
|
||||||
#include "PercentageConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable PercentageConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto decimal{ winrt::unbox_value<double>(value) };
|
|
||||||
const unsigned int number{ base::ClampMul(decimal, 100u) };
|
|
||||||
return winrt::box_value<double>(number);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable PercentageConverter::ConvertBack(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto number{ winrt::unbox_value<double>(value) };
|
|
||||||
const auto decimal{ base::ClampDiv<double, double>(number, 100) };
|
|
||||||
return winrt::box_value<double>(decimal);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "PercentageConverter.g.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
struct PercentageConverter : PercentageConverterT<PercentageConverter>
|
|
||||||
{
|
|
||||||
PercentageConverter() = default;
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
|
|
||||||
Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
|
||||||
Windows::Foundation::IInspectable const& parameter,
|
|
||||||
hstring const& language);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
||||||
{
|
|
||||||
BASIC_FACTORY(PercentageConverter);
|
|
||||||
}
|
|
|
@ -20,6 +20,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||||
|
|
||||||
Model::TerminalSettings TermSettings() const;
|
Model::TerminalSettings TermSettings() const;
|
||||||
|
|
||||||
|
void SetAcrylicOpacityPercentageValue(double value)
|
||||||
|
{
|
||||||
|
AcrylicOpacity(winrt::Microsoft::Terminal::Settings::Editor::Converters::PercentageValueToPercentage(value));
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetPadding(double value)
|
||||||
|
{
|
||||||
|
Padding(to_hstring(value));
|
||||||
|
}
|
||||||
|
|
||||||
// starting directory
|
// starting directory
|
||||||
bool UseParentProcessDirectory();
|
bool UseParentProcessDirectory();
|
||||||
void UseParentProcessDirectory(const bool useParent);
|
void UseParentProcessDirectory(const bool useParent);
|
||||||
|
|
|
@ -19,6 +19,9 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||||
Windows.Foundation.Collections.IObservableVector<Font> MonospaceFontList { get; };
|
Windows.Foundation.Collections.IObservableVector<Font> MonospaceFontList { get; };
|
||||||
Microsoft.Terminal.Settings.Model.TerminalSettings TermSettings { get; };
|
Microsoft.Terminal.Settings.Model.TerminalSettings TermSettings { get; };
|
||||||
|
|
||||||
|
void SetAcrylicOpacityPercentageValue(Double value);
|
||||||
|
void SetPadding(Double value);
|
||||||
|
|
||||||
Boolean CanDeleteProfile { get; };
|
Boolean CanDeleteProfile { get; };
|
||||||
Boolean IsBaseLayer;
|
Boolean IsBaseLayer;
|
||||||
Boolean UseParentProcessDirectory;
|
Boolean UseParentProcessDirectory;
|
||||||
|
@ -105,5 +108,7 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||||
|
|
||||||
IInspectable CurrentScrollState;
|
IInspectable CurrentScrollState;
|
||||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> ScrollStateList { get; };
|
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> ScrollStateList { get; };
|
||||||
|
|
||||||
|
Windows.UI.Xaml.Controls.Slider AcrylicOpacitySlider { get; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,17 +33,6 @@
|
||||||
<TextBlock FontFamily="{x:Bind Name}"
|
<TextBlock FontFamily="{x:Bind Name}"
|
||||||
Text="{x:Bind LocalizedName}" />
|
Text="{x:Bind LocalizedName}" />
|
||||||
</DataTemplate>
|
</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>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
|
@ -78,7 +67,7 @@
|
||||||
-->
|
-->
|
||||||
<local:SettingContainer x:Uid="Profile_Name"
|
<local:SettingContainer x:Uid="Profile_Name"
|
||||||
Margin="0,0,0,24"
|
Margin="0,0,0,24"
|
||||||
Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.IsBaseLayer), Mode=OneWay}">
|
||||||
<TextBox Style="{StaticResource TextBoxSettingStyle}"
|
<TextBox Style="{StaticResource TextBoxSettingStyle}"
|
||||||
Text="{x:Bind State.Profile.Name, Mode=TwoWay}" />
|
Text="{x:Bind State.Profile.Name, Mode=TwoWay}" />
|
||||||
</local:SettingContainer>
|
</local:SettingContainer>
|
||||||
|
@ -90,7 +79,7 @@
|
||||||
ClearSettingValue="{x:Bind State.Profile.ClearCommandline}"
|
ClearSettingValue="{x:Bind State.Profile.ClearCommandline}"
|
||||||
HasSettingValue="{x:Bind State.Profile.HasCommandline, Mode=OneWay}"
|
HasSettingValue="{x:Bind State.Profile.HasCommandline, Mode=OneWay}"
|
||||||
SettingOverrideSource="{x:Bind State.Profile.CommandlineOverrideSource, Mode=OneWay}"
|
SettingOverrideSource="{x:Bind State.Profile.CommandlineOverrideSource, Mode=OneWay}"
|
||||||
Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.IsBaseLayer), Mode=OneWay}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBox Style="{StaticResource TextBoxSettingStyle}"
|
<TextBox Style="{StaticResource TextBoxSettingStyle}"
|
||||||
Text="{x:Bind State.Profile.Commandline, Mode=TwoWay}" />
|
Text="{x:Bind State.Profile.Commandline, Mode=TwoWay}" />
|
||||||
|
@ -150,7 +139,7 @@
|
||||||
|
|
||||||
<!-- Hidden -->
|
<!-- Hidden -->
|
||||||
<local:SettingContainer x:Uid="Profile_Hidden"
|
<local:SettingContainer x:Uid="Profile_Hidden"
|
||||||
Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.IsBaseLayer), Mode=OneWay}">
|
||||||
<ToggleSwitch IsOn="{x:Bind State.Profile.Hidden, Mode=TwoWay}" />
|
<ToggleSwitch IsOn="{x:Bind State.Profile.Hidden, Mode=TwoWay}" />
|
||||||
</local:SettingContainer>
|
</local:SettingContainer>
|
||||||
|
|
||||||
|
@ -280,10 +269,10 @@
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Slider x:Name="AcrylicOpacitySlider"
|
<Slider x:Name="AcrylicOpacitySlider"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Value="{x:Bind State.Profile.AcrylicOpacity, Converter={StaticResource PercentageConverter}, Mode=TwoWay}" />
|
Value="{x:Bind local:Converters.PercentageToPercentageValue(State.Profile.AcrylicOpacity), BindBack=State.Profile.SetAcrylicOpacityPercentageValue, Mode=TwoWay}" />
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
Style="{StaticResource SliderValueLabelStyle}"
|
Style="{StaticResource SliderValueLabelStyle}"
|
||||||
Text="{Binding ElementName=AcrylicOpacitySlider, Path=Value, Mode=OneWay, Converter={StaticResource PercentageSignConverter}}" />
|
Text="{x:Bind local:Converters.AppendPercentageSign(AcrylicOpacitySlider.Value), Mode=OneWay}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</local:SettingContainer>
|
</local:SettingContainer>
|
||||||
|
@ -307,7 +296,7 @@
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Slider x:Name="PaddingSlider"
|
<Slider x:Name="PaddingSlider"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Value="{x:Bind State.Profile.Padding, Converter={StaticResource PaddingConverter}, Mode=TwoWay}" />
|
Value="{x:Bind local:Converters.MaxValueFromPaddingString(State.Profile.Padding), BindBack=State.Profile.SetPadding, Mode=TwoWay}" />
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
Style="{StaticResource SliderValueLabelStyle}"
|
Style="{StaticResource SliderValueLabelStyle}"
|
||||||
Text="{Binding ElementName=PaddingSlider, Path=Value, Mode=OneWay}" />
|
Text="{Binding ElementName=PaddingSlider, Path=Value, Mode=OneWay}" />
|
||||||
|
@ -333,7 +322,7 @@
|
||||||
Margin="32,0,0,0"
|
Margin="32,0,0,0"
|
||||||
Click="CreateUnfocusedAppearance_Click"
|
Click="CreateUnfocusedAppearance_Click"
|
||||||
Style="{StaticResource BaseButtonStyle}"
|
Style="{StaticResource BaseButtonStyle}"
|
||||||
Visibility="{x:Bind State.Profile.HasUnfocusedAppearance, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
|
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.HasUnfocusedAppearance), Mode=OneWay}">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<FontIcon FontSize="{StaticResource StandardIconSize}"
|
<FontIcon FontSize="{StaticResource StandardIconSize}"
|
||||||
Glyph="" />
|
Glyph="" />
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="CommonResources.xaml" />
|
<ResourceDictionary Source="CommonResources.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<local:StringIsEmptyConverter x:Key="CommandKeyChordVisibilityConverter" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Template for actions. This is _heavily_ copied from the command
|
Template for actions. This is _heavily_ copied from the command
|
||||||
palette, with modifications:
|
palette, with modifications:
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "StringIsEmptyConverter.h"
|
|
||||||
#include "StringIsEmptyConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
using namespace winrt::Windows::UI::Text;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable StringIsEmptyConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
const auto& name = winrt::unbox_value_or<hstring>(value, L"");
|
|
||||||
return winrt::box_value(name.empty() ? Visibility::Collapsed : Visibility::Visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable StringIsEmptyConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "StringIsEmptyConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, StringIsEmptyConverter);
|
|
|
@ -1,50 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "StringIsNotDesktopConverter.h"
|
|
||||||
#include "StringIsNotDesktopConverter.g.cpp"
|
|
||||||
#include "DesktopWallpaperToEmptyStringConverter.g.cpp"
|
|
||||||
|
|
||||||
using namespace winrt::Windows;
|
|
||||||
using namespace winrt::Windows::UI::Xaml;
|
|
||||||
using namespace winrt::Windows::UI::Text;
|
|
||||||
|
|
||||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
||||||
{
|
|
||||||
Foundation::IInspectable StringIsNotDesktopConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
// Returns Visible if the string is _not_ "desktopWallpaper", else returns Collapsed
|
|
||||||
const auto& name = winrt::unbox_value_or<hstring>(value, L"");
|
|
||||||
return winrt::box_value(name != L"desktopWallpaper");
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable StringIsNotDesktopConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
throw hresult_not_implemented();
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable DesktopWallpaperToEmptyStringConverter::Convert(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /* parameter */,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
// Returns the empty string if the string is "desktopWallpaper", else returns the original value.
|
|
||||||
const auto& name = winrt::unbox_value_or<hstring>(value, L"");
|
|
||||||
return winrt::box_value(name == L"desktopWallpaper" ? L"" : name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foundation::IInspectable DesktopWallpaperToEmptyStringConverter::ConvertBack(Foundation::IInspectable const& value,
|
|
||||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
||||||
Foundation::IInspectable const& /*parameter*/,
|
|
||||||
hstring const& /* language */)
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT license.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "StringIsNotDesktopConverter.g.h"
|
|
||||||
#include "DesktopWallpaperToEmptyStringConverter.g.h"
|
|
||||||
#include "../inc/cppwinrt_utils.h"
|
|
||||||
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, StringIsNotDesktopConverter);
|
|
||||||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, DesktopWallpaperToEmptyStringConverter);
|
|
|
@ -60,6 +60,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||||
void UnparsedDefaultProfile(const hstring& value);
|
void UnparsedDefaultProfile(const hstring& value);
|
||||||
void ClearUnparsedDefaultProfile();
|
void ClearUnparsedDefaultProfile();
|
||||||
|
|
||||||
|
// TODO GH#9207: Remove this once we have a GlobalAppSettingsViewModel in TerminalSettingsEditor
|
||||||
|
void SetInvertedDisableAnimationsValue(bool invertedDisableAnimationsValue)
|
||||||
|
{
|
||||||
|
DisableAnimations(!invertedDisableAnimationsValue);
|
||||||
|
}
|
||||||
|
|
||||||
INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS);
|
INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS);
|
||||||
INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS);
|
INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS);
|
||||||
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true);
|
INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true);
|
||||||
|
|
|
@ -36,6 +36,9 @@ namespace Microsoft.Terminal.Settings.Model
|
||||||
|
|
||||||
[default_interface] runtimeclass GlobalAppSettings {
|
[default_interface] runtimeclass GlobalAppSettings {
|
||||||
Guid DefaultProfile;
|
Guid DefaultProfile;
|
||||||
|
|
||||||
|
void SetInvertedDisableAnimationsValue(Boolean invertedDisableAnimationsValue);
|
||||||
|
|
||||||
INHERITABLE_SETTING(String, UnparsedDefaultProfile);
|
INHERITABLE_SETTING(String, UnparsedDefaultProfile);
|
||||||
|
|
||||||
INHERITABLE_SETTING(Int32, InitialRows);
|
INHERITABLE_SETTING(Int32, InitialRows);
|
||||||
|
|
Loading…
Reference in a new issue