diff --git a/dev/Generated/NumberBox.properties.cpp b/dev/Generated/NumberBox.properties.cpp index 7aaa1bf8e2..d3b3eb37a6 100644 --- a/dev/Generated/NumberBox.properties.cpp +++ b/dev/Generated/NumberBox.properties.cpp @@ -13,6 +13,7 @@ GlobalDependencyProperty NumberBoxProperties::s_DescriptionProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_HeaderProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_HeaderTemplateProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_IsWrapEnabledProperty{ nullptr }; +GlobalDependencyProperty NumberBoxProperties::s_LargeChangeProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_MaximumProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_MinimumProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_NumberFormatterProperty{ nullptr }; @@ -20,8 +21,8 @@ GlobalDependencyProperty NumberBoxProperties::s_PlaceholderTextProperty{ nullptr GlobalDependencyProperty NumberBoxProperties::s_PreventKeyboardDisplayOnProgrammaticFocusProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_SelectionFlyoutProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_SelectionHighlightColorProperty{ nullptr }; +GlobalDependencyProperty NumberBoxProperties::s_SmallChangeProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_SpinButtonPlacementModeProperty{ nullptr }; -GlobalDependencyProperty NumberBoxProperties::s_StepFrequencyProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_TextProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_TextReadingOrderProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_ValidationModeProperty{ nullptr }; @@ -90,6 +91,17 @@ void NumberBoxProperties::EnsureProperties() ValueHelper::BoxValueIfNecessary(false), winrt::PropertyChangedCallback(&OnIsWrapEnabledPropertyChanged)); } + if (!s_LargeChangeProperty) + { + s_LargeChangeProperty = + InitializeDependencyProperty( + L"LargeChange", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(10), + nullptr); + } if (!s_MaximumProperty) { s_MaximumProperty = @@ -167,6 +179,17 @@ void NumberBoxProperties::EnsureProperties() ValueHelper::BoxedDefaultValue(), nullptr); } + if (!s_SmallChangeProperty) + { + s_SmallChangeProperty = + InitializeDependencyProperty( + L"SmallChange", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(1), + winrt::PropertyChangedCallback(&OnSmallChangePropertyChanged)); + } if (!s_SpinButtonPlacementModeProperty) { s_SpinButtonPlacementModeProperty = @@ -178,17 +201,6 @@ void NumberBoxProperties::EnsureProperties() ValueHelper::BoxValueIfNecessary(winrt::NumberBoxSpinButtonPlacementMode::Hidden), winrt::PropertyChangedCallback(&OnSpinButtonPlacementModePropertyChanged)); } - if (!s_StepFrequencyProperty) - { - s_StepFrequencyProperty = - InitializeDependencyProperty( - L"StepFrequency", - winrt::name_of(), - winrt::name_of(), - false /* isAttached */, - ValueHelper::BoxValueIfNecessary(1), - winrt::PropertyChangedCallback(&OnStepFrequencyPropertyChanged)); - } if (!s_TextProperty) { s_TextProperty = @@ -242,6 +254,7 @@ void NumberBoxProperties::ClearProperties() s_HeaderProperty = nullptr; s_HeaderTemplateProperty = nullptr; s_IsWrapEnabledProperty = nullptr; + s_LargeChangeProperty = nullptr; s_MaximumProperty = nullptr; s_MinimumProperty = nullptr; s_NumberFormatterProperty = nullptr; @@ -249,8 +262,8 @@ void NumberBoxProperties::ClearProperties() s_PreventKeyboardDisplayOnProgrammaticFocusProperty = nullptr; s_SelectionFlyoutProperty = nullptr; s_SelectionHighlightColorProperty = nullptr; + s_SmallChangeProperty = nullptr; s_SpinButtonPlacementModeProperty = nullptr; - s_StepFrequencyProperty = nullptr; s_TextProperty = nullptr; s_TextReadingOrderProperty = nullptr; s_ValidationModeProperty = nullptr; @@ -299,20 +312,20 @@ void NumberBoxProperties::OnNumberFormatterPropertyChanged( winrt::get_self(owner)->OnNumberFormatterPropertyChanged(args); } -void NumberBoxProperties::OnSpinButtonPlacementModePropertyChanged( +void NumberBoxProperties::OnSmallChangePropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args) { auto owner = sender.as(); - winrt::get_self(owner)->OnSpinButtonPlacementModePropertyChanged(args); + winrt::get_self(owner)->OnSmallChangePropertyChanged(args); } -void NumberBoxProperties::OnStepFrequencyPropertyChanged( +void NumberBoxProperties::OnSpinButtonPlacementModePropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args) { auto owner = sender.as(); - winrt::get_self(owner)->OnStepFrequencyPropertyChanged(args); + winrt::get_self(owner)->OnSpinButtonPlacementModePropertyChanged(args); } void NumberBoxProperties::OnTextPropertyChanged( @@ -389,6 +402,16 @@ bool NumberBoxProperties::IsWrapEnabled() return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IsWrapEnabledProperty)); } +void NumberBoxProperties::LargeChange(double value) +{ + static_cast(this)->SetValue(s_LargeChangeProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +double NumberBoxProperties::LargeChange() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_LargeChangeProperty)); +} + void NumberBoxProperties::Maximum(double value) { static_cast(this)->SetValue(s_MaximumProperty, ValueHelper::BoxValueIfNecessary(value)); @@ -461,24 +484,24 @@ winrt::SolidColorBrush NumberBoxProperties::SelectionHighlightColor() return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SelectionHighlightColorProperty)); } -void NumberBoxProperties::SpinButtonPlacementMode(winrt::NumberBoxSpinButtonPlacementMode const& value) +void NumberBoxProperties::SmallChange(double value) { - static_cast(this)->SetValue(s_SpinButtonPlacementModeProperty, ValueHelper::BoxValueIfNecessary(value)); + static_cast(this)->SetValue(s_SmallChangeProperty, ValueHelper::BoxValueIfNecessary(value)); } -winrt::NumberBoxSpinButtonPlacementMode NumberBoxProperties::SpinButtonPlacementMode() +double NumberBoxProperties::SmallChange() { - return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SpinButtonPlacementModeProperty)); + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SmallChangeProperty)); } -void NumberBoxProperties::StepFrequency(double value) +void NumberBoxProperties::SpinButtonPlacementMode(winrt::NumberBoxSpinButtonPlacementMode const& value) { - static_cast(this)->SetValue(s_StepFrequencyProperty, ValueHelper::BoxValueIfNecessary(value)); + static_cast(this)->SetValue(s_SpinButtonPlacementModeProperty, ValueHelper::BoxValueIfNecessary(value)); } -double NumberBoxProperties::StepFrequency() +winrt::NumberBoxSpinButtonPlacementMode NumberBoxProperties::SpinButtonPlacementMode() { - return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_StepFrequencyProperty)); + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SpinButtonPlacementModeProperty)); } void NumberBoxProperties::Text(winrt::hstring const& value) diff --git a/dev/Generated/NumberBox.properties.h b/dev/Generated/NumberBox.properties.h index d74e011c37..fb9c4757db 100644 --- a/dev/Generated/NumberBox.properties.h +++ b/dev/Generated/NumberBox.properties.h @@ -24,6 +24,9 @@ class NumberBoxProperties void IsWrapEnabled(bool value); bool IsWrapEnabled(); + void LargeChange(double value); + double LargeChange(); + void Maximum(double value); double Maximum(); @@ -45,12 +48,12 @@ class NumberBoxProperties void SelectionHighlightColor(winrt::SolidColorBrush const& value); winrt::SolidColorBrush SelectionHighlightColor(); + void SmallChange(double value); + double SmallChange(); + void SpinButtonPlacementMode(winrt::NumberBoxSpinButtonPlacementMode const& value); winrt::NumberBoxSpinButtonPlacementMode SpinButtonPlacementMode(); - void StepFrequency(double value); - double StepFrequency(); - void Text(winrt::hstring const& value); winrt::hstring Text(); @@ -68,6 +71,7 @@ class NumberBoxProperties static winrt::DependencyProperty HeaderProperty() { return s_HeaderProperty; } static winrt::DependencyProperty HeaderTemplateProperty() { return s_HeaderTemplateProperty; } static winrt::DependencyProperty IsWrapEnabledProperty() { return s_IsWrapEnabledProperty; } + static winrt::DependencyProperty LargeChangeProperty() { return s_LargeChangeProperty; } static winrt::DependencyProperty MaximumProperty() { return s_MaximumProperty; } static winrt::DependencyProperty MinimumProperty() { return s_MinimumProperty; } static winrt::DependencyProperty NumberFormatterProperty() { return s_NumberFormatterProperty; } @@ -75,8 +79,8 @@ class NumberBoxProperties static winrt::DependencyProperty PreventKeyboardDisplayOnProgrammaticFocusProperty() { return s_PreventKeyboardDisplayOnProgrammaticFocusProperty; } static winrt::DependencyProperty SelectionFlyoutProperty() { return s_SelectionFlyoutProperty; } static winrt::DependencyProperty SelectionHighlightColorProperty() { return s_SelectionHighlightColorProperty; } + static winrt::DependencyProperty SmallChangeProperty() { return s_SmallChangeProperty; } static winrt::DependencyProperty SpinButtonPlacementModeProperty() { return s_SpinButtonPlacementModeProperty; } - static winrt::DependencyProperty StepFrequencyProperty() { return s_StepFrequencyProperty; } static winrt::DependencyProperty TextProperty() { return s_TextProperty; } static winrt::DependencyProperty TextReadingOrderProperty() { return s_TextReadingOrderProperty; } static winrt::DependencyProperty ValidationModeProperty() { return s_ValidationModeProperty; } @@ -87,6 +91,7 @@ class NumberBoxProperties static GlobalDependencyProperty s_HeaderProperty; static GlobalDependencyProperty s_HeaderTemplateProperty; static GlobalDependencyProperty s_IsWrapEnabledProperty; + static GlobalDependencyProperty s_LargeChangeProperty; static GlobalDependencyProperty s_MaximumProperty; static GlobalDependencyProperty s_MinimumProperty; static GlobalDependencyProperty s_NumberFormatterProperty; @@ -94,8 +99,8 @@ class NumberBoxProperties static GlobalDependencyProperty s_PreventKeyboardDisplayOnProgrammaticFocusProperty; static GlobalDependencyProperty s_SelectionFlyoutProperty; static GlobalDependencyProperty s_SelectionHighlightColorProperty; + static GlobalDependencyProperty s_SmallChangeProperty; static GlobalDependencyProperty s_SpinButtonPlacementModeProperty; - static GlobalDependencyProperty s_StepFrequencyProperty; static GlobalDependencyProperty s_TextProperty; static GlobalDependencyProperty s_TextReadingOrderProperty; static GlobalDependencyProperty s_ValidationModeProperty; @@ -125,11 +130,11 @@ class NumberBoxProperties winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args); - static void OnSpinButtonPlacementModePropertyChanged( + static void OnSmallChangePropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args); - static void OnStepFrequencyPropertyChanged( + static void OnSpinButtonPlacementModePropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args); diff --git a/dev/NumberBox/InteractionTests/NumberBoxTests.cs b/dev/NumberBox/InteractionTests/NumberBoxTests.cs index e1011a308a..a2082b1312 100644 --- a/dev/NumberBox/InteractionTests/NumberBoxTests.cs +++ b/dev/NumberBox/InteractionTests/NumberBoxTests.cs @@ -64,9 +64,9 @@ public void UpDownTest() downButton.InvokeAndWait(); Verify.AreEqual(0, numBox.Value); - Log.Comment("Change Step value to 5"); - RangeValueSpinner stepNumBox = FindElement.ByName("StepNumberBox"); - stepNumBox.SetValue(5); + Log.Comment("Change SmallChange value to 5"); + RangeValueSpinner smallChangeNumBox = FindElement.ByName("SmallChangeNumberBox"); + smallChangeNumBox.SetValue(5); Wait.ForIdle(); Log.Comment("Verify that up button increases value by 5"); @@ -267,6 +267,11 @@ public void BasicKeyboardTest() KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.AreEqual(75, numBox.Value); + + Log.Comment("Verify that pressing PageUp key increases value by 10"); + KeyboardHelper.PressKey(Key.PageUp); + Wait.ForIdle(); + Verify.AreEqual(85, numBox.Value); } } diff --git a/dev/NumberBox/NumberBox.cpp b/dev/NumberBox/NumberBox.cpp index 9975822241..85cabef6f8 100644 --- a/dev/NumberBox/NumberBox.cpp +++ b/dev/NumberBox/NumberBox.cpp @@ -189,7 +189,7 @@ void NumberBox::OnMaximumPropertyChanged(const winrt::DependencyPropertyChangedE UpdateSpinButtonEnabled(); } -void NumberBox::OnStepFrequencyPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +void NumberBox::OnSmallChangePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) { UpdateSpinButtonEnabled(); } @@ -353,12 +353,12 @@ void NumberBox::ValidateInput() void NumberBox::OnSpinDownClick(winrt::IInspectable const& sender, winrt::RoutedEventArgs const& args) { - StepValueDown(); + StepValue(-SmallChange()); } void NumberBox::OnSpinUpClick(winrt::IInspectable const& sender, winrt::RoutedEventArgs const& args) { - StepValueUp(); + StepValue(SmallChange()); } void NumberBox::OnNumberBoxKeyDown(winrt::IInspectable const& sender, winrt::KeyRoutedEventArgs const& args) @@ -367,12 +367,22 @@ void NumberBox::OnNumberBoxKeyDown(winrt::IInspectable const& sender, winrt::Key switch (args.OriginalKey()) { case winrt::VirtualKey::Up: - StepValueUp(); - args.Handled(true); + StepValue(SmallChange()); + args.Handled(true); break; case winrt::VirtualKey::Down: - StepValueDown(); + StepValue(-SmallChange()); + args.Handled(true); + break; + + case winrt::VirtualKey::PageUp: + StepValue(LargeChange()); + args.Handled(true); + break; + + case winrt::VirtualKey::PageDown: + StepValue(-LargeChange()); args.Handled(true); break; } @@ -405,17 +415,17 @@ void NumberBox::OnNumberBoxScroll(winrt::IInspectable const& sender, winrt::Poin const auto delta = args.GetCurrentPoint(*this).Properties().MouseWheelDelta(); if (delta > 0) { - StepValueUp(); + StepValue(SmallChange()); } else if (delta < 0) { - StepValueDown(); + StepValue(-SmallChange()); } } } } -void NumberBox::StepValue(bool isPositive) +void NumberBox::StepValue(double change) { // Before adjusting the value, validate the contents of the textbox so we don't override it. ValidateInput(); @@ -423,14 +433,7 @@ void NumberBox::StepValue(bool isPositive) auto newVal = Value(); if (!std::isnan(newVal)) { - if (isPositive) - { - newVal += StepFrequency(); - } - else - { - newVal -= StepFrequency(); - } + newVal += change; if (IsWrapEnabled()) { diff --git a/dev/NumberBox/NumberBox.h b/dev/NumberBox/NumberBox.h index 290b123ca3..05a86cda47 100644 --- a/dev/NumberBox/NumberBox.h +++ b/dev/NumberBox/NumberBox.h @@ -47,7 +47,8 @@ class NumberBox : void OnValuePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); void OnMinimumPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); void OnMaximumPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); - void OnStepFrequencyPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnSmallChangePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnLargeChangePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); void OnIsWrapEnabledPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); void OnNumberFormatterPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); @@ -72,9 +73,7 @@ class NumberBox : void UpdateSpinButtonPlacement(); void UpdateSpinButtonEnabled(); - void StepValue(bool isPositive); - void StepValueUp() { StepValue(true); } - void StepValueDown() { StepValue(false); } + void StepValue(double change); bool IsInBounds(double value); diff --git a/dev/NumberBox/NumberBox.idl b/dev/NumberBox/NumberBox.idl index 7caaf5d41d..1a9ea1cb2c 100644 --- a/dev/NumberBox/NumberBox.idl +++ b/dev/NumberBox/NumberBox.idl @@ -46,7 +46,10 @@ unsealed runtimeclass NumberBox : Windows.UI.Xaml.Controls.Control [MUX_DEFAULT_VALUE("1")] [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] - Double StepFrequency; + Double SmallChange; + + [MUX_DEFAULT_VALUE("10")] + Double LargeChange; [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] String Text; @@ -84,7 +87,8 @@ unsealed runtimeclass NumberBox : Windows.UI.Xaml.Controls.Control static Windows.UI.Xaml.DependencyProperty MinimumProperty{ get; }; static Windows.UI.Xaml.DependencyProperty MaximumProperty{ get; }; static Windows.UI.Xaml.DependencyProperty ValueProperty{ get; }; - static Windows.UI.Xaml.DependencyProperty StepFrequencyProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty SmallChangeProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty LargeChangeProperty{ get; }; static Windows.UI.Xaml.DependencyProperty TextProperty{ get; }; static Windows.UI.Xaml.DependencyProperty HeaderProperty{ get; }; diff --git a/dev/NumberBox/NumberBoxAutomationPeer.cpp b/dev/NumberBox/NumberBoxAutomationPeer.cpp index c122d97ba4..b320f2bba3 100644 --- a/dev/NumberBox/NumberBoxAutomationPeer.cpp +++ b/dev/NumberBox/NumberBoxAutomationPeer.cpp @@ -64,12 +64,12 @@ double NumberBoxAutomationPeer::Value() double NumberBoxAutomationPeer::SmallChange() { - return GetImpl()->StepFrequency(); + return GetImpl()->SmallChange(); } double NumberBoxAutomationPeer::LargeChange() { - return GetImpl()->StepFrequency(); + return GetImpl()->LargeChange(); } void NumberBoxAutomationPeer::SetValue(double value) diff --git a/dev/NumberBox/TestUI/NumberBoxPage.xaml b/dev/NumberBox/TestUI/NumberBoxPage.xaml index 711771fb3e..1e83b14017 100644 --- a/dev/NumberBox/TestUI/NumberBoxPage.xaml +++ b/dev/NumberBox/TestUI/NumberBoxPage.xaml @@ -38,7 +38,8 @@ - + + @@ -69,7 +70,8 @@ Header="NumberBox" PlaceholderText="Text" ValueChanged="NumberBoxValueChanged" - StepFrequency="{x:Bind StepNumberBox.Value, Mode=OneWay}" + SmallChange="{x:Bind SmallChangeNumberBox.Value, Mode=OneWay}" + LargeChange="{x:Bind LargeChangeNumberBox.Value, Mode=OneWay}" AcceptsExpression="{x:Bind ExpressionCheckBox.IsChecked.Value, Mode=OneWay}" IsWrapEnabled="{x:Bind WrapCheckBox.IsChecked.Value, Mode=OneWay}" IsEnabled="{x:Bind EnabledCheckBox.IsChecked.Value, Mode=OneWay}"/> diff --git a/dev/Repeater/TestUI/Samples/CollectionChangeDemo.xaml b/dev/Repeater/TestUI/Samples/CollectionChangeDemo.xaml index e8a4a6d996..f6e73fecf6 100644 --- a/dev/Repeater/TestUI/Samples/CollectionChangeDemo.xaml +++ b/dev/Repeater/TestUI/Samples/CollectionChangeDemo.xaml @@ -62,7 +62,7 @@ - +