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

[profile-menu] Add rounded rect border

A rounded rectangular border is added around the identity info
and the shortcut feature buttons.

Screenshot:
https://drive.google.com/file/d/1TDtoomMKru6rwWfd_fqoUmbEJfF7k9UB/view?usp=sharing

Flag: profile-menu-revamp

Bug: 995720
Change-Id: Icfb031632b2564a0c49acbf2cf6b8cd17f6605ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1796327Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695992}
parent 8b0a574f
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h" #include "ui/views/controls/separator.h"
#include "ui/views/controls/styled_label.h" #include "ui/views/controls/styled_label.h"
#include "ui/views/layout/fill_layout.h"
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
#include "chrome/browser/ui/views/profiles/profile_menu_view.h" #include "chrome/browser/ui/views/profiles/profile_menu_view.h"
...@@ -62,6 +63,32 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout( ...@@ -62,6 +63,32 @@ std::unique_ptr<views::BoxLayout> CreateBoxLayout(
return layout; return layout;
} }
std::unique_ptr<views::View> CreateBorderedBoxView(
std::unique_ptr<views::View> children_container) {
constexpr int kOuterMargin = 16;
constexpr int kBorderThickness = 1;
constexpr int kCornerRadius = 8;
const SkColor kBorderColor =
ui::NativeTheme::GetInstanceForNativeUi()->GetSystemColor(
ui::NativeTheme::kColorId_MenuSeparatorColor);
// Add rounded rectangular border around children.
children_container->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical));
children_container->SetBorder(views::CreateRoundedRectBorder(
kBorderThickness, kCornerRadius, kBorderColor));
// Create outer view with margin.
// 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>());
outer_view->SetBorder(views::CreateEmptyBorder(gfx::Insets(kOuterMargin)));
outer_view->AddChildView(std::move(children_container));
return outer_view;
}
} // namespace } // namespace
// MenuItems-------------------------------------------------------------------- // MenuItems--------------------------------------------------------------------
...@@ -152,12 +179,15 @@ ProfileMenuViewBase::~ProfileMenuViewBase() { ...@@ -152,12 +179,15 @@ ProfileMenuViewBase::~ProfileMenuViewBase() {
void ProfileMenuViewBase::SetIdentityInfo(const gfx::Image& image, void ProfileMenuViewBase::SetIdentityInfo(const gfx::Image& image,
const base::string16& title, const base::string16& title,
const base::string16& subtitle) { const base::string16& subtitle) {
constexpr int kTopMargin = 16;
constexpr int kImageToLabelSpacing = 4; constexpr int kImageToLabelSpacing = 4;
identity_info_container_->RemoveAllChildViews(/*delete_children=*/true); identity_info_container_->RemoveAllChildViews(/*delete_children=*/true);
identity_info_container_->SetLayoutManager( identity_info_container_->SetLayoutManager(
CreateBoxLayout(views::BoxLayout::Orientation::kVertical, CreateBoxLayout(views::BoxLayout::Orientation::kVertical,
views::BoxLayout::CrossAxisAlignment::kCenter)); views::BoxLayout::CrossAxisAlignment::kCenter));
identity_info_container_->SetBorder(
views::CreateEmptyBorder(kTopMargin, 0, 0, 0));
views::ImageView* image_view = identity_info_container_->AddChildView( views::ImageView* image_view = identity_info_container_->AddChildView(
std::make_unique<views::ImageView>()); std::make_unique<views::ImageView>());
...@@ -326,10 +356,14 @@ void ProfileMenuViewBase::Reset() { ...@@ -326,10 +356,14 @@ 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.
auto bordered_box_container = std::make_unique<views::View>();
identity_info_container_ = identity_info_container_ =
components->AddChildView(std::make_unique<views::View>()); bordered_box_container->AddChildView(std::make_unique<views::View>());
shortcut_features_container_ = shortcut_features_container_ =
components->AddChildView(std::make_unique<views::View>()); bordered_box_container->AddChildView(std::make_unique<views::View>());
components->AddChildView(
CreateBorderedBoxView(std::move(bordered_box_container)));
selectable_profiles_container_ = selectable_profiles_container_ =
components->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
......
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