Commit 982e81b1 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Implement blue app menu button highlight for in-product help

Bug: 909747
Change-Id: I4f7f9d6a34242d7dec8b343ff38aaa2b05019cec
Reviewed-on: https://chromium-review.googlesource.com/c/1362190Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615731}
parent ca7f9b77
......@@ -100,7 +100,7 @@ void IncognitoWindowTracker::ShowPromo() {
FeaturePromoBubbleView::ActivationAction::ACTIVATE);
views::Widget* widget = incognito_promo_->GetWidget();
incognito_promo_observer_.Add(widget);
app_menu_button->SetIsProminent(true);
app_menu_button->SetPromoIsShowing(true);
}
void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) {
......@@ -110,7 +110,7 @@ void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) {
incognito_promo_observer_.Remove(widget);
BrowserAppMenuButton* app_menu_button = GetAppMenuButton();
if (app_menu_button)
app_menu_button->SetIsProminent(false);
app_menu_button->SetPromoIsShowing(false);
}
}
......
......@@ -33,7 +33,7 @@ void ReopenTabPromoController::ShowPromo() {
BrowserAppMenuButton* app_menu_button =
browser_view_->toolbar()->app_menu_button();
app_menu_button->AddMenuListener(this);
app_menu_button->SetHighlighted(true);
app_menu_button->SetPromoIsShowing(true);
promo_bubble_ = FeaturePromoBubbleView::CreateOwned(
app_menu_button, views::BubbleBorder::Arrow::TOP_RIGHT,
......@@ -66,8 +66,7 @@ void ReopenTabPromoController::OnWidgetDestroying(views::Widget* widget) {
BrowserAppMenuButton* app_menu_button =
browser_view_->toolbar()->app_menu_button();
app_menu_button->RemoveMenuListener(this);
app_menu_button->SetHighlighted(false);
app_menu_button->SetPromoIsShowing(false);
iph_service_->HelpDismissed();
}
}
......@@ -78,6 +77,8 @@ void ReopenTabPromoController::AppMenuClosed() {
// Success is determined by whether the reopen tab event was sent.
iph_service_->HelpDismissed();
browser_view_->toolbar()->app_menu_button()->SetPromoIsShowing(false);
AppMenu* app_menu = browser_view_->toolbar()->app_menu_button()->app_menu();
app_menu->RemoveObserver(this);
}
......
......@@ -34,13 +34,25 @@
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_state.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/metrics.h"
#include "ui/views/view.h"
#include "ui/views/view_properties.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#endif // defined(OS_CHROMEOS)
namespace {
// Button background and icon color for in-product help promos.
// TODO(collinbaker): https://crbug.com/909747 handle themed toolbar colors, and
// maybe move this into theme system.
constexpr SkColor kFeaturePromoHighlightColor = gfx::kGoogleBlue600;
} // namespace
// static
bool BrowserAppMenuButton::g_open_app_immediately_for_testing = false;
......@@ -69,13 +81,19 @@ void BrowserAppMenuButton::SetTypeAndSeverity(
UpdateIcon();
}
void BrowserAppMenuButton::SetIsProminent(bool is_prominent) {
if (is_prominent) {
SetBackground(views::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ProminentButtonColor)));
} else {
SetBackground(nullptr);
}
void BrowserAppMenuButton::SetPromoIsShowing(bool promo_is_showing) {
if (promo_is_showing_ == promo_is_showing)
return;
promo_is_showing_ = promo_is_showing;
// We override GetInkDropBaseColor below in the |promo_is_showing_| case. This
// sets the ink drop into the activated state, which will highlight it in the
// desired color.
GetInkDrop()->AnimateToState(promo_is_showing_
? views::InkDropState::ACTIVATED
: views::InkDropState::HIDDEN);
UpdateIcon();
SchedulePaint();
}
......@@ -118,7 +136,9 @@ void BrowserAppMenuButton::UpdateIcon() {
const ui::NativeTheme* native_theme = GetNativeTheme();
switch (type_and_severity_.severity) {
case AppMenuIconController::Severity::NONE:
severity_color = GetThemeProvider()->GetColor(
severity_color = promo_is_showing_
? kFeaturePromoHighlightColor
: GetThemeProvider()->GetColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
break;
case AppMenuIconController::Severity::LOW:
......@@ -251,3 +271,8 @@ std::unique_ptr<views::InkDropHighlight>
BrowserAppMenuButton::CreateInkDropHighlight() const {
return CreateToolbarInkDropHighlight(this);
}
SkColor BrowserAppMenuButton::GetInkDropBaseColor() const {
return promo_is_showing_ ? kFeaturePromoHighlightColor
: AppMenuButton::GetInkDropBaseColor();
}
......@@ -36,9 +36,9 @@ class BrowserAppMenuButton : public AppMenuButton,
// drag-and-drop operation.
void ShowMenu(bool for_drop);
// Sets the background to a prominent color if |is_prominent| is true. This is
// used for an experimental UI for In-Product Help.
void SetIsProminent(bool is_prominent);
// Sets whether an in-product help feature promo is showing for the app menu.
// When true, the button is highlighted in a noticeable color.
void SetPromoIsShowing(bool promo_is_showing);
// views::MenuButton:
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
......@@ -63,7 +63,7 @@ class BrowserAppMenuButton : public AppMenuButton,
private:
void UpdateBorder();
// views::MenuButton:
// AppMenuButton:
const char* GetClassName() const override;
bool GetDropFormats(
int* formats,
......@@ -77,6 +77,7 @@ class BrowserAppMenuButton : public AppMenuButton,
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
SkColor GetInkDropBaseColor() const override;
AppMenuIconController::TypeAndSeverity type_and_severity_{
AppMenuIconController::IconType::NONE,
......@@ -89,6 +90,9 @@ class BrowserAppMenuButton : public AppMenuButton,
// a maximized state to extend to the full window width.
int margin_trailing_ = 0;
// Whether an in-product help promo is currently showing for the app menu.
bool promo_is_showing_ = false;
ScopedObserver<ui::MaterialDesignController,
ui::MaterialDesignControllerObserver>
md_observer_{this};
......
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