optional uint32

This commit is contained in:
Pankaj Bhojwani
2025-02-21 12:31:28 -08:00
parent 6d550b36ff
commit b5eafa6912
4 changed files with 30 additions and 16 deletions

View File

@@ -405,16 +405,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return winrt::unbox_value<uint32_t>(value);
}
uint32_t ArgWrapper::UnboxUInt32Optional(const Windows::Foundation::IInspectable& value)
float ArgWrapper::UnboxUInt32Optional(const Windows::Foundation::IInspectable& value)
{
const auto unboxed = winrt::unbox_value<winrt::Windows::Foundation::IReference<uint32_t>>(value);
if (unboxed)
{
return unboxed.Value();
return static_cast<float>(unboxed.Value());
}
else
{
return 0;
return NAN;
}
}
@@ -463,14 +463,26 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Value(box_value(newValue));
}
void ArgWrapper::DoubleBindBack(const double newValue)
void ArgWrapper::Int32BindBack(const double newValue)
{
Value(box_value(static_cast<int32_t>(newValue)));
}
void ArgWrapper::UInt32BindBack(const double newValue)
{
Value(box_value(static_cast<uint32_t>(newValue)));
}
void ArgWrapper::DoubleOptionalBindBack(const double newValue)
void ArgWrapper::UInt32OptionalBindBack(const double newValue)
{
Value(box_value(static_cast<uint32_t>(newValue)));
if (!isnan(newValue))
{
Value(box_value(static_cast<uint32_t>(newValue)));
}
else
{
Value(nullptr);
}
}
void ArgWrapper::FloatBindBack(const double newValue)

View File

@@ -189,16 +189,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
winrt::hstring UnboxString(const Windows::Foundation::IInspectable& value);
int32_t UnboxInt32(const Windows::Foundation::IInspectable& value);
uint32_t UnboxUInt32(const Windows::Foundation::IInspectable& value);
uint32_t UnboxUInt32Optional(const Windows::Foundation::IInspectable& value);
float UnboxUInt32Optional(const Windows::Foundation::IInspectable& value);
float UnboxFloat(const Windows::Foundation::IInspectable& value);
winrt::Windows::Foundation::IReference<bool> UnboxBoolOptional(const Windows::Foundation::IInspectable& value);
winrt::Windows::Foundation::IReference<Microsoft::Terminal::Core::Color> UnboxTerminalCoreColorOptional(const Windows::Foundation::IInspectable& value);
winrt::Windows::Foundation::IReference<Microsoft::Terminal::Core::Color> UnboxWindowsUIColorOptional(const Windows::Foundation::IInspectable& value);
// Bind back functions
// bind back functions
void StringBindBack(const winrt::hstring& newValue);
void DoubleBindBack(const double newValue);
void DoubleOptionalBindBack(const double newValue);
void Int32BindBack(const double newValue);
void UInt32BindBack(const double newValue);
void UInt32OptionalBindBack(const double newValue);
void FloatBindBack(const double newValue);
void BoolBindBack(const Windows::Foundation::IReference<bool> newValue);
void TerminalCoreColorBindBack(const winrt::Windows::Foundation::IReference<Microsoft::Terminal::Core::Color> newValue);

View File

@@ -93,7 +93,7 @@ namespace Microsoft.Terminal.Settings.Editor
String UnboxString(Object value);
UInt32 UnboxInt32(Object value);
UInt32 UnboxUInt32(Object value);
UInt32 UnboxUInt32Optional(Object value);
Single UnboxUInt32Optional(Object value);
Single UnboxFloat(Object value);
Windows.Foundation.IReference<Boolean> UnboxBoolOptional(Object value);
Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> UnboxTerminalCoreColorOptional(Object value);
@@ -101,8 +101,9 @@ namespace Microsoft.Terminal.Settings.Editor
// bind back functions
void StringBindBack(String newValue);
void DoubleBindBack(Double newValue);
void DoubleOptionalBindBack(Double newValue);
void Int32BindBack(Double newValue);
void UInt32BindBack(Double newValue);
void UInt32OptionalBindBack(Double newValue);
void FloatBindBack(Double newValue);
void BoolBindBack(Windows.Foundation.IReference<Boolean> newValue);
void TerminalCoreColorBindBack(Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> newValue);

View File

@@ -237,7 +237,7 @@
Spacing="8">
<TextBlock Text="{x:Bind Name}"
VerticalAlignment="Center" />
<muxc:NumberBox Value="{x:Bind UnboxInt32(Value), Mode=TwoWay, BindBack=DoubleBindBack}"
<muxc:NumberBox Value="{x:Bind UnboxInt32(Value), Mode=TwoWay, BindBack=Int32BindBack}"
Style="{StaticResource NumberBoxSettingStyle}"
Minimum="0"
Maximum="999"
@@ -254,7 +254,7 @@
Spacing="8">
<TextBlock Text="{x:Bind Name}"
VerticalAlignment="Center" />
<muxc:NumberBox Value="{x:Bind UnboxUInt32(Value), Mode=TwoWay, BindBack=DoubleBindBack}"
<muxc:NumberBox Value="{x:Bind UnboxUInt32(Value), Mode=TwoWay, BindBack=UInt32BindBack}"
Style="{StaticResource NumberBoxSettingStyle}"
Minimum="0"
Maximum="999"
@@ -271,7 +271,7 @@
Spacing="8">
<TextBlock Text="{x:Bind Name}"
VerticalAlignment="Center" />
<muxc:NumberBox Value="{x:Bind UnboxUInt32Optional(Value), Mode=TwoWay, BindBack=DoubleOptionalBindBack}"
<muxc:NumberBox Value="{x:Bind UnboxUInt32Optional(Value), Mode=TwoWay, BindBack=UInt32OptionalBindBack}"
Style="{StaticResource NumberBoxSettingStyle}"
Minimum="0"
Maximum="999"