Skip to content

Commit

Permalink
Update InfoBarPanel API names (#3704)
Browse files Browse the repository at this point in the history
* Update API names

* Remove grid.columns
  • Loading branch information
marcelwgn authored Nov 27, 2020
1 parent 06b3e1d commit f48eaee
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 60 deletions.
88 changes: 70 additions & 18 deletions dev/Generated/InfoBarPanel.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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::Thickness>(),
winrt::name_of<winrt::InfoBarPanel>(),
false /* isAttached */,
ValueHelper<winrt::Thickness>::BoxedDefaultValue(),
nullptr);
}
if (!s_PaddingInVerticalOrientationProperty)
{
s_PaddingInVerticalOrientationProperty =
InitializeDependencyProperty(
L"PaddingInVerticalOrientation",
winrt::name_of<winrt::Thickness>(),
winrt::name_of<winrt::InfoBarPanel>(),
false /* isAttached */,
ValueHelper<winrt::Thickness>::BoxedDefaultValue(),
nullptr);
}
if (!s_SpacingInHorizontalOrientationProperty)
{
s_SpacingInHorizontalOrientationProperty =
InitializeDependencyProperty(
L"SpacingInHorizontalOrientation",
winrt::name_of<winrt::Thickness>(),
winrt::name_of<winrt::InfoBarPanel>(),
true /* isAttached */,
ValueHelper<winrt::Thickness>::BoxedDefaultValue(),
nullptr);
}
if (!s_VerticalMarginProperty)
if (!s_SpacingInVerticalOrientationProperty)
{
s_VerticalMarginProperty =
s_SpacingInVerticalOrientationProperty =
InitializeDependencyProperty(
L"VerticalMargin",
L"SpacingInVerticalOrientation",
winrt::name_of<winrt::Thickness>(),
winrt::name_of<winrt::InfoBarPanel>(),
true /* isAttached */,
Expand All @@ -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<InfoBarPanel*>(this)->SetValue(s_PaddingInHorizontalOrientationProperty, ValueHelper<winrt::Thickness>::BoxValueIfNecessary(value));
}
}

winrt::Thickness InfoBarPanelProperties::PaddingInHorizontalOrientation()
{
return ValueHelper<winrt::Thickness>::CastOrUnbox(static_cast<InfoBarPanel*>(this)->GetValue(s_PaddingInHorizontalOrientationProperty));
}

void InfoBarPanelProperties::PaddingInVerticalOrientation(winrt::Thickness const& value)
{
[[gsl::suppress(con)]]
{
static_cast<InfoBarPanel*>(this)->SetValue(s_PaddingInVerticalOrientationProperty, ValueHelper<winrt::Thickness>::BoxValueIfNecessary(value));
}
}

winrt::Thickness InfoBarPanelProperties::PaddingInVerticalOrientation()
{
return ValueHelper<winrt::Thickness>::CastOrUnbox(static_cast<InfoBarPanel*>(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<winrt::Thickness>::BoxValueIfNecessary(value));
target.SetValue(s_SpacingInHorizontalOrientationProperty, ValueHelper<winrt::Thickness>::BoxValueIfNecessary(value));
}

winrt::Thickness InfoBarPanelProperties::GetHorizontalMargin(winrt::DependencyObject const& target)
winrt::Thickness InfoBarPanelProperties::GetSpacingInHorizontalOrientation(winrt::DependencyObject const& target)
{
return ValueHelper<winrt::Thickness>::CastOrUnbox(target.GetValue(s_HorizontalMarginProperty));
return ValueHelper<winrt::Thickness>::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<winrt::Thickness>::BoxValueIfNecessary(value));
target.SetValue(s_SpacingInVerticalOrientationProperty, ValueHelper<winrt::Thickness>::BoxValueIfNecessary(value));
}

winrt::Thickness InfoBarPanelProperties::GetVerticalMargin(winrt::DependencyObject const& target)
winrt::Thickness InfoBarPanelProperties::GetSpacingInVerticalOrientation(winrt::DependencyObject const& target)
{
return ValueHelper<winrt::Thickness>::CastOrUnbox(target.GetValue(s_VerticalMarginProperty));
return ValueHelper<winrt::Thickness>::CastOrUnbox(target.GetValue(s_SpacingInVerticalOrientationProperty));
}
26 changes: 18 additions & 8 deletions dev/Generated/InfoBarPanel.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 12 additions & 6 deletions dev/InfoBar/InfoBar.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
}

}
Expand Down
19 changes: 8 additions & 11 deletions dev/InfoBar/InfoBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,34 +136,31 @@
<primitives:InfoBarPanel
Grid.Column="1"
Margin="{StaticResource InfoBarPanelMargin}"
primitives:InfoBarPanel.HorizontalMargin="{StaticResource InfoBarPanelHorizontalLayoutMargin}"
primitives:InfoBarPanel.VerticalMargin="{StaticResource InfoBarPanelVerticalLayoutMargin}">
PaddingInHorizontalOrientation="{StaticResource InfoBarPanelPaddingInHorizontalOrientation}"
PaddingInVerticalOrientation="{StaticResource InfoBarPanelPaddingInVerticalOrientation}">

