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() { ...@@ -100,7 +100,7 @@ void IncognitoWindowTracker::ShowPromo() {
FeaturePromoBubbleView::ActivationAction::ACTIVATE); FeaturePromoBubbleView::ActivationAction::ACTIVATE);
views::Widget* widget = incognito_promo_->GetWidget(); views::Widget* widget = incognito_promo_->GetWidget();
incognito_promo_observer_.Add(widget); incognito_promo_observer_.Add(widget);
app_menu_button->SetIsProminent(true); app_menu_button->SetPromoIsShowing(true);
} }
void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) { void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) {
...@@ -110,7 +110,7 @@ void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) { ...@@ -110,7 +110,7 @@ void IncognitoWindowTracker::OnWidgetDestroying(views::Widget* widget) {
incognito_promo_observer_.Remove(widget); incognito_promo_observer_.Remove(widget);
BrowserAppMenuButton* app_menu_button = GetAppMenuButton(); BrowserAppMenuButton* app_menu_button = GetAppMenuButton();
if (app_menu_button) if (app_menu_button)
app_menu_button->SetIsProminent(false); app_menu_button->SetPromoIsShowing(false);
} }
} }
......
...@@ -33,7 +33,7 @@ void ReopenTabPromoController::ShowPromo() { ...@@ -33,7 +33,7 @@ void ReopenTabPromoController::ShowPromo() {
BrowserAppMenuButton* app_menu_button = BrowserAppMenuButton* app_menu_button =
browser_view_->toolbar()->app_menu_button(); browser_view_->toolbar()->app_menu_button();
app_menu_button->AddMenuListener(this); app_menu_button->AddMenuListener(this);
app_menu_button->SetHighlighted(true); app_menu_button->SetPromoIsShowing(true);
promo_bubble_ = FeaturePromoBubbleView::CreateOwned( promo_bubble_ = FeaturePromoBubbleView::CreateOwned(
app_menu_button, views::BubbleBorder::Arrow::TOP_RIGHT, app_menu_button, views::BubbleBorder::Arrow::TOP_RIGHT,
...@@ -66,8 +66,7 @@ void ReopenTabPromoController::OnWidgetDestroying(views::Widget* widget) { ...@@ -66,8 +66,7 @@ void ReopenTabPromoController::OnWidgetDestroying(views::Widget* widget) {
BrowserAppMenuButton* app_menu_button = BrowserAppMenuButton* app_menu_button =
browser_view_->toolbar()->app_menu_button(); browser_view_->toolbar()->app_menu_button();
app_menu_button->RemoveMenuListener(this); app_menu_button->RemoveMenuListener(this);
app_menu_button->SetHighlighted(false); app_menu_button->SetPromoIsShowing(false);
iph_service_->HelpDismissed(); iph_service_->HelpDismissed();
} }
} }
...@@ -78,6 +77,8 @@ void ReopenTabPromoController::AppMenuClosed() { ...@@ -78,6 +77,8 @@ void ReopenTabPromoController::AppMenuClosed() {
// Success is determined by whether the reopen tab event was sent. // Success is determined by whether the reopen tab event was sent.
iph_service_->HelpDismissed(); iph_service_->HelpDismissed();
browser_view_->toolbar()->app_menu_button()->SetPromoIsShowing(false);
AppMenu* app_menu = browser_view_->toolbar()->app_menu_button()->app_menu(); AppMenu* app_menu = browser_view_->toolbar()->app_menu_button()->app_menu();
app_menu->RemoveObserver(this); app_menu->RemoveObserver(this);
} }
......
...@@ -34,13 +34,25 @@ ...@@ -34,13 +34,25 @@
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/ink_drop.h" #include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.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/controls/button/label_button_border.h"
#include "ui/views/metrics.h" #include "ui/views/metrics.h"
#include "ui/views/view.h"
#include "ui/views/view_properties.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#endif // defined(OS_CHROMEOS) #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 // static
bool BrowserAppMenuButton::g_open_app_immediately_for_testing = false; bool BrowserAppMenuButton::g_open_app_immediately_for_testing = false;
...@@ -69,13 +81,19 @@ void BrowserAppMenuButton::SetTypeAndSeverity( ...@@ -69,13 +81,19 @@ void BrowserAppMenuButton::SetTypeAndSeverity(
UpdateIcon(); UpdateIcon();
} }
void BrowserAppMenuButton::SetIsProminent(bool is_prominent) { void BrowserAppMenuButton::SetPromoIsShowing(bool promo_is_showing) {
if (is_prominent) { if (promo_is_showing_ == promo_is_showing)
SetBackground(views::CreateSolidBackground(GetNativeTheme()->GetSystemColor( return;
ui::NativeTheme::kColorId_ProminentButtonColor)));
} else { promo_is_showing_ = promo_is_showing;
SetBackground(nullptr); // 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(); SchedulePaint();
} }
...@@ -118,8 +136,10 @@ void BrowserAppMenuButton::UpdateIcon() { ...@@ -118,8 +136,10 @@ void BrowserAppMenuButton::UpdateIcon() {
const ui::NativeTheme* native_theme = GetNativeTheme(); const ui::NativeTheme* native_theme = GetNativeTheme();
switch (type_and_severity_.severity) { switch (type_and_severity_.severity) {
case AppMenuIconController::Severity::NONE: case AppMenuIconController::Severity::NONE:
severity_color = GetThemeProvider()->GetColor( severity_color = promo_is_showing_
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); ? kFeaturePromoHighlightColor
: GetThemeProvider()->GetColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
break; break;
case AppMenuIconController::Severity::LOW: case AppMenuIconController::Severity::LOW:
severity_color = native_theme->GetSystemColor( severity_color = native_theme->GetSystemColor(
...@@ -251,3 +271,8 @@ std::unique_ptr<views::InkDropHighlight> ...@@ -251,3 +271,8 @@ std::unique_ptr<views::InkDropHighlight>
BrowserAppMenuButton::CreateInkDropHighlight() const { BrowserAppMenuButton::CreateInkDropHighlight() const {
return CreateToolbarInkDropHighlight(this); return CreateToolbarInkDropHighlight(this);
} }
SkColor BrowserAppMenuButton::GetInkDropBaseColor() const {
return promo_is_showing_ ? kFeaturePromoHighlightColor
: AppMenuButton::GetInkDropBaseColor();
}
...@@ -36,9 +36,9 @@ class BrowserAppMenuButton : public AppMenuButton, ...@@ -36,9 +36,9 @@ class BrowserAppMenuButton : public AppMenuButton,
// drag-and-drop operation. // drag-and-drop operation.
void ShowMenu(bool for_drop); void ShowMenu(bool for_drop);
// Sets the background to a prominent color if |is_prominent| is true. This is // Sets whether an in-product help feature promo is showing for the app menu.
// used for an experimental UI for In-Product Help. // When true, the button is highlighted in a noticeable color.
void SetIsProminent(bool is_prominent); void SetPromoIsShowing(bool promo_is_showing);
// views::MenuButton: // views::MenuButton:
void OnBoundsChanged(const gfx::Rect& previous_bounds) override; void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
...@@ -63,7 +63,7 @@ class BrowserAppMenuButton : public AppMenuButton, ...@@ -63,7 +63,7 @@ class BrowserAppMenuButton : public AppMenuButton,
private: private:
void UpdateBorder(); void UpdateBorder();
// views::MenuButton: // AppMenuButton:
const char* GetClassName() const override; const char* GetClassName() const override;
bool GetDropFormats( bool GetDropFormats(
int* formats, int* formats,
...@@ -77,6 +77,7 @@ class BrowserAppMenuButton : public AppMenuButton, ...@@ -77,6 +77,7 @@ class BrowserAppMenuButton : public AppMenuButton,
std::unique_ptr<views::InkDrop> CreateInkDrop() override; std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override; const override;
SkColor GetInkDropBaseColor() const override;
AppMenuIconController::TypeAndSeverity type_and_severity_{ AppMenuIconController::TypeAndSeverity type_and_severity_{
AppMenuIconController::IconType::NONE, AppMenuIconController::IconType::NONE,
...@@ -89,6 +90,9 @@ class BrowserAppMenuButton : public AppMenuButton, ...@@ -89,6 +90,9 @@ class BrowserAppMenuButton : public AppMenuButton,
// a maximized state to extend to the full window width. // a maximized state to extend to the full window width.
int margin_trailing_ = 0; 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, ScopedObserver<ui::MaterialDesignController,
ui::MaterialDesignControllerObserver> ui::MaterialDesignControllerObserver>
md_observer_{this}; 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