| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ | 5 #ifndef CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ |
| 6 #define CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ | 6 #define CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "app/animation_delegate.h" | |
| 11 #include "app/slide_animation.h" | |
| 12 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
| 11 #include "ui/base/animation/animation_delegate.h" |
| 12 #include "ui/base/animation/slide_animation.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class Point; | 15 class Point; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class InfoBar; | 18 class InfoBar; |
| 19 | 19 |
| 20 // A helper class that tracks the state of an infobar arrow and provides a | 20 // A helper class that tracks the state of an infobar arrow and provides a |
| 21 // utility to draw it. | 21 // utility to draw it. |
| 22 class InfoBarArrowModel : public AnimationDelegate { | 22 class InfoBarArrowModel : public ui::AnimationDelegate { |
| 23 public: | 23 public: |
| 24 class Observer { | 24 class Observer { |
| 25 public: | 25 public: |
| 26 // The arrow has changed states; relevant widgets need to be repainted. | 26 // The arrow has changed states; relevant widgets need to be repainted. |
| 27 virtual void PaintStateChanged() = 0; | 27 virtual void PaintStateChanged() = 0; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 explicit InfoBarArrowModel(Observer* observer); | 30 explicit InfoBarArrowModel(Observer* observer); |
| 31 virtual ~InfoBarArrowModel(); | 31 virtual ~InfoBarArrowModel(); |
| 32 | 32 |
| 33 // An infobar has been added or removed that will affect the state of this | 33 // An infobar has been added or removed that will affect the state of this |
| 34 // arrow. | 34 // arrow. |
| 35 void ShowArrowFor(InfoBar* bar, bool animate); | 35 void ShowArrowFor(InfoBar* bar, bool animate); |
| 36 | 36 |
| 37 // Returns true if the arrow is showing at all. | 37 // Returns true if the arrow is showing at all. |
| 38 bool NeedToDrawInfoBarArrow(); | 38 bool NeedToDrawInfoBarArrow(); |
| 39 | 39 |
| 40 // Paints the arrow on |widget|, in response to |expose|, with the bottom | 40 // Paints the arrow on |widget|, in response to |expose|, with the bottom |
| 41 // center of the arrow at |origin|, drawing a border with |border_color|. | 41 // center of the arrow at |origin|, drawing a border with |border_color|. |
| 42 void Paint(GtkWidget* widget, | 42 void Paint(GtkWidget* widget, |
| 43 GdkEventExpose* expose, | 43 GdkEventExpose* expose, |
| 44 const gfx::Point& origin, | 44 const gfx::Point& origin, |
| 45 const GdkColor& border_color); | 45 const GdkColor& border_color); |
| 46 | 46 |
| 47 // Overridden from AnimationDelegate. | 47 // Overridden from ui::AnimationDelegate. |
| 48 virtual void AnimationEnded(const Animation* animation); | 48 virtual void AnimationEnded(const ui::Animation* animation); |
| 49 virtual void AnimationProgressed(const Animation* animation); | 49 virtual void AnimationProgressed(const ui::Animation* animation); |
| 50 virtual void AnimationCanceled(const Animation* animation); | 50 virtual void AnimationCanceled(const ui::Animation* animation); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // A pair of colors used to draw a gradient for an arrow. | 53 // A pair of colors used to draw a gradient for an arrow. |
| 54 struct InfoBarColors { | 54 struct InfoBarColors { |
| 55 SkColor top; | 55 SkColor top; |
| 56 SkColor bottom; | 56 SkColor bottom; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Calculates the currently showing arrow color, which is a blend of the new | 59 // Calculates the currently showing arrow color, which is a blend of the new |
| 60 // arrow color and the old arrow color. | 60 // arrow color and the old arrow color. |
| 61 InfoBarColors CurrentInfoBarColors(); | 61 InfoBarColors CurrentInfoBarColors(); |
| 62 | 62 |
| 63 // The view that owns us. | 63 // The view that owns us. |
| 64 Observer* observer_; | 64 Observer* observer_; |
| 65 | 65 |
| 66 // An animation that tracks the progress of the transition from the last color | 66 // An animation that tracks the progress of the transition from the last color |
| 67 // to the new color. | 67 // to the new color. |
| 68 SlideAnimation animation_; | 68 ui::SlideAnimation animation_; |
| 69 | 69 |
| 70 // The color we are animating towards. | 70 // The color we are animating towards. |
| 71 InfoBarColors target_colors_; | 71 InfoBarColors target_colors_; |
| 72 // The last color we showed (the one we are animating away from). | 72 // The last color we showed (the one we are animating away from). |
| 73 InfoBarColors previous_colors_; | 73 InfoBarColors previous_colors_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(InfoBarArrowModel); | 75 DISALLOW_COPY_AND_ASSIGN(InfoBarArrowModel); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ | 78 #endif // CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_ |
| OLD | NEW |