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