Skip to content

Commit

Permalink
Move radio buttons onto repeater (#1623)
Browse files Browse the repository at this point in the history
* Move radio buttons onto repeater

* clean up some mistakes

* Remove the custom left and right focus movement code, replaced by XY focus which works basically just as well.

Respond to CR feedback.

* Remove SelectionModel in favor of managing selection myself.  Because the selection model is so simple for radio buttons (single select, flat list) selection model was overly complex and wasn't worth the cost.

Remove MissStrategy which is not longer used after the last commit.

* Remove GetContainerFromItem from the ElementFactory

* Remove the changes to SelectionModel, now that RadioButtons isn't using it.

* Fix a few of the tests and respond to some more feedback.

* Remove the m_isControlDown falg in favor of  using GetAsyncKeyState.

* Updates for minor API adjustments.

* Fix an issue with the tests running down level and with the call to GetAsyncKeyState which was not being evaluated correctly resulting in the first control arrow key moving selection.

* Fix RadioButtons to account for slightly different focus manager behavior down level.

* Fix crash on RS2 due to the use of PreviewKeyDown which was introduced in RS3.  This api is needed to get the keyboarding behavior we want so on RS2 I've changed the keyboarding behavior since the desired behavior isn't possible.

Fix a crash on RS2 and RS3 due to the use of TrySetNewFocusedElement, this means that on RS2 and RS3 we will not focus the selected items when tabbing into the radio button's control.

remove redundant radio button style from the theme resources and move the column and row spacing into the theme resources

* Add an RS2 keyboarding test

* Disable failing test on RS2.

* Move maximum columns to a binding in the template

* Fix a typo in the gamepad test....

* Fix an issue comparing pointer instead of value.

* Move to validation callback to fix unboxing error
  • Loading branch information
StephenLPeters authored Nov 23, 2019
1 parent 94d5e09 commit 22adf4d
Show file tree
Hide file tree
Showing 46 changed files with 2,403 additions and 625 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ artifacts/
HelixPayload/
/test/MUXControlsTestApp/MSTest/MUXControlsTestApp_Test
/test/MUXControlsTestApp/TAEF/MUXControlsTestApp_Test
UnreliableTestReport.csv
UnreliableTestReport.csv
3 changes: 2 additions & 1 deletion MUXControlsInnerLoop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ProgressBar_InteractionTests", "dev\ProgressBar\InteractionTests\ProgressBar_InteractionTests.shproj", "{3D044EC1-C9D3-4745-B79E-E7BED66E93F8}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ProgressBar_TestUI", "dev\ProgressBar\TestUI\ProgressBar_TestUI.shproj", "{1A5321F3-B837-4EB6-9547-37CC70088EA9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NumberBox", "NumberBox", "{E95C2CA1-FF23-47CC-A896-CC5175B37890}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NumberBox", "dev\NumberBox\NumberBox.vcxitems", "{9D23C997-1F46-444A-8C07-4A4BFF7E4E63}"
Expand Down Expand Up @@ -559,7 +560,7 @@ Global
dev\IconSource\IconSource.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\Lights\Lights.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\Materials\Acrylic\AcrylicBrush.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\Materials\Reveal\RevealBrush.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\Materials\Reveal\RevealBrush.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\ProgressBar\ProgressBar.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\NumberBox\NumberBox.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
dev\ResourceHelper\ResourceHelper.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4
Expand Down
4 changes: 4 additions & 0 deletions dev/CommonStyles/CommonStyles.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)..\RadioButtons\RadioButton_themeresources.xaml">
<Version>RS1</Version>
<Type>ThemeResources</Type>
</Page>
<Page Include="$(MSBuildThisFileDirectory)AppBarButton_themeresources.xaml">
<Version>RS1</Version>
<Type>ThemeResources</Type>
Expand Down
128 changes: 128 additions & 0 deletions dev/Generated/ColumnMajorUniformToLargestGridLayout.properties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#include "pch.h"
#include "common.h"
#include "ColumnMajorUniformToLargestGridLayout.h"

CppWinRTActivatableClassWithDPFactory(ColumnMajorUniformToLargestGridLayout)

GlobalDependencyProperty ColumnMajorUniformToLargestGridLayoutProperties::s_ColumnSpacingProperty{ nullptr };
GlobalDependencyProperty ColumnMajorUniformToLargestGridLayoutProperties::s_MaximumColumnsProperty{ nullptr };
GlobalDependencyProperty ColumnMajorUniformToLargestGridLayoutProperties::s_RowSpacingProperty{ nullptr };

ColumnMajorUniformToLargestGridLayoutProperties::ColumnMajorUniformToLargestGridLayoutProperties()
{
EnsureProperties();
}

void ColumnMajorUniformToLargestGridLayoutProperties::EnsureProperties()
{
if (!s_ColumnSpacingProperty)
{
s_ColumnSpacingProperty =
InitializeDependencyProperty(
L"ColumnSpacing",
winrt::name_of<int>(),
winrt::name_of<winrt::ColumnMajorUniformToLargestGridLayout>(),
false /* isAttached */,
ValueHelper<int>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnColumnSpacingPropertyChanged));
}
if (!s_MaximumColumnsProperty)
{
s_MaximumColumnsProperty =
InitializeDependencyProperty(
L"MaximumColumns",
winrt::name_of<int>(),
winrt::name_of<winrt::ColumnMajorUniformToLargestGridLayout>(),
false /* isAttached */,
ValueHelper<int>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnMaximumColumnsPropertyChanged));
}
if (!s_RowSpacingProperty)
{
s_RowSpacingProperty =
InitializeDependencyProperty(
L"RowSpacing",
winrt::name_of<int>(),
winrt::name_of<winrt::ColumnMajorUniformToLargestGridLayout>(),
false /* isAttached */,
ValueHelper<int>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnRowSpacingPropertyChanged));
}
}

void ColumnMajorUniformToLargestGridLayoutProperties::ClearProperties()
{
s_ColumnSpacingProperty = nullptr;
s_MaximumColumnsProperty = nullptr;
s_RowSpacingProperty = nullptr;
}

void ColumnMajorUniformToLargestGridLayoutProperties::OnColumnSpacingPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ColumnMajorUniformToLargestGridLayout>();
winrt::get_self<ColumnMajorUniformToLargestGridLayout>(owner)->OnColumnSpacingPropertyChanged(args);
}

void ColumnMajorUniformToLargestGridLayoutProperties::OnMaximumColumnsPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ColumnMajorUniformToLargestGridLayout>();

auto value = winrt::unbox_value<int>(args.NewValue());
auto coercedValue = value;
winrt::get_self<ColumnMajorUniformToLargestGridLayout>(owner)->ValidateGreaterThanZero(coercedValue);
if (value != coercedValue)
{
sender.SetValue(args.Property(), winrt::box_value<int>(coercedValue));
return;
}

winrt::get_self<ColumnMajorUniformToLargestGridLayout>(owner)->OnMaximumColumnsPropertyChanged(args);
}

void ColumnMajorUniformToLargestGridLayoutProperties::OnRowSpacingPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::ColumnMajorUniformToLargestGridLayout>();
winrt::get_self<ColumnMajorUniformToLargestGridLayout>(owner)->OnRowSpacingPropertyChanged(args);
}

void ColumnMajorUniformToLargestGridLayoutProperties::ColumnSpacing(int value)
{
static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->SetValue(s_ColumnSpacingProperty, ValueHelper<int>::BoxValueIfNecessary(value));
}

int ColumnMajorUniformToLargestGridLayoutProperties::ColumnSpacing()
{
return ValueHelper<int>::CastOrUnbox(static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->GetValue(s_ColumnSpacingProperty));
}

void ColumnMajorUniformToLargestGridLayoutProperties::MaximumColumns(int value)
{
int coercedValue = value;
static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->ValidateGreaterThanZero(coercedValue);
static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->SetValue(s_MaximumColumnsProperty, ValueHelper<int>::BoxValueIfNecessary(coercedValue));
}

int ColumnMajorUniformToLargestGridLayoutProperties::MaximumColumns()
{
return ValueHelper<int>::CastOrUnbox(static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->GetValue(s_MaximumColumnsProperty));
}

