From 38a38d9835f7d1ac1e84f2f2a6f2617eacf3b2c9 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Fri, 27 Nov 2020 14:19:38 +0100 Subject: [PATCH] Update InfoBarPanel API names (#3704) * Update API names * Remove grid.columns --- dev/Generated/InfoBarPanel.properties.cpp | 88 ++++++++++++++++++----- dev/Generated/InfoBarPanel.properties.h | 26 ++++--- dev/InfoBar/InfoBar.idl | 18 +++-- dev/InfoBar/InfoBar.xaml | 19 +++-- dev/InfoBar/InfoBarPanel.cpp | 16 ++--- dev/InfoBar/InfoBar_themeresources.xaml | 18 ++--- 6 files changed, 125 insertions(+), 60 deletions(-) diff --git a/dev/Generated/InfoBarPanel.properties.cpp b/dev/Generated/InfoBarPanel.properties.cpp index 520c74027f..93a64110e9 100644 --- a/dev/Generated/InfoBarPanel.properties.cpp +++ b/dev/Generated/InfoBarPanel.properties.cpp @@ -13,8 +13,10 @@ namespace winrt::Microsoft::UI::Xaml::Controls::Primitives #include "InfoBarPanel.g.cpp" -GlobalDependencyProperty InfoBarPanelProperties::s_HorizontalMarginProperty{ nullptr }; -GlobalDependencyProperty InfoBarPanelProperties::s_VerticalMarginProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_PaddingInHorizontalOrientationProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_PaddingInVerticalOrientationProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_SpacingInHorizontalOrientationProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_SpacingInVerticalOrientationProperty{ nullptr }; InfoBarPanelProperties::InfoBarPanelProperties() { @@ -23,22 +25,44 @@ InfoBarPanelProperties::InfoBarPanelProperties() void InfoBarPanelProperties::EnsureProperties() { - if (!s_HorizontalMarginProperty) + if (!s_PaddingInHorizontalOrientationProperty) { - s_HorizontalMarginProperty = + s_PaddingInHorizontalOrientationProperty = InitializeDependencyProperty( - L"HorizontalMargin", + L"PaddingInHorizontalOrientation", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_PaddingInVerticalOrientationProperty) + { + s_PaddingInVerticalOrientationProperty = + InitializeDependencyProperty( + L"PaddingInVerticalOrientation", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_SpacingInHorizontalOrientationProperty) + { + s_SpacingInHorizontalOrientationProperty = + InitializeDependencyProperty( + L"SpacingInHorizontalOrientation", winrt::name_of(), winrt::name_of(), true /* isAttached */, ValueHelper::BoxedDefaultValue(), nullptr); } - if (!s_VerticalMarginProperty) + if (!s_SpacingInVerticalOrientationProperty) { - s_VerticalMarginProperty = + s_SpacingInVerticalOrientationProperty = InitializeDependencyProperty( - L"VerticalMargin", + L"SpacingInVerticalOrientation", winrt::name_of(), winrt::name_of(), true /* isAttached */, @@ -49,28 +73,56 @@ void InfoBarPanelProperties::EnsureProperties() void InfoBarPanelProperties::ClearProperties() { - s_HorizontalMarginProperty = nullptr; - s_VerticalMarginProperty = nullptr; + s_PaddingInHorizontalOrientationProperty = nullptr; + s_PaddingInVerticalOrientationProperty = nullptr; + s_SpacingInHorizontalOrientationProperty = nullptr; + s_SpacingInVerticalOrientationProperty = nullptr; +} + +void InfoBarPanelProperties::PaddingInHorizontalOrientation(winrt::Thickness const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_PaddingInHorizontalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::Thickness InfoBarPanelProperties::PaddingInHorizontalOrientation() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_PaddingInHorizontalOrientationProperty)); +} + +void InfoBarPanelProperties::PaddingInVerticalOrientation(winrt::Thickness const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_PaddingInVerticalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::Thickness InfoBarPanelProperties::PaddingInVerticalOrientation() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_PaddingInVerticalOrientationProperty)); } -void InfoBarPanelProperties::SetHorizontalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) +void InfoBarPanelProperties::SetSpacingInHorizontalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value) { - target.SetValue(s_HorizontalMarginProperty, ValueHelper::BoxValueIfNecessary(value)); + target.SetValue(s_SpacingInHorizontalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); } -winrt::Thickness InfoBarPanelProperties::GetHorizontalMargin(winrt::DependencyObject const& target) +winrt::Thickness InfoBarPanelProperties::GetSpacingInHorizontalOrientation(winrt::DependencyObject const& target) { - return ValueHelper::CastOrUnbox(target.GetValue(s_HorizontalMarginProperty)); + return ValueHelper::CastOrUnbox(target.GetValue(s_SpacingInHorizontalOrientationProperty)); } -void InfoBarPanelProperties::SetVerticalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) +void InfoBarPanelProperties::SetSpacingInVerticalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value) { - target.SetValue(s_VerticalMarginProperty, ValueHelper::BoxValueIfNecessary(value)); + target.SetValue(s_SpacingInVerticalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); } -winrt::Thickness InfoBarPanelProperties::GetVerticalMargin(winrt::DependencyObject const& target) +winrt::Thickness InfoBarPanelProperties::GetSpacingInVerticalOrientation(winrt::DependencyObject const& target) { - return ValueHelper::CastOrUnbox(target.GetValue(s_VerticalMarginProperty)); + return ValueHelper::CastOrUnbox(target.GetValue(s_SpacingInVerticalOrientationProperty)); } diff --git a/dev/Generated/InfoBarPanel.properties.h b/dev/Generated/InfoBarPanel.properties.h index 5ba874f11b..470fd0b286 100644 --- a/dev/Generated/InfoBarPanel.properties.h +++ b/dev/Generated/InfoBarPanel.properties.h @@ -9,17 +9,27 @@ class InfoBarPanelProperties public: InfoBarPanelProperties(); - static void SetHorizontalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); - static winrt::Thickness GetHorizontalMargin(winrt::DependencyObject const& target); + void PaddingInHorizontalOrientation(winrt::Thickness const& value); + winrt::Thickness PaddingInHorizontalOrientation(); - static void SetVerticalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); - static winrt::Thickness GetVerticalMargin(winrt::DependencyObject const& target); + void PaddingInVerticalOrientation(winrt::Thickness const& value); + winrt::Thickness PaddingInVerticalOrientation(); - static winrt::DependencyProperty HorizontalMarginProperty() { return s_HorizontalMarginProperty; } - static winrt::DependencyProperty VerticalMarginProperty() { return s_VerticalMarginProperty; } + static void SetSpacingInHorizontalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetSpacingInHorizontalOrientation(winrt::DependencyObject const& target); - static GlobalDependencyProperty s_HorizontalMarginProperty; - static GlobalDependencyProperty s_VerticalMarginProperty; + static void SetSpacingInVerticalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetSpacingInVerticalOrientation(winrt::DependencyObject const& target); + + static winrt::DependencyProperty PaddingInHorizontalOrientationProperty() { return s_PaddingInHorizontalOrientationProperty; } + static winrt::DependencyProperty PaddingInVerticalOrientationProperty() { return s_PaddingInVerticalOrientationProperty; } + static winrt::DependencyProperty SpacingInHorizontalOrientationProperty() { return s_SpacingInHorizontalOrientationProperty; } + static winrt::DependencyProperty SpacingInVerticalOrientationProperty() { return s_SpacingInVerticalOrientationProperty; } + + static GlobalDependencyProperty s_PaddingInHorizontalOrientationProperty; + static GlobalDependencyProperty s_PaddingInVerticalOrientationProperty; + static GlobalDependencyProperty s_SpacingInHorizontalOrientationProperty; + static GlobalDependencyProperty s_SpacingInVerticalOrientationProperty; static void EnsureProperties(); static void ClearProperties(); diff --git a/dev/InfoBar/InfoBar.idl b/dev/InfoBar/InfoBar.idl index fd0d164e74..5193fd8aa6 100644 --- a/dev/InfoBar/InfoBar.idl +++ b/dev/InfoBar/InfoBar.idl @@ -117,13 +117,19 @@ unsealed runtimeclass InfoBarPanel : Windows.UI.Xaml.Controls.Panel { InfoBarPanel(); - static Windows.UI.Xaml.DependencyProperty HorizontalMarginProperty{ get; }; - static void SetHorizontalMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); - static Windows.UI.Xaml.Thickness GetHorizontalMargin(Windows.UI.Xaml.DependencyObject object); + Windows.UI.Xaml.Thickness PaddingInHorizontalOrientation; + static Windows.UI.Xaml.DependencyProperty PaddingInHorizontalOrientationProperty{ get; }; - static Windows.UI.Xaml.DependencyProperty VerticalMarginProperty{ get; }; - static void SetVerticalMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); - static Windows.UI.Xaml.Thickness GetVerticalMargin(Windows.UI.Xaml.DependencyObject object); + Windows.UI.Xaml.Thickness PaddingInVerticalOrientation; + static Windows.UI.Xaml.DependencyProperty PaddingInVerticalOrientationProperty{ get; }; + + static void SetSpacingInHorizontalOrientation(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetSpacingInHorizontalOrientation(Windows.UI.Xaml.DependencyObject object); + static Windows.UI.Xaml.DependencyProperty SpacingInHorizontalOrientationProperty{ get; }; + + static void SetSpacingInVerticalOrientation(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetSpacingInVerticalOrientation(Windows.UI.Xaml.DependencyObject object); + static Windows.UI.Xaml.DependencyProperty SpacingInVerticalOrientationProperty{ get; }; } } diff --git a/dev/InfoBar/InfoBar.xaml b/dev/InfoBar/InfoBar.xaml index 9a04848e94..781b96968f 100644 --- a/dev/InfoBar/InfoBar.xaml +++ b/dev/InfoBar/InfoBar.xaml @@ -136,34 +136,31 @@ + PaddingInHorizontalOrientation="{StaticResource InfoBarPanelPaddingInHorizontalOrientation}" + PaddingInVerticalOrientation="{StaticResource InfoBarPanelPaddingInVerticalOrientation}"> diff --git a/dev/InfoBar/InfoBarPanel.cpp b/dev/InfoBar/InfoBarPanel.cpp index 61f7ff4688..ad5b7ac923 100644 --- a/dev/InfoBar/InfoBarPanel.cpp +++ b/dev/InfoBar/InfoBarPanel.cpp @@ -27,11 +27,11 @@ winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) if (childDesiredSize.Width != 0 && childDesiredSize.Height != 0) { // Add up the width of all items if they were laid out horizontally - const auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(child); + const auto horizontalMargin = winrt::InfoBarPanel::GetSpacingInHorizontalOrientation(child); totalWidth += childDesiredSize.Width + (nItems > 0 ? (float)horizontalMargin.Left : 0) + (float)horizontalMargin.Right; // Add up the height of all items if they were laid out vertically - const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(child); + const auto verticalMargin = winrt::InfoBarPanel::GetSpacingInVerticalOrientation(child); totalHeight += childDesiredSize.Height + (nItems > 0 ? (float)verticalMargin.Top : 0) + (float)verticalMargin.Bottom; if (childDesiredSize.Width > widthOfWidest) @@ -61,7 +61,7 @@ winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) if (nItems == 1 || totalWidth > availableSize.Width || (minHeight > 0 && heightOfTallestInHorizontal > minHeight)) { m_isVertical = true; - const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(*this); + const auto verticalMargin = PaddingInVerticalOrientation(); desiredSize.Width = widthOfWidest; desiredSize.Height = totalHeight + (float)verticalMargin.Top + (float)verticalMargin.Bottom; @@ -69,7 +69,7 @@ winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) else { m_isVertical = false; - const auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(*this); + const auto horizontalMargin = PaddingInHorizontalOrientation(); desiredSize.Width = totalWidth + (float)horizontalMargin.Left + (float)horizontalMargin.Right; desiredSize.Height = heightOfTallest; @@ -85,7 +85,7 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) if (m_isVertical) { // Layout elements vertically - float verticalOffset = (float)winrt::InfoBarPanel::GetVerticalMargin(*this).Top; + float verticalOffset = (float)PaddingInVerticalOrientation().Top; bool hasPreviousElement = false; for (winrt::UIElement const& child : Children()) { @@ -94,7 +94,7 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) auto const desiredSize = child.DesiredSize(); if (desiredSize.Width != 0 && desiredSize.Height != 0) { - const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(child); + const auto verticalMargin = winrt::InfoBarPanel::GetSpacingInVerticalOrientation(child); verticalOffset += hasPreviousElement ? (float)verticalMargin.Top : 0; child.Arrange(winrt::Rect{ (float)verticalMargin.Left, verticalOffset, desiredSize.Width, desiredSize.Height }); @@ -108,7 +108,7 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) else { // Layout elements horizontally - float horizontalOffset = (float)winrt::InfoBarPanel::GetHorizontalMargin(*this).Left; + float horizontalOffset = (float)PaddingInHorizontalOrientation().Left; bool hasPreviousElement = false; for (winrt::UIElement const& child : Children()) { @@ -117,7 +117,7 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) auto const desiredSize = child.DesiredSize(); if (desiredSize.Width != 0 && desiredSize.Height != 0) { - auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(child); + auto horizontalMargin = winrt::InfoBarPanel::GetSpacingInHorizontalOrientation(child); horizontalOffset += hasPreviousElement ? (float)horizontalMargin.Left : 0; child.Arrange(winrt::Rect{ horizontalOffset, (float)horizontalMargin.Top, desiredSize.Width, finalSize.Height }); diff --git a/dev/InfoBar/InfoBar_themeresources.xaml b/dev/InfoBar/InfoBar_themeresources.xaml index dd84b6384b..bd95861660 100644 --- a/dev/InfoBar/InfoBar_themeresources.xaml +++ b/dev/InfoBar/InfoBar_themeresources.xaml @@ -86,17 +86,17 @@ 20 0,0,12,0 - 0,0,0,0 - 0,10,0,10 - - 0,10,0,0 - 0,10,0,0 + 0,0,0,0 + 0,10,0,10 + + 0,10,0,0 + 0,10,0,0 - 8,10,0,0 - 0,4,0,0 + 8,10,0,0 + 0,4,0,0 - 12,8,0,0 - 0,12,0,0 + 12,8,0,0 + 0,12,0,0 96 24