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

Side by Side Diff: ui/views/controls/glow_hover_controller.h

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/text_button.cc ('k') | ui/views/controls/glow_hover_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_ 5 #ifndef UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_
6 #define UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_ 6 #define UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_
7 7
8 #include "ui/base/animation/animation_delegate.h" 8 #include "ui/gfx/animation/animation_delegate.h"
9 #include "ui/base/animation/slide_animation.h" 9 #include "ui/gfx/animation/slide_animation.h"
10 #include "ui/views/views_export.h" 10 #include "ui/views/views_export.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 class Canvas; 13 class Canvas;
14 class ImageSkia; 14 class ImageSkia;
15 class Point; 15 class Point;
16 } 16 }
17 17
18 namespace views { 18 namespace views {
19 19
20 class View; 20 class View;
21 21
22 // GlowHoverController is responsible for drawing a hover effect as is used by 22 // GlowHoverController is responsible for drawing a hover effect as is used by
23 // the tabstrip. Typical usage: 23 // the tabstrip. Typical usage:
24 // OnMouseEntered() -> invoke Show(). 24 // OnMouseEntered() -> invoke Show().
25 // OnMouseMoved() -> invoke SetLocation(). 25 // OnMouseMoved() -> invoke SetLocation().
26 // OnMouseExited() -> invoke Hide(). 26 // OnMouseExited() -> invoke Hide().
27 // OnPaint() -> if ShouldDraw() returns true invoke Draw(). 27 // OnPaint() -> if ShouldDraw() returns true invoke Draw().
28 // Internally GlowHoverController uses an animation to animate the glow and 28 // Internally GlowHoverController uses an animation to animate the glow and
29 // invokes SchedulePaint() back on the View as necessary. 29 // invokes SchedulePaint() back on the View as necessary.
30 class VIEWS_EXPORT GlowHoverController : public ui::AnimationDelegate { 30 class VIEWS_EXPORT GlowHoverController : public gfx::AnimationDelegate {
31 public: 31 public:
32 enum Style { 32 enum Style {
33 SUBTLE, 33 SUBTLE,
34 PRONOUNCED 34 PRONOUNCED
35 }; 35 };
36 36
37 explicit GlowHoverController(views::View* view); 37 explicit GlowHoverController(views::View* view);
38 virtual ~GlowHoverController(); 38 virtual ~GlowHoverController();
39 39
40 // Sets the AnimationContainer used by the animation. 40 // Sets the AnimationContainer used by the animation.
41 void SetAnimationContainer(ui::AnimationContainer* container); 41 void SetAnimationContainer(gfx::AnimationContainer* container);
42 42
43 // Sets the location of the hover, relative to the View passed to the 43 // Sets the location of the hover, relative to the View passed to the
44 // constructor. 44 // constructor.
45 void SetLocation(const gfx::Point& location); 45 void SetLocation(const gfx::Point& location);
46 46
47 // Initiates showing the hover. 47 // Initiates showing the hover.
48 void Show(Style style); 48 void Show(Style style);
49 49
50 // Hides the hover. 50 // Hides the hover.
51 void Hide(); 51 void Hide();
52 52
53 // Hides the hover immediately. 53 // Hides the hover immediately.
54 void HideImmediately(); 54 void HideImmediately();
55 55
56 // Returns the value of the animation. 56 // Returns the value of the animation.
57 double GetAnimationValue() const; 57 double GetAnimationValue() const;
58 58
59 // Returns true if there is something to be drawn. Use this instead of 59 // Returns true if there is something to be drawn. Use this instead of
60 // invoking Draw() if creating |mask_image| is expensive. 60 // invoking Draw() if creating |mask_image| is expensive.
61 bool ShouldDraw() const; 61 bool ShouldDraw() const;
62 62
63 // If the hover is currently visible it is drawn to the supplied canvas. 63 // If the hover is currently visible it is drawn to the supplied canvas.
64 // |mask_image| is used to determine what parts of the canvas to draw on. 64 // |mask_image| is used to determine what parts of the canvas to draw on.
65 void Draw(gfx::Canvas* canvas, const gfx::ImageSkia& mask_image) const; 65 void Draw(gfx::Canvas* canvas, const gfx::ImageSkia& mask_image) const;
66 66
67 // ui::AnimationDelegate overrides: 67 // gfx::AnimationDelegate overrides:
68 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 68 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
69 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 69 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
70 70
71 private: 71 private:
72 // View we're drawing to. 72 // View we're drawing to.
73 views::View* view_; 73 views::View* view_;
74 74
75 // Opacity of the glow ramps up over time. 75 // Opacity of the glow ramps up over time.
76 ui::SlideAnimation animation_; 76 gfx::SlideAnimation animation_;
77 77
78 // Location of the glow, relative to view. 78 // Location of the glow, relative to view.
79 gfx::Point location_; 79 gfx::Point location_;
80 double opacity_scale_; 80 double opacity_scale_;
81 81
82 DISALLOW_COPY_AND_ASSIGN(GlowHoverController); 82 DISALLOW_COPY_AND_ASSIGN(GlowHoverController);
83 }; 83 };
84 84
85 } // namespace views 85 } // namespace views
86 86
87 #endif // UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_ 87 #endif // UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/text_button.cc ('k') | ui/views/controls/glow_hover_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698