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