Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3050)

Unified Diff: chrome/browser/ui/toolbar/app_menu_animation.cc

Issue 2858313002: Refactored AppMenuAnimation (Closed)
Patch Set: Add comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d30232668db1d74222e4d5d669accf8ec22f03c7 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"
@@ -63,7 +62,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 =
@@ -113,19 +113,12 @@ void AppMenuAnimation::AppMenuDot::Paint(const gfx::PointF& center_point,
color_progress, start_color, target_color)
: target_color;
- cc::PaintFlags flags;
- flags.setColor(color);
- flags.setStrokeWidth(bounds.height() * kCloseStroke);
- 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);
+ delegate->PaintDot(point, color, gfx::SizeF(dot_width, dot_height), canvas);
msw 2017/05/05 18:47:38 Would #if defined(OS_MACOSX) && !BUILDFLAG(MAC_VIE
spqchan 2017/05/05 21:20:53 Removed the delegate method
}
-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 +148,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 +171,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();
}

Powered by Google App Engine
This is Rietveld 408576698