Chromium Code Reviews| Index: chrome/browser/ui/toolbar/app_menu_animation.cc |
| diff --git a/chrome/browser/ui/views/toolbar/app_menu_animation.cc b/chrome/browser/ui/toolbar/app_menu_animation.cc |
| similarity index 88% |
| rename from chrome/browser/ui/views/toolbar/app_menu_animation.cc |
| rename to chrome/browser/ui/toolbar/app_menu_animation.cc |
| index 01d0b5a07074a3ec2faae7516f823f07e24065f8..f8254b3a9ae4875353e3c2bddcc8cd9fd64e7735 100644 |
| --- a/chrome/browser/ui/views/toolbar/app_menu_animation.cc |
| +++ b/chrome/browser/ui/toolbar/app_menu_animation.cc |
| @@ -2,11 +2,10 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ui/views/toolbar/app_menu_animation.h" |
| +#include "chrome/browser/ui/toolbar/app_menu_animation.h" |
| #include "base/memory/ptr_util.h" |
| #include "cc/paint/paint_flags.h" |
| -#include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| #include "ui/gfx/animation/tween.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/color_palette.h" |
| @@ -49,6 +48,9 @@ constexpr float kBottomStrokeOpenInterval = 266.7f / kOpenDurationMs; |
| // The % of time it takes for each dot to animate its width and stroke. |
| constexpr float kWidthStrokeCloseInterval = 150.0f / kCloseDurationMs; |
| +// The radius of each dot in the icon. |
|
msw
2017/05/05 21:26:24
optional nit: reorder up, just above kDotYOffset o
spqchan
2017/05/05 21:37:34
Done.
|
| +constexpr float kDotRadius = 2.0f; |
| + |
| } // namespace |
| AppMenuAnimation::AppMenuDot::AppMenuDot(base::TimeDelta delay, |
| @@ -63,7 +65,8 @@ void AppMenuAnimation::AppMenuDot::Paint(const gfx::PointF& center_point, |
| SkColor target_color, |
| gfx::Canvas* canvas, |
| const gfx::Rect& bounds, |
| - const gfx::SlideAnimation* animation) { |
| + const gfx::SlideAnimation* animation, |
| + AppMenuAnimationDelegate* delegate) { |
| bool is_opening = animation->IsShowing(); |
| float total_duration = is_opening ? kOpenDurationMs : kCloseDurationMs; |
| float width_duration = |
| @@ -115,17 +118,17 @@ void AppMenuAnimation::AppMenuDot::Paint(const gfx::PointF& center_point, |
| cc::PaintFlags flags; |
| flags.setColor(color); |
| - flags.setStrokeWidth(bounds.height() * kCloseStroke); |
| + flags.setStrokeWidth(dot_height); |
| flags.setStrokeCap(cc::PaintFlags::kRound_Cap); |
| flags.setStyle(cc::PaintFlags::kFill_Style); |
| flags.setAntiAlias(true); |
| - |
| - gfx::SizeF dot_size = gfx::SizeF(dot_width, dot_height); |
| - canvas->DrawRoundRect(gfx::RectF(point, dot_size), 2.0, flags); |
| + canvas->DrawRoundRect(gfx::RectF(point, gfx::SizeF(dot_width, dot_height)), |
| + kDotRadius, flags); |
| } |
| -AppMenuAnimation::AppMenuAnimation(AppMenuButton* owner, SkColor initial_color) |
| - : owner_(owner), |
| +AppMenuAnimation::AppMenuAnimation(AppMenuAnimationDelegate* delegate, |
| + SkColor initial_color) |
| + : delegate_(delegate), |
| animation_(base::MakeUnique<gfx::SlideAnimation>(this)), |
| bottom_dot_(base::TimeDelta(), |
| kBottomWidthOpenInterval, |
| @@ -155,18 +158,18 @@ void AppMenuAnimation::PaintAppMenu(gfx::Canvas* canvas, |
| bottom_point.Offset(0, y_offset); |
| middle_dot_.Paint(middle_point, start_color_, target_color_, canvas, bounds, |
| - animation_.get()); |
| + animation_.get(), delegate_); |
| top_dot_.Paint(top_point, start_color_, target_color_, canvas, bounds, |
| - animation_.get()); |
| + animation_.get(), delegate_); |
| bottom_dot_.Paint(bottom_point, start_color_, target_color_, canvas, bounds, |
| - animation_.get()); |
| + animation_.get(), delegate_); |
| } |
| void AppMenuAnimation::StartAnimation() { |
| if (!animation_->is_animating()) { |
| animation_->SetSlideDuration(kOpenDurationMs); |
| animation_->Show(); |
| - owner_->AppMenuAnimationStarted(); |
| + delegate_->AppMenuAnimationStarted(); |
| } |
| } |
| @@ -178,9 +181,9 @@ void AppMenuAnimation::AnimationEnded(const gfx::Animation* animation) { |
| start_color_ = target_color_; |
| } |
| - owner_->AppMenuAnimationEnded(); |
| + delegate_->AppMenuAnimationEnded(); |
| } |
| void AppMenuAnimation::AnimationProgressed(const gfx::Animation* animation) { |
| - owner_->SchedulePaint(); |
| + delegate_->InvalidateIcon(); |
| } |