<TextBlock x:Name="Title"
Grid.Column="0"
Text="{TemplateBinding Title}"
Foreground="{ThemeResource InfoBarTitleForeground}"
primitives:InfoBarPanel.HorizontalMargin="{StaticResource InfoBarTitleHorizontalLayoutMargin}"
primitives:InfoBarPanel.VerticalMargin="{StaticResource InfoBarTitleVerticalLayoutMargin}"
primitives:InfoBarPanel.SpacingInHorizontalOrientation="{StaticResource InfoBarTitleSpacingInHorizontalOrientation}"
primitives:InfoBarPanel.SpacingInVerticalOrientation="{StaticResource InfoBarTitleSpacingInVerticalOrientation}"
TextWrapping="WrapWholeWords"
AutomationProperties.LandmarkType="Navigation"
FontWeight="{StaticResource InfoBarTitleFontWeight}"
FontSize="{StaticResource InfoBarTitleFontSize}"/>

<TextBlock x:Name="Message"
Grid.Column="1"
Text="{TemplateBinding Message}"
Foreground="{ThemeResource InfoBarMessageForeground}"
primitives:InfoBarPanel.HorizontalMargin="{StaticResource InfoBarMessageHorizontalLayoutMargin}"
primitives:InfoBarPanel.VerticalMargin="{StaticResource InfoBarMessageVerticalLayoutMargin}"
primitives:InfoBarPanel.SpacingInHorizontalOrientation="{StaticResource InfoBarMessageSpacingInHorizontalOrientation}"
primitives:InfoBarPanel.SpacingInVerticalOrientation="{StaticResource InfoBarMessageSpacingInVerticalOrientation}"
TextWrapping="WrapWholeWords"
FontWeight="{StaticResource InfoBarMessageFontWeight}"
FontSize="{StaticResource InfoBarMessageFontSize}"/>

<ContentPresenter
Grid.Column="2"
primitives:InfoBarPanel.HorizontalMargin="{StaticResource InfoBarActionHorizontalLayoutMargin}"
primitives:InfoBarPanel.VerticalMargin="{StaticResource InfoBarActionVerticalLayoutMargin}"
primitives:InfoBarPanel.SpacingInHorizontalOrientation="{StaticResource InfoBarActionSpacingInHorizontalOrientation}"
primitives:InfoBarPanel.SpacingInVerticalOrientation="{StaticResource InfoBarActionSpacingInVerticalOrientation}"
VerticalAlignment="Top"
Content="{TemplateBinding ActionButton}">

Expand Down
16 changes: 8 additions & 8 deletions dev/InfoBar/InfoBarPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -61,15 +61,15 @@ 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;
}
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;
Expand All @@ -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())
{
Expand All @@ -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 });
Expand All @@ -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())
{
Expand All @@ -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 });
Expand Down
18 changes: 9 additions & 9 deletions dev/InfoBar/InfoBar_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@
<x:Double x:Key="InfoBarIconFontSize">20</x:Double>

<Thickness x:Key="InfoBarPanelMargin">0,0,12,0</Thickness>
<Thickness x:Key="InfoBarPanelHorizontalLayoutMargin">0,0,0,0</Thickness>
<Thickness x:Key="InfoBarPanelVerticalLayoutMargin">0,10,0,10</Thickness>
<Thickness x:Key="InfoBarTitleHorizontalLayoutMargin">0,10,0,0</Thickness>
<Thickness x:Key="InfoBarTitleVerticalLayoutMargin">0,10,0,0</Thickness>
<Thickness x:Key="InfoBarPanelPaddingInHorizontalOrientation">0,0,0,0</Thickness>
<Thickness x:Key="InfoBarPanelPaddingInVerticalOrientation">0,10,0,10</Thickness>

<Thickness x:Key="InfoBarTitleSpacingInHorizontalOrientation">0,10,0,0</Thickness>
<Thickness x:Key="InfoBarTitleSpacingInVerticalOrientation">0,10,0,0</Thickness>

<Thickness x:Key="InfoBarMessageHorizontalLayoutMargin">8,10,0,0</Thickness>
<Thickness x:Key="InfoBarMessageVerticalLayoutMargin">0,4,0,0</Thickness>
<Thickness x:Key="InfoBarMessageSpacingInHorizontalOrientation">8,10,0,0</Thickness>
<Thickness x:Key="InfoBarMessageSpacingInVerticalOrientation">0,4,0,0</Thickness>

<Thickness x:Key="InfoBarActionHorizontalLayoutMargin">12,8,0,0</Thickness>
<Thickness x:Key="InfoBarActionVerticalLayoutMargin">0,12,0,0</Thickness>
<Thickness x:Key="InfoBarActionSpacingInHorizontalOrientation">12,8,0,0</Thickness>
<Thickness x:Key="InfoBarActionSpacingInVerticalOrientation">0,12,0,0</Thickness>

<x:Double x:Key="InfoBarActionButtonMinWidth">96</x:Double>
<x:Double x:Key="InfoBarActionButtonMinHeight">24</x:Double>
Expand Down

0 comments on commit f48eaee

Please sign in to comment.