| 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_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
| 6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/frame/caption_buttons/caption_button_types.h" | 9 #include "ash/frame/caption_buttons/caption_button_types.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); | 31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); |
| 32 ~FrameCaptionButton() override; | 32 ~FrameCaptionButton() override; |
| 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 icon_image_id, | 40 int icon_image_id, |
| 41 int inactive_icon_image_id, | |
| 42 int hovered_background_image_id, | 41 int hovered_background_image_id, |
| 43 int pressed_background_image_id); | 42 int pressed_background_image_id); |
| 44 | 43 |
| 45 // Returns true if the button is crossfading to new visuals set in | 44 // Returns true if the button is crossfading to new visuals set in |
| 46 // SetImages(). | 45 // SetImages(). |
| 47 bool IsAnimatingImageSwap() const; | 46 bool IsAnimatingImageSwap() const; |
| 48 | 47 |
| 49 // Sets the alpha to use for painting. Used to animate visibility changes. | 48 // Sets the alpha to use for painting. Used to animate visibility changes. |
| 50 void SetAlpha(int alpha); | 49 void SetAlpha(int alpha); |
| 51 | 50 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 62 return icon_; | 61 return icon_; |
| 63 } | 62 } |
| 64 | 63 |
| 65 int icon_image_id() const { return icon_image_id_; } | 64 int icon_image_id() const { return icon_image_id_; } |
| 66 | 65 |
| 67 protected: | 66 protected: |
| 68 // views::CustomButton override: | 67 // views::CustomButton override: |
| 69 void OnGestureEvent(ui::GestureEvent* event) override; | 68 void OnGestureEvent(ui::GestureEvent* event) override; |
| 70 | 69 |
| 71 private: | 70 private: |
| 72 // Returns the icon image to paint based on |paint_as_active_|. | |
| 73 const gfx::ImageSkia& GetIconImageToPaint() const; | |
| 74 | |
| 75 // Paints |to_center| centered within the button with |alpha|. | 71 // Paints |to_center| centered within the button with |alpha|. |
| 76 void PaintCentered(gfx::Canvas* canvas, | 72 void PaintCentered(gfx::Canvas* canvas, |
| 77 const gfx::ImageSkia& to_center, | 73 const gfx::ImageSkia& to_center, |
| 78 int alpha); | 74 int alpha); |
| 79 | 75 |
| 80 // The button's current icon. | 76 // The button's current icon. |
| 81 CaptionButtonIcon icon_; | 77 CaptionButtonIcon icon_; |
| 82 | 78 |
| 83 // Whether the button should be painted as active. | 79 // Whether the button should be painted as active. |
| 84 bool paint_as_active_; | 80 bool paint_as_active_; |
| 85 | 81 |
| 86 // Current alpha to use for painting. | 82 // Current alpha to use for painting. |
| 87 int alpha_; | 83 int alpha_; |
| 88 | 84 |
| 89 // The images and image ids used to paint the button. | 85 // The images and image ids used to paint the button. |
| 90 int icon_image_id_; | 86 int icon_image_id_; |
| 91 int inactive_icon_image_id_; | |
| 92 int hovered_background_image_id_; | 87 int hovered_background_image_id_; |
| 93 int pressed_background_image_id_; | 88 int pressed_background_image_id_; |
| 94 gfx::ImageSkia icon_image_; | 89 gfx::ImageSkia icon_image_; |
| 95 gfx::ImageSkia inactive_icon_image_; | |
| 96 gfx::ImageSkia hovered_background_image_; | 90 gfx::ImageSkia hovered_background_image_; |
| 97 gfx::ImageSkia pressed_background_image_; | 91 gfx::ImageSkia pressed_background_image_; |
| 98 | 92 |
| 99 // The icon image to crossfade from. | 93 // The icon image to crossfade from. |
| 100 gfx::ImageSkia crossfade_icon_image_; | 94 gfx::ImageSkia crossfade_icon_image_; |
| 101 | 95 |
| 102 // Crossfade animation started when the button's images are changed by | 96 // Crossfade animation started when the button's images are changed by |
| 103 // SetImages(). | 97 // SetImages(). |
| 104 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; | 98 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; |
| 105 | 99 |
| 106 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); | 100 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); |
| 107 }; | 101 }; |
| 108 | 102 |
| 109 } // namespace ash | 103 } // namespace ash |
| 110 | 104 |
| 111 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 105 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
| OLD | NEW |