Commit d1c80a64 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Move bordered box to sync info

 - Remove big bordered box
 - Move sync info into bordered box when a blue
   button is shown
 - Refactor spacing

Screenshot:
https://drive.google.com/open?id=1CmKpM_rEA92NO-dP_V71q7TghYAALV_S

Bug: 995720
Change-Id: I1e47024c57330a69c77632ac8020d11d6e983b77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864786Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706427}
parent fd12ffbe
...@@ -55,6 +55,7 @@ constexpr int kMenuWidth = 288; ...@@ -55,6 +55,7 @@ constexpr int kMenuWidth = 288;
constexpr int kIconSize = 16; constexpr int kIconSize = 16;
constexpr int kIdentityImageSize = 64; constexpr int kIdentityImageSize = 64;
constexpr int kMaxImageSize = kIdentityImageSize; constexpr int kMaxImageSize = kIdentityImageSize;
constexpr int kDefaultVerticalMargin = 12;
// If the bubble is too large to fit on the screen, it still needs to be at // If the bubble is too large to fit on the screen, it still needs to be at
// least this tall to show one row. // least this tall to show one row.
...@@ -135,21 +136,6 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout( ...@@ -135,21 +136,6 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout(
return layout; return layout;
} }
std::unique_ptr<views::View> CreateBorderedBoxView() {
constexpr int kBorderThickness = 1;
auto bordered_box = std::make_unique<views::View>();
bordered_box->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical));
bordered_box->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness,
views::LayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH),
GetDefaultSeparatorColor()));
bordered_box->SetProperty(views::kMarginsKey, gfx::Insets(kMenuEdgeMargin));
return bordered_box;
}
std::unique_ptr<views::Button> CreateCircularImageButton( std::unique_ptr<views::Button> CreateCircularImageButton(
views::ButtonListener* listener, views::ButtonListener* listener,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
...@@ -356,33 +342,46 @@ void ProfileMenuViewBase::SetSyncInfo(const gfx::ImageSkia& icon, ...@@ -356,33 +342,46 @@ void ProfileMenuViewBase::SetSyncInfo(const gfx::ImageSkia& icon,
const base::string16& description, const base::string16& description,
const base::string16& clickable_text, const base::string16& clickable_text,
base::RepeatingClosure action) { base::RepeatingClosure action) {
constexpr int kVerticalSpacing = 8;
constexpr int kIconSize = 16; constexpr int kIconSize = 16;
const int kDescriptionIconSpacing =
ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_LABEL_HORIZONTAL);
constexpr int kBorderThickness = 1;
const int kBorderCornerRadius =
views::LayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH);
sync_info_container_->RemoveAllChildViews(/*delete_children=*/true); sync_info_container_->RemoveAllChildViews(/*delete_children=*/true);
sync_info_container_->SetLayoutManager(std::make_unique<views::BoxLayout>( sync_info_container_->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical, gfx::Insets(),
kDefaultVerticalMargin));
views::LabelButton* button = nullptr;
if (description.empty()) { if (description.empty()) {
button = sync_info_container_->AddChildView(std::make_unique<HoverButton>( views::Button* button =
sync_info_container_->AddChildView(std::make_unique<HoverButton>(
this, SizeImage(icon, kIconSize), clickable_text)); this, SizeImage(icon, kIconSize), clickable_text));
} else { RegisterClickAction(button, std::move(action));
// Add icon + description on top. return;
}
// Add padding, rounded border and margins.
sync_info_container_->SetBorder(views::CreatePaddedBorder(
views::CreateRoundedRectBorder(kBorderThickness, kBorderCornerRadius,
GetDefaultSeparatorColor()),
/*padding=*/gfx::Insets(kDefaultVerticalMargin, kMenuEdgeMargin)));
sync_info_container_->SetProperty(
views::kMarginsKey, gfx::Insets(kDefaultVerticalMargin, kMenuEdgeMargin));
// Add icon + description at the top.
views::View* description_container = views::View* description_container =
sync_info_container_->AddChildView(std::make_unique<views::View>()); sync_info_container_->AddChildView(std::make_unique<views::View>());
views::BoxLayout* description_layout = views::BoxLayout* description_layout =
description_container->SetLayoutManager( description_container->SetLayoutManager(
std::make_unique<views::BoxLayout>( std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, views::BoxLayout::Orientation::kHorizontal, gfx::Insets(),
gfx::Insets(kVerticalSpacing, kMenuEdgeMargin), kDescriptionIconSpacing));
/*between_child_spacing=*/
ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_LABEL_HORIZONTAL)));
if (icon.isNull()) { if (icon.isNull()) {
// If there is no image, the description text should be centered. // If there is no image, the description is centered.
description_layout->set_main_axis_alignment( description_layout->set_main_axis_alignment(
views::BoxLayout::MainAxisAlignment::kCenter); views::BoxLayout::MainAxisAlignment::kCenter);
} else { } else {
...@@ -397,14 +396,8 @@ void ProfileMenuViewBase::SetSyncInfo(const gfx::ImageSkia& icon, ...@@ -397,14 +396,8 @@ void ProfileMenuViewBase::SetSyncInfo(const gfx::ImageSkia& icon,
label->SetHandlesTooltips(false); label->SetHandlesTooltips(false);
// Add blue button at the bottom. // Add blue button at the bottom.
button = sync_info_container_->AddChildView( views::Button* button = sync_info_container_->AddChildView(
views::MdTextButton::CreateSecondaryUiBlueButton(this, clickable_text)); views::MdTextButton::CreateSecondaryUiBlueButton(this, clickable_text));
button->SetProperty(
views::kMarginsKey,
gfx::Insets(/*top=*/0, /*left=*/kMenuEdgeMargin,
/*bottom=*/kVerticalSpacing, /*right=*/kMenuEdgeMargin));
}
RegisterClickAction(button, std::move(action)); RegisterClickAction(button, std::move(action));
} }
...@@ -456,27 +449,26 @@ void ProfileMenuViewBase::SetProfileManagementHeading( ...@@ -456,27 +449,26 @@ void ProfileMenuViewBase::SetProfileManagementHeading(
/*delete_children=*/true); /*delete_children=*/true);
profile_mgmt_heading_container_->SetLayoutManager( profile_mgmt_heading_container_->SetLayoutManager(
std::make_unique<views::FillLayout>()); std::make_unique<views::FillLayout>());
profile_mgmt_heading_container_->SetBorder(views::CreateEmptyBorder(
gfx::Insets(kDefaultVerticalMargin, kMenuEdgeMargin)));
views::Label* label = profile_mgmt_heading_container_->AddChildView( views::Label* label = profile_mgmt_heading_container_->AddChildView(
std::make_unique<views::Label>(heading, views::style::CONTEXT_LABEL, std::make_unique<views::Label>(heading, views::style::CONTEXT_LABEL,
STYLE_HINT)); STYLE_HINT));
label->SetHorizontalAlignment(gfx::ALIGN_LEFT); label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetHandlesTooltips(false); label->SetHandlesTooltips(false);
label->SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kMenuEdgeMargin)));
} }
void ProfileMenuViewBase::AddSelectableProfile(const gfx::ImageSkia& image, void ProfileMenuViewBase::AddSelectableProfile(const gfx::ImageSkia& image,
const base::string16& name, const base::string16& name,
base::RepeatingClosure action) { base::RepeatingClosure action) {
constexpr int kTopMargin = 8;
constexpr int kImageSize = 22; constexpr int kImageSize = 22;
// Initialize layout if this is the first time a button is added. // Initialize layout if this is the first time a button is added.
if (!selectable_profiles_container_->GetLayoutManager()) { if (!selectable_profiles_container_->GetLayoutManager()) {
selectable_profiles_container_->SetLayoutManager( selectable_profiles_container_->SetLayoutManager(
std::make_unique<views::BoxLayout>( std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, views::BoxLayout::Orientation::kVertical));
gfx::Insets(kTopMargin, 0, 0, 0)));
} }
gfx::ImageSkia sized_image = CropCircle(SizeImage(image, kImageSize)); gfx::ImageSkia sized_image = CropCircle(SizeImage(image, kImageSize));
...@@ -635,23 +627,23 @@ void ProfileMenuViewBase::Reset() { ...@@ -635,23 +627,23 @@ void ProfileMenuViewBase::Reset() {
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
// 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 parts of the current profile.
views::View* bordered_box = components->AddChildView(CreateBorderedBoxView());
heading_container_ = heading_container_ =
bordered_box->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
identity_info_container_ = identity_info_container_ =
bordered_box->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
shortcut_features_container_ = shortcut_features_container_ =
bordered_box->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
sync_info_container_ = sync_info_container_ =
bordered_box->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
features_container_ = features_container_ =
bordered_box->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
// Second, add the profile header. // Second, add the profile management header.
components->AddChildView(new views::Separator());
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 = profile_header->SetLayoutManager(
profile_header->SetLayoutManager(std::make_unique<views::BoxLayout>( CreateBoxLayout(views::BoxLayout::Orientation::kHorizontal,
views::BoxLayout::Orientation::kHorizontal)); views::BoxLayout::CrossAxisAlignment::kCenter));
profile_mgmt_heading_container_ = profile_mgmt_heading_container_ =
profile_header->AddChildView(std::make_unique<views::View>()); profile_header->AddChildView(std::make_unique<views::View>());
profile_header_layout->SetFlexForView(profile_mgmt_heading_container_, 1); profile_header_layout->SetFlexForView(profile_mgmt_heading_container_, 1);
...@@ -660,7 +652,7 @@ void ProfileMenuViewBase::Reset() { ...@@ -660,7 +652,7 @@ void ProfileMenuViewBase::Reset() {
profile_header_layout->SetFlexForView( profile_header_layout->SetFlexForView(
profile_mgmt_shortcut_features_container_, 0); profile_mgmt_shortcut_features_container_, 0);
components->AddChildView(std::move(profile_header)); components->AddChildView(std::move(profile_header));
// Third, add the profile buttons at the bottom. // Third, add the profile management buttons.
selectable_profiles_container_ = selectable_profiles_container_ =
components->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
profile_mgmt_features_container_ = profile_mgmt_features_container_ =
......
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