void ColumnMajorUniformToLargestGridLayoutProperties::RowSpacing(int value)
{
static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->SetValue(s_RowSpacingProperty, ValueHelper<int>::BoxValueIfNecessary(value));
}

int ColumnMajorUniformToLargestGridLayoutProperties::RowSpacing()
{
return ValueHelper<int>::CastOrUnbox(static_cast<ColumnMajorUniformToLargestGridLayout*>(this)->GetValue(s_RowSpacingProperty));
}
43 changes: 43 additions & 0 deletions dev/Generated/ColumnMajorUniformToLargestGridLayout.properties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#pragma once

class ColumnMajorUniformToLargestGridLayoutProperties
{
public:
ColumnMajorUniformToLargestGridLayoutProperties();

void ColumnSpacing(int value);
int ColumnSpacing();

void MaximumColumns(int value);
int MaximumColumns();

void RowSpacing(int value);
int RowSpacing();

static winrt::DependencyProperty ColumnSpacingProperty() { return s_ColumnSpacingProperty; }
static winrt::DependencyProperty MaximumColumnsProperty() { return s_MaximumColumnsProperty; }
static winrt::DependencyProperty RowSpacingProperty() { return s_RowSpacingProperty; }

static GlobalDependencyProperty s_ColumnSpacingProperty;
static GlobalDependencyProperty s_MaximumColumnsProperty;
static GlobalDependencyProperty s_RowSpacingProperty;

static void EnsureProperties();
static void ClearProperties();

static void OnColumnSpacingPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnMaximumColumnsPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnRowSpacingPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);
};
12 changes: 6 additions & 6 deletions dev/Generated/RadioButtons.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ void RadioButtonsProperties::EnsureProperties()
s_ItemTemplateProperty =
InitializeDependencyProperty(
L"ItemTemplate",
winrt::name_of<winrt::DataTemplate>(),
winrt::name_of<winrt::IInspectable>(),
winrt::name_of<winrt::RadioButtons>(),
false /* isAttached */,
ValueHelper<winrt::DataTemplate>::BoxedDefaultValue(),
ValueHelper<winrt::IInspectable>::BoxValueIfNecessary(winrt::RadioButtonsElementFactory{}),
winrt::PropertyChangedCallback(&OnItemTemplatePropertyChanged));
}
if (!s_MaximumColumnsProperty)
Expand Down Expand Up @@ -200,14 +200,14 @@ winrt::IInspectable RadioButtonsProperties::ItemsSource()
return ValueHelper<winrt::IInspectable>::CastOrUnbox(static_cast<RadioButtons*>(this)->GetValue(s_ItemsSourceProperty));
}

void RadioButtonsProperties::ItemTemplate(winrt::DataTemplate const& value)
void RadioButtonsProperties::ItemTemplate(winrt::IInspectable const& value)
{
static_cast<RadioButtons*>(this)->SetValue(s_ItemTemplateProperty, ValueHelper<winrt::DataTemplate>::BoxValueIfNecessary(value));
static_cast<RadioButtons*>(this)->SetValue(s_ItemTemplateProperty, ValueHelper<winrt::IInspectable>::BoxValueIfNecessary(value));
}

winrt::DataTemplate RadioButtonsProperties::ItemTemplate()
winrt::IInspectable RadioButtonsProperties::ItemTemplate()
{
return ValueHelper<winrt::DataTemplate>::CastOrUnbox(static_cast<RadioButtons*>(this)->GetValue(s_ItemTemplateProperty));
return ValueHelper<winrt::IInspectable>::CastOrUnbox(static_cast<RadioButtons*>(this)->GetValue(s_ItemTemplateProperty));
}

void RadioButtonsProperties::MaximumColumns(int value)
Expand Down
4 changes: 2 additions & 2 deletions dev/Generated/RadioButtons.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class RadioButtonsProperties
void ItemsSource(winrt::IInspectable const& value);
winrt::IInspectable ItemsSource();

