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

Side by Side Diff: chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h

Issue 2859903003: [Mac] App Menu Animated Icon (Closed)
Patch Set: Clean up 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
6 #define CHROME_BROWSER_UI_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #include <memory>
11
12 #include "base/mac/scoped_nsobject.h"
13 #include "base/time/time.h"
14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/animation/animation_delegate.h"
16
17 namespace gfx {
18 class SlideAnimation;
19 } // namespace gfx
20
21 @class AppToolbarButton;
22
23 // This class is used to represent and paint a dot on the app menu.
24 class AppMenuDot {
25 public:
26 AppMenuDot(base::TimeDelta delay,
27 float width_open_interval,
28 float stroke_open_interval);
29
30 void DrawDot(NSPoint center_pt,
31 NSSize imageSize,
32 SkColor startColor,
33 SkColor targetColor,
34 const gfx::SlideAnimation* animation);
35
36 private:
37 // The delay before the dot starts animating in ms.
38 const base::TimeDelta delay_;
39
40 // The percentage of the overall animation duration it takes to animate the
41 // width and stroke to their open state.
42 const float width_open_interval_;
43 const float stroke_open_interval_;
44
45 DISALLOW_COPY_AND_ASSIGN(AppMenuDot);
46 };
47
48 // This class is used for animating and drawing the app menu icon.
49 class AppToolbarButtonIcon : public gfx::AnimationDelegate {
50 public:
51 AppToolbarButtonIcon(AppToolbarButton* owner, SkColor start_color);
52
53 ~AppToolbarButtonIcon() override;
54
55 // Draws the App Menu Icon according to the given |frame|.
56 void DrawIcon(NSRect frame);
57
58 // Starts the animation if it's not already running.
59 void StartAnimation();
60
61 // gfx::AnimationDelegate:
62 void AnimationEnded(const gfx::Animation* animation) override;
63 void AnimationProgressed(const gfx::Animation* animation) override;
64
65 void set_target_color(SkColor target_color) { target_color_ = target_color; }
66
67 private:
68 std::unique_ptr<gfx::SlideAnimation> animation_;
69
70 AppMenuDot bottom_dot_;
71 AppMenuDot center_dot_;
72 AppMenuDot top_dot_;
73
74 // The color the icon is animating from/to.
75 SkColor start_color_;
76 SkColor target_color_;
77
78 AppToolbarButton* owner_; // weak.
79 };
80
81 #endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698