Commit 9ad88042 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Refactor bordered box view

The outer margins view is replaced by specifying
the outer margins using the property kMarginsKey.

Bug: 995720
Change-Id: I1c2ad9414dd24188aa528f85aa367872672cfdd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813356Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698413}
parent 1573d6ba
...@@ -89,28 +89,19 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout( ...@@ -89,28 +89,19 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout(
return layout; return layout;
} }
std::unique_ptr<views::View> CreateBorderedBoxView( std::unique_ptr<views::View> CreateBorderedBoxView() {
std::unique_ptr<views::View> children_container) {
constexpr int kBorderThickness = 1; constexpr int kBorderThickness = 1;
// Add rounded rectangular border around children. auto bordered_box = std::make_unique<views::View>();
children_container->SetLayoutManager(std::make_unique<views::BoxLayout>( bordered_box->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
children_container->SetBorder(views::CreateRoundedRectBorder( bordered_box->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kBorderThickness,
views::LayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH), views::LayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH),
GetDefaultSeparatorColor())); GetDefaultSeparatorColor()));
bordered_box->SetProperty(views::kMarginsKey, gfx::Insets(kMenuEdgeMargin));
// Create outer view with margin. return bordered_box;
// The outer view is needed because |BoxLayout| doesn't support outer
// margins.
auto outer_view = std::make_unique<views::View>();
outer_view->SetLayoutManager(std::make_unique<views::FillLayout>());
constexpr auto kOuterMargin = gfx::Insets(16);
outer_view->SetBorder(views::CreateEmptyBorder(kOuterMargin));
outer_view->AddChildView(std::move(children_container));
return outer_view;
} }
std::unique_ptr<views::Button> CreateCircularImageButton( std::unique_ptr<views::Button> CreateCircularImageButton(
...@@ -519,17 +510,15 @@ void ProfileMenuViewBase::Reset() { ...@@ -519,17 +510,15 @@ void ProfileMenuViewBase::Reset() {
// Create and add new component containers in the correct order. // Create and add new component containers in the correct order.
// First, add the bordered box with the identity and feature buttons. // First, add the bordered box with the identity and feature buttons.
auto bordered_box_container = std::make_unique<views::View>(); views::View* bordered_box = components->AddChildView(CreateBorderedBoxView());
identity_info_container_ = identity_info_container_ =
bordered_box_container->AddChildView(std::make_unique<views::View>()); bordered_box->AddChildView(std::make_unique<views::View>());
shortcut_features_container_ = shortcut_features_container_ =
bordered_box_container->AddChildView(std::make_unique<views::View>()); bordered_box->AddChildView(std::make_unique<views::View>());
sync_info_container_ = sync_info_container_ =
bordered_box_container->AddChildView(std::make_unique<views::View>()); bordered_box->AddChildView(std::make_unique<views::View>());
account_features_container_ = account_features_container_ =
bordered_box_container->AddChildView(std::make_unique<views::View>()); bordered_box->AddChildView(std::make_unique<views::View>());
components->AddChildView(
CreateBorderedBoxView(std::move(bordered_box_container)));
// Second, add the profile header. // Second, add the profile header.
auto profile_header = std::make_unique<views::View>(); auto profile_header = std::make_unique<views::View>();
views::BoxLayout* profile_header_layout = views::BoxLayout* profile_header_layout =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment