| OLD | NEW |
| 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/base/animation/animation_delegate.h" |
| 9 #include "ui/base/animation/slide_animation.h" | 9 #include "ui/base/animation/slide_animation.h" |
| 10 #include "ui/views/views_export.h" | 10 #include "ui/views/views_export.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 ui::AnimationDelegate { |
| 31 public: | 31 public: |
| 32 enum Style { |
| 33 SUBTLE, |
| 34 PRONOUNCED |
| 35 }; |
| 36 |
| 32 explicit GlowHoverController(views::View* view); | 37 explicit GlowHoverController(views::View* view); |
| 33 virtual ~GlowHoverController(); | 38 virtual ~GlowHoverController(); |
| 34 | 39 |
| 35 // Sets the AnimationContainer used by the animation. | 40 // Sets the AnimationContainer used by the animation. |
| 36 void SetAnimationContainer(ui::AnimationContainer* container); | 41 void SetAnimationContainer(ui::AnimationContainer* container); |
| 37 | 42 |
| 38 // 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 |
| 39 // constructor. | 44 // constructor. |
| 40 void SetLocation(const gfx::Point& location); | 45 void SetLocation(const gfx::Point& location); |
| 41 | 46 |
| 42 // Initiates showing the hover. | 47 // Initiates showing the hover. |
| 43 void Show(); | 48 void Show(Style style); |
| 44 | 49 |
| 45 // Hides the hover. | 50 // Hides the hover. |
| 46 void Hide(); | 51 void Hide(); |
| 47 | 52 |
| 48 // Hides the hover immediately. | 53 // Hides the hover immediately. |
| 49 void HideImmediately(); | 54 void HideImmediately(); |
| 50 | 55 |
| 51 // Returns the value of the animation. | 56 // Returns the value of the animation. |
| 52 double GetAnimationValue() const; | 57 double GetAnimationValue() const; |
| 53 | 58 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 | 70 |
| 66 private: | 71 private: |
| 67 // View we're drawing to. | 72 // View we're drawing to. |
| 68 views::View* view_; | 73 views::View* view_; |
| 69 | 74 |
| 70 // Opacity of the glow ramps up over time. | 75 // Opacity of the glow ramps up over time. |
| 71 ui::SlideAnimation animation_; | 76 ui::SlideAnimation animation_; |
| 72 | 77 |
| 73 // Location of the glow, relative to view. | 78 // Location of the glow, relative to view. |
| 74 gfx::Point location_; | 79 gfx::Point location_; |
| 80 double opacity_scale_; |
| 75 | 81 |
| 76 DISALLOW_COPY_AND_ASSIGN(GlowHoverController); | 82 DISALLOW_COPY_AND_ASSIGN(GlowHoverController); |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 } // namespace views | 85 } // namespace views |
| 80 | 86 |
| 81 #endif // UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_ | 87 #endif // UI_VIEWS_CONTROLS_GLOW_HOVER_CONTROLLER_H_ |
| OLD | NEW |