| 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" |
| 11 #include "ui/compositor/layer_owner_delegate.h" | |
| 12 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/views/controls/button/custom_button.h" | 12 #include "ui/views/controls/button/custom_button.h" |
| 14 | 13 |
| 15 namespace gfx { | 14 namespace gfx { |
| 16 class SlideAnimation; | 15 class SlideAnimation; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace ash { | 18 namespace ash { |
| 20 | 19 |
| 21 // Base class for the window caption buttons (minimize, maximize, restore, | 20 // Base class for the window caption buttons (minimize, maximize, restore, |
| 22 // close). | 21 // close). |
| 23 class ASH_EXPORT FrameCaptionButton : public views::CustomButton, | 22 class ASH_EXPORT FrameCaptionButton : public views::CustomButton { |
| 24 public ui::LayerOwnerDelegate { | |
| 25 public: | 23 public: |
| 26 enum Animate { | 24 enum Animate { |
| 27 ANIMATE_YES, | 25 ANIMATE_YES, |
| 28 ANIMATE_NO | 26 ANIMATE_NO |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 static const char kViewClassName[]; | 29 static const char kViewClassName[]; |
| 32 | 30 |
| 33 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); | 31 FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon); |
| 34 virtual ~FrameCaptionButton(); | 32 virtual ~FrameCaptionButton(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 // Returns the icon image to paint based on |paint_as_active_|. | 67 // Returns the icon image to paint based on |paint_as_active_|. |
| 70 const gfx::ImageSkia& GetIconImageToPaint() const; | 68 const gfx::ImageSkia& GetIconImageToPaint() const; |
| 71 | 69 |
| 72 // Paints |to_center| centered within the button with |alpha|. | 70 // Paints |to_center| centered within the button with |alpha|. |
| 73 void PaintCentered(gfx::Canvas* canvas, | 71 void PaintCentered(gfx::Canvas* canvas, |
| 74 const gfx::ImageSkia& to_center, | 72 const gfx::ImageSkia& to_center, |
| 75 int alpha); | 73 int alpha); |
| 76 | 74 |
| 77 // ui::LayerOwnerDelegate: | |
| 78 virtual void OnLayerRecreated(ui::Layer* old_layer, | |
| 79 ui::Layer* new_layer) OVERRIDE; | |
| 80 | |
| 81 // The button's current icon. | 75 // The button's current icon. |
| 82 CaptionButtonIcon icon_; | 76 CaptionButtonIcon icon_; |
| 83 | 77 |
| 84 // Whether the button should be painted as active. | 78 // Whether the button should be painted as active. |
| 85 bool paint_as_active_; | 79 bool paint_as_active_; |
| 86 | 80 |
| 87 // The images and image ids used to paint the button. | 81 // The images and image ids used to paint the button. |
| 88 int icon_image_id_; | 82 int icon_image_id_; |
| 89 int inactive_icon_image_id_; | 83 int inactive_icon_image_id_; |
| 90 int hovered_background_image_id_; | 84 int hovered_background_image_id_; |
| 91 int pressed_background_image_id_; | 85 int pressed_background_image_id_; |
| 92 gfx::ImageSkia icon_image_; | 86 gfx::ImageSkia icon_image_; |
| 93 gfx::ImageSkia inactive_icon_image_; | 87 gfx::ImageSkia inactive_icon_image_; |
| 94 gfx::ImageSkia hovered_background_image_; | 88 gfx::ImageSkia hovered_background_image_; |
| 95 gfx::ImageSkia pressed_background_image_; | 89 gfx::ImageSkia pressed_background_image_; |
| 96 | 90 |
| 97 // The icon image to crossfade from. | 91 // The icon image to crossfade from. |
| 98 gfx::ImageSkia crossfade_icon_image_; | 92 gfx::ImageSkia crossfade_icon_image_; |
| 99 | 93 |
| 100 // Crossfade animation started when the button's images are changed by | 94 // Crossfade animation started when the button's images are changed by |
| 101 // SetImages(). | 95 // SetImages(). |
| 102 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; | 96 scoped_ptr<gfx::SlideAnimation> swap_images_animation_; |
| 103 | 97 |
| 104 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); | 98 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButton); |
| 105 }; | 99 }; |
| 106 | 100 |
| 107 } // namespace ash | 101 } // namespace ash |
| 108 | 102 |
| 109 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ | 103 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_H_ |
| OLD | NEW |