Commit 20a988ab authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

[Tab Groups] Visual update for the tab group editor bubble.

Bug: 1015634
Change-Id: I48e2c78071619827843f45c74852c0a127f75c59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879649
Commit-Queue: Charlene Yan <cyan@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710538}
parent bd3349d0
...@@ -17,6 +17,7 @@ namespace { ...@@ -17,6 +17,7 @@ namespace {
// respected (there's 3 * unit / 4 in use to express 12). // respected (there's 3 * unit / 4 in use to express 12).
// The Harmony layout unit. All distances are in terms of this unit. // The Harmony layout unit. All distances are in terms of this unit.
constexpr int kHarmonyLayoutUnit = 16; constexpr int kHarmonyLayoutUnit = 16;
constexpr int kExtraSmallBubbleSize = 240;
constexpr int kSmallSnapPoint = 320; constexpr int kSmallSnapPoint = 320;
constexpr int kMediumSnapPoint = 448; constexpr int kMediumSnapPoint = 448;
constexpr int kLargeSnapPoint = 512; constexpr int kLargeSnapPoint = 512;
...@@ -160,6 +161,8 @@ int ChromeLayoutProvider::GetDistanceMetric(int metric) const { ...@@ -160,6 +161,8 @@ int ChromeLayoutProvider::GetDistanceMetric(int metric) const {
return kHarmonyLayoutUnit; return kHarmonyLayoutUnit;
case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE: case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE:
return kHarmonyLayoutUnit; return kHarmonyLayoutUnit;
case DISTANCE_BUBBLE_TABSTRIP_PREFERRED_WIDTH:
return kExtraSmallBubbleSize;
case DISTANCE_BUBBLE_PREFERRED_WIDTH: case DISTANCE_BUBBLE_PREFERRED_WIDTH:
return kSmallSnapPoint; return kSmallSnapPoint;
case DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH: case DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH:
......
...@@ -69,6 +69,8 @@ enum ChromeDistanceMetric { ...@@ -69,6 +69,8 @@ enum ChromeDistanceMetric {
DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH, DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH,
// Width of larger modal dialogs that require extra width. // Width of larger modal dialogs that require extra width.
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH, DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH,
// Width of a bubble attached to the tabstrip.
DISTANCE_BUBBLE_TABSTRIP_PREFERRED_WIDTH,
// Width of a bubble unless the content is too wide to make that // Width of a bubble unless the content is too wide to make that
// feasible. // feasible.
DISTANCE_BUBBLE_PREFERRED_WIDTH, DISTANCE_BUBBLE_PREFERRED_WIDTH,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/favicon_size.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/highlight_path_generator.h"
...@@ -108,7 +109,7 @@ class ColorPickerElementView : public views::Button, ...@@ -108,7 +109,7 @@ class ColorPickerElementView : public views::Button,
gfx::Size CalculatePreferredSize() const override { gfx::Size CalculatePreferredSize() const override {
const gfx::Insets insets = GetInsets(); const gfx::Insets insets = GetInsets();
gfx::Size size(24, 24); gfx::Size size(gfx::kFaviconSize, gfx::kFaviconSize);
size.Enlarge(insets.width(), insets.height()); size.Enlarge(insets.width(), insets.height());
return size; return size;
} }
......
...@@ -70,16 +70,10 @@ views::Widget* TabGroupEditorBubbleView::Show(TabGroupHeader* anchor_view, ...@@ -70,16 +70,10 @@ views::Widget* TabGroupEditorBubbleView::Show(TabGroupHeader* anchor_view,
gfx::Size TabGroupEditorBubbleView::CalculatePreferredSize() const { gfx::Size TabGroupEditorBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric( const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_BUBBLE_PREFERRED_WIDTH) - DISTANCE_BUBBLE_TABSTRIP_PREFERRED_WIDTH);
margins().width();
return gfx::Size(width, GetHeightForWidth(width)); return gfx::Size(width, GetHeightForWidth(width));
} }
base::string16 TabGroupEditorBubbleView::GetWindowTitle() const {
// TODO(crbug.com/989174): remove this and other hardcoded ASCII strings.
return base::ASCIIToUTF16("Customize tab group visuals");
}
ui::ModalType TabGroupEditorBubbleView::GetModalType() const { ui::ModalType TabGroupEditorBubbleView::GetModalType() const {
return ui::MODAL_TYPE_NONE; return ui::MODAL_TYPE_NONE;
} }
...@@ -97,50 +91,33 @@ TabGroupEditorBubbleView::TabGroupEditorBubbleView( ...@@ -97,50 +91,33 @@ TabGroupEditorBubbleView::TabGroupEditorBubbleView(
title_field_controller_(this), title_field_controller_(this),
menu_button_listener_(tab_controller, anchor_view, group) { menu_button_listener_(tab_controller, anchor_view, group) {
SetAnchorView(anchor_view); SetAnchorView(anchor_view);
// Title insets assume there is content (and thus have no bottom padding). Use
// dialog insets to get the bottom margin back.
set_title_margins(
ChromeLayoutProvider::Get()->GetInsetsMetric(views::INSETS_DIALOG));
set_margins(gfx::Insets()); set_margins(gfx::Insets());
const auto* layout_provider = ChromeLayoutProvider::Get(); const auto* layout_provider = ChromeLayoutProvider::Get();
const TabGroupVisualData* current_data = const TabGroupVisualData* current_data =
tab_controller_->GetVisualDataForGroup(group_); tab_controller_->GetVisualDataForGroup(group_);
const int horizontal_spacing = layout_provider->GetDistanceMetric(
// Layout vertically with margin collapsing. This allows us to use spacer views::DISTANCE_RELATED_CONTROL_HORIZONTAL);
// views with |DISTANCE_UNRELATED_CONTROL_VERTICAL| margins without worrying const int vertical_spacing = layout_provider->GetDistanceMetric(
// about the default |DISTANCE_RELATED_CONTROL_VERTICAL| spacing. views::DISTANCE_RELATED_CONTROL_VERTICAL);
auto container_layout = std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(),
layout_provider->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_VERTICAL),
true /* collapse_margins_spacing */);
container_layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kStretch);
views::View* group_modifier_container = views::View* group_modifier_container =
AddChildView(std::make_unique<views::View>()); AddChildView(std::make_unique<views::View>());
group_modifier_container->SetBorder( group_modifier_container->SetBorder(
views::CreateEmptyBorder(gfx::Insets(layout_provider->GetDistanceMetric( views::CreateEmptyBorder(gfx::Insets(horizontal_spacing)));
views::DISTANCE_RELATED_CONTROL_VERTICAL)))); views::FlexLayout* container_layout =
group_modifier_container->SetLayoutManager(std::move(container_layout)); group_modifier_container->SetLayoutManager(
std::make_unique<views::FlexLayout>());
container_layout->SetOrientation(views::LayoutOrientation::kVertical)
.SetIgnoreDefaultMainAxisMargins(true);
// Add the text field for editing the title. // Add the text field for editing the title.
title_field_ = group_modifier_container->AddChildView( title_field_ = group_modifier_container->AddChildView(
std::make_unique<views::Textfield>()); std::make_unique<views::Textfield>());
title_field_->SetDefaultWidthInChars(15);
title_field_->SetText(current_data->title()); title_field_->SetText(current_data->title());
title_field_->SetAccessibleName(base::ASCIIToUTF16("Group title")); title_field_->SetAccessibleName(base::ASCIIToUTF16("Group title"));
title_field_->set_controller(&title_field_controller_); title_field_->set_controller(&title_field_controller_);
title_field_->SetProperty(
views::kMarginsKey,
gfx::Insets(0, 0,
layout_provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL),
0));
color_selector_ = color_selector_ =
group_modifier_container->AddChildView(std::make_unique<ColorPickerView>( group_modifier_container->AddChildView(std::make_unique<ColorPickerView>(
GetColorPickerList(), GetColorPickerList(),
...@@ -149,28 +126,44 @@ TabGroupEditorBubbleView::TabGroupEditorBubbleView( ...@@ -149,28 +126,44 @@ TabGroupEditorBubbleView::TabGroupEditorBubbleView(
AddChildView(std::make_unique<views::Separator>()); AddChildView(std::make_unique<views::Separator>());
views::View* menu_items_container =
AddChildView(std::make_unique<views::View>());
menu_items_container->SetBorder(
views::CreateEmptyBorder(gfx::Insets(vertical_spacing, 0)));
views::FlexLayout* layout_manager_ = menu_items_container->SetLayoutManager(
std::make_unique<views::FlexLayout>());
layout_manager_->SetOrientation(views::LayoutOrientation::kVertical)
.SetIgnoreDefaultMainAxisMargins(true);
gfx::Insets menu_item_border_inset =
gfx::Insets(vertical_spacing, horizontal_spacing);
std::unique_ptr<views::LabelButton> new_tab_menu_item = CreateBubbleMenuItem( std::unique_ptr<views::LabelButton> new_tab_menu_item = CreateBubbleMenuItem(
TAB_GROUP_HEADER_CXMENU_NEW_TAB_IN_GROUP, TAB_GROUP_HEADER_CXMENU_NEW_TAB_IN_GROUP,
l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_NEW_TAB_IN_GROUP), l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_NEW_TAB_IN_GROUP),
&menu_button_listener_); &menu_button_listener_);
AddChildView(std::move(new_tab_menu_item)); new_tab_menu_item->SetBorder(
views::CreateEmptyBorder(menu_item_border_inset));
menu_items_container->AddChildView(std::move(new_tab_menu_item));
std::unique_ptr<views::LabelButton> ungroup_menu_item = CreateBubbleMenuItem( std::unique_ptr<views::LabelButton> ungroup_menu_item = CreateBubbleMenuItem(
TAB_GROUP_HEADER_CXMENU_UNGROUP, TAB_GROUP_HEADER_CXMENU_UNGROUP,
l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_UNGROUP), l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_UNGROUP),
&menu_button_listener_); &menu_button_listener_);
AddChildView(std::move(ungroup_menu_item)); ungroup_menu_item->SetBorder(
views::CreateEmptyBorder(menu_item_border_inset));
menu_items_container->AddChildView(std::move(ungroup_menu_item));
std::unique_ptr<views::LabelButton> close_menu_item = CreateBubbleMenuItem( std::unique_ptr<views::LabelButton> close_menu_item = CreateBubbleMenuItem(
TAB_GROUP_HEADER_CXMENU_CLOSE_GROUP, TAB_GROUP_HEADER_CXMENU_CLOSE_GROUP,
l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_CLOSE_GROUP), l10n_util::GetStringUTF16(IDS_TAB_GROUP_HEADER_CXMENU_CLOSE_GROUP),
&menu_button_listener_); &menu_button_listener_);
AddChildView(std::move(close_menu_item)); close_menu_item->SetBorder(views::CreateEmptyBorder(menu_item_border_inset));
menu_items_container->AddChildView(std::move(close_menu_item));
views::FlexLayout* layout_manager_ = views::FlexLayout* menu_layout_manager_ =
SetLayoutManager(std::make_unique<views::FlexLayout>()); SetLayoutManager(std::make_unique<views::FlexLayout>());
layout_manager_->SetOrientation(views::LayoutOrientation::kVertical) menu_layout_manager_->SetOrientation(views::LayoutOrientation::kVertical);
.SetIgnoreDefaultMainAxisMargins(true);
} }
TabGroupEditorBubbleView::~TabGroupEditorBubbleView() = default; TabGroupEditorBubbleView::~TabGroupEditorBubbleView() = default;
......
...@@ -22,9 +22,6 @@ class Size; ...@@ -22,9 +22,6 @@ class Size;
class ColorPickerView; class ColorPickerView;
// A dialog for changing a tab group's visual parameters. // A dialog for changing a tab group's visual parameters.
//
// TODO(crbug.com/989174): polish this UI. It is currently sufficient for
// testing, but it is not ready to be launched.
class TabGroupEditorBubbleView : public views::BubbleDialogDelegateView { class TabGroupEditorBubbleView : public views::BubbleDialogDelegateView {
public: public:
// Shows the editor for |group|. Returns an *unowned* pointer to the // Shows the editor for |group|. Returns an *unowned* pointer to the
...@@ -35,7 +32,6 @@ class TabGroupEditorBubbleView : public views::BubbleDialogDelegateView { ...@@ -35,7 +32,6 @@ class TabGroupEditorBubbleView : public views::BubbleDialogDelegateView {
// views::BubbleDialogDelegateView: // views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
base::string16 GetWindowTitle() const override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
......
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