void ItemTemplate(winrt::DataTemplate const& value);
winrt::DataTemplate ItemTemplate();
void ItemTemplate(winrt::IInspectable const& value);
winrt::IInspectable ItemTemplate();

void MaximumColumns(int value);
int MaximumColumns();
Expand Down
46 changes: 46 additions & 0 deletions dev/Generated/RadioButtonsElementFactory.properties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#include "pch.h"
#include "common.h"
#include "RadioButtonsElementFactory.h"

CppWinRTActivatableClassWithDPFactory(RadioButtonsElementFactory)

GlobalDependencyProperty RadioButtonsElementFactoryProperties::s_DataTemplateProperty{ nullptr };

RadioButtonsElementFactoryProperties::RadioButtonsElementFactoryProperties()
{
EnsureProperties();
}

void RadioButtonsElementFactoryProperties::EnsureProperties()
{
if (!s_DataTemplateProperty)
{
s_DataTemplateProperty =
InitializeDependencyProperty(
L"DataTemplate",
winrt::name_of<winrt::DataTemplate>(),
winrt::name_of<winrt::RadioButtonsElementFactory>(),
false /* isAttached */,
ValueHelper<winrt::DataTemplate>::BoxedDefaultValue(),
nullptr);
}
}

void RadioButtonsElementFactoryProperties::ClearProperties()
{
s_DataTemplateProperty = nullptr;
}

void RadioButtonsElementFactoryProperties::DataTemplate(winrt::DataTemplate const& value)
{
static_cast<RadioButtonsElementFactory*>(this)->SetValue(s_DataTemplateProperty, ValueHelper<winrt::DataTemplate>::BoxValueIfNecessary(value));
}

winrt::DataTemplate RadioButtonsElementFactoryProperties::DataTemplate()
{
return ValueHelper<winrt::DataTemplate>::CastOrUnbox(static_cast<RadioButtonsElementFactory*>(this)->GetValue(s_DataTemplateProperty));
}
21 changes: 21 additions & 0 deletions dev/Generated/RadioButtonsElementFactory.properties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#pragma once

class RadioButtonsElementFactoryProperties
{
public:
RadioButtonsElementFactoryProperties();

void DataTemplate(winrt::DataTemplate const& value);
winrt::DataTemplate DataTemplate();

static winrt::DependencyProperty DataTemplateProperty() { return s_DataTemplateProperty; }

static GlobalDependencyProperty s_DataTemplateProperty;

static void EnsureProperties();
static void ClearProperties();
};
33 changes: 33 additions & 0 deletions dev/Generated/RadioButtonsTestHooks.properties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#include "pch.h"
#include "common.h"
#include "RadioButtonsTestHooks.h"

CppWinRTActivatableClassWithBasicFactory(RadioButtonsTestHooks)


RadioButtonsTestHooksProperties::RadioButtonsTestHooksProperties()
: m_layoutChangedEventSource{static_cast<RadioButtonsTestHooks*>(this)}
{
}

void RadioButtonsTestHooksProperties::EnsureProperties()
{
}

void RadioButtonsTestHooksProperties::ClearProperties()
{
}

winrt::event_token RadioButtonsTestHooksProperties::LayoutChanged(winrt::TypedEventHandler<winrt::RadioButtons, winrt::IInspectable> const& value)
{
return m_layoutChangedEventSource.add(value);
}

void RadioButtonsTestHooksProperties::LayoutChanged(winrt::event_token const& token)
{
m_layoutChangedEventSource.remove(token);
}
21 changes: 21 additions & 0 deletions dev/Generated/RadioButtonsTestHooks.properties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#pragma once

class RadioButtonsTestHooksProperties
{
public:
RadioButtonsTestHooksProperties();



winrt::event_token LayoutChanged(winrt::TypedEventHandler<winrt::RadioButtons, winrt::IInspectable> const& value);
void LayoutChanged(winrt::event_token const& token);

event_source<winrt::TypedEventHandler<winrt::RadioButtons, winrt::IInspectable>> m_layoutChangedEventSource;

static void EnsureProperties();
static void ClearProperties();
};
Loading

0 comments on commit 22adf4d

Please sign in to comment.