Skip to content

Commit

Permalink
[UWP] Fix AdaptiveColumn width (#3340)
Browse files Browse the repository at this point in the history
With change fee0c03, pixel width and string width in the shared model are now
last-writer-wins. Update `AdaptiveColumn::GetSharedModel()` to account for that.

Fixes #3339.
  • Loading branch information
paulcam206 authored Aug 16, 2019
1 parent 0930d5e commit 1642b59
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ namespace AdaptiveCardsSharedModelUnitTest
auto columnTest = std::make_shared<AdaptiveCards::Column>();
Assert::AreEqual(0, columnTest->GetPixelWidth());
Assert::AreEqual("Auto"s, columnTest->GetWidth());
Assert::AreEqual("{\"items\":[],\"type\":\"Column\",\"width\":\"Auto\"}\n"s, columnTest->Serialize());

columnTest->SetWidth("20px"s);
Assert::AreEqual(20, columnTest->GetPixelWidth());
Assert::AreEqual("20px"s, columnTest->GetWidth());
Assert::AreEqual("{\"items\":[],\"type\":\"Column\",\"width\":\"20px\"}\n"s, columnTest->Serialize());

columnTest->SetPixelWidth(40);
Assert::AreEqual(40, columnTest->GetPixelWidth());
Assert::AreEqual("40px"s, columnTest->GetWidth());
Assert::AreEqual("{\"items\":[],\"type\":\"Column\",\"width\":\"40px\"}\n"s, columnTest->Serialize());

columnTest->SetWidth("Stretch");
Assert::AreEqual(0, columnTest->GetPixelWidth());
Assert::AreEqual("stretch"s, columnTest->GetWidth());
Assert::AreEqual("{\"items\":[],\"type\":\"Column\",\"width\":\"stretch\"}\n"s, columnTest->Serialize());
}
};
}
12 changes: 10 additions & 2 deletions source/uwp/Renderer/lib/AdaptiveColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ namespace AdaptiveNamespace

column->SetStyle(static_cast<AdaptiveSharedNamespace::ContainerStyle>(m_style));
column->SetVerticalContentAlignment(static_cast<AdaptiveSharedNamespace::VerticalContentAlignment>(m_verticalAlignment));
column->SetWidth(HStringToUTF8(m_width.Get()));
column->SetPixelWidth(m_pixelWidth);

if (m_pixelWidth)
{
column->SetPixelWidth(m_pixelWidth);
}
else
{
column->SetWidth(HStringToUTF8(m_width.Get()));
}

column->SetMinHeight(m_minHeight);
column->SetBleed(m_bleed);

Expand Down

0 comments on commit 1642b59

Please sign in to comment.