Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/app_menu_button.cc |
| diff --git a/chrome/browser/ui/views/toolbar/app_menu_button.cc b/chrome/browser/ui/views/toolbar/app_menu_button.cc |
| index 3f94b5292384e231c915c069a902ce5edcd2e873..2b74557ce345f1fb32891ffcb51e4926e2c357dd 100644 |
| --- a/chrome/browser/ui/views/toolbar/app_menu_button.cc |
| +++ b/chrome/browser/ui/views/toolbar/app_menu_button.cc |
| @@ -14,11 +14,12 @@ |
| #include "cc/paint/paint_flags.h" |
| #include "chrome/app/vector_icons/vector_icons.h" |
| #include "chrome/browser/themes/theme_properties.h" |
| +#include "chrome/browser/themes/theme_service.h" |
| +#include "chrome/browser/themes/theme_service_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_otr_state.h" |
| #include "chrome/browser/ui/layout_constants.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| -#include "chrome/browser/ui/toolbar/app_menu_animation.h" |
| #include "chrome/browser/ui/toolbar/app_menu_model.h" |
| #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
| #include "chrome/browser/ui/views/toolbar/app_menu.h" |
| @@ -134,7 +135,8 @@ gfx::Size AppMenuButton::GetPreferredSize() const { |
| } |
| void AppMenuButton::Layout() { |
| - if (animation_) { |
| + if (new_icon_) { |
| + new_icon_->SetBoundsRect(GetContentsBounds()); |
| ink_drop_container()->SetBoundsRect(GetLocalBounds()); |
| image()->SetBoundsRect(GetLocalBounds()); |
| return; |
| @@ -143,15 +145,8 @@ void AppMenuButton::Layout() { |
| views::MenuButton::Layout(); |
| } |
| -void AppMenuButton::OnPaint(gfx::Canvas* canvas) { |
| - if (!animation_) { |
| - views::MenuButton::OnPaint(canvas); |
| - return; |
| - } |
| - |
| - gfx::Rect bounds = GetLocalBounds(); |
| - bounds.Inset(gfx::Insets(ToolbarButton::kInteriorPadding)); |
| - animation_->PaintAppMenu(canvas, bounds); |
| +void AppMenuButton::OnThemeChanged() { |
| + UpdateIcon(false); |
| } |
| void AppMenuButton::TabInsertedAt(TabStripModel* tab_strip_model, |
| @@ -161,19 +156,6 @@ void AppMenuButton::TabInsertedAt(TabStripModel* tab_strip_model, |
| AnimateIconIfPossible(); |
| } |
| -void AppMenuButton::AppMenuAnimationStarted() { |
| - SetPaintToLayer(); |
| - layer()->SetFillsBoundsOpaquely(false); |
| -} |
| - |
| -void AppMenuButton::AppMenuAnimationEnded() { |
| - DestroyLayer(); |
| -} |
| - |
| -void AppMenuButton::InvalidateIcon() { |
| - SchedulePaint(); |
| -} |
| - |
| void AppMenuButton::UpdateIcon(bool should_animate) { |
| SkColor severity_color = gfx::kPlaceholderColor; |
| SkColor toolbar_icon_color = |
| @@ -198,10 +180,21 @@ void AppMenuButton::UpdateIcon(bool should_animate) { |
| } |
| if (should_use_new_icon_) { |
| - if (!animation_) |
| - animation_ = base::MakeUnique<AppMenuAnimation>(this, toolbar_icon_color); |
| + if (!new_icon_) { |
| + new_icon_ = new views::AnimatedIconView(kBrowserToolsAnimatedIcon); |
| + new_icon_->set_can_process_events_within_subtree(false); |
| + AddChildView(new_icon_); |
| + } |
| + |
| + // Only show a special color for severity when using the classic Chrome |
| + // theme. Otherwise, we can't be sure that it contrasts with the toolbar |
| + // background. |
|
Peter Kasting
2017/05/31 02:08:28
What about just always running the severity_color
Evan Stade
2017/05/31 17:08:16
I can experiment with that as a follow up, but eve
Peter Kasting
2017/05/31 17:24:31
If you put in red, you always get red out. That's
|
| + new_icon_->set_color( |
| + ThemeServiceFactory::GetForProfile(toolbar_view_->browser()->profile()) |
| + ->UsingDefaultTheme() |
| + ? severity_color |
| + : toolbar_icon_color); |
| - animation_->set_target_color(severity_color); |
| if (should_animate) |
| AnimateIconIfPossible(); |
| @@ -234,12 +227,12 @@ void AppMenuButton::SetTrailingMargin(int margin) { |
| } |
| void AppMenuButton::AnimateIconIfPossible() { |
| - if (!animation_ || !should_use_new_icon_ || |
| + if (!new_icon_ || !should_use_new_icon_ || |
| severity_ == AppMenuIconController::Severity::NONE) { |
| return; |
| } |
| - animation_->StartAnimation(); |
| + new_icon_->Animate(views::AnimatedIconView::END); |
|
sadrul
2017/05/30 17:06:51
Who calls Animate(START)?
Peter Kasting
2017/05/31 02:08:28
I assume no one, since this means "animate to the
|
| } |
| const char* AppMenuButton::GetClassName() const { |