Skip to content

Commit

Permalink
Replacing Scroller and ScrollViewer's IsChildAvailableWidthConstraine…
Browse files Browse the repository at this point in the history
…d/IsChildAvailableHeightConstrained with ContentOrientation (#214)

* Step #1: Introduce Scroller/ScrollViewer.ContentOrientation.

* Step #2: Replace IsChildAvailableWidthConstrained/IsChildAvailableHeightConstrained usage with ContentOrientation and remove them.

* Updating ScrollerDynamicPage test UI.

* Fixing test ValidateSupportForScrollerConfigurationChanges.
  • Loading branch information
RBrid authored Jan 25, 2019
1 parent 6b5795c commit 2e6920c
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 411 deletions.
12 changes: 4 additions & 8 deletions dev/Generated/MetadataSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ public MetadataSummary()
NeedsPropChangedCallbackMetadata["Scroller.ComputedHorizontalScrollMode"] = true;
NeedsPropChangedCallbackMetadata["Scroller.ComputedVerticalScrollMode"] = true;
NeedsPropChangedCallbackMetadata["Scroller.Content"] = true;
NeedsPropChangedCallbackMetadata["Scroller.ContentOrientation"] = true;
NeedsPropChangedCallbackMetadata["Scroller.HorizontalAnchorRatio"] = true;
PropValidationCallbackMetadata["Scroller.HorizontalAnchorRatio"] = "ValidateAnchorRatio";
NeedsPropChangedCallbackMetadata["Scroller.HorizontalScrollChainingMode"] = true;
Expand All @@ -455,8 +456,6 @@ public MetadataSummary()
NeedsPropChangedCallbackMetadata["Scroller.InputKind"] = true;
NeedsPropChangedCallbackMetadata["Scroller.IsAnchoredAtHorizontalExtent"] = true;
NeedsPropChangedCallbackMetadata["Scroller.IsAnchoredAtVerticalExtent"] = true;
NeedsPropChangedCallbackMetadata["Scroller.IsChildAvailableHeightConstrained"] = true;
NeedsPropChangedCallbackMetadata["Scroller.IsChildAvailableWidthConstrained"] = true;
NeedsPropChangedCallbackMetadata["Scroller.MaxZoomFactor"] = true;
PropValidationCallbackMetadata["Scroller.MaxZoomFactor"] = "ValidateZoomFactoryBoundary";
NeedsPropChangedCallbackMetadata["Scroller.MinZoomFactor"] = true;
Expand All @@ -471,15 +470,14 @@ public MetadataSummary()
// Scroller -- DefaultValueMetadata
DefaultValueMetadata["Scroller.ComputedHorizontalScrollMode"] = @"Scroller::s_defaultComputedVerticalScrollMode";
DefaultValueMetadata["Scroller.ComputedVerticalScrollMode"] = @"Scroller::s_defaultComputedVerticalScrollMode";
DefaultValueMetadata["Scroller.ContentOrientation"] = @"Scroller::s_defaultContentOrientation";
DefaultValueMetadata["Scroller.HorizontalAnchorRatio"] = @"Scroller::s_defaultAnchorRatio";
DefaultValueMetadata["Scroller.HorizontalScrollChainingMode"] = @"Scroller::s_defaultHorizontalScrollChainingMode";
DefaultValueMetadata["Scroller.HorizontalScrollMode"] = @"Scroller::s_defaultHorizontalScrollMode";
DefaultValueMetadata["Scroller.HorizontalScrollRailingMode"] = @"Scroller::s_defaultHorizontalScrollRailingMode";
DefaultValueMetadata["Scroller.InputKind"] = @"Scroller::s_defaultInputKind";
DefaultValueMetadata["Scroller.IsAnchoredAtHorizontalExtent"] = @"Scroller::s_defaultAnchorAtExtent";
DefaultValueMetadata["Scroller.IsAnchoredAtVerticalExtent"] = @"Scroller::s_defaultAnchorAtExtent";
DefaultValueMetadata["Scroller.IsChildAvailableHeightConstrained"] = @"Scroller::s_defaultIsChildAvailableHeightConstrained";
DefaultValueMetadata["Scroller.IsChildAvailableWidthConstrained"] = @"Scroller::s_defaultIsChildAvailableWidthConstrained";
DefaultValueMetadata["Scroller.MaxZoomFactor"] = @"Scroller::s_defaultMaxZoomFactor";
DefaultValueMetadata["Scroller.MinZoomFactor"] = @"Scroller::s_defaultMinZoomFactor";
DefaultValueMetadata["Scroller.VerticalAnchorRatio"] = @"Scroller::s_defaultAnchorRatio";
Expand All @@ -498,6 +496,7 @@ public MetadataSummary()
NeedsPropChangedCallbackMetadata["ScrollViewer.ComputedHorizontalScrollMode"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.ComputedVerticalScrollMode"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.Content"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.ContentOrientation"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.HorizontalAnchorRatio"] = true;
PropValidationCallbackMetadata["ScrollViewer.HorizontalAnchorRatio"] = "ValidateAnchorRatio";
NeedsPropChangedCallbackMetadata["ScrollViewer.HorizontalScrollBarVisibility"] = true;
Expand All @@ -508,8 +507,6 @@ public MetadataSummary()
NeedsPropChangedCallbackMetadata["ScrollViewer.InputKind"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.IsAnchoredAtHorizontalExtent"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.IsAnchoredAtVerticalExtent"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.IsChildAvailableHeightConstrained"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.IsChildAvailableWidthConstrained"] = true;
NeedsPropChangedCallbackMetadata["ScrollViewer.MaxZoomFactor"] = true;
PropValidationCallbackMetadata["ScrollViewer.MaxZoomFactor"] = "ValidateZoomFactoryBoundary";
NeedsPropChangedCallbackMetadata["ScrollViewer.MinZoomFactor"] = true;
Expand All @@ -528,6 +525,7 @@ public MetadataSummary()
// ScrollViewer -- DefaultValueMetadata
DefaultValueMetadata["ScrollViewer.ComputedHorizontalScrollMode"] = @"ScrollViewer::s_defaultComputedHorizontalScrollMode";
DefaultValueMetadata["ScrollViewer.ComputedVerticalScrollMode"] = @"ScrollViewer::s_defaultComputedVerticalScrollMode";
DefaultValueMetadata["ScrollViewer.ContentOrientation"] = @"ScrollViewer::s_defaultContentOrientation";
DefaultValueMetadata["ScrollViewer.HorizontalAnchorRatio"] = @"ScrollViewer::s_defaultAnchorRatio";
DefaultValueMetadata["ScrollViewer.HorizontalScrollBarVisibility"] = @"ScrollViewer::s_defaultHorizontalScrollBarVisibility";
DefaultValueMetadata["ScrollViewer.HorizontalScrollChainingMode"] = @"ScrollViewer::s_defaultHorizontalScrollChainingMode";
Expand All @@ -536,8 +534,6 @@ public MetadataSummary()
DefaultValueMetadata["ScrollViewer.InputKind"] = @"ScrollViewer::s_defaultInputKind";
DefaultValueMetadata["ScrollViewer.IsAnchoredAtHorizontalExtent"] = @"ScrollViewer::s_defaultAnchorAtExtent";
DefaultValueMetadata["ScrollViewer.IsAnchoredAtVerticalExtent"] = @"ScrollViewer::s_defaultAnchorAtExtent";
DefaultValueMetadata["ScrollViewer.IsChildAvailableHeightConstrained"] = @"ScrollViewer::s_defaultIsChildAvailableHeightConstrained";
DefaultValueMetadata["ScrollViewer.IsChildAvailableWidthConstrained"] = @"ScrollViewer::s_defaultIsChildAvailableWidthConstrained";
DefaultValueMetadata["ScrollViewer.MaxZoomFactor"] = @"ScrollViewer::s_defaultMaxZoomFactor";
DefaultValueMetadata["ScrollViewer.MinZoomFactor"] = @"ScrollViewer::s_defaultMinZoomFactor";
DefaultValueMetadata["ScrollViewer.VerticalAnchorRatio"] = @"ScrollViewer::s_defaultAnchorRatio";
Expand Down
69 changes: 23 additions & 46 deletions dev/Generated/ScrollViewer.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CppWinRTActivatableClassWithDPFactory(ScrollViewer)
GlobalDependencyProperty ScrollViewerProperties::s_ComputedHorizontalScrollModeProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_ComputedVerticalScrollModeProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_ContentProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_ContentOrientationProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_HorizontalAnchorRatioProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_HorizontalScrollBarVisibilityProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_HorizontalScrollChainingModeProperty{ nullptr };
Expand All @@ -20,8 +21,6 @@ GlobalDependencyProperty ScrollViewerProperties::s_HorizontalScrollRailingModePr
GlobalDependencyProperty ScrollViewerProperties::s_InputKindProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_IsAnchoredAtHorizontalExtentProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_IsAnchoredAtVerticalExtentProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_IsChildAvailableHeightConstrainedProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_IsChildAvailableWidthConstrainedProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_MaxZoomFactorProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_MinZoomFactorProperty{ nullptr };
GlobalDependencyProperty ScrollViewerProperties::s_ScrollerProperty{ nullptr };
Expand Down Expand Up @@ -82,6 +81,17 @@ void ScrollViewerProperties::EnsureProperties()
ValueHelper<winrt::UIElement>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_ContentOrientationProperty)
{
s_ContentOrientationProperty =
InitializeDependencyProperty(
L"ContentOrientation",
winrt::name_of<winrt::ContentOrientation>(),
winrt::name_of<winrt::ScrollViewer>(),
false /* isAttached */,
ValueHelper<winrt::ContentOrientation>::BoxValueIfNecessary(ScrollViewer::s_defaultContentOrientation),
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_HorizontalAnchorRatioProperty)
{
s_HorizontalAnchorRatioProperty =
Expand Down Expand Up @@ -181,28 +191,6 @@ void ScrollViewerProperties::EnsureProperties()
ValueHelper<bool>::BoxValueIfNecessary(ScrollViewer::s_defaultAnchorAtExtent),
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_IsChildAvailableHeightConstrainedProperty)
{
s_IsChildAvailableHeightConstrainedProperty =
InitializeDependencyProperty(
L"IsChildAvailableHeightConstrained",
winrt::name_of<bool>(),
winrt::name_of<winrt::ScrollViewer>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(ScrollViewer::s_defaultIsChildAvailableHeightConstrained),
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_IsChildAvailableWidthConstrainedProperty)
{
s_IsChildAvailableWidthConstrainedProperty =
InitializeDependencyProperty(
L"IsChildAvailableWidthConstrained",
winrt::name_of<bool>(),
winrt::name_of<winrt::ScrollViewer>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(ScrollViewer::s_defaultIsChildAvailableWidthConstrained),
winrt::PropertyChangedCallback(&OnPropertyChanged));
}
if (!s_MaxZoomFactorProperty)
{
s_MaxZoomFactorProperty =
Expand Down Expand Up @@ -331,6 +319,7 @@ void ScrollViewerProperties::ClearProperties()
s_ComputedHorizontalScrollModeProperty = nullptr;
s_ComputedVerticalScrollModeProperty = nullptr;
s_ContentProperty = nullptr;
s_ContentOrientationProperty = nullptr;
s_HorizontalAnchorRatioProperty = nullptr;
s_HorizontalScrollBarVisibilityProperty = nullptr;
s_HorizontalScrollChainingModeProperty = nullptr;
Expand All @@ -340,8 +329,6 @@ void ScrollViewerProperties::ClearProperties()
s_InputKindProperty = nullptr;
s_IsAnchoredAtHorizontalExtentProperty = nullptr;
s_IsAnchoredAtVerticalExtentProperty = nullptr;
s_IsChildAvailableHeightConstrainedProperty = nullptr;
s_IsChildAvailableWidthConstrainedProperty = nullptr;
s_MaxZoomFactorProperty = nullptr;
s_MinZoomFactorProperty = nullptr;
s_ScrollerProperty = nullptr;
Expand Down Expand Up @@ -427,6 +414,16 @@ winrt::UIElement ScrollViewerProperties::Content()
return ValueHelper<winrt::UIElement>::CastOrUnbox(static_cast<ScrollViewer*>(this)->GetValue(s_ContentProperty));
}

void ScrollViewerProperties::ContentOrientation(winrt::ContentOrientation const& value)
{
static_cast<ScrollViewer*>(this)->SetValue(s_ContentOrientationProperty, ValueHelper<winrt::ContentOrientation>::BoxValueIfNecessary(value));
}

winrt::ContentOrientation ScrollViewerProperties::ContentOrientation()
{
return ValueHelper<winrt::ContentOrientation>::CastOrUnbox(static_cast<ScrollViewer*>(this)->GetValue(s_ContentOrientationProperty));
}

void ScrollViewerProperties::HorizontalAnchorRatio(double value)
{
static_cast<ScrollViewer*>(this)->ValidateAnchorRatio(value);
Expand Down Expand Up @@ -518,26 +515,6 @@ bool ScrollViewerProperties::IsAnchoredAtVerticalExtent()
return ValueHelper<bool>::CastOrUnbox(static_cast<ScrollViewer*>(this)->GetValue(s_IsAnchoredAtVerticalExtentProperty));
}

void ScrollViewerProperties::IsChildAvailableHeightConstrained(bool value)
{
static_cast<ScrollViewer*>(this)->SetValue(s_IsChildAvailableHeightConstrainedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool ScrollViewerProperties::IsChildAvailableHeightConstrained()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<ScrollViewer*>(this)->GetValue(s_IsChildAvailableHeightConstrainedProperty));
}

void ScrollViewerProperties::IsChildAvailableWidthConstrained(bool value)
{
static_cast<ScrollViewer*>(this)->SetValue(s_IsChildAvailableWidthConstrainedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool ScrollViewerProperties::IsChildAvailableWidthConstrained()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<ScrollViewer*>(this)->GetValue(s_IsChildAvailableWidthConstrainedProperty));
}

void ScrollViewerProperties::MaxZoomFactor(double value)
{
static_cast<ScrollViewer*>(this)->ValidateZoomFactoryBoundary(value);
Expand Down
15 changes: 5 additions & 10 deletions dev/Generated/ScrollViewer.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ScrollViewerProperties
void Content(winrt::UIElement const& value);
winrt::UIElement Content();

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

void HorizontalAnchorRatio(double value);
double HorizontalAnchorRatio();

Expand Down Expand Up @@ -45,12 +48,6 @@ class ScrollViewerProperties
void IsAnchoredAtVerticalExtent(bool value);
bool IsAnchoredAtVerticalExtent();

void IsChildAvailableHeightConstrained(bool value);
bool IsChildAvailableHeightConstrained();

void IsChildAvailableWidthConstrained(bool value);
bool IsChildAvailableWidthConstrained();

void MaxZoomFactor(double value);
double MaxZoomFactor();

Expand Down Expand Up @@ -84,6 +81,7 @@ class ScrollViewerProperties
static winrt::DependencyProperty ComputedHorizontalScrollModeProperty() { return s_ComputedHorizontalScrollModeProperty; }
static winrt::DependencyProperty ComputedVerticalScrollModeProperty() { return s_ComputedVerticalScrollModeProperty; }
static winrt::DependencyProperty ContentProperty() { return s_ContentProperty; }
static winrt::DependencyProperty ContentOrientationProperty() { return s_ContentOrientationProperty; }
static winrt::DependencyProperty HorizontalAnchorRatioProperty() { return s_HorizontalAnchorRatioProperty; }
static winrt::DependencyProperty HorizontalScrollBarVisibilityProperty() { return s_HorizontalScrollBarVisibilityProperty; }
static winrt::DependencyProperty HorizontalScrollChainingModeProperty() { return s_HorizontalScrollChainingModeProperty; }
Expand All @@ -93,8 +91,6 @@ class ScrollViewerProperties
static winrt::DependencyProperty InputKindProperty() { return s_InputKindProperty; }
static winrt::DependencyProperty IsAnchoredAtHorizontalExtentProperty() { return s_IsAnchoredAtHorizontalExtentProperty; }
static winrt::DependencyProperty IsAnchoredAtVerticalExtentProperty() { return s_IsAnchoredAtVerticalExtentProperty; }
static winrt::DependencyProperty IsChildAvailableHeightConstrainedProperty() { return s_IsChildAvailableHeightConstrainedProperty; }
static winrt::DependencyProperty IsChildAvailableWidthConstrainedProperty() { return s_IsChildAvailableWidthConstrainedProperty; }
static winrt::DependencyProperty MaxZoomFactorProperty() { return s_MaxZoomFactorProperty; }
static winrt::DependencyProperty MinZoomFactorProperty() { return s_MinZoomFactorProperty; }
static winrt::DependencyProperty ScrollerProperty() { return s_ScrollerProperty; }
Expand All @@ -110,6 +106,7 @@ class ScrollViewerProperties
static GlobalDependencyProperty s_ComputedHorizontalScrollModeProperty;
static GlobalDependencyProperty s_ComputedVerticalScrollModeProperty;
static GlobalDependencyProperty s_ContentProperty;
static GlobalDependencyProperty s_ContentOrientationProperty;
static GlobalDependencyProperty s_HorizontalAnchorRatioProperty;
static GlobalDependencyProperty s_HorizontalScrollBarVisibilityProperty;
static GlobalDependencyProperty s_HorizontalScrollChainingModeProperty;
Expand All @@ -119,8 +116,6 @@ class ScrollViewerProperties
static GlobalDependencyProperty s_InputKindProperty;
static GlobalDependencyProperty s_IsAnchoredAtHorizontalExtentProperty;
static GlobalDependencyProperty s_IsAnchoredAtVerticalExtentProperty;
static GlobalDependencyProperty s_IsChildAvailableHeightConstrainedProperty;
static GlobalDependencyProperty s_IsChildAvailableWidthConstrainedProperty;
static GlobalDependencyProperty s_MaxZoomFactorProperty;
static GlobalDependencyProperty s_MinZoomFactorProperty;
static GlobalDependencyProperty s_ScrollerProperty;
Expand Down
Loading

0 comments on commit 2e6920c

Please sign in to comment.