diff --git a/dev/Generated/InfoBarPanel.properties.cpp b/dev/Generated/InfoBarPanel.properties.cpp index 93a64110e9..34571f9b38 100644 --- a/dev/Generated/InfoBarPanel.properties.cpp +++ b/dev/Generated/InfoBarPanel.properties.cpp @@ -13,10 +13,10 @@ namespace winrt::Microsoft::UI::Xaml::Controls::Primitives #include "InfoBarPanel.g.cpp" -GlobalDependencyProperty InfoBarPanelProperties::s_PaddingInHorizontalOrientationProperty{ nullptr }; -GlobalDependencyProperty InfoBarPanelProperties::s_PaddingInVerticalOrientationProperty{ nullptr }; -GlobalDependencyProperty InfoBarPanelProperties::s_SpacingInHorizontalOrientationProperty{ nullptr }; -GlobalDependencyProperty InfoBarPanelProperties::s_SpacingInVerticalOrientationProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_HorizontalOrientationMarginProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_HorizontalOrientationPaddingProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_VerticalOrientationMarginProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_VerticalOrientationPaddingProperty{ nullptr }; InfoBarPanelProperties::InfoBarPanelProperties() { @@ -25,47 +25,47 @@ InfoBarPanelProperties::InfoBarPanelProperties() void InfoBarPanelProperties::EnsureProperties() { - if (!s_PaddingInHorizontalOrientationProperty) + if (!s_HorizontalOrientationMarginProperty) { - s_PaddingInHorizontalOrientationProperty = + s_HorizontalOrientationMarginProperty = InitializeDependencyProperty( - L"PaddingInHorizontalOrientation", + L"HorizontalOrientationMargin", winrt::name_of(), winrt::name_of(), - false /* isAttached */, + true /* isAttached */, ValueHelper::BoxedDefaultValue(), nullptr); } - if (!s_PaddingInVerticalOrientationProperty) + if (!s_HorizontalOrientationPaddingProperty) { - s_PaddingInVerticalOrientationProperty = + s_HorizontalOrientationPaddingProperty = InitializeDependencyProperty( - L"PaddingInVerticalOrientation", + L"HorizontalOrientationPadding", winrt::name_of(), winrt::name_of(), false /* isAttached */, ValueHelper::BoxedDefaultValue(), nullptr); } - if (!s_SpacingInHorizontalOrientationProperty) + if (!s_VerticalOrientationMarginProperty) { - s_SpacingInHorizontalOrientationProperty = + s_VerticalOrientationMarginProperty = InitializeDependencyProperty( - L"SpacingInHorizontalOrientation", + L"VerticalOrientationMargin", winrt::name_of(), winrt::name_of(), true /* isAttached */, ValueHelper::BoxedDefaultValue(), nullptr); } - if (!s_SpacingInVerticalOrientationProperty) + if (!s_VerticalOrientationPaddingProperty) { - s_SpacingInVerticalOrientationProperty = + s_VerticalOrientationPaddingProperty = InitializeDependencyProperty( - L"SpacingInVerticalOrientation", + L"VerticalOrientationPadding", winrt::name_of(), winrt::name_of(), - true /* isAttached */, + false /* isAttached */, ValueHelper::BoxedDefaultValue(), nullptr); } @@ -73,56 +73,56 @@ void InfoBarPanelProperties::EnsureProperties() void InfoBarPanelProperties::ClearProperties() { - s_PaddingInHorizontalOrientationProperty = nullptr; - s_PaddingInVerticalOrientationProperty = nullptr; - s_SpacingInHorizontalOrientationProperty = nullptr; - s_SpacingInVerticalOrientationProperty = nullptr; + s_HorizontalOrientationMarginProperty = nullptr; + s_HorizontalOrientationPaddingProperty = nullptr; + s_VerticalOrientationMarginProperty = nullptr; + s_VerticalOrientationPaddingProperty = nullptr; } -void InfoBarPanelProperties::PaddingInHorizontalOrientation(winrt::Thickness const& value) + +void InfoBarPanelProperties::SetHorizontalOrientationMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) { - [[gsl::suppress(con)]] - { - static_cast(this)->SetValue(s_PaddingInHorizontalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); - } + target.SetValue(s_HorizontalOrientationMarginProperty, ValueHelper::BoxValueIfNecessary(value)); } -winrt::Thickness InfoBarPanelProperties::PaddingInHorizontalOrientation() +winrt::Thickness InfoBarPanelProperties::GetHorizontalOrientationMargin(winrt::DependencyObject const& target) { - return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_PaddingInHorizontalOrientationProperty)); + return ValueHelper::CastOrUnbox(target.GetValue(s_HorizontalOrientationMarginProperty)); } -void InfoBarPanelProperties::PaddingInVerticalOrientation(winrt::Thickness const& value) +void InfoBarPanelProperties::HorizontalOrientationPadding(winrt::Thickness const& value) { [[gsl::suppress(con)]] { - static_cast(this)->SetValue(s_PaddingInVerticalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); + static_cast(this)->SetValue(s_HorizontalOrientationPaddingProperty, ValueHelper::BoxValueIfNecessary(value)); } } -winrt::Thickness InfoBarPanelProperties::PaddingInVerticalOrientation() +winrt::Thickness InfoBarPanelProperties::HorizontalOrientationPadding() { - return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_PaddingInVerticalOrientationProperty)); + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_HorizontalOrientationPaddingProperty)); } -void InfoBarPanelProperties::SetSpacingInHorizontalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value) +void InfoBarPanelProperties::SetVerticalOrientationMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) { - target.SetValue(s_SpacingInHorizontalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); + target.SetValue(s_VerticalOrientationMarginProperty, ValueHelper::BoxValueIfNecessary(value)); } -winrt::Thickness InfoBarPanelProperties::GetSpacingInHorizontalOrientation(winrt::DependencyObject const& target) +winrt::Thickness InfoBarPanelProperties::GetVerticalOrientationMargin(winrt::DependencyObject const& target) { - return ValueHelper::CastOrUnbox(target.GetValue(s_SpacingInHorizontalOrientationProperty)); + return ValueHelper::CastOrUnbox(target.GetValue(s_VerticalOrientationMarginProperty)); } - -void InfoBarPanelProperties::SetSpacingInVerticalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value) +void InfoBarPanelProperties::VerticalOrientationPadding(winrt::Thickness const& value) { - target.SetValue(s_SpacingInVerticalOrientationProperty, ValueHelper::BoxValueIfNecessary(value)); + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_VerticalOrientationPaddingProperty, ValueHelper::BoxValueIfNecessary(value)); + } } -winrt::Thickness InfoBarPanelProperties::GetSpacingInVerticalOrientation(winrt::DependencyObject const& target) +winrt::Thickness InfoBarPanelProperties::VerticalOrientationPadding() { - return ValueHelper::CastOrUnbox(target.GetValue(s_SpacingInVerticalOrientationProperty)); + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_VerticalOrientationPaddingProperty)); } diff --git a/dev/Generated/InfoBarPanel.properties.h b/dev/Generated/InfoBarPanel.properties.h index 470fd0b286..0db31d720b 100644 --- a/dev/Generated/InfoBarPanel.properties.h +++ b/dev/Generated/InfoBarPanel.properties.h @@ -9,27 +9,27 @@ class InfoBarPanelProperties public: InfoBarPanelProperties(); - void PaddingInHorizontalOrientation(winrt::Thickness const& value); - winrt::Thickness PaddingInHorizontalOrientation(); + static void SetHorizontalOrientationMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetHorizontalOrientationMargin(winrt::DependencyObject const& target); - void PaddingInVerticalOrientation(winrt::Thickness const& value); - winrt::Thickness PaddingInVerticalOrientation(); + void HorizontalOrientationPadding(winrt::Thickness const& value); + winrt::Thickness HorizontalOrientationPadding(); - static void SetSpacingInHorizontalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value); - static winrt::Thickness GetSpacingInHorizontalOrientation(winrt::DependencyObject const& target); + static void SetVerticalOrientationMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetVerticalOrientationMargin(winrt::DependencyObject const& target); - static void SetSpacingInVerticalOrientation(winrt::DependencyObject const& target, winrt::Thickness const& value); - static winrt::Thickness GetSpacingInVerticalOrientation(winrt::DependencyObject const& target); + void VerticalOrientationPadding(winrt::Thickness const& value); + winrt::Thickness VerticalOrientationPadding(); - 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 winrt::DependencyProperty HorizontalOrientationMarginProperty() { return s_HorizontalOrientationMarginProperty; } + static winrt::DependencyProperty HorizontalOrientationPaddingProperty() { return s_HorizontalOrientationPaddingProperty; } + static winrt::DependencyProperty VerticalOrientationMarginProperty() { return s_VerticalOrientationMarginProperty; } + static winrt::DependencyProperty VerticalOrientationPaddingProperty() { return s_VerticalOrientationPaddingProperty; } - static GlobalDependencyProperty s_PaddingInHorizontalOrientationProperty; - static GlobalDependencyProperty s_PaddingInVerticalOrientationProperty; - static GlobalDependencyProperty s_SpacingInHorizontalOrientationProperty; - static GlobalDependencyProperty s_SpacingInVerticalOrientationProperty; + static GlobalDependencyProperty s_HorizontalOrientationMarginProperty; + static GlobalDependencyProperty s_HorizontalOrientationPaddingProperty; + static GlobalDependencyProperty s_VerticalOrientationMarginProperty; + static GlobalDependencyProperty s_VerticalOrientationPaddingProperty; static void EnsureProperties(); static void ClearProperties(); diff --git a/dev/InfoBar/InfoBar.idl b/dev/InfoBar/InfoBar.idl index 5193fd8aa6..0aa13f4b33 100644 --- a/dev/InfoBar/InfoBar.idl +++ b/dev/InfoBar/InfoBar.idl @@ -117,19 +117,19 @@ unsealed runtimeclass InfoBarPanel : Windows.UI.Xaml.Controls.Panel { InfoBarPanel(); - Windows.UI.Xaml.Thickness PaddingInHorizontalOrientation; - static Windows.UI.Xaml.DependencyProperty PaddingInHorizontalOrientationProperty{ get; }; + Windows.UI.Xaml.Thickness HorizontalOrientationPadding; + static Windows.UI.Xaml.DependencyProperty HorizontalOrientationPaddingProperty{ get; }; - Windows.UI.Xaml.Thickness PaddingInVerticalOrientation; - static Windows.UI.Xaml.DependencyProperty PaddingInVerticalOrientationProperty{ get; }; + Windows.UI.Xaml.Thickness VerticalOrientationPadding; + static Windows.UI.Xaml.DependencyProperty VerticalOrientationPaddingProperty{ 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 SetHorizontalOrientationMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetHorizontalOrientationMargin(Windows.UI.Xaml.DependencyObject object); + static Windows.UI.Xaml.DependencyProperty HorizontalOrientationMarginProperty{ 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; }; + static void SetVerticalOrientationMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetVerticalOrientationMargin(Windows.UI.Xaml.DependencyObject object); + static Windows.UI.Xaml.DependencyProperty VerticalOrientationMarginProperty{ get; }; } } diff --git a/dev/InfoBar/InfoBar.xaml b/dev/InfoBar/InfoBar.xaml index 781b96968f..0a5549cd57 100644 --- a/dev/InfoBar/InfoBar.xaml +++ b/dev/InfoBar/InfoBar.xaml @@ -136,14 +136,14 @@ + HorizontalOrientationPadding="{StaticResource InfoBarPanelHorizontalOrientationPadding}" + VerticalOrientationPadding="{StaticResource InfoBarPanelVerticalOrientationPadding}"> diff --git a/dev/InfoBar/InfoBarPanel.cpp b/dev/InfoBar/InfoBarPanel.cpp index ad5b7ac923..9a0afcc0ab 100644 --- a/dev/InfoBar/InfoBarPanel.cpp +++ b/dev/InfoBar/InfoBarPanel.cpp @@ -19,7 +19,9 @@ winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) const auto parent = this->Parent().try_as(); const float minHeight = !parent ? 0.0f : (float)(parent.MinHeight() - (Margin().Top + Margin().Bottom)); - for (winrt::UIElement const& child : Children()) + const auto children = Children(); + const auto childCount = (int)children.Size(); + for (winrt::UIElement const& child : children) { child.Measure(availableSize); const auto childDesiredSize = child.DesiredSize(); @@ -27,12 +29,18 @@ 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::GetSpacingInHorizontalOrientation(child); - totalWidth += childDesiredSize.Width + (nItems > 0 ? (float)horizontalMargin.Left : 0) + (float)horizontalMargin.Right; + const auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalOrientationMargin(child); + // Ignore left margin of first and right margin of last child + totalWidth += childDesiredSize.Width + + (nItems > 0 ? (float)horizontalMargin.Left : 0) + + (nItems < childCount -1 ? (float)horizontalMargin.Right : 0); // Add up the height of all items if they were laid out vertically - const auto verticalMargin = winrt::InfoBarPanel::GetSpacingInVerticalOrientation(child); - totalHeight += childDesiredSize.Height + (nItems > 0 ? (float)verticalMargin.Top : 0) + (float)verticalMargin.Bottom; + const auto verticalMargin = winrt::InfoBarPanel::GetVerticalOrientationMargin(child); + // Ignore top margin of first and bottom margin of last child + totalHeight += childDesiredSize.Height + + (nItems > 0 ? (float)verticalMargin.Top : 0) + + (nItems < childCount -1 ? (float)verticalMargin.Bottom: 0); if (childDesiredSize.Width > widthOfWidest) { @@ -61,18 +69,18 @@ winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) if (nItems == 1 || totalWidth > availableSize.Width || (minHeight > 0 && heightOfTallestInHorizontal > minHeight)) { m_isVertical = true; - const auto verticalMargin = PaddingInVerticalOrientation(); + const auto verticalPadding = VerticalOrientationPadding(); - desiredSize.Width = widthOfWidest; - desiredSize.Height = totalHeight + (float)verticalMargin.Top + (float)verticalMargin.Bottom; + desiredSize.Width = widthOfWidest + (float)verticalPadding.Left + (float)verticalPadding.Right; + desiredSize.Height = totalHeight + (float)verticalPadding.Top + (float)verticalPadding.Bottom; } else { m_isVertical = false; - const auto horizontalMargin = PaddingInHorizontalOrientation(); + const auto horizontalPadding = HorizontalOrientationPadding(); - desiredSize.Width = totalWidth + (float)horizontalMargin.Left + (float)horizontalMargin.Right; - desiredSize.Height = heightOfTallest; + desiredSize.Width = totalWidth + (float)horizontalPadding.Left + (float)horizontalPadding.Right; + desiredSize.Height = heightOfTallest + (float)horizontalPadding.Top + (float)horizontalPadding.Bottom ; } return desiredSize; @@ -85,7 +93,9 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) if (m_isVertical) { // Layout elements vertically - float verticalOffset = (float)PaddingInVerticalOrientation().Top; + const auto verticalOrientationPadding = VerticalOrientationPadding(); + float verticalOffset = (float)verticalOrientationPadding.Top; + bool hasPreviousElement = false; for (winrt::UIElement const& child : Children()) { @@ -94,10 +104,10 @@ 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::GetSpacingInVerticalOrientation(child); + const auto verticalMargin = winrt::InfoBarPanel::GetVerticalOrientationMargin(child); verticalOffset += hasPreviousElement ? (float)verticalMargin.Top : 0; - child.Arrange(winrt::Rect{ (float)verticalMargin.Left, verticalOffset, desiredSize.Width, desiredSize.Height }); + child.Arrange(winrt::Rect{ (float)verticalOrientationPadding.Left + (float)verticalMargin.Left, verticalOffset, desiredSize.Width, desiredSize.Height }); verticalOffset += desiredSize.Height + (float)verticalMargin.Bottom; hasPreviousElement = true; @@ -108,7 +118,8 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) else { // Layout elements horizontally - float horizontalOffset = (float)PaddingInHorizontalOrientation().Left; + const auto horizontalOrientationPadding = HorizontalOrientationPadding(); + float horizontalOffset = (float)horizontalOrientationPadding.Left; bool hasPreviousElement = false; for (winrt::UIElement const& child : Children()) { @@ -117,10 +128,10 @@ winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) auto const desiredSize = child.DesiredSize(); if (desiredSize.Width != 0 && desiredSize.Height != 0) { - auto horizontalMargin = winrt::InfoBarPanel::GetSpacingInHorizontalOrientation(child); + auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalOrientationMargin(child); horizontalOffset += hasPreviousElement ? (float)horizontalMargin.Left : 0; - child.Arrange(winrt::Rect{ horizontalOffset, (float)horizontalMargin.Top, desiredSize.Width, finalSize.Height }); + child.Arrange(winrt::Rect{ horizontalOffset, (float)horizontalOrientationPadding.Top + (float)horizontalMargin.Top, desiredSize.Width, desiredSize.Height }); horizontalOffset += desiredSize.Width + (float)horizontalMargin.Right; hasPreviousElement = true; diff --git a/dev/InfoBar/InfoBar_themeresources.xaml b/dev/InfoBar/InfoBar_themeresources.xaml index bd95861660..01595c58f1 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,0,0,0 + 0,10,0,10 - 0,10,0,0 - 0,10,0,0 + 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