OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 5 #ifndef ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
6 #define ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 6 #define ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/wm/caption_buttons/caption_button_types.h" | 9 #include "ash/wm/caption_buttons/caption_button_types.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); | 31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); |
32 virtual ~FrameCaptionButton(); | 32 virtual ~FrameCaptionButton(); |
33 | 33 |
34 // Sets the images to use to paint the button. If |animate| is ANIMATE_YES, | 34 // Sets the images to use to paint the button. If |animate| is ANIMATE_YES, |
35 // the button crossfades to the new visuals. If the image ids match those | 35 // the button crossfades to the new visuals. If the image ids match those |
36 // currently used by the button and |animate| is ANIMATE_NO the crossfade | 36 // currently used by the button and |animate| is ANIMATE_NO the crossfade |
37 // animation is progressed to the end. | 37 // animation is progressed to the end. |
38 void SetImages(CaptionButtonIcon icon, | 38 void SetImages(CaptionButtonIcon icon, |
39 Animate animate, | 39 Animate animate, |
40 int normal_image_id, | 40 int icon_image_id, |
41 int hovered_image_id, | 41 int inactive_icon_image_id, |
42 int pressed_image_id); | 42 int hovered_background_image_id, |
| 43 int pressed_background_image_id); |
43 | 44 |
44 // Returns true if the button is crossfading to new visuals set in | 45 // Returns true if the button is crossfading to new visuals set in |
45 // SetImages(). | 46 // SetImages(). |
46 bool IsAnimatingImageSwap() const; | 47 bool IsAnimatingImageSwap() const; |
47 | 48 |
48 // views::View overrides: | 49 // views::View overrides: |
49 virtual gfx::Size GetPreferredSize() OVERRIDE; | 50 virtual gfx::Size GetPreferredSize() OVERRIDE; |
50 virtual const char* GetClassName() const OVERRIDE; | 51 virtual const char* GetClassName() const OVERRIDE; |
51 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
52 | 53 |
| 54 void set_paint_as_active(bool paint_as_active) { |
| 55 paint_as_active_ = paint_as_active; |
| 56 } |
| 57 |
53 CaptionButtonIcon icon() const { | 58 CaptionButtonIcon icon() const { |
54 return icon_; | 59 return icon_; |
55 } | 60 } |
56 | 61 |
57 protected: | 62 protected: |
58 // views::CustomButton overrides: | 63 // views::CustomButton overrides: |
59 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 64 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
60 virtual void StateChanged() OVERRIDE; | 65 virtual void StateChanged() OVERRIDE; |
61 | 66 |
62 private: | 67 private: |
63 // Paints the button as it will look at the end of |swap_images_animation_| | 68 // Paints the button as it will look at the end of |swap_images_animation_| |
64 // but with |opacity|. | 69 // but with |opacity|. |
65 void PaintWithAnimationEndState(gfx::Canvas* canvas, int opacity); | 70 void PaintWithAnimationEndState(gfx::Canvas* canvas, int opacity); |
66 | 71 |
67 // The button's current icon. | 72 // The button's current icon. |
68 CaptionButtonIcon icon_; | 73 CaptionButtonIcon icon_; |
69 | 74 |
| 75 // Whether the button should be painted as active. |
| 76 bool paint_as_active_; |
| 77 |
70 // The scale at which the button was previously painted. | 78 // The scale at which the button was previously painted. |
71 float last_paint_scale_; | 79 float last_paint_scale_; |
72 | 80 |
73 // The images and image ids used to paint the button. | 81 // The images and image ids used to paint the button. |
74 int normal_image_id_; | 82 int icon_image_id_; |
75 int hovered_image_id_; | 83 int inactive_icon_image_id_; |
76 int pressed_image_id_; | 84 int hovered_background_image_id_; |
77 gfx::ImageSkia normal_image_; | 85 int pressed_background_image_id_; |
78 gfx::ImageSkia hovered_image_; | 86 gfx::ImageSkia icon_image_; |
79 gfx::ImageSkia pressed_image_; | 87 gfx::ImageSkia inactive_icon_image_; |
| 88 gfx::ImageSkia hovered_background_image_; |
| 89 gfx::ImageSkia pressed_background_image_; |
80 | 90 |
81 // The image to crossfade from. | 91 // The image to crossfade from. |
82 gfx::ImageSkia crossfade_image_; | 92 gfx::ImageSkia crossfade_image_; |
83 | 93 |
84 // Crossfade animation started when the button's images are changed by | 94 // Crossfade animation started when the button's images are changed by |
85 // SetImages(). | 95 // SetImages(). |
86 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; | 96 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; |
87 | 97 |
88 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); | 98 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); |
89 }; | 99 }; |
90 | 100 |
91 } // namespace ash | 101 } // namespace ash |
92 | 102 |
93 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 103 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
OLD | NEW |