Commit 57ec7ab6 authored by Wei Li's avatar Wei Li Committed by Commit Bot

[HaTS] Fine tune bubble banner UI

Add back the product icon as the bubble title icon. Also align the
bubble's content area to the beginning of the title text instead
of the the title area.

BUG=979530

Change-Id: Iea4132d713dc43a13f4871ed85ae5ee09c66ecb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1723303Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682359}
parent fc28da5f
......@@ -8,6 +8,7 @@
#include "base/task/post_task.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/hats/hats_web_dialog.h"
#include "chrome/grit/chromium_strings.h"
......@@ -19,8 +20,10 @@
#include "content/public/browser/web_contents.h"
#include "ui/base/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
......@@ -54,19 +57,15 @@ HatsBubbleView::HatsBubbleView(AppMenuButton* anchor_button,
set_close_on_deactivate(false);
set_parent_window(parent_view);
set_margins(gfx::Insets());
auto* layout_manager = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(10, 20, 10, 0),
10));
layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
layout_manager->set_main_axis_alignment(
views::BoxLayout::MainAxisAlignment::kStart);
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
set_margins(
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT));
SetLayoutManager(std::make_unique<views::FillLayout>());
auto message = std::make_unique<views::Label>(
l10n_util::GetStringUTF16(IDS_HATS_BUBBLE_TEXT));
message->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(std::move(message));
views::BubbleDialogDelegateView::CreateBubble(this);
......@@ -80,6 +79,15 @@ base::string16 HatsBubbleView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_HATS_BUBBLE_TITLE);
}
gfx::ImageSkia HatsBubbleView::GetWindowIcon() {
return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_PRODUCT_LOGO_32);
}
bool HatsBubbleView::ShouldShowWindowIcon() const {
return true;
}
base::string16 HatsBubbleView::GetDialogButtonLabel(
ui::DialogButton button) const {
return button == ui::DIALOG_BUTTON_OK
......@@ -100,3 +108,16 @@ void HatsBubbleView::OnWidgetDestroying(views::Widget* widget) {
BubbleDialogDelegateView::OnWidgetDestroying(widget);
instance_ = nullptr;
}
void HatsBubbleView::Layout() {
auto* frame_view = GetBubbleFrameView();
if (frame_view && frame_view->title()) {
// Align bubble content to the beginning of the title text.
gfx::Point point(frame_view->title()->x(), 0);
views::View::ConvertPointToTarget(frame_view, GetWidget()->client_view(),
&point);
SetX(point.x());
}
views::BubbleDialogDelegateView::Layout();
}
......@@ -24,13 +24,22 @@ class HatsBubbleView : public views::BubbleDialogDelegateView {
static void Show(AppMenuButton* anchor_button, Browser* browser);
protected:
// views::BubbleDialogDelegateView:
// views::WidgetDelegate:
base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override;
// views::DialogDelegate:
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool Accept() override;
bool ShouldShowCloseButton() const override;
// views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override;
// views::View:
void Layout() override;
private:
HatsBubbleView(AppMenuButton* anchor_button,
Browser* browser,
